def test_string_conversion(self): protein = core.Protein("n", "l", "a-b", "+", "anno") self.assertEqual(str(protein), "l\tn\ta\tb\t+\tanno\n") # test name is used when no locus tag protein = core.Protein("n", "no_locus_tag", "a-b", "+", "anno") self.assertEqual(str(protein), "n\tn\ta\tb\t+\tanno\n") # test location protein = core.Protein("n", "no_locus_tag", "abb", "+", "anno") with self.assertRaises(ValueError) as context: str(protein) self.assertTrue(str(context.exception).startswith("Invalid location in Protein")) protein = core.Protein("n", "no_locus_tag", 123., "+", "anno") with self.assertRaises(AttributeError) as context: str(protein)
def test_missing_removed(self): proteins = {} for name in "ABDEFH": proteins[name] = core.Protein(name, "dummylocus", "1-5", "+", "annotation") clusters = { "1": core.ReferenceCluster("1", "c1", ["A", "B", "C"], "desc", "type", ["tag1"]), "2": core.ReferenceCluster("2", "c1", ["D", "E"], "desc", "type", ["tag3"]), "3": core.ReferenceCluster("3", "c1", ["F", "G"], "desc", "type", ["tag2"]), "4": core.ReferenceCluster("4", "c2", ["H"], "desc", "type", ["tag4"]) } core.strip_clusters_missing_proteins(clusters, proteins) assert sorted(clusters) == ["2", "4"] assert sorted(proteins) == ["D", "E", "H"]
def test_members(self): protein = core.Protein("n", "no_locus_tag", "a-b", "+", "anno") protein.locus_tag = "l" # if this doesn't raise an exception, __slots__ was removed from Protein with self.assertRaises(AttributeError): protein.something = 1