Exemple #1
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')
Exemple #2
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')
Exemple #3
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, [])
Exemple #4
0
 def test_locus_cannot_add_spurious_codons(self):
     c = models.Codon()
     with self.assertRaises(ValueError):
         l = models.Locus(codons=[c, 'abc'])
Exemple #5
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))
Exemple #6
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])