【发布时间】:2014-03-03 06:03:13
【问题描述】:
我对 python 比较陌生,所以请原谅这个问题带来的白痴。我有一个 genbank 文件,并编写了一段代码,它将获取前 3 个最长的基因并将它们放入一个新生成的 fasta 文件中。
from Bio import SeqIO
file="sequence.gb"
output=open("Top3.faa", "w")
record=SeqIO.parse(file, "genbank")
rec=next(record)
print('The genes with the top 3 longest lengths have beens saved in Top3.faa')
for f in rec.features:
end=f.location.end.position
start=f.location.start.position
length=end-start
bug=(rec.seq)
if f.type=='CDS':
if 'gene' in f.qualifiers:
if length>7000:
geneName=f.qualifiers['gene']
name=str(geneName)
lenth=str(length)
seq=str(bug[start:end])
output.write('>')
output.write(lenth)
output.write('\n')
output.write(seq)
output.write('\n')
output.close()
我正在尝试做的不是手动输入检查是否超过 7kb,而是找到一种代码方式自行完成并自动找到 3 个热门点击。任何有关我可以去哪里的帮助将不胜感激。谢谢
【问题讨论】:
标签: python sorting biopython fasta genbank