def test_one(): # Just use the defaults c = Configuration() c.init() p = Parser(c) p.parse_configuration(test1) assert len(c.user_subsets) == 9 assert len(c.user_schemes) == 6
def test_identity(): c = Configuration() c.init() s1 = Subset(c, set(range(10))) s2 = Subset(c, set(range(20))) s3 = Subset(c, set(range(10, 20))) s4 = Subset(c, set(range(20))) # Not just equal BUT THE SAME (see the __new__ member of the class Subset) assert s1 is not s2 assert s1 is not s3 assert s2 is s4
def test_overlap(caplog): c = Configuration() c.init() s1 = Subset(c, set(range(10))) s2 = Subset(c, set(range(10, 20))) s3 = Subset(c, set(range(9, 20))) # This should be okay... Scheme(c, 'a', [s1, s2]) # This isn't with pytest.raises(SchemeError): Scheme(c, 'a', [s1, s3]) assert "contains overlapping" in caplog.text()
def test_construction(): c = Configuration() p1 = Partition(c, 'one', (1, 10)) Partition(c, 'two', (11, 20)) Partition(c, 'three', (21, 21)) assert p1.columnset == set(range(10)) assert c.partitions.columnset == set(range(0, 21))
def test_parse_aminoacid(): pth = os.path.join(MISC_PATH, 'raxml_aminoacid.output') c = Configuration().init(datatype='protein', phylogeny_program="raxml") p = raxml.Parser(c) res = p.parse(open(pth).read()) expected = numpy.array([ 0.046704, 0.017460, 0.068093, 0.030991, 0.003492, 0.021388, 0.027499, 0.064164, 0.027499, 0.131820, 0.121781, 0.019642, 0.061545, 0.073330, 0.035356, 0.102139, 0.048014, 0.025753, 0.035356, 0.037975 ]) assert numpy.allclose(res.freqs[0], expected)
def test_parse_nucleotide(): pth = os.path.join(MISC_PATH, 'raxml_nucleotide.output') c = Configuration().init(datatype='DNA', phylogeny_program="raxml") p = raxml.Parser(c) res = p.parse(open(pth).read()) expected = numpy.array([ 0.315909, 0.232955, 0.190909, 0.260227, ]) assert numpy.allclose(res.freqs[0], expected)
def test_parse_lg4m(): pth = os.path.join(MISC_PATH, 'raxml_aminoacid_LG4M+G.output') c = Configuration().init(datatype='protein', phylogeny_program="raxml") p = raxml.Parser(c) res = p.parse(open(pth).read()) # Make sure we got the first block of rates expected = numpy.array([ 0.082276, 0.055172, 0.043853, 0.053484, 0.018957, 0.028152, 0.046679, 0.15781701, 0.033297, 0.028284, 0.054284, 0.025275, 0.023665, 0.041874, 0.063071, 0.066501, 0.065424, 0.023837, 0.038633, 0.049465 ]) assert numpy.allclose(res.freqs[0], expected)
def test_identity(): c = Configuration() pa = Partition(c, 'a', (1, 10, 3)) pb = Partition(c, 'b', (2, 10, 3)) pc = Partition(c, 'c', (3, 10, 3)) s1 = Subset(pa, pb) s2 = Subset(pa, pb) s3 = Subset(pa, pc) s4 = Subset(pa, pb) # Not just equal BUT THE SAME assert s1 is s2 assert s1 is s4 assert s1 is not s3
def test_overlap(): c = Configuration() with pytest.raises(PartitionError): Partition(c, 'one', (1, 10)) Partition(c, 'two', (10, 20))