#! perl -slw
use strict;
use Time::HiRes qw[ time ];
use List::Util qw[sum];;
my $sequence = join'', map{ ( qw[ A C G T ] )[ rand 4 ] } 1 .. 600_000
+;
my $start = time;
my( %one, %two, %three );
$one{ $_ }++ for unpack '(A1)*', $sequence;
$two{ $_ }++ for unpack '(A2X)*', $sequence;
delete @two{ (qw'A C G T') };;
$three{ $_ }++ for unpack '(A3XX)*', $sequence;
delete @three{ (qw'AA AC AG AT CA CC CG CT GA GC GG GT TA TC TG TT') }
+;
printf "Elapsed: %3f seconds\n", time - $start;
print sum values %one;
print sum values %two;
print sum values %three;
__END__
P:\test>junk
Elapsed: 3.390625 seconds
600000
599999
599998
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
| [reply] [d/l] |