求DNA序列中各个碱基的含量

方法很简单,用count就可以了,

with open (r'D:\Rosalind\rosalind_dna.txt','r') as f:
    for nucleotide in f.readlines():
        num_A = nucleotide.count("A")
        num_G = nucleotide.count("G")
        num_C = nucleotide.count("C")
        num_T = nucleotide.count("T")
        
print ("The numbers of 'A' ====> " + str(num_A))
print ("The numbers of 'G' ====> " + str(num_G))
print ("The numbers of 'C' ====> " + str(num_C))
print ("The numbers of 'T' ====> " + str(num_T))

 

posted @ 2017-01-11 12:51  Bio-Liu  阅读(693)  评论(0编辑  收藏  举报