in reply to manipulating hashes

The counts get messed up because you changed the while loop to an if statement... to get 0 for the unseen combinations, just assign 0 before the while loop, like this:
foreach $prot_string (@truncated_sequences) { foreach $tri_seq (@triamino_combo) { $tri_freq{$tri_seq} = 0; while ($prot_string =~ /$tri_seq/g) { $tri_freq{$tri_seq}++; } } }

-- Mike

--
just,my${.02}

Replies are listed 'Best First'.
Re: Re: manipulating hashes
by insensate (Hermit) on Nov 19, 2002 at 19:23 UTC
    Then you're starting back at 0 for each $prot_string... I'm not sure that's what you want...You can also use index()
    foreach $prot_string (@truncated_sequences) { foreach $tri_seq (@triamino_combo) { $i=-1; while(($i=index($prot_string,$tri_seq,$i)) > -1){ $tri_freq{$tri_seq}++; $i+=3; } $tri_freq{$tri_seq}='0' unless defined $tri_freq{$tri_seq}; } }