Exemplo n.º 1
0
    def test_translation_ends_at_stop_codon(self):
        result = translate_dna('acgTAGtc')
        expected = 'T*'
        self.assertEqual(result, expected)

        result = translate_dna('TAA')
        expected = '_'
        self.assertEqual(result, expected)

        result = translate_dna('ACGCACTATGAGTGA')
        expected = 'THYE_'
        self.assertEqual(result, expected)
Exemplo n.º 2
0
def translate():
    data = request.json
    dna_sequence = data['dna_sequence']

    if not is_valid_dna_sequence(dna_sequence):
        raise UnprocessableEntity('DNA character not recognised')

    try:
        protein_sequence = translate_dna(dna_sequence)
    except ValueError as exception:
        raise UnprocessableEntity(str(exception))

    return protein_sequence
Exemplo n.º 3
0
 def test_unknown_codon(self):
     with self.assertRaises(ValueError):
         translate_dna('ACGXACGG')
Exemplo n.º 4
0
 def test_not_multiple_of_three(self):
     result = translate_dna('acgCACtc')
     expected = 'TH'
     self.assertEqual(result, expected)
Exemplo n.º 5
0
 def test_lower_case(self):
     result = translate_dna('acgCACtca')
     expected = 'THS'
     self.assertEqual(result, expected)