回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>代码:</p>
<pre class="lang-py prettyprint-override"><code>n = 3
DNA-Sequence = { #dictionary of DNA
"Phenylalanine": ["UUU", "UUC"],
"Leucine": ["UUA", "CUU", "CUC", "CUA", "CUG", "UUG"],
"Isoleucine": ["AUU", "AUC", "AUA"],
"Methionine": "AUG",
"Valine": ["GUU", "GUC", "GUA", "GUG"],
"Serine": ["UCU", "UCC", "UCA", "UCG"],
"Proline": ["CCU", "CCC", "CCA", "CCG"],
"Threonine": ["ACU", "ACC", "ACA", "ACG"],
"Alanine": ["GCU", "GCC", "GCA", "GCG"],
"Tyrosine": ["UAU", "UAC"],
"Histidine": ["CAU", "CAC"],
"Glutamine": ["CAA", "CAG"],
"Asparagine": ["AAU", "AAC"],
"Lysine": ["AAA", "AAG"],
"Asparatic Acid": ["GAU", "GAC"],
"Glutamic Acid": ["GAA", "GAG"],
"Cysteine": ["UGU", "UGC"],
"Trytophan": "UGG",
"Arginine": ["CGU", "CGC", "CGA", "CGG", "AGG", "AGA"],
"Serine": ["AGU", "AGC"],
"Glycine": ["GGU", "GGC", "GGA", "GGG"]
}
lookup_dict = {k: key for key, values in DNA-Sequence.items() for k in values} #this is used to find the values in the dictionary using the inputDNA
inputDNA = input("Enter your DNA sequence: ")
inputDNA = inputDNA.upper()
print("Your DNA sequence is", inputDNA)
str(inputDNA)
RNA = inputDNA.replace('C', 'G') #this is me trying to convert DNA sequence to RNA
RNA = RNA.replace('A', "U") #this is me trying to convert DNA sequence to RNA
RNA = RNA.replace('T', 'A') #this is me trying to convert DNA sequence to RNA
print(RNA)
b = len(inputDNA)
if b % 3 == 0: #if the length of inputDNA is a multiple of 3
for k in (inputDNA[i:i + n] for i in range(0, len(inputDNA), n)):
for _, values in DNA-Sequence.items():
if k in values:
print(lookup_dict[k], end=" ")
break
else: #if the length of inputDNA is not a multiple of 3
print("I hate u")
</code></pre>
<p>发生了什么:</p>
<pre><code>Enter your DNA sequence: CCATAGCACGTT
Your DNA sequence is: CCATAGCACGTT
GGUAUGGUGGAA
Proline I hate u
Histidine I hate u
</code></pre>
<p>我想发生什么:</p>
<pre><code>Enter your DNA sequence: CCATAGCACGTT
Your DNA sequence is: CCATAGCACGTT #this is because I need to convert DNA sequence to RNA but I am not sure of the formula and how to do it in python
GGUAUCGUGCAA
Your amino acids chain is: Glycine, Isoleucine, Valine, Glutamine
</code></pre>
<p>为什么我要得到<code>A</code>的输出,如何将其修复为我想要的输出?我知道我没有做<code>RNA = RNA.replace('G', 'C')</code>,但是当我做了那件事,输出就变成了</p>
<pre><code>Enter your DNA sequence: CAACAUGCU
Your DNA sequence is CAACAUGCU
A
Glutamine Histidine Alanine
</code></pre>
<p>或者类似的事情,但肯定不是我所做的。请帮忙?你知道吗</p>