我正在使用数组中的 foreach 循环获取文件的输出。
获取所有内容后,如何仅将文件的一部分提取到新数组中。
这是我的代码
foreach (@genetic_codes) {
chomp;
my @genetic_codes = split(':', $_);
if (@genetic_codes != 5) { # error on this line next;
}
my $amino_acid = join('","', split(/,/, $genetic_codes[4]));
print "$genetic_codes[2]=> [$genetic_codes[0],$genetic_codes[1],[$amino_acid]],\n";
}
这是我的正确输出。
"M"=> ["Methionine","Met",["ATG"]],
"F"=> ["Phenylalanine","Phe",["TTT"," TTC"]],
"P"=> ["Proline","Pro",["CCT"," CCC"," CCA"," CCG"]],
"S"=> ["Serine","Ser",["TCT"," TCC"," TCA"," TCG"," AGT"," AGC"]],
"T"=> ["Threonine","Thr",["ACT"," ACC"," ACA"," ACG"]],
"W"=> ["Tryptophan","Trp",["TGG"]],
现在我需要获取所有密码子并将它们放入一个变量Z
中以消除重复项。
我需要单独制作一个foreach循环吗?
我完全迷路了,请帮助。我需要我的最后一个输出----
"Z"=>["ACT","AGT",---------------SO ON]],
上面一行的所有三个字母都在一个变量中。