[Biopython] Reading from stdin with Bio.SeqIO

Brad Chapman chapmanb at 50mail.com
Thu Jun 4 12:47:20 EDT 2009


Hi Giles;
You are very welcome in Python-land.

> I need to convert a solexa format fastq file into a sanger format fastq 
> file.
[...]
> Unfortunately I can't find any documentation on how to read from or write to
> Unix pipes with Bio.SeqIO.
> Can anyone help?

You want to use sys.stdin and sys.stdout, which provide file handles
to standard in and out:

import sys
from Bio import SeqIO

recs = SeqIO.parse(sys.stdin, "fastq-solexa")
SeqIO.write(recs, sys.stdout, "fastq")

It would be great if you wanted to add this as an example in the
Cookbook documentation:

http://biopython.org/wiki/Category:Cookbook

Hope this helps,
Brad


More information about the Biopython mailing list