Skip to content

Instantly share code, notes, and snippets.

@peterjc
Created September 7, 2011 16:27
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/1201025 to your computer and use it in GitHub Desktop.
Save peterjc/1201025 to your computer and use it in GitHub Desktop.
Selecting FASTQ sequences by ID (Biopython with SeqRecord object)
from Bio import SeqIO
import sys
ids = set(x[:-1] for x in open(sys.argv[1]))
wanted = (rec for rec in SeqIO.parse(sys.stdin, "fastq") if rec.id in ids)
SeqIO.write(wanted, sys.stdout, "fastq")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment