madM has asked for the wisdom of the Perl Monks concerning the following question:
while (my $key1 = shift @keys) { ##enters loop 2 alignments at the t +ime foreach my $key2 (@keys) { $seq1 =$sequences->{$key1}; $seq2 =$sequences->{$key2}; LINE: for (my $i=0; $i< length $seq1; $i++){ my ($substr1,$substr2) = (substr($seq1,$i,1),substr($seq2, $i, +1)); next LINE if ("$substr1$substr2" =~ /-/); if("$substr1$substr2"=~ /[^@aminos]/){ $else->{$substr1}->{$substr2}+=1; $else->{$substr2}->{$substr1}+=1; next LINE; } if ($substr1 eq $substr2){ $matrix->{$substr1}->{$substr2}++; $eq->{$substr1}++; }elsif ($substr1 ne $substr2){ $matrix->{$substr1}->{$substr2} += 1/2; $matrix->{$substr2}->{$substr1} += 1/2; } } } } print " A C D E F G H I K L M N + P Q R S T V W Y\n\n"; foreach my $key (sort keys %$matrix){ print $key." "x2; foreach my $key2 (sort keys %{$matrix->{$key}}){ printf("%3d ", $matrix->{$key}->{$key2}); } print "\n"x2; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: converting a hash based matrix into an array based matrix
by Athanasius (Cardinal) on Aug 12, 2013 at 17:22 UTC | |
|
Re: converting a hash based matrix into an array based matrix
by SuicideJunkie (Vicar) on Aug 12, 2013 at 17:25 UTC |