суббота, 14 января 2017 г.

Inferring mRNA from Protein (ROSALIND MRNA)

Given: A protein string of length at most 1000 aa.

Return: The total number of different RNA strings from which the protein could have been translated, modulo 1,000,000. (Don't neglect the importance of the stop codon in protein translation.)

Using my old function codon_table()

def rev_codon_table():
    c_t = codon_table()
    rev_c_t = {}
    for key in sorted(c_t.keys()):
        val = c_t[key]
        if val in rev_c_t:
            rev_c_t[val] += 1 
        else:
            rev_c_t[val] = 1     
    return rev_c_t

f = open('mrna.txt', 'r')
line = ''for l in f:
    line += l
line = line.replace('\n', '')

rct = rev_codon_table()
res = 3 #there are 3 stop-codons 
for s in line:
    res = res*rct[s]%1000000
print(res)

Комментариев нет:

Отправить комментарий