Skip to content

Instantly share code, notes, and snippets.

@jasongallant
Created August 29, 2012 21:36
Show Gist options
  • Save jasongallant/3519281 to your computer and use it in GitHub Desktop.
Save jasongallant/3519281 to your computer and use it in GitHub Desktop.
Extract Sequences
"""
%prog some.fasta wanted-list.txt
"""
from Bio import SeqIO
import sys
wanted = [line.strip() for line in open(sys.argv[2])]
seqiter = SeqIO.parse(open(sys.argv[1]), 'fasta')
SeqIO.write((seq for seq in seqiter if seq.id in wanted), sys.stdout, "fasta")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment