Sha256: 35ffd78e74ad19dd16ee842a9eec6c4cf215722f94bac96dabf7576863c2903e

Contents?: true

Size: 1.92 KB

Versions: 111

Compression:

Stored size: 1.92 KB

Contents

import unittest

from protein_translation import of_codon, of_rna


class ProteinTranslationTests(unittest.TestCase):

    def test_AUG_translates_to_methionine(self):
        self.assertEqual('Methionine', of_codon('AUG'))

    def test_identifies_Phenylalanine_codons(self):
        for codon in ['UUU', 'UUC']:
            self.assertEqual('Phenylalanine', of_codon(codon))

    def test_identifies_Leucine_codons(self):
        for codon in ['UUA', 'UUG']:
            self.assertEqual('Leucine', of_codon(codon))

    def test_identifies_Serine_codons(self):
        for codon in ['UCU', 'UCC', 'UCA', 'UCG']:
            self.assertEqual('Serine', of_codon(codon))

    def test_identifies_Tyrosine_codons(self):
        for codon in ['UAU', 'UAC']:
            self.assertEqual('Tyrosine', of_codon(codon))

    def test_identifies_Cysteine_codons(self):
        for codon in ['UGU', 'UGC']:
            self.assertEqual('Cysteine', of_codon(codon))

    def test_identifies_Tryptophan_codons(self):
        self.assertEqual('Tryptophan', of_codon('UGG'))

    def test_identifies_stop_codons(self):
        for codon in ['UAA', 'UAG', 'UGA']:
            self.assertEqual('STOP', of_codon(codon))

    def test_translates_rna_strand_into_correct_protein(self):
        strand = 'AUGUUUUGG'
        expected = ['Methionine', 'Phenylalanine', 'Tryptophan']
        self.assertEqual(expected, of_rna(strand))

    def test_stops_translation_if_stop_codon_present(self):
        strand = 'AUGUUUUAA'
        expected = ['Methionine', 'Phenylalanine']
        self.assertEqual(expected, of_rna(strand))

    def test_stops_translation_of_longer_strand(self):
        strand = 'UGGUGUUAUUAAUGGUUU'
        expected = ['Tryptophan', 'Cysteine', 'Tyrosine']
        self.assertEqual(expected, of_rna(strand))

    def test_invalid_codons(self):
        with self.assertRaises(ValueError):
            of_rna('CARROT')


if __name__ == '__main__':
    unittest.main()

Version data entries

111 entries across 111 versions & 1 rubygems

Version Path
trackler-2.2.1.73 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.72 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.71 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.70 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.69 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.68 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.67 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.66 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.65 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.64 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.63 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.62 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.61 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.60 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.59 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.58 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.57 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.56 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.55 tracks/python/exercises/protein-translation/protein_translation_test.py
trackler-2.2.1.54 tracks/python/exercises/protein-translation/protein_translation_test.py