Beispiel #1
0
 def test_init(self):
     """NcbiTaxon init should return object containing taxonomy data"""
     good_1 = """1\t|\t1\t|\tno rank\t|\t\t|\t8\t|\t0\t|\t1\t|\t0\t|\t0\t|\t0\t|\t0\t|\t0\t|\t\t|\n"""
     good_2 = """2\t|\t1\t|\tsuperkingdom\t|\t\t|\t0\t|\t0\t|\t11\t|\t0\t|\t0\t|\t0\t|\t0\t|\t0\t|\t\t|\n"""
     good_3 = """6\t|\t2\t|\tgenus\t|\t\t|\t0\t|\t1\t|\t11\t|\t1\t|\t0\t|\t1\t|\t0\t|\t0\t|\t|\n"""
     good_4 = """7\t|\t6\t|\tspecies\t|\tAC\t|\t0\t|\t1\t|\t11\t|\t1\t|\t0\t|\t1\t|\t0\t|\t0\t|\t\t|\n"""
     node_1 = NcbiTaxon(good_1)  # make a NcbiTaxon object
     node_2 = NcbiTaxon(good_2)  # from the corresponding
     node_3 = NcbiTaxon(good_3)  # line.
     node_4 = NcbiTaxon(good_4)
     self.assertEqual(node_1.Rank, "no rank")  # confirm object holds
     self.assertEqual(node_1.RankId, 28)  # right data
     self.assertEqual(node_1.ParentId, 1)
     self.assertEqual(node_2.Rank, "superkingdom")
     self.assertEqual(node_2.RankId, 27)
     self.assertEqual(node_2.ParentId, 1)
     self.assertEqual(node_3.Rank, "genus")
     self.assertEqual(node_3.RankId, 8)
     self.assertEqual(node_3.ParentId, 2)
     self.assertEqual(node_4.Rank, "species")
     self.assertEqual(node_4.RankId, 4)
     self.assertEqual(node_4.ParentId, 6)
     # test some comparisons
     assert node_1 > node_2
     assert node_1 > node_3
     assert node_1 > node_4
     assert node_1 == node_1
     assert node_2 < node_1
     assert node_2 == node_2
     assert node_4 < node_1
     assert node_3 > node_4
Beispiel #2
0
 def test_str(self):
     """NcbiTaxon str should write data in input format from nodes.dmp"""
     good = """2\t|\t1\t|\tsuperkingdom\t|\t\t|\t0\t|\t0\t|\t11\t|\t0\t|\t0\t|\t0\t|\t0\t|\t0\t|\t\t|\n"""
     node = NcbiTaxon(good)
     self.assertEqual(str(node), good)
     root = """1\t|\t1\t|\tno rank\t|\t\t|\t8\t|\t0\t|\t1\t|\t0\t|\t0\t|\t0\t|\t0\t|\t0\t|\t\t|"""
     root_node = NcbiTaxon(root)
     self.assertEqual(str(root), root)