Skip to content

Instantly share code, notes, and snippets.

@peterjc
Created September 7, 2011 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterjc/1201033 to your computer and use it in GitHub Desktop.
Save peterjc/1201033 to your computer and use it in GitHub Desktop.
Selecting FASTQ sequences by ID (Biopython with strings)
from Bio.SeqIO.QualityIO import FastqGeneralIterator
import sys
ids = set(x[:-1] for x in open(sys.argv[1]))
for title, seq, quals in FastqGeneralIterator(sys.stdin):
if title.split(None,1)[0] in ids:
print "@%s\n%s\n+\n%s\n" % (title, seq, quals)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment