Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Entering the land of Perl

by Cristoforo (Deacon)
on Apr 24, 2013 at 22:18 UTC ( #1030548=note: print w/ replies, xml ) Need Help??

in reply to Entering the land of Perl

Or, using the Bio::SeqIO, Bio::Tools::SeqStats modules from the Bio::Seq distribution, you can come up with this, (though more useful for less trivial tasks as the one here).
#!/usr/bin/perl use strict; use warnings; use 5.014; use Bio::SeqIO; use Bio::Tools::SeqStats; my $in = Bio::SeqIO->new (-fh => \*DATA, -format=>'fasta'); while(my $seq = $in->next_seq() ) { my $seq_stats = Bio::Tools::SeqStats->new(-seq => $seq); my $count = $seq_stats->count_monomers(); print "Count: A $count->{A} T $count->{T} G $count->{G} C $count-> +{C}\n"; } __DATA__ >NR_037701 1 aggagctatgaatattaatgaaagtggtcctgatgcatgcatattaaaca tgcatcttacatatgacacatgttcaccttggggtggagacttaatattt aaatattgcaatcaggccctatacatcaaaaggtctattcaggacatgaa ggcactcaagtatgcaatctctgtaaacccgctagaaccagtcatggtcg gtgggctccttaccaggagaaaattaccgaaatcactcttgtccaatcaa agctgtagttatggctggtggagttcagttagtcagcatctggtggagct gcaagtgttttagtattgtttatttagaggccagtgcttatttagctgct agagaaaaggaaaacttgtggcagttagaacatagtttattcttttaagt gtagggctgcatgacttaacccttgtttggcatggccttaggtcctgttt gtaatttggtatcttgttgccacaaagagtgtgtttggtcagtcttatga cctctattttgacattaatgctggttggttgtgtctaaaccataaaaggg aggggagtataatgaggtgtgtctgacctcttgtcctgtcatggctggga actcagtttctaaggtttttctggggtcctctttgccaagagcgtttcta ttcagttggtggaggggacttaggattttatttttagtttgcagccaggg tcagtacatttcagtcacccccgcccagccctcctgatcctcctgtcatt cctcacatcctgtcattgtcagagattttacagatatagagctgaatcat ttcctgccatctcttttaacacacaggcctcccagatctttctaacccag gacctacttggaaaggcatgctgggtctcttccacagactttaagctctc cctacaccagaatttaggtgagtgctttgaggacatgaagctattcctcc caccaccagtagccttgggctggcccacgccaactgtggagctggagcgg
C:\Old_Data\perlp>perl Count: A 244 T 311 G 232 C 213 C:\Old_Data\perlp>

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1030548]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2016-07-27 10:25 GMT
Find Nodes?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?

    Results (242 votes). Check out past polls.