[Biopython] Reading from stdin with Bio.SeqIO

Peter biopython at maubp.freeserve.co.uk
Thu Jun 4 13:24:37 EDT 2009


On Thu, Jun 4, 2009 at 5:04 PM, Giles Weaver
<giles.weaver at googlemail.com> wrote:
> Hi,
>
> I'm new to biopython, having used bioperl and biosql for some time. I need
> to convert a solexa format fastq file into a sanger format fastq file. This
> isn't yet possible in bioperl as there isn't a bioperl parser for solexa
> fastq yet, so I thought I'd give biopython a go.
>
> I want to right the biopython equivalent of the following:
> ...
> Unfortunately I can't find any documentation on how to read from or write to
> Unix pipes with Bio.SeqIO.
> Can anyone help?

Brad has kindly posted a solution - four lines of python code for the
whole script (but with the format names hard coded).

Our tutorial does try and emphasise that Bio.SeqIO works with handles,
which can be open files (as in most of the examples), internet
connections, output from command lines (as in some of our example), or
indeed the standard input/output pipes for the python script itself
(if run at the command line). I hadn't considered including an example
of this in the main tutorial on the grounds it would probably only of
interest to people already familiar with the Unix command line. But
Brad is right, this would make a nice wiki cookbook entry.

Peter

P.S. If you do want a perl solution, there is a script included with
maq which I found quite handy as a reference implementation for
Biopython.
http://maq.sourceforge.net/fq_all2std.pl


More information about the Biopython mailing list