[Biopython] Reading from stdin with Bio.SeqIO

Giles Weaver giles.weaver at googlemail.com
Thu Jun 4 16:04:20 UTC 2009


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:

use Bio::SeqIO;

# get command-line arguments, or die with a usage statement
my $usage = "Usage: perl sequence_file_converter.pl [informat] [outformat] <
[input file] > [output file]\n";
my $informat = shift or die $usage;
my $outformat = shift or die $usage;

# create one SeqIO object to read in, and another to write out
my $in = Bio::SeqIO->new(-fh => \*STDIN, -format => $informat);
my $out = Bio::SeqIO->new(-fh => \*STDOUT, -format => $outformat);

# write each entry in the input to the output
while (my $seq = $in->next_seq)
{
    $out->write_seq($seq);
}
exit;

Unfortunately I can't find any documentation on how to read from or write to
Unix pipes with Bio.SeqIO.
Can anyone help?

Thanks,

Giles



More information about the Biopython mailing list