def setUp(self): self.node0 = taxidTools.Node(taxid=0, name="root", rank="root", parent=None) self.node1 = taxidTools.Node(taxid=1, name="node1", rank="rank1", parent=self.node0) self.node2 = taxidTools.Node(taxid=2, name="node2", rank="rank1", parent=self.node0) self.node11 = taxidTools.Node(taxid=11, name="node11", rank="rank2", parent=self.node1) self.node12 = taxidTools.Node(taxid=12, name="node12", rank="rank2", parent=self.node1) self.node21 = taxidTools.Node(taxid=21, name="node21", rank="rank2", parent=self.node2) self.node22 = taxidTools.Node(taxid=22, name="node22", rank="rank2", parent=self.node2) self.node23 = taxidTools.Node(taxid=23, name="node23", rank="rank2", parent=self.node2) self.node121 = taxidTools.Node(taxid=121, name="node121", rank="rank3", parent=self.node12) self.node122 = taxidTools.Node(taxid=122, name="node122", rank="rank3", parent=self.node12) nodes = { "0": self.node0, "1": self.node1, "2": self.node2, "11": self.node11, "12": self.node12, "21": self.node21, "22": self.node22, "23": self.node23, "121": self.node121, "122": self.node122 } self.txd = taxidTools.Taxonomy(nodes)
def setUp(self): self.parent = taxidTools.Node(taxid=0, name="root", rank="root", parent=None) self.child = taxidTools.Node(taxid=1, name="child", rank="child", parent=self.parent) self.txd = taxidTools.Taxonomy({'0': self.parent, '1': self.child})
def test_consensus_dummynodes(self): node0 = taxidTools.Node(0) node1 = taxidTools.Node(1, parent=node0) dummy1 = taxidTools.DummyNode(parent=node0) node2 = taxidTools.Node(2, parent=node1) node3 = taxidTools.Node(3, parent=dummy1) node4 = taxidTools.Node(4, parent=dummy1) tax = taxidTools.Taxonomy.from_list( [node0, node1, dummy1, node2, node3, node4]) cons = tax.consensus(["2", "3", "4"], 0.51) self.assertEqual(cons, node0)
def test_insert_nodes_recc(self): node001 = taxidTools.Node('001', name="node0011", rank="rank3", parent=self.node0) node3 = taxidTools.Node('3', name="node3", rank="rank1", parent=self.node0) self.txd.addNode(node3) new_nodes = _insert_nodes_recc(self.node0, ['rank3', 'rank2', 'rank1.5', 'rank1']) self.assertEqual(len(new_nodes), 15)
def test_filter(self): node001 = taxidTools.Node('001', name="node0011", rank="rank3", parent=self.node0) self.txd.addNode(node001) self.txd.filterRanks(ranks=['rank3', 'rank1']) self.assertEqual(len(self.txd), 8) # test relinking self.assertEqual(self.node121.parent, self.node1) self.assertIsInstance(node001.parent, taxidTools.DummyNode)
def setUp(self): self.parent = taxidTools.Node(taxid = 0, name = "root", rank = "root", parent = None) self.rank1 = taxidTools.Node(taxid = 1, name = "node1", rank = "rank1", parent = self.parent) self.rank2 = taxidTools.Node(taxid = 2, name = "node2", rank = "rank2", parent = self.rank1) self.rank3 = taxidTools.Node(taxid = 3, name = "node3", rank = "rank3", parent = self.rank2)
def setUp(self): self.node = taxidTools.Node(taxid=123456) self.midnode = taxidTools.Node(taxid=2, parent=self.node) self.lownode = taxidTools.Node(taxid=3, parent=self.midnode)
def test_parent(self): parent1 = taxidTools.Node(taxid=789) self.node.parent = parent1 self.assertEqual(self.node.parent.taxid, "789")