Skip to content

Instantly share code, notes, and snippets.

@macmanes
Last active May 4, 2017 19:44
Show Gist options
  • Save macmanes/2a847c8850d28cf3f50abd89a0fb9d24 to your computer and use it in GitHub Desktop.
Save macmanes/2a847c8850d28cf3f50abd89a0fb9d24 to your computer and use it in GitHub Desktop.
from Bio import SeqIO
import sys
##python filter.py file.fasta names.list | tee -a output.fasta
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