我正在尝试将我用 C++ 制作的程序重新创建为 C# windows 窗体程序,我已经完成了大部分工作。有一件小事使程序无法正常工作。
我的程序是一个生物信息学程序,它允许用户输入 DNA 或 RNA 字符的字符串/序列,程序将其转换为相应的蛋白质/氨基酸,并为程序看到的每个密码子打印出一个氨基酸/蛋白质。因此,如果我输入“AAA GGG CCC”,它会打印出“赖氨酸甘氨酸脯氨酸”。
这是我在 C++ 版本中遇到问题的代码片段
for (i=0; i<numberOfCodons;i++)
{
endIndex=beginIndex+3;
codon="";
{
//here is where I'm having the trouble converting this to C# and have it cout the write
//way
codon.append(RNA.substr(beginIndex,endIndex-beginIndex));
}
for (k=0;k<64;k++)
{
if(codon==codons[k])
{
//here is where I'm having the trouble converting this to C# and have it cout the write way
//like I metioned previously AAA GGG CCC couts Lysine Glycine Proline
protein.append(aminoAcids[k]);
}
}
beginIndex+=3;
}
cout<<protein<<endl;
protein.clear();
到目前为止,这是我在 c# 中所拥有的
private void Tranlate_Click(object sender, EventArgs e)
{
numberOfCodons = rnaLength / 3;
beginIndex = 0;
richTextBox2.AppendText("Total Number Of codons are: ");
richTextBox2.AppendText(numberOfCodons.ToString());
richTextBox2.AppendText("\n");
for (i = 0; i < numberOfCodons; i++)
{
endIndex = beginIndex + 3;
codon = "";
{
// these are the two possible conversions of the C++ code that dont work at all for me******
// codon.AppendText(RNA.Substring(beginIndex, endIndex - beginIndex));
codon=(RNA.Substring(beginIndex, endIndex - beginIndex));
}
for (k = 0; k < 64; k++)
{
if (codon == codons[k])
{
//supposed to print out all the coresponding amino acids from the array and it will only print out one amino acid (Lysine)*******
//protein.AppendText(aminoAcids[k]);
protein = (aminoAcids[k]);
}
}
beginIndex += 3;
}
richTextBox2.AppendText(protein);
richTextBox2.AppendText("\n");
//protein.clear();
}
为什么会这样,我该如何解决?