Hi,
I have opened a file with blast results and printed out the hits in fasta format to the screen.
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?
Thanks! Jon
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?