作者:赵lamarta | 来源:互联网 | 2023-07-30 20:51
Ihaveopenedafilewithblastresultsandprintedoutthehitsinfastaformattothescreen.我打开了
I have opened a file with blast results and printed out the hits in fasta format to the screen.
我打开了一个带有爆破结果的文件,并以fasta格式打印到屏幕上。
The code looks like this:
代码如下所示:
result_handle = open("/Users/jonbra/Desktop/my_blast.xml")
from Bio.Blast import NCBIXML
blast_records = NCBIXML.parse(result_handle)
blast_record = blast_records.next()
for alignment in blast_record.alignments:
for hsp in alignment.hsps:
print '>', alignment.title
print hsp.sbjct
This outputs a list of fasta files to the screen. But how can I create a file and save the fasta output to this file?
这会将fasta文件列表输出到屏幕。但是如何创建文件并将fasta输出保存到此文件中?
Update: I guess I would have to replace the print statements within the loop with something.write(), but how will the '>', alignment.title we written?
更新:我想我必须用something.write()替换循环中的print语句,但是我们如何编写'>',alignment.title?
5 个解决方案