55 lines
1.2 KiB
Python
55 lines
1.2 KiB
Python
|
## Genetic code
|
||
|
|
||
|
comp = {
|
||
|
"A": "T",
|
||
|
"T": "A",
|
||
|
"C": "G",
|
||
|
"G": "C",
|
||
|
}
|
||
|
|
||
|
ammin = {
|
||
|
"ser": ("UCG", "UCA", "UCC", "AGU", "UCU", "AGC"),
|
||
|
"leu": ("CUG", "CUA", "CUC", "CUU", "UUG", "UUA"),
|
||
|
"arg": ("AGG", "AGA", "CGU", "CGA", "CGG"),
|
||
|
"ala": ("GCA", "GCG", "GCC", "GCU"),
|
||
|
"gly": ("GGU", "GGG", "GGC", "GGA"),
|
||
|
"pro": ("CCC", "CCA", "CCU", "CCG"),
|
||
|
"thr": ("ACA", "ACC", "ACG", "ACU"),
|
||
|
"val": ("GUG", "GUA", "GUU", "GUC"),
|
||
|
"ile": ("AUC", "AUA", "AUU"),
|
||
|
"asn": ("AAU", "AAC"),
|
||
|
"asp": ("GAC", "GAU"),
|
||
|
"cys": ("UGC", "UGU"),
|
||
|
"gln": ("CAA", "CAG"),
|
||
|
"glu": ("GAA", "GAG"),
|
||
|
"his": ("CAU", "CAC"),
|
||
|
"lys": ("AAA", "AAG"),
|
||
|
"tyr": ("UAC", "UAU"),
|
||
|
"phe": ("UUC", "UUU"),
|
||
|
"trp": ("UGG",),
|
||
|
"stop": ("UAA", "UAG", "UGA"),
|
||
|
}
|
||
|
ammin = {c: a for a in ammin for c in ammin[a]}
|
||
|
|
||
|
|
||
|
def split(sequence):
|
||
|
return map("".join, zip(*[iter(sequence)] * 3))
|
||
|
|
||
|
|
||
|
def cdna(sequence):
|
||
|
return (comp[base] for base in sequence)
|
||
|
|
||
|
|
||
|
def mrna(sequence):
|
||
|
return ("U" if base == "T" else base for base in sequence)
|
||
|
|
||
|
|
||
|
def trna(sequence):
|
||
|
return (ammin[codon] for codon in sequence)
|
||
|
|
||
|
sequence = "ACCGATCGATTACGTATAGTATTTGCTATCATACATATATATCGATGCGTTCAT"
|
||
|
message = split(mrna(cdna(sequence)))
|
||
|
protein = trna(message)
|
||
|
|
||
|
print(*protein)
|