in reply to Count Occurrences of a string

Here's a solution using Bioperl:
#!/usr/bin/perl -w use strict; use Bio::SeqIO; my @files = <*.seq>; my $pattern = '([AN]*)'; foreach my $file (@files) { my $seqio = Bio::SeqIO->new( -file => $file ); while ( my $seqobj = $seqio->next_seq() ) { my $raw_seq = $seqobj->seq(); my @length_of_matches; while ( $raw_seq =~ /$pattern/og ) { push @length_of_matches, length $1; } @length_of_matches = sort { $b <=> $a } @length_of_matches; print $length_of_matches[ 0 ], ' ', $file, "\n"; } }
Using Bioperl for easy scripts likes this is a good idea, because it allows you to very easily port your program to almost any sequence file format known to man.

Replies are listed 'Best First'.
Samples Help, Thank you
by MiamiGenome (Sexton) on Sep 10, 2003 at 14:38 UTC
    Dear Perl Monks,

    Thank you all for your constructive and instructive help.

    I am dealing with 2 conflicting, yet synergistic issues in my research, namely 1. getting my analyses completed, and 2. learning BioPerl/Perl.

    For nearly all my scripting, I am whip out quick jiffies to answer the questions of our genome center, but as my BioPerl comes up to speed, I sporadically need more guidance.

    I again thank you all.

    (No, my question wasn't homework :) )

      Good luck with your research.In addition to Perl Monks, a good resource for learning BioPerl is the doc.bioperl.org website, and the BioPerl mailing lists.

      Your name suggests that we may have a mutual friend in common, do you know Ken Rudd at the University of Miami? If so, tell him that Tex Thompson from the Rochester Institute of Technology says hello. :)