[Bioperl-l] Fasta counting script?

Liam Elbourne liam.elbourne at mq.edu.au
Mon Nov 21 23:11:12 EST 2011

Hi Kylie,

I think the length() method is what you're after:

my $sequence_length = $seq_obj->length();


in your case. Have a look at:

HOWTO:SeqIO - BioPerl


HOWTO:Beginners - BioPerl

for some more general stuff.


On 22/11/2011, at 1:23 PM, Kylie Goodyear 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
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.open-bio.org/pipermail/bioperl-l/attachments/20111122/d6589266/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.open-bio.org/pipermail/bioperl-l/attachments/20111122/d6589266/attachment.bin>

More information about the Bioperl-l mailing list