Skip to content

Instantly share code, notes, and snippets.

@peterjc
Created September 7, 2011 16:27
Show Gist options
  • Select an option

  • Save peterjc/1201025 to your computer and use it in GitHub Desktop.

Select an option

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