📌  相关文章
📜  当给定一串mRNA代码时,要构建的函数amino_acids必须返回一个元组列表和一个整数. - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:10.857000             🧑  作者: Mango

代码示例1
def amino_acids(mrna):
    protein = ""  # Start with empty protein string
    translation = {"AUG": "Met", "CCA": "Pro", "CCU": "Pro"}  # Which codon translates for which amino acid
    stop_codons = {"UGA"}  # Define stop codons
    while mrna:  # Repeat loop while mRNA isn't exhausted
        codon = mrna[:3]  # Select first three codes
        mrna = mrna[3:]  # Remove current codon from mRNA
        if codon in stop_codons:
            break  # Break loop if triple is a stop codon
        amino_acid = translation[codon]  # Translate codon into its amino acid
        protein += amino_acid  # Add the amino acid to the protein string
    return protein

print(amino_acids("AUGCCACCUUGA"))