P
PB0711
Hello all,
I have just finished a script with 3 for loops, at the end of which it
generates an HoA. I've printed out that it goes throught all expected
8000 loops but there are only a unique 1599 keys. However, if I print
the keys out before I put them into the HoA I can see that it does all
combinations that I expect. Is this a bug or a size limit on the number
of keys for an HoA??
Thanks,
Paul
-------------OUTPUT------------
1599 <- keys
total 8000
-------------CODE-------------
my @AoA = (
["Ala", "Alanine", "71.08", "3", "2", "1","7", "0"],
["Arg", "Arginine", "156.19", "6", "2", "4", "14", "0"],
["His", "Histidine", "137.14","6","2","3","9", "0"],
["Phe", "Phenylalanine", "147.18", "9", "2", "1", "11", "0"],
["Cys", "Cysteine", "103.14", "3", "2", "1", "7", "1"],
["Gly", "Glycine", "57.05", "2", "2", "1", "5", "0"],
["Gln", "Glutamine", "128.13", "5", "3", "2", "10", "0"],
["Glu", "Glutamate", "129.11", "5", "4", "1", "9", "0"],
["Asp", "Asparte", "115.09", "4", "4", "1", "7", "0"],
["Lys", "Lysine", "128.17", "6", "2", "2", "14", "0"],
["Leu", "Leucine", "113.16", "6", "2", "1", "13", "0"],
["Met", "Methionine", "131.20", "5", "2","1","11", "1"],
["Asn", "Asparagine", "114.10", "4", "3", "2","8", "0"],
["Ser", "Serine", "87.08", "3", "3", "1", "7", "0"],
["Tyr", "Tryosine", "163.17", "9", "3", "1","11", "0"],
["Thr", "Threonine", "101.10", "4", "3", "1", "9", "0"],
["Ile", "Isoleucine", "113.16", "6","2","1","13","0"],
["Trp", "Trytophan","186.21","11","2","2","12", "0"],
["Pro", "Proline", "97.12", "5", "2", "1","9", "0"],
["Val", "Valine", "99.13", "5", "2", "1", "11", "0"],
);
#----------------------------------
#making dipeptides - a nasty way V2 will do a sub
for (my $i=0; $i < $#AoA+1; $i++){
for (my $j=0; $j < $#AoA+1; $j++){
for (my $n=0; $n < $#AoA+1; $n++) {
$total++;
my $formula=0;
my $c=($AoA[$i][3]+$AoA[$j][3])+$AoA[$n][3];
my $o=($AoA[$i][4]+$AoA[$j][4])+$AoA[$n][4];
my $h=($AoA[$i][6]+$AoA[$j][6])+$AoA[$n][6];
my $n=($AoA[$i][5]+$AoA[$j][5])+$AoA[$n][5];
my $s=($AoA[$i][7]+$AoA[$j][7])+$AoA[$n][7];
if ($s == 0){
$formula = "C$c" . "H$h" . "N$n" . "O$o";
} else {
$formula = "C$c" . "H$h" . "N$n" . "O$o" . "S$s";
}
my $mass = ($AoA[$i][2] + $AoA[$j][2]) + $AoA[$n][2];
my $name = "$AoA[$i][0] $AoA[$j][0] $AoA[$n][0]";
$HoA{$name} = [ "$mass", "$formula"];
print "$name\n";
}
}
}
#for my $comp (keys %HoA) {
# print "$comp: @{$HoA{$comp}}\n";
#}
my ($count, $added);
my @key = keys %HoA;
print "$#key <- keys\n";
#----------------------------------
print "total $total\n";
I have just finished a script with 3 for loops, at the end of which it
generates an HoA. I've printed out that it goes throught all expected
8000 loops but there are only a unique 1599 keys. However, if I print
the keys out before I put them into the HoA I can see that it does all
combinations that I expect. Is this a bug or a size limit on the number
of keys for an HoA??
Thanks,
Paul
-------------OUTPUT------------
1599 <- keys
total 8000
-------------CODE-------------
my @AoA = (
["Ala", "Alanine", "71.08", "3", "2", "1","7", "0"],
["Arg", "Arginine", "156.19", "6", "2", "4", "14", "0"],
["His", "Histidine", "137.14","6","2","3","9", "0"],
["Phe", "Phenylalanine", "147.18", "9", "2", "1", "11", "0"],
["Cys", "Cysteine", "103.14", "3", "2", "1", "7", "1"],
["Gly", "Glycine", "57.05", "2", "2", "1", "5", "0"],
["Gln", "Glutamine", "128.13", "5", "3", "2", "10", "0"],
["Glu", "Glutamate", "129.11", "5", "4", "1", "9", "0"],
["Asp", "Asparte", "115.09", "4", "4", "1", "7", "0"],
["Lys", "Lysine", "128.17", "6", "2", "2", "14", "0"],
["Leu", "Leucine", "113.16", "6", "2", "1", "13", "0"],
["Met", "Methionine", "131.20", "5", "2","1","11", "1"],
["Asn", "Asparagine", "114.10", "4", "3", "2","8", "0"],
["Ser", "Serine", "87.08", "3", "3", "1", "7", "0"],
["Tyr", "Tryosine", "163.17", "9", "3", "1","11", "0"],
["Thr", "Threonine", "101.10", "4", "3", "1", "9", "0"],
["Ile", "Isoleucine", "113.16", "6","2","1","13","0"],
["Trp", "Trytophan","186.21","11","2","2","12", "0"],
["Pro", "Proline", "97.12", "5", "2", "1","9", "0"],
["Val", "Valine", "99.13", "5", "2", "1", "11", "0"],
);
#----------------------------------
#making dipeptides - a nasty way V2 will do a sub
for (my $i=0; $i < $#AoA+1; $i++){
for (my $j=0; $j < $#AoA+1; $j++){
for (my $n=0; $n < $#AoA+1; $n++) {
$total++;
my $formula=0;
my $c=($AoA[$i][3]+$AoA[$j][3])+$AoA[$n][3];
my $o=($AoA[$i][4]+$AoA[$j][4])+$AoA[$n][4];
my $h=($AoA[$i][6]+$AoA[$j][6])+$AoA[$n][6];
my $n=($AoA[$i][5]+$AoA[$j][5])+$AoA[$n][5];
my $s=($AoA[$i][7]+$AoA[$j][7])+$AoA[$n][7];
if ($s == 0){
$formula = "C$c" . "H$h" . "N$n" . "O$o";
} else {
$formula = "C$c" . "H$h" . "N$n" . "O$o" . "S$s";
}
my $mass = ($AoA[$i][2] + $AoA[$j][2]) + $AoA[$n][2];
my $name = "$AoA[$i][0] $AoA[$j][0] $AoA[$n][0]";
$HoA{$name} = [ "$mass", "$formula"];
print "$name\n";
}
}
}
#for my $comp (keys %HoA) {
# print "$comp: @{$HoA{$comp}}\n";
#}
my ($count, $added);
my @key = keys %HoA;
print "$#key <- keys\n";
#----------------------------------
print "total $total\n";