Exemple #1
0
def encode(dna, peptide):
    rna = transcribe(dna)
    reverse_complement_rna = transcribe(reverse_complement(dna))
    rna_substr_len = len(peptide) * 3

    return [dna[i:i + rna_substr_len] for i in range(0, len(rna) - rna_substr_len + 1) if
            translate(rna[i:i + rna_substr_len]) == peptide or
            translate(reverse_complement_rna[len(rna) - (i + rna_substr_len):len(rna) - i]) == peptide]
Exemple #2
0
import encoding
import protein_translation
import sys

switch = sys.argv[1]
filename = sys.argv[2]

with open(filename, 'r') as f:
    if switch == 'encoding':
        text = f.readline().strip()
        peptide = f.readline().strip()
        print('\n'.join(encoding.encode(text, peptide)))

    else:
        input = f.readline().strip()
        print(protein_translation.translate(input))
def test_translate():
    input = 'AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA'
    expected = 'MAMAPRTEINSTRING'
    actual = translate(input)

    assert (expected == actual)