Skip to content

Instantly share code, notes, and snippets.

@andrewcstewart
Created December 12, 2013 18:27
Show Gist options
  • Save andrewcstewart/7932901 to your computer and use it in GitHub Desktop.
Save andrewcstewart/7932901 to your computer and use it in GitHub Desktop.
Quick routine for parsing hits out of a blast file using BioPython.
import sys
from Bio import SearchIO
# usage: parse_blast_hits.py inputfile > outputfile
file = sys.argv[1]
for qresult in SearchIO.parse(file, 'blast-text'):
print("%s" % (qresult.id))
# First install BioPython.
# If the following doesn't work (ie, you don't have pip installed),
# then any of the other methods at http://biopython.org/wiki/Download
# should work just as well.
pip install biopython
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment