示例#1
0
 def test_locus_add_codon(self):
     c = models.Codon()
     l = models.Locus()
     for codon in [c, 'atg']:
         l.add_codon(codon)
     self.assertEqual(len(l.codons), 2)
     self.assertEqual(l.codons[0].seq, '---')
     self.assertEqual(l.codons[1].seq, 'atg')
示例#2
0
 def test_locus_init(self):
     l = models.Locus()
     self.assertEqual(l.loc, 0)
     self.assertEqual(l.loc_aa, 1)
     self.assertEqual(l.__str__(), '<Locus >')
     l = models.Locus(codons=[models.Codon(), 'atg'])
     self.assertEqual(len(l.codons), 2)
     self.assertEqual(l.codons[0].seq, '---')
     self.assertEqual(l.codons[1].seq, 'atg')
示例#3
0
 def test_make_sub_from_p(self):
     q = models.goldman_Q(scale_q=False)
     p = models.convert_q_to_p(q, t=10)
     p_cumsum, p_codons, p_cumsum_dict = models.get_cumulative_p(p, return_dict=True)
     old_codon_seq = 'aaa'
     old_codon = models.Codon(seq=old_codon_seq)
     models.make_sub_from_p(old_codon, p_cumsum_dict)
     self.assertEqual(len(old_codon.seq), 3)
     allowed_letters = 'atgc'
     for i in old_codon.seq:
         self.assertIn(i, allowed_letters)
示例#4
0
 def test_make_subs_in_locus(self):
     q = models.goldman_Q(scale_q=False)
     p = models.convert_q_to_p(q, t=10)
     p_cumsum, p_codons, p_cumsum_dict = models.get_cumulative_p(p, return_dict=True)
     old_codon_seq = 'aaa'
     old_codons = [models.Codon(seq=old_codon_seq)]*2
     locus = models.Locus(codons=old_codons)
     old_seq = locus.sequence
     while locus.sequence == old_seq:
         models.make_subs_in_locus(locus, p_cumsum_dict)
     self.assertNotEqual(locus.history, [])
示例#5
0
 def test_locus_cannot_add_spurious_codons(self):
     c = models.Codon()
     with self.assertRaises(ValueError):
         l = models.Locus(codons=[c, 'abc'])
示例#6
0
 def test_codon_delete(self):
     c = models.Codon(seq='atg')
     self.assertEqual(c.seq, 'atg')
     c.delete()
     self.assertEqual(c.seq, '---')
示例#7
0
 def test_codon_seq_validation(self):
     c = models.Codon()
     c.seq = 'a'
     self.assertEqual(c.seq, 'a--')
示例#8
0
 def test_codon_init(self):
     c = models.Codon()
     self.assertEqual(c.__str__(), '<Codon --->')
示例#9
0
 def test_make_indel_force_insertion(self):
     c = models.Codon(seq='atg')
     l = models.Locus(codons=[c])
     models.make_indel(l, index=0, ti_td=1e12, codon_freq=None)
     self.assertEqual(len(l.codons), 2)
     self.assertFalse(any(i.seq == '---' for i in l.codons))
示例#10
0
 def test_make_indel_force_deletion(self):
     c = models.Codon(seq='atg')
     l = models.Locus(codons=[c])
     models.make_indel(l, index=0, ti_td=0.0, codon_freq=None)
     self.assertIn('---', [i.seq for i in l.codons])