[Bioperl-l] Bio::SeqIO can't guess the format of data from a pipe

Hilmar Lapp hlapp at drycafe.net
Sat Aug 27 03:43:57 UTC 2011


The format is already available - it is in essence the class of the SeqIO instance:

my $format = ref($in);

Rather than passing that into SeqIO->new(), you can directly instantiate a new object from it:

my $out = ref($in)->new(-file => ...);

Would that address what you are trying to accomplish?

-hilmar

Sent with a tap.

On Aug 27, 2011, at 8:12 PM, Florent Angly <florent.angly at gmail.com> wrote:

> My proposal would be to store the format of a file somewhere in the Bio::SeqIO object and create a new get/set method in Bio::SeqIO called format() to store of access its value. The idea would be that the example code above could be rewritten as:
> 
>    # Open the file and let BioPerl guess its format
>    my $in = Bio::SeqIO->new( -file => $input_seqfile );
> 
>    # Retrieve the format guessed by BioPerl
>    my $format = $in->format( );
> 
>    # Open the output file using the same format as the input file
>    my $out = Bio::SeqIO->new( -file => ">".$output_seqfile , format => $format );
> 
>    # Now do the work...
> 
> I think this is more elegant since it is more readable, requires less computation (the file format is guessed once), and is more consistent with other Bio::SeqIO methods like alphabet, that guesses the alphabet but has a get/set method to access it.




More information about the Bioperl-l mailing list