求GC含量

代码如下:

from collections import OrderedDict
ID_name = ''
temp_dict = OrderedDict()
with open(r'D:	estpyRosalind
osalind_gc.txt','r') as f:
    for line in f:
        if line.startswith('>'):
            ID_name = line.strip()
            temp_dict[ID_name] = ''  #之前一直不会将ID和seq存到序列中,这里给temp_dicr[ID_name]一个空值就是为了将ID存进字典里。
        else:
            temp_dict[ID_name] += line
            
for ID,seq in temp_dict.items():
  GC_num
= seq.count('G') + seq.count('C') GC_ration = GC_num/len(seq) print (ID + " ====> " +"%.8f"%GC_ration)
原文地址:https://www.cnblogs.com/nklzj/p/6275729.html