Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: What is wrong in this code???

by BillKSmith (Deacon)
on Dec 08, 2012 at 20:02 UTC ( #1007921=note: print w/ replies, xml ) Need Help??


in reply to What is wrong in this code???

A much shorter solution (probably slower) uses a regexp to copy all the A's to a temp array and then uses the size of that array as the count. Repeat for other letters.

use strict; use warnings; use Data::Dumper qw(Dumper); my @letters = ('A', 'T', 'G', 'C', '-'); while (my $seq = <>){ print $seq; my @temp; my %cnts = map {($_, scalar ( @temp = $seq =~ /($_)/g))} @letters; print Dumper \%cnts; }
Bill


Comment on Re: What is wrong in this code???
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2015-07-06 06:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls