def test_jc69_from_alignment(self): """compute JC69 dists from an alignment""" calc = JC69Pair(DNA, alignment=self.alignment) calc.run(show_progress=False) self.assertEqual(calc.lengths["s1", "s2"], 10) self.assertEqual(calc.proportions["s1", "s2"], 0.2) # value from OSX MEGA 5 assert_allclose(calc.dists["s1", "s2"], 0.2326161962) # value**2 from OSX MEGA 5 assert_allclose(calc.variances["s1", "s2"], 0.029752066125078681) # value from OSX MEGA 5 assert_allclose(calc.stderr["s1", "s2"], 0.1724878724) # same answer when using ambiguous alignment calc.run(self.ambig_alignment, show_progress=False) assert_allclose(calc.dists["s1", "s2"], 0.2326161962) # but different answer if subsequent alignment is different calc.run(self.diff_alignment, show_progress=False) self.assertTrue(calc.dists["s1", "s2"] != 0.2326161962)
def test_wrong_moltype(self): """specifying wrong moltype raises ValueError""" with self.assertRaises(ValueError): _ = JC69Pair(PROTEIN, alignment=self.alignment)