def test_translate_varied_genetic_codes(self): # spot check using a few NCBI and custom genetic codes to translate seq = RNA('AAUGAUGUGACUAUCAGAAGG') # table_id=2 exp = Protein('NDVTI**') obs = GeneticCode.from_ncbi(2).translate(seq) self.assertEqual(obs, exp) exp = Protein('MTI') obs = GeneticCode.from_ncbi(2).translate(seq, start='require', stop='require') self.assertEqual(obs, exp) # table_id=22 exp = Protein('NDVTIRR') obs = GeneticCode.from_ncbi(22).translate(seq) self.assertEqual(obs, exp) with six.assertRaisesRegex(self, ValueError, 'reading_frame=1.*start=\'require\''): GeneticCode.from_ncbi(22).translate(seq, start='require', stop='require') # custom, no start codons gc = GeneticCode('MWN*' * 16, '-' * 64) exp = Protein('MM*MWN*') obs = gc.translate(seq) self.assertEqual(obs, exp) with six.assertRaisesRegex(self, ValueError, 'reading_frame=1.*start=\'require\''): gc.translate(seq, start='require', stop='require')
def test_translate_varied_genetic_codes(self): # spot check using a few NCBI and custom genetic codes to translate seq = RNA('AAUGAUGUGACUAUCAGAAGG') # table_id=2 exp = Protein('NDVTI**') obs = GeneticCode.from_ncbi(2).translate(seq) self.assertEqual(obs, exp) exp = Protein('MTI') obs = GeneticCode.from_ncbi(2).translate(seq, start='require', stop='require') self.assertEqual(obs, exp) # table_id=22 exp = Protein('NDVTIRR') obs = GeneticCode.from_ncbi(22).translate(seq) self.assertEqual(obs, exp) with self.assertRaisesRegex(ValueError, 'reading_frame=1.*start=\'require\''): GeneticCode.from_ncbi(22).translate(seq, start='require', stop='require') # custom, no start codons gc = GeneticCode('MWN*' * 16, '-' * 64) exp = Protein('MM*MWN*') obs = gc.translate(seq) self.assertEqual(obs, exp) with self.assertRaisesRegex(ValueError, 'reading_frame=1.*start=\'require\''): gc.translate(seq, start='require', stop='require')
def test_from_ncbi_valid_table_ids(self): # spot check a few tables self.assertEqual(GeneticCode.from_ncbi().name, 'Standard') self.assertEqual( GeneticCode.from_ncbi(2).name, 'Vertebrate Mitochondrial') self.assertEqual( GeneticCode.from_ncbi(12).name, 'Alternative Yeast Nuclear') self.assertEqual( GeneticCode.from_ncbi(25).name, 'Candidate Division SR1 and Gracilibacteria')
def test_from_ncbi_valid_table_ids(self): # spot check a few tables self.assertEqual(GeneticCode.from_ncbi().name, 'Standard') self.assertEqual(GeneticCode.from_ncbi(2).name, 'Vertebrate Mitochondrial') self.assertEqual(GeneticCode.from_ncbi(12).name, 'Alternative Yeast Nuclear') self.assertEqual(GeneticCode.from_ncbi(25).name, 'Candidate Division SR1 and Gracilibacteria')
def test_from_ncbi_invalid_input(self): with six.assertRaisesRegex(self, ValueError, 'table_id.*7'): GeneticCode.from_ncbi(7) with six.assertRaisesRegex(self, ValueError, 'table_id.*42'): GeneticCode.from_ncbi(42)
def setUp(self): self.sgc = GeneticCode.from_ncbi(1)
def test_from_ncbi_invalid_input(self): with self.assertRaisesRegex(ValueError, 'table_id.*7'): GeneticCode.from_ncbi(7) with self.assertRaisesRegex(ValueError, 'table_id.*42'): GeneticCode.from_ncbi(42)
def setUp(self): self.sgc = GeneticCode.from_ncbi(1)