コード例 #1
0
    def test_regeneration(self):
        datafile = helpers.get_path_to_balhymicin_genbank()
        results = helpers.run_and_regenerate_results_for_module(
            datafile, nrps_pks_domains, self.options)
        assert results
        assert len(results.cds_results) == 9

        expected_types = {
            'bpsC': 'NRPS',
            'pks': 'other',
            'bpsD': 'NRPS-like protein',
            'dpgD': 'other',
            'pgat': 'other',
            'dpgB': 'other',
            'bpsA': 'Glycopeptide NRPS',
            'bpsB': 'Glycopeptide NRPS',
            'dpgC': 'other'
        }

        for cds, cds_result in results.cds_results.items():
            assert isinstance(cds_result,
                              nrps_pks_domains.domain_identification.CDSResult)
            # motifs can be empty, but domains cannot be
            assert cds_result.domain_hmms
            assert cds_result.type
            # ensure results were added as they regenerated, as it's a detection module
            assert len(cds_result.domain_hmms) == len(cds.nrps_pks.domains)
            assert len(cds_result.motif_hmms) == len(cds.motifs)
            assert cds.nrps_pks.type == cds_result.type

        found_types = {
            cds.get_name(): result.type
            for cds, result in results.cds_results.items()
        }
        assert found_types == expected_types
コード例 #2
0
 def test_minimal(self):
     with TemporaryDirectory(change=True) as tempdir:
         self.options = build_config(["--minimal", "--output-dir", tempdir],
                                     isolated=True, modules=antismash.get_all_modules())
         with patch.object(nrps_pks, "run_on_record", side_effect=RuntimeError("shouldn't run")):
             antismash.main.run_antismash(helpers.get_path_to_balhymicin_genbank(),
                                          self.options)
コード例 #3
0
 def test_minimal(self):
     with TemporaryDirectory(change=True) as tempdir:
         self.options = build_config(["--minimal", "--output-dir", tempdir],
                                     isolated=True, modules=antismash.get_all_modules())
         antismash.main.run_antismash(helpers.get_path_to_balhymicin_genbank(),
                                      self.options)
     # make sure it didn't run
     minimock.assert_same_trace(self.tracker, "")
コード例 #4
0
 def test_balhymicin(self):
     filename = helpers.get_path_to_balhymicin_genbank()
     results = helpers.run_and_regenerate_results_for_module(filename, nrps_pks, self.options)
     for key, val in results.pks.method_results.items():
         if key != "minowa_cal":
             assert not val
             continue
         assert len(val) == 1
         assert len(val["nrpspksdomains_pks_CAL1"]) == 5
         assert val["nrpspksdomains_pks_CAL1"][0] == ["AHBA", 167.0]
     # when the NRPS subsections are added, this needs to change
     assert results.nrps == {}
     # as does this, though it still won't use domain docking
     assert results.cluster_predictions == {'1': [
             '(nrp-nrp-nrp) + (nrp-nrp-nrp) + (nrp) + (nrp) + (pk)', False]}
コード例 #5
0
    def test_balhymicin(self):
        filename = helpers.get_path_to_balhymicin_genbank()
        results = helpers.run_and_regenerate_results_for_module(
            filename, nrps_pks, self.options)
        assert len(results.domain_predictions) == 9
        a_domains = [("bpsA", 1), ("bpsA", 2), ("bpsA", 3), ("bpsB", 1),
                     ("bpsB", 2), ("bpsB", 3), ("bpsC", 1), ("bpsD", 1)]
        nrps_names = [
            'nrpspksdomains_%s_AMP-binding.%d' % a_dom for a_dom in a_domains
        ]
        feature_names = nrps_names + ["nrpspksdomains_pks_CAL_domain.1"]
        assert set(results.domain_predictions) == set(feature_names)

        assert set(results.domain_predictions[feature_names[0]]) == {
            "NRPSPredictor2"
        }
        nrpspred2_results = {}
        for domain, methods in results.domain_predictions.items():
            if "CAL" in domain:
                continue
            nrpspred2_results[domain] = methods[
                "NRPSPredictor2"].get_classification()
        expected_preds = [["leu"], ["bht"], ["asn"], ["hpg"], ["hpg"], ["bht"],
                          ["dhpg"], ["tyr"], ["pk"]]
        expected_nrps2 = {
            name: pred
            for name, pred in zip(nrps_names, expected_preds)
        }
        assert nrpspred2_results == expected_nrps2

        cal = results.domain_predictions["nrpspksdomains_pks_CAL_domain.1"][
            "minowa_cal"]
        assert len(cal.predictions) == 5
        assert cal.predictions[0] == ["AHBA", 167.0]

        assert len(results.region_predictions[1]) == 2
        # as does this, though it still won't use domain docking
        pred = results.region_predictions[1][0]
        monomers = '(leu - bht - asn) + (hpg - hpg - bht) + (dhpg) + (tyr) + (pk)'
        assert pred.polymer == monomers
        assert not pred.domain_docking_used

        pred = results.region_predictions[1][1]
        assert pred.polymer == "(tyr) + (pk)"
        assert not pred.domain_docking_used
コード例 #6
0
    def test_full(self):
        assert cluster_compare.is_enabled(self.options)
        input_path = helpers.get_path_to_balhymicin_genbank()
        results = helpers.run_and_regenerate_results_for_module(input_path, cluster_compare, self.options)

        proto = results.by_database["MIBiG"].by_region[1]["ProtoToRegion_RiQ"]
        # ordering should be correct
        assert proto.scores_by_region[0][1] > proto.scores_by_region[1][1]
        # check the winner makes sense for proto to region, the value won't be 1.0
        assert proto.scores_by_region[0][0].accession == "BGC0000311.1"
        self.assertAlmostEqual(proto.scores_by_region[0][1], 1.80874, places=5)

        region = results.by_database["MIBiG"].by_region[1]["RegionToRegion_RiQ"]
        # ordering should be correct
        assert region.scores_by_region[0][1] > region.scores_by_region[1][1]
        # again, check the winner, but this time it *should* be 1.0 as there's no protoclusters used
        assert region.scores_by_region[0][0].accession == "BGC0000311.1", region.scores_by_region
        self.assertAlmostEqual(region.scores_by_region[0][1], 1.0, places=5)
コード例 #7
0
    def test_regeneration(self):
        datafile = helpers.get_path_to_balhymicin_genbank()
        results = helpers.run_and_regenerate_results_for_module(
            datafile, active_site_finder, self.options)
        assert results.pairings
        for domain, labels in results.pairings:
            for label in labels:
                assert label
                assert isinstance(label, str)
            assert isinstance(domain, secmet.AntismashDomain)
        record = parse_input_sequence(datafile)

        # check the reuse portion works
        rerun = active_site_finder.run_on_record(record, results, self.options)
        assert rerun is results  # specifically checking it's the same object

        with self.assertRaisesRegex(AssertionError, "str"):
            active_site_finder.run_on_record(record, "invalid", self.options)
コード例 #8
0
 def check_balhymicin(self, expected):
     return self.run_antismash(helpers.get_path_to_balhymicin_genbank(),
                               expected)