def test_tree_integrity_ascii(self): with open('test_data/tree_example.p', 'rb') as file: test_tree = pickle.load(file) TaxTree.ranked_lineage_filepath = '../../bin/database/taxonomy/rankedlineage.dmp' rootNode = TaxTree.TaxNode("ROOT") TaxTree.loadRankedLineage(species_indexes,rootNode) rootNode.countChildren() ETETree = TaxTree.create_ETE_tree(rootNode) ascii = TaxTree.get_ASCII_tree(ETETree) self.assertEqual(ascii, test_tree)
def test_least(self): with open('test_data/least_example.p', 'rb') as file: least_test = pickle.load(file) TaxTree.ranked_lineage_filepath = '../../bin/database/taxonomy/rankedlineage.dmp' rootNode = TaxTree.TaxNode("ROOT") TaxTree.loadRankedLineage(species_indexes, rootNode) rootNode.countChildren() ranks = ['Species', 'Genus', 'Family', 'Order', 'Class', 'Phylum', 'Kingdom', 'Superkingdom', 'All'] f = io.StringIO() with redirect_stdout(f): for r in ranks: rootNode.calculateCommonnessByRank(r, 5, rootNode, False) output = f.getvalue() self.assertEqual(least_test, output)
def test_ETETree(self): with open('test_data/ETETree_example.p', 'rb') as file: ETETree_example = pickle.load(file) TaxTree.ranked_lineage_filepath = '../../bin/database/taxonomy/rankedlineage.dmp' rootNode = TaxTree.TaxNode("ROOT") TaxTree.loadRankedLineage(species_indexes, rootNode) rootNode.countChildren() ETETree = TaxTree.create_ETE_tree(rootNode) f = io.StringIO() with redirect_stdout(f): ETETree.describe() ETE_describe = f.getvalue() t = io.StringIO() with redirect_stdout(t): ETETree_example.describe() ETE_test_describe = t.getvalue() self.assertEqual(ETE_describe,ETE_test_describe)