3

寻找故障排除和编辑帮助。这是一个家庭作业。我的教授鼓励使用论坛。我还没有使用 Perl Functions 或 Subs 的经验,所以请将响应限制在适当的级别,以便我理解。

该脚本的目的是读取一串 DNA(或我稍后将添加的命令行文件),将其翻译成 RNA,然后以大写单字母氨基酸名称的形式返回蛋白质的值。

脚本的作用:

  1. 从第一个字符中取出 3 个字符“密码子”,并给它们一个单字母符号(哈希表中的大写单字母氨基酸名称)

  2. 打印以 AUG(“M”)开头并以 UAG、UAA 或 UGA 结尾的字符串的 RNA 蛋白质。

  3. 如果遇到间隙,则启动新行并重复该过程。我们可以假设间隙是三的倍数。

据我所知,主要问题:

  1. 我不知道数据在哪里循环通过哈希表。我试过在我的 Foreach 块之前和之后放置它。我还完全取消了 Foreach 块并尝试了 While & If。

  2. Foreach 块似乎并未处理所有 @all_codons 数组,仅在 AUG 处停止。

  3. 明显和最大的问题是它什么也没返回。沿途某处 $next_codon 值被分配“假”。我已经尝试逐条注释每一行 - 返回任何内容的最后一行是 My $start 并且从那里开始它都是错误的。

剧本:

$^W = 1;
use strict;


my $dna_string = "CCCCAAATGCTGGGATTACAGGCGTGAGCCACCACGCCCGGCCACTTGGCATGAATTTAATTCCCGCCATAAACCTGTGAGATAGGTAATTCTGTTATATCCACTTTACAAATGAAGAGACTGAGGCAAAGAAAGATGATGTAACTTACGCAAAGC";

my %codon_codes = (
    "UUU" => "f", "UUC" => "f", "UUA" => "l", "UUG" => "l",
    "CUU" => "l", "CUC" => "l", "CUA" => "l", "CUG" => "l",
    "AUU" => "i", "AUC" => "i", "AUA" => "i", "AUG" => "m",
    "GUU" => "v", "GUC" => "v", "GUA" => "v", "GUG" => "v",
    "UCU" => "s", "UCC" => "s", "UCA" => "s", "UCG" => "s",
    "CCU" => "p", "CCC" => "p", "CCA" => "p", "CCG" => "p",
    "ACU" => "t", "ACC" => "t", "ACA" => "t", "ACG" => "t", 
    "GCU" => "a", "GCC" => "a", "GCA" => "a", "GCG" => "a",
    "UAU" => "y", "UAC" => "y", "UAA" => " ", "UAG" => " ",
    "CAU" => "h", "CAC" => "h", "CAA" => "q", "CAG" => "q",
    "AAU" => "n", "AAC" => "n", "AAA" => "k", "AAG" => "k"
 );

my $rna_string = $dna_string;
$rna_string =~ tr/[tT]/U/;

my @all_codons = ($rna_string =~ m/.../g);

foreach my $next_codon(@all_codons){
            
    while ($next_codon =~ /AUG/gi){
            
        my $start = pos ($next_codon) -3;
    
        last unless $next_codon =~ /U(AA|GA|AG)/gi;
    
        my $stop = pos($next_codon);
            
        my $genelen = $stop - $start;
            
        my $gene = substr ($next_codon, $start, $genelen);
            
        print "\n" . join($start+1, $stop, $gene,) . "\n";
    }
}
4

1 回答 1

3

我不明白“通过哈希表的数据循环”部分。

在我看来,对于每个密码子,您需要检查它是起始密码子、终止密码子、缺口还是氨基酸。而且您需要某种方式来保持状态(如下所示$in_gene)。

my $in_gene = 0;

foreach my $next_codon(@all_codons){
    if ($next_codon eq 'AUG') {
        $in_gene = 1;
    }
    elsif ($next_codon =~ m/U(AA|GA|AG)/) {
        $in_gene = 0;
    }
    elsif ($in_gene == 1) {
        my $aminoacid = $codon_codes{$next_codon};
        print "\n" and next unless defined $aminoacid;
        print $aminoacid;
    }
}

这打印

l
lqak
l
q
k
于 2010-11-09T07:57:23.080 回答