in reply to Re: Re: counting occurances
in thread counting occurances
Outputsmy $temp = <DATA>; print "Discarding the file header line.\n"; print " ", $temp; my @chars = qw( A C G T ); my %cnts; while( <DATA> ) { foreach my $char (@chars) { # my $cnt = () = m/$char/g; # $cnts{$char} += $cnt; # printf " For char '%s' I found %d\n", $char, $cnt; $cnts{$char} += () = m/$char/g; } } foreach my $char (@chars) { printf " Char '%s': %6d\n", $char, $cnts{$char}; } __DATA__ Generated by a completely confused program yesterday ACGTGACTAGAGGCCCGGGGAAAAAAAAAACCCCCCC ACCTGACTAGAGGCCCGGGGAAAAAAAAAACCCCCCC ACGTGACTAGAGGCCCGGGGAAAAAAAAAACCCCCCC AGGTGAGTAGAGGGGGGGGGAAAAAAAAAAGGGGGGG ACGTGACTAGAGGCCCGGGGAAAAAAAAAACCCCCCC
Discarding the file header line.
Generated by a completely confused program yesterday
Char 'A': 70
Char 'C': 49
Char 'G': 56
Char 'T': 10
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: counting occurances
by shenme (Priest) on Sep 19, 2003 at 21:40 UTC |