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)
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
def test_unknown_codon(self): with self.assertRaises(ValueError): translate_dna('ACGXACGG')
def test_not_multiple_of_three(self): result = translate_dna('acgCACtc') expected = 'TH' self.assertEqual(result, expected)
def test_lower_case(self): result = translate_dna('acgCACtca') expected = 'THS' self.assertEqual(result, expected)