in reply to Weighted frequency of characters in an array of strings
You probably don't need to store your data into an array, and then go through the array, compute your counters right away when reading the data;
Use a hash of counters : $freq{$_} ++;
Don't do the division for each single letter: compute the counters, and only at the end, do the four needed divisions; or calculate 1/@data only once into a variable, and use the variable;
Using tr// is likely to be faster than a regex to count the letters. For example:
$c = "ACCCTGATTGC"; $d = $c =~ tr/A/A/; print $d; # prints 2
|
---|