[Biopython] Reading from stdin with Bio.SeqIO

Giles Weaver giles.weaver at googlemail.com
Fri Jun 5 08:12:57 EDT 2009


I've added some cookbook documentation on this topic at
http://biopython.org/wiki/Reading_from_unix_pipes

Regarding the error messages, it might be helpful to refer to the list of
valid sequence formats and the supporting biopython versions at
http://biopython.org/wiki/SeqIO#File_Formats
I'd have spotted the problem right away if I hadn't already been
desensitised by the previous python newbie error messages I'd just seen!

2009/6/4 Brad Chapman <chapmanb at 50mail.com>

> 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