[Bioperl-l] Fasta counting script?

Smithies, Russell Russell.Smithies at agresearch.co.nz
Tue Nov 22 20:47:36 UTC 2011


Or again, you could use the builtin scripts bp_seq_length.pl or bp_gccalc.pl
As previous posters have hinted, RTFM - the answers are all in there!

--Russell

> -----Original Message-----
> From: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-
> bounces at lists.open-bio.org] On Behalf Of Fields, Christopher J
> Sent: Wednesday, 23 November 2011 5:13 a.m.
> To: Kylie Goodyear
> Cc: <bioperl-l at bioperl.org>
> Subject: Re: [Bioperl-l] Fasta counting script?
> 
> This sounds a little homework-y.  Sure this isn't for a class? :)
> 
> One clue (and a good thing to keep in mind): always 'use strict; use warnings;'
> with your scripts if you are new to perl.  Doing so would let you know there is
> a problem with the script the way it is written, specifically, the place where
> you are inquiring about the length.
> 
> chris
> 
> On Nov 22, 2011, at 7:00 AM, Kylie Goodyear wrote:
> 
> > Thank you for your help. It keeps telling me that it can't find
> > "length" do you think it has to do with the way I am coding it?
> >
> > #!/usr/bin/perl -w
> > #Defines perl modules
> >
> > #Bio::Seq deal with sequences and their features use Bio::Seq;
> >
> > #Bio::SeqIO handles reading and parsing of sequences of many different
> > formats use Bio::SeqIO;
> >
> >
> > #Read FASTA file
> > $seqio_obj = Bio::SeqIO->new(-file => "DNA_sequences.fasta", -format
> > => "fasta" );
> >
> >
> > #Count how many sequences are present in file my $countseq=0; while
> > (my $seq_obj = $seqio_obj->next_seq, ) {
> >    $countseq++;
> >    }
> > #Display the number of sequences present print "There are $countseq
> > sequences present.\n";
> >
> > #Count number of charcaters in file
> > my $seq_length = $seq_obj->length ;
> > print $seq_length
> >
> >
> > On Nov 22, 5:08 am, Dave Messina <David.Mess... at sbc.su.se> wrote:
> >> Hi Kylie,
> >>
> >> You can use the length method for this.
> >>
> >> my $seq_length = $seq_obj->length();
> >>
> >> Have you taken a look at the beginner's HOWTO? There's a nice table
> >> of sequence methods as well lots of other good information in there.
> >>
> >> http://www.bioperl.org/wiki/HOWTO:Beginners
> >>
> >> Dave
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Tue, Nov 22, 2011 at 03:23, Kylie Goodyear <goodyea... at gmail.com>
> wrote:
> >>> Hi,
> >>> This may seem like a stupid question but I am just learning bioperl
> >>> and I am trying to figure out how to get a count of all the
> >>> characters in my FASTA file. I manged to get the number of sequences
> >>> using the following. Is there a way to tell bioperl to count the characters?
> >>
> >>> #!/usr/bin/perl -w
> >>> #Defines perl modules
> >>> #Bio::Seq deal with sequences and their features use Bio::Seq;
> >>> #Bio::SeqIO handles reading and parsing of sequences of many
> >>> different formats use Bio::SeqIO; #Read FASTA file $seqio_obj =
> >>> Bio::SeqIO->new(-file => "DNA_sequences.fasta", -format => "fasta"
> >>> ); #Count how many sequences are present in file my $count=0; while
> >>> (my $seq_obj = $seqio_obj->next_seq) {
> >>>    $count++;
> >>> }
> >>> #Display the number of sequences present print "There are $count
> >>> sequences present.\n";
> >>
> >>> _______________________________________________
> >>> Bioperl-l mailing list
> >>> Bioper... at lists.open-bio.org
> >>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
> >>
> >> _______________________________________________
> >> Bioperl-l mailing list
> >> Bioper... at lists.open-bio.orghttp://lists.open-bio.org/mailman/listinf
> >> o/bioperl-l
> >
> > _______________________________________________
> > Bioperl-l mailing list
> > Bioperl-l at lists.open-bio.org
> > http://lists.open-bio.org/mailman/listinfo/bioperl-l
> 
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
=======================================================================
Attention: The information contained in this message and/or attachments
from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the
sender immediately.
=======================================================================




More information about the Bioperl-l mailing list