[Bioperl-l] use Bio::SeqIO to read Fasta sequence from pipe, or @ARGV, like "while (<>) {....}"

Haiyan Lin linhy0120 at gmail.com
Sat Jul 12 12:35:11 UTC 2014


Hill, dear perlers,

I‘m trying to use Bio::SeqIO to read Fasta sequence from pipe, or @ARGV,
like "while (<>) {....}". After several trier and error,  I'm failed and
need to ask for herp from you. Could you please help me to check or try
following code?

Thanks in advance.

---------------------------------------
use Bio::SeqIO ;
use Statistics::Descriptive ;

my %opt = () ;
my $sta = Statistics::Descriptive::Full->new();

##### here is the key, I think.
my $in = Bio::SeqIO->new(-format=>"Fasta");
while(my $s = $in->next_seq()){
    $sta->add_data($s->length()) ;
}
print $sta->sum() if $opt{sum} ;

__DATA__
>ct1
AGAGAGAGA
>ctg2
ATATATAT
-----------------------------------------------

Regards

Haiyan








More information about the Bioperl-l mailing list