def test_mixed(self): domains = [ DummyHMMResult("PKS_KS", start=1, end=40), DummyHMMResult("PKS_AT", start=50, end=90), DummyHMMResult("PKS_KS", start=100, end=140), ] sub_hits = [DummyHMMResult("trans-AT", start=99, end=139)] assert self.func(domains, sub_hits) == ["", "trans-AT"]
def test_module_for_orphans(self): for name in [ NRPS_START, NRPS_LOAD, PKS_START, PKS_LOAD, "cMT", "ACP", "Trans-AT_docking" ]: modules = build_modules_for_cds([DummyHMMResult(name)], [DummyHMMResult("")]) assert len(modules) == 1 assert not modules[0].is_complete()
def test_construction(self): domain = DummyHMMResult("ACP") component = Component(domain) assert component.domain == domain assert component.label == domain.hit_id assert component.subtype == "" assert component.classification == "CP" domain._hit_id = PKS_START component = Component(domain, "some-subtype") assert component.subtype == "some-subtype" assert component.classification == "KS"
def test_json(self): component = Component(DummyHMMResult(PKS_START), subtype=TRANS_AT_SUBTYPE) intermediate = component.to_json() new = Component.from_json(json.loads(json.dumps(intermediate))) assert new.to_json() == intermediate assert new.domain == component.domain assert new.subtype == TRANS_AT_SUBTYPE assert new.classification == component.classification
def test_starters(self): for domain_type in [NRPS_LOAD, PKS_LOAD]: domains = [DummyHMMResult(i) for i in [domain_type, "ACP", domain_type, "ACP"]] modules = build_modules_for_cds(domains, []) print(modules) assert len(modules) == 2 assert modules[0]._first_in_cds assert modules[0].is_complete() assert not modules[1]._first_in_cds print(modules[1], modules[1].is_complete()) print(modules[1]._starter, modules[1]._loader, modules[1]._carrier_protein, modules[1]._starter is modules[1]._loader) assert not modules[1].is_complete()
def test_module_for_each_starter(self): modules = build_modules_for_cds([ DummyHMMResult("Condensation_DCL"), DummyHMMResult("Condensation_LCL") ], []) assert len(modules) == 2
def test_unclassifiable(self): with self.assertRaisesRegex(ValueError, "could not classify domain"): build_modules_for_cds([DummyHMMResult("UNCLASSIFIABLE")], [])
def test_no_empties(self): assert build_modules_for_cds([], []) == [] assert build_modules_for_cds([DummyHMMResult("ACPS")], []) == []
def test_mismatching_ks_subtypes(self): with self.assertRaises(StopIteration): build_modules_for_cds([DummyHMMResult(PKS_START)], [])
def dummy_hmm(hit_id="dummy", start=1): return DummyHMMResult(hit_id, start, start + 40, 1e-5, 10)
def test_condensation(self): for cond in CLASSIFICATIONS["C"]: assert Component(DummyHMMResult(cond)).is_condensation() assert not Component(DummyHMMResult(NRPS_LOAD)).is_condensation()
def add_component(module, name, sub="", start=1, end=10, cds_name="test_name"): assert cds_name module.add_component( Component(DummyHMMResult(name, start, end), cds_name, sub))
def test_PKS_with_no_hit(self): assert self.func( [DummyHMMResult("PKS_KS", start=1, end=40)], [DummyHMMResult("trans-AT", start=41, end=48)]) == [""]
def test_non_PKS(self): assert self.func([DummyHMMResult()], []) == []
def test_bad_add_makes_new_module(self): modules = build_modules_for_cds([DummyHMMResult(NRPS_LOAD)] * 2, []) assert len(modules) == 2 assert not modules[0].is_complete()
def add_component(module, name, sub="", start=1, end=10): module.add_component(Component(DummyHMMResult(name, start, end), sub))
def test_unknown_component_type(self): component = Component(DummyHMMResult(NRPS_LOAD)) component._domain._hit_id = "unclassifiable" component.classification = "unclassifiable" with self.assertRaisesRegex(ValueError, "unhandled"): Module().add_component(component)
def test_loader(self): for cond in [PKS_LOAD, "AMP-binding", "A-OX"]: assert Component(DummyHMMResult(cond)).is_loader() assert not Component(DummyHMMResult(NRPS_START)).is_loader()
def test_pks_with_hit(self): assert self.func( [DummyHMMResult("PKS_KS", start=1, end=40)], [DummyHMMResult("trans-AT", start=1, end=38)]) == ["trans-AT"]