首页 > 其他 > 详细

求GC含量

时间:2017-01-12 13:10:25      阅读:258      评论:0      收藏:0      [点我收藏+]

代码如下:

from collections import OrderedDict
ID_name = ‘‘
temp_dict = OrderedDict()
with open(rD:\testpy\Rosalind\rosalind_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)

 

求GC含量

原文:http://www.cnblogs.com/nklzj/p/6275729.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!