if I have a text contain: >ID:1 ATTGGGACC >ID:2 GCCTTAAC >ID:3 TGAACT and I want to know the ID number of the string having the highest GC-content. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

if I have a text contain: >ID:1 ATTGGGACC >ID:2 GCCTTAAC >ID:3 TGAACT and I want to know the ID number of the string having the highest GC-content.

I wrote this function def GC (seq): gCount=seq.count('G') cCount=seq.count('C') SeqLength=float(len(seq)) gcCount=round (( gCount+ cCount)/ SeqLength,4) return str (( gcCount)*100)+'%' but I didn't know how to use it with text to get the right output.

22nd Aug 2016, 1:38 AM
sola
sola - avatar
2 Answers
+ 1
def GC (seq): gCount=seq.count('G') cCount=seq.count('C') SeqLength=float(len(seq)) gcCount=round (( gCount+ cCount)/SeqLength,4) return gcCount*100 idList = {'id1':'ATTGGGACC', 'id2':'GCCTTAAC', 'id3':'TGAACT'} max = -1 for id in idList: curr = int(GC(idList[id])) if curr > max: max = curr maxId = id print(str(max)+'%') print(maxId)
24th Aug 2016, 11:36 PM
‫Ido Tal
‫Ido Tal - avatar
0
thanks~
25th Aug 2016, 12:59 AM
sola
sola - avatar