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.
2 Réponses
+ 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)
0
thanks~