[Bioperl-l] difference in opening file from @ARGV and STDIN?

Felipe Figueiredo philsf79 at gmail.com
Thu Sep 11 08:40:26 UTC 2008


I'm not sure if this is related to bioperl (Bio::AlignIO) or if it's a
general perl error on my part, but I find strange that the following
code gives differente results depending on how I input the alignment:

--- test.pl ---
#!/usr/bin/perl

use warnings;
use strict;

use Bio::AlignIO;

my $file;
if (@ARGV) {
    $file = shift @ARGV;
}
else {
    $file = "-";
}

my $align = Bio::AlignIO->new(-file=>$file)->next_aln;

printf "Sequences: %s\n",$align->no_sequences;
--- test.pl ---

If I run this using a file containing 4 sequences, the following
hapens: 

--- run tests ---
$ ./test.pl  exemplo-alinhamento.fasta
Sequences: 4

$ ./test.pl < exemplo-alinhamento.fasta
Sequences: 3

$ cat exemplo-alinhamento.fasta | ./test.pl 
Sequences: 3
--- run tests ---

The missing sequence is always the first one. Am I missing something, or
my code for reading stdin is mistaken or is it a bug in Bio::AlignIO?

I'm using bioperl 1.5.2.102-1ubuntu1, in Ubuntu 8.04 Hardy.

best regards
FF




More information about the Bioperl-l mailing list