Skip to content

Instantly share code, notes, and snippets.

@mscook
Created March 18, 2014 07:12
Show Gist options
  • Save mscook/9614992 to your computer and use it in GitHub Desktop.
Save mscook/9614992 to your computer and use it in GitHub Desktop.
from Bio.Blast import NCBIXML
input = 'CFT073.B2_comp.fa_blast.xml'
for record in NCBIXML.parse(open('CFT073.B2_comp.fa_blast.xml')):
for align in record.alignments:
for idx, hsp in enumerate(align.hsps):
if idx == 0:
print ">"+input.split("_")[0]+"_"+record.query.split(',')[1].strip()
print hsp.sbjct
else:
print ">Multiple HSP's for"+record.query.split(',')[1].strip()+str(hsp.sbjct_start)+":"+str(hsp.sbjct_end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment