擅长:python、mysql、java
<p>这会得到所有的记录。与原始版本相比,新颖之处在于<br/></p>
<pre><code>for blast_record in blast_records
</code></pre>
<p>这是一个python习惯用法,用于遍历“类列表”对象(如blast_记录)中的项(检查<a href="http://www.biopython.org/DIST/docs/api/Bio.Blast.NCBIXML-module.html" rel="nofollow noreferrer">CBIXML module documentation</a>显示parse()确实返回一个迭代器)</p>
<pre><code>from Bio.Blast import NCBIXM
blast_records = NCBIXML.parse(result_handle)
save_file = open("/Users/jonbra/Desktop/my_fasta_seq.fasta", 'w')
for blast_record in blast_records:
for alignment in blast_record.alignments:
for hsp in alignment.hsps:
save_file.write('>%s\n' % (alignment.title,))
#here possibly to output something to file, between each blast_record
save_file.close()
</code></pre>