<p dir="ltr">You should do<br>
cat try.fa | perl ..<br>
rather than less,IMO. less formats things.</p>
<p dir="ltr">You can add<br>
no warnings qw/once/;<br>
to get rid of that warning, it shouldn't affect<br>
the program.</p>
<p dir="ltr">MAJ</p>
<br/><div class="cm_quote" style=" color: #787878">On Sat, Jul 12, 2014 at 8:03 PM, Haiyan Lin <<a href="mailto:linhy0120@gmail.com">linhy0120@gmail.com</a>> wrote:</div><br><div id="oldcontent" style="background-color: rgb(255, 255, 255); background-position: initial initial; background-repeat: initial initial;"><blockquote style=""><p dir="ltr"><br>
Hi, Paul,</p>
<p dir="ltr">Thanks for your quick replay and advice. Soryy for my late feedback, I can't send maill in my location yesterday. I have tried your method. But<br>
it complains that</p>
<p dir="ltr">------------------------------------<br>
[linhy@bioinfo1 Script]$ less try.fa | perl ./fastaLen.pl<br>
Name "main::DATA" used only once: possible typo at ./fastaLen.pl line<br>
42.<br>
Use of uninitialized value in print at ./fastaLen.pl line 49.<br>
------------------------------------<br></p>
<p dir="ltr">I had also tried the "-fh=>\*STDIN", and "-fh=><>",according to the<br>
documentation returned by "perldoc Bio::SeqIO" at termminal, but I still<br>
haven't got I want.Thanks again.</p>
<p dir="ltr">... ...</p>
<p dir="ltr"> Bio::SeqIO->new()<br>
$seqIO = Bio::SeqIO->new(-file => 'filename',<br>
-format=>$format);<br>
$seqIO = Bio::SeqIO->new(-fh => \*FILEHANDLE,<br>
-format=>$format);<br>
$seqIO = Bio::SeqIO->new(-format => $format);</p>
<p dir="ltr"> ... ... </p>
<p dir="ltr"> -fh You may provide new() with a previously-opened filehandle.<br>
For example, to read from STDIN:</p>
<p dir="ltr"> $seqIO = Bio::SeqIO->new(-fh => \*STDIN);</p>
<p dir="ltr"> Note that you must pass filehandles as references to globs.</p>
<p dir="ltr"> If neither a filehandle nor a filename is specified, then<br>
the module will read from the @ARGV array or STDIN, using the<br>
familiar <> semantics.</p>
<p dir="ltr">-------------------------------<br><br></p>
<p dir="ltr">Regards</p>
<p dir="ltr">Haiyan<br><br><br></p>
<p dir="ltr">On Sat, 2014-07-12 at 10:22 -0400, Paul Cantalupo wrote:<br>
> Hi Haiyan,<br>
> <br>
> <br>
> You need to use the '-fh' option in Bio::SeqIO new and have it use<br>
> Perl's DATA filehandle like so:<br>
> my $in = Bio::SeqIO->new(-fh => \*DATA, -format => 'fasta');<br>
> <br>
> This was taken from<br>
> http://perldoc.perl.org/perldata.html#Special-Literals:<br>
> "Text after __DATA__ may be read via the filehandle PACKNAME::DATA ,<br>
> where PACKNAME is the package that was current when the __DATA__ token<br>
> was encountered."<br>
> <br>
> <br>
> <br>
> Good luck,<br>
> <br>
> Paul<br>
> <br>
> <br>
> <br>
> <br>
> Paul Cantalupo<br>
> University of Pittsburgh<br>
> <br>
> <br>
> <br>
> On Sat, Jul 12, 2014 at 8:35 AM, Haiyan Lin <linhy0120@gmail.com><br>
> wrote:<br>
> Hill, dear perlers,<br>
> <br>
> I‘m trying to use Bio::SeqIO to read Fasta sequence from pipe,<br>
> or @ARGV,<br>
> like "while (<>) {....}". After several trier and error, I'm<br>
> failed and<br>
> need to ask for herp from you. Could you please help me to<br>
> check or try<br>
> following code?<br>
> <br>
> Thanks in advance.<br>
> <br>
> ---------------------------------------<br>
> use Bio::SeqIO ;<br>
> use Statistics::Descriptive ;<br>
> <br>
> my %opt = () ;<br>
> my $sta = Statistics::Descriptive::Full->new();<br>
> <br>
> ##### here is the key, I think.<br>
> my $in = Bio::SeqIO->new(-format=>"Fasta");<br>
> while(my $s = $in->next_seq()){<br>
> $sta->add_data($s->length()) ;<br>
> }<br>
> print $sta->sum() if $opt{sum} ;<br>
> <br>
> __DATA__<br>
> >ct1<br>
> AGAGAGAGA<br>
> >ctg2<br>
> ATATATAT<br>
> -----------------------------------------------<br>
> <br>
> Regards<br>
> <br>
> Haiyan<br>
> <br>
> <br>
> <br>
> <br>
> <br>
> <br>
> _______________________________________________<br>
> Bioperl-l mailing list<br>
> Bioperl-l@mailman.open-bio.org<br>
> http://mailman.open-bio.org/mailman/listinfo/bioperl-l<br>
> <br>
> <br><br></p>
<p dir="ltr">_______________________________________________<br>
Bioperl-l mailing list<br>
Bioperl-l@mailman.open-bio.org<br>
http://mailman.open-bio.org/mailman/listinfo/bioperl-l</p>
</blockquote></div>