예제 #1
0
    def test_thiostrepton(self):
        def callback(outdir):
            # make sure the html_output section was tested
            with open(os.path.join(outdir, "index.html")) as handle:
                content = handle.read()
                assert "ACN52291.1 leader / core peptide, putative Type II" in content

        genbank = path.get_full_path(__file__, 'data', 'thiostrepton_before_analysis.gbk')
        result = helpers.run_and_regenerate_results_for_module(genbank, thiopeptides,
                                                               self.config, callback=callback)

        result = helpers.run_and_regenerate_results_for_module(genbank, thiopeptides, self.config)

        assert len(result.motifs) == 1
        prepeptide = result.motifs[0]

        # check prepeptide values
        self.assertAlmostEqual(1639.6, prepeptide.monoisotopic_mass, places=1)
        self.assertAlmostEqual(1640.9, prepeptide.molecular_weight, places=1)
        assert prepeptide.leader == "MSNAALEIGVEGLTGLDVDTLEISDYMDETLLDGEDLTVTM"
        assert prepeptide.core == "IASASCTTCICTCSCSS"
        assert prepeptide.detailed_information.macrocycle == "26-member"
        assert prepeptide.peptide_subclass == "Type II"
        expected_features = ("Central ring: piperidine;"
                             " second macrocycle containing a quinaldic acid moiety")
        assert prepeptide.detailed_information.core_features == expected_features
        for calc, expect in zip(prepeptide.detailed_information.mature_weights,
                                [1646.8, 1645.5, 1664.8, 1682.8, 1700.8, 1718.8,
                                 1736.9, 1754.9, 1772.9, 1790.9]):
            self.assertAlmostEqual(calc, expect, places=1)
예제 #2
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
예제 #3
0
    def test_lactazole(self):
        "Test thiopeptide prediction for lactazole - lazA"
        genbank = path.get_full_path(__file__, 'data', 'lac_before_analysis.gbk')

        results = helpers.run_and_regenerate_results_for_module(genbank, thiopeptides, self.config)
        assert len(results.motifs) == 1

        rec = secmet.Record.from_genbank(genbank, "bacteria")[0]
        before_count = rec.get_feature_count()
        assert not rec.get_cds_motifs()

        # add and check new motif added
        results.add_to_record(rec)
        assert rec.get_feature_count() == before_count + 1
        assert len(rec.get_cds_motifs()) == 1
        prepeptide = rec.get_cds_motifs()[0]
        assert prepeptide is results.motifs[0]

        # check prepeptide values
        self.assertAlmostEqual(1362.5, prepeptide.monoisotopic_mass, places=1)
        self.assertAlmostEqual(1363.5, prepeptide.molecular_weight, places=1)
        assert prepeptide.leader == "MSDITASRVESLDLQDLDLSELTVTSLRDTVALPENGA"
        assert prepeptide.core == "SWGSCSCQASSSCA"
        assert not prepeptide.detailed_information.macrocycle
        assert prepeptide.peptide_subclass == "Type III"
        assert prepeptide.detailed_information.core_features == 'Central ring: pyridine trisubstituted'
        assert prepeptide.tail == 'QPQDM'
        for calc, expected in zip(prepeptide.alternative_weights,
                                  [1381.5, 1399.5, 1417.5, 1435.5, 1453.6, 1471.6]):
            self.assertAlmostEqual(calc, expected, places=1)
        assert len(prepeptide.to_biopython()) == 3  # leader, core, tail
예제 #4
0
 def test_CP009369(self):  # pylint: disable=invalid-name
     " tests the special case HMM files for rodeo "
     config = build_config(["--minimal", "--enable-thiopeptides"],
                           isolated=True,
                           modules=antismash.get_all_modules())
     record_path = path.get_full_path(__file__, 'data', 'CP009369.1.gbk')
     results = helpers.run_and_regenerate_results_for_module(
         record_path, thiopeptides, config)
     assert results
     assert len(results.motifs) == 1
     prepeptide = results.motifs[0]
     self.assertAlmostEqual(1934.6, prepeptide.monoisotopic_mass, places=1)
     self.assertAlmostEqual(1936.0, prepeptide.molecular_weight, places=1)
     assert prepeptide.leader == "MVKSIIKARESGRFYETKYLKGGEEMKEQKELKNEEFELDVEFLDLDEVSAIPETTA"
     assert prepeptide.core == "SSGTSSCSASSTCGSSSCCGSC"
     assert not prepeptide.macrocycle
     assert prepeptide.peptide_subclass == "Type III"
     assert prepeptide.core_features == 'Central ring: pyridine trisubstituted'
     assert prepeptide.tail == ''
     for calc, expected in zip(prepeptide.alternative_weights, [
             1954.0, 1972.1, 1990.1, 2008.1, 2026.1, 2044.1, 2062.2, 2080.2,
             2098.2, 2116.2, 2134.2, 2152.3, 2170.3
     ]):
         self.assertAlmostEqual(calc, expected, places=1)
     assert len(prepeptide.to_biopython()) == 2  # no tail
예제 #5
0
 def test_cp002271_c19(self):
     filename = path.get_full_path(__file__, 'data', 'CP002271.1.cluster019.gbk')
     results = helpers.run_and_regenerate_results_for_module(filename, nrps_pks, self.options)
     # catch ordering changes along with ensuring ATResults are there
     pred = results.domain_predictions["nrpspksdomains_STAUR_3982_PKS_AT.1"]
     assert pred["signature"].predictions[0][1].score == 87.5
     # ensure all genes are present and have the right consensus
     assert results.consensus == {'nrpspksdomains_STAUR_3982_PKS_AT.1': 'mmal',
                                  'nrpspksdomains_STAUR_3983_PKS_AT.1': 'mmal',
                                  'nrpspksdomains_STAUR_3984_PKS_AT.1': 'mmal',
                                  'nrpspksdomains_STAUR_3985_PKS_AT.1': 'pk',
                                  'nrpspksdomains_STAUR_3985_PKS_AT.2': 'mmal'}
     assert len(results.region_predictions) == 1
     assert list(results.region_predictions) == [1]
     assert len(results.region_predictions[1]) == 1
     # check the gene ordering and, in this case, that it used domain docking
     sc_pred = results.region_predictions[1][0]
     assert sc_pred.polymer == '(Me-ccmal) + (Me-ccmal) + (Me-ccmal)'
     assert sc_pred.domain_docking_used
     assert sc_pred.ordering == ['STAUR_3983', 'STAUR_3984', 'STAUR_3985', 'STAUR_3982']
     assert len(results.domain_predictions) == 10
     expected_domains = {'nrpspksdomains_STAUR_3982_PKS_AT.1',
                         'nrpspksdomains_STAUR_3983_PKS_AT.1',
                         'nrpspksdomains_STAUR_3984_PKS_AT.1',
                         'nrpspksdomains_STAUR_3985_PKS_AT.1',
                         'nrpspksdomains_STAUR_3985_PKS_AT.2',
                         'nrpspksdomains_STAUR_3972_PKS_KR.1',
                         'nrpspksdomains_STAUR_3984_PKS_KR.1',
                         'nrpspksdomains_STAUR_3985_PKS_KR.1',
                         'nrpspksdomains_STAUR_3983_PKS_KR.1',
                         'nrpspksdomains_STAUR_3983_PKS_KR.1',
                         'nrpspksdomains_STAUR_3982_PKS_KR.1'}
     assert set(results.domain_predictions) == expected_domains
예제 #6
0
    def test_nosiheptide(self):
        "Test thiopeptide prediction for nosiheptide - nosM"
        genbank = path.get_full_path(__file__, 'data', 'nosi_before_analysis.gbk')
        result = helpers.run_and_regenerate_results_for_module(genbank, thiopeptides, self.config)
        rec = secmet.Record.from_genbank(genbank, "bacteria")[0]
        existing_feature_count = rec.get_feature_count()
        assert result.motifs[0].peptide_subclass == "Type I"
        assert not rec.get_cds_motifs()
        assert rec.get_feature_count() == existing_feature_count

        assert len(result.motifs) == 1

        result.add_to_record(rec)
        for i in rec.get_cds_motifs():
            print(i, i.leader, i.score, i.detailed_information.rodeo_score)
        assert len(rec.get_cds_motifs()) == 1, rec.get_cds_motifs()
        assert rec.get_feature_count() == existing_feature_count + 1

        # check the motif in an existing CDS
        prepeptide = rec.get_cds_motifs()[0]
        assert prepeptide is result.motifs[0]

        self.assertAlmostEqual(1315.3, prepeptide.monoisotopic_mass, places=1)
        self.assertAlmostEqual(1316.5, prepeptide.molecular_weight, places=1)
        assert prepeptide.leader == "MDAAHLSDLDIDALEISEFLDESRLEDSEVVAKVMSA"
        assert prepeptide.core == "SCTTCECCCSCSS"
        assert prepeptide.detailed_information.macrocycle == "26-member"
        assert prepeptide.peptide_subclass == "Type I"
        for calc, expected in zip(prepeptide.detailed_information.mature_weights,
                                  [1222.4, 1221.2, 1240.4, 1258.4, 1276.5, 1294.5, 1312.5, 1330.5]):
            self.assertAlmostEqual(calc, expected, places=1)
        expected_core_features = ("Central ring: pyridine tetrasubstituted (hydroxyl group present);"
                                  " second macrocycle")
        assert prepeptide.detailed_information.core_features == expected_core_features
        assert prepeptide.detailed_information.amidation
    def test_reuse(self):
        nisin = helpers.get_path_to_nisin_genbank()
        record = record_processing.parse_input_sequence(nisin)[0]

        results = helpers.run_and_regenerate_results_for_module(
            nisin, cluster_hmmer, self.options)
        json = results.to_json()
        assert len(results.hits) == 24
        self.check_add_to_record(nisin, results)

        # test regeneration when thresholds are less restrictive
        new_score_threshold = self.original_min_score - .1
        self.set_min_score(new_score_threshold)
        new_results = cluster_hmmer.regenerate_previous_results(
            json, record, self.options)
        assert new_results is None
        self.set_min_score(self.original_min_score)

        new_evalue_threshold = self.original_max_evalue + .1
        self.set_max_evalue(new_evalue_threshold)
        new_results = cluster_hmmer.regenerate_previous_results(
            json, record, self.options)
        assert new_results is None
        self.set_max_evalue(self.original_max_evalue)

        # test regeneration when evalue threshold is more restrictive
        new_evalue_threshold = sorted(hit["evalue"]
                                      for hit in results.hits)[12]
        assert new_evalue_threshold < self.original_max_evalue
        new_hits = []
        for hit in results.hits:
            if hit["evalue"] <= new_evalue_threshold:
                new_hits.append(hit)
        new_hits.sort(key=lambda x: x["evalue"])
        assert len(new_hits) < 24

        self.set_max_evalue(new_evalue_threshold)
        new_results = cluster_hmmer.regenerate_previous_results(
            json, record, self.options)
        self.set_max_evalue(self.original_max_evalue)
        assert sorted(new_results.hits, key=lambda x: x["evalue"]) == new_hits
        self.check_add_to_record(nisin, results)

        # test regeneration when score threshold is more restrictive
        new_score_threshold = sorted(hit["score"] for hit in results.hits)[12]
        assert new_score_threshold > cluster_hmmer.MIN_SCORE
        new_hits = []
        for hit in results.hits:
            if hit["score"] >= new_score_threshold:
                new_hits.append(hit)
        new_hits.sort(key=lambda x: x["score"])
        assert len(new_hits) < 24

        self.set_min_score(new_score_threshold)
        new_results = cluster_hmmer.regenerate_previous_results(
            json, record, self.options)
        self.set_min_score(self.original_min_score)
        assert sorted(new_results.hits, key=lambda x: x["score"]) == new_hits
        self.check_add_to_record(nisin, results)
 def test_nisin_end_to_end(self):
     # skip fimo being disabled for this, we already test the computational
     # side elsewhere
     if self.options.without_fimo:
         return
     nisin = helpers.get_path_to_nisin_genbank()
     result = helpers.run_and_regenerate_results_for_module(
         nisin, lanthipeptides, self.options)
     assert list(result.motifs_by_locus) == ["nisB"]
     prepeptide = result.motifs_by_locus["nisB"][0]
     self.assertAlmostEqual(3336.0, prepeptide.molecular_weight, delta=0.05)
예제 #9
0
 def run_antismash(self, filename, expected):
     with TemporaryDirectory() as output_dir:
         update_config({"output_dir": output_dir})
         results = helpers.run_and_regenerate_results_for_module(filename, clusterblast, self.options)
         update_config({"output_dir": ""})
         results, global_results = self.get_results(results)
         assert len(results.region_results) == 1
         cluster = results.region_results[0]
         assert len(cluster.ranking) == expected  # will change if database does
         self.check_svgs(global_results, expected, output_dir)
     return results
예제 #10
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]}
 def test_nisin(self):
     genbank = helpers.get_path_to_nisin_with_detection()
     results = helpers.run_and_regenerate_results_for_module(genbank, rrefinder, self.options)
     assert isinstance(results, rrefinder.RREFinderResults)
     assert results.bitscore_cutoff == self.options.rre_cutoff
     assert results.min_length == self.options.rre_min_length
     assert results.record_id == 'HM219853.1'
     assert len(results.features) == 1
     feature = results.features[0]
     assert feature.locus_tag == 'nisB'
     assert feature.score == 34.9
     assert feature.protein_location == FeatureLocation(141, 228)
     assert feature.domain == 'Lanthipeptide_RRE'
     assert feature.translation == 'FTRNNANYKFGDRVFQVYTINSSELEEVNIKYTNVYQIISEFC' +
                                   'ENDYQKYEDICETVTLCYGDEYRELSEQYLGSLIVNHYLISNLQK'
예제 #12
0
 def test_cp002271_c19(self):
     filename = path.get_full_path(__file__, 'data', 'CP002271.1.cluster019.gbk')
     results = helpers.run_and_regenerate_results_for_module(filename, nrps_pks, self.options)
     # catch ordering changes along with ensuring ATResults are there
     assert results.pks.method_results["signature"]["nrpspksdomains_STAUR_3982_AT1"][0].score == 87.5
     # ensure all genes are present and have the right consensus
     assert results.consensus == {'nrpspksdomains_STAUR_3982_AT1': 'ohmmal',
                                  'nrpspksdomains_STAUR_3983_AT1': 'ccmmal',
                                  'nrpspksdomains_STAUR_3984_AT1': 'ccmmal',
                                  'nrpspksdomains_STAUR_3985_AT1': 'pk',
                                  'nrpspksdomains_STAUR_3985_AT2': 'pk'}
     # check the gene ordering and, in this case, that it used domain docking
     assert results.cluster_predictions == {'1': [
             '(ccmmal) + (ccmmal) + (pk-pk) + (ohmmal)', True]}
     # no A domains in the cluster, so make sure no NRPS results
     assert results.nrps == {}
예제 #13
0
 def test_reuse(self):
     test_file = path.get_full_path(__file__, 'data',
                                    'NC_003888.3.cluster011.gbk')
     results = helpers.run_and_regenerate_results_for_module(
         test_file, t2pks, self.options)
     assert list(results.cluster_predictions) == [1]
     pred = results.cluster_predictions[1]
     assert pred.starter_units == [
         t2pks.results.Prediction('acetyl-CoA', 0., 0.)
     ]
     assert pred.malonyl_elongations == [
         t2pks.results.Prediction('7', 743.5, 1.2e-226)
     ]
     assert pred.product_classes == {'benzoisochromanequinone'}
     assert list(pred.molecular_weights) == ['acetyl-CoA_7']
     self.assertAlmostEqual(pred.molecular_weights['acetyl-CoA_7'],
                            342.3845)
예제 #14
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
예제 #15
0
    def test_reuse(self):
        nisin = helpers.get_path_to_nisin_genbank()
        results = helpers.run_and_regenerate_results_for_module(
            nisin, pfam2go, self.options)
        #  are the expected go ids for pfams found/no wrong ids for pfams?
        expected_pfams_and_gos_with_descs = {
            "PF00005": {
                "GO:0005524": "ATP binding",
                "GO:0016887": "ATPase activity"
            },
            "PF00072": {
                "GO:0000160": "phosphorelay signal transduction system"
            },
            "PF00486": {
                "GO:0003677": "DNA binding",
                "GO:0000160": "phosphorelay signal transduction system",
                "GO:0006355": "regulation of transcription, DNA-templated"
            }
        }
        expected_pfams_found = set()
        for pfam, all_ontologies in results.pfam_domains_with_gos.items():
            pfam_ids_without_versions = [
                pfam_id.partition(".")[0] for pfam_id in pfam.db_xref
            ]
            # make sure the Pfams without gos aren't in the results
            assert "PF05147" not in pfam_ids_without_versions and "PF04738" not in pfam_ids_without_versions
            for ontologies in all_ontologies:
                # make sure GeneOntologies' pfam id actually is one found in the domain's ids
                assert ontologies.pfam in pfam_ids_without_versions
                # did it find the right amount of GO IDs for the sample Pfams, and did it find the right ones?
                if ontologies.pfam in expected_pfams_and_gos_with_descs:
                    expected_pfams_found.add(ontologies.pfam)
                    go_ids = [
                        str(go_entry) for go_entry in ontologies.go_entries
                    ]
                    assert len(go_ids) == len(
                        expected_pfams_and_gos_with_descs[ontologies.pfam])
                    for go_id in go_ids:
                        assert go_id in expected_pfams_and_gos_with_descs[
                            ontologies.pfam]
        # make sure all expected pfams have been found
        assert len(expected_pfams_found) == len(
            expected_pfams_and_gos_with_descs)

        self.check_add_to_record(nisin, results)
예제 #16
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)
예제 #17
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)
예제 #18
0
    def test_thiostrepton_full(self):
        def callback(outdir):
            # make sure the html_output section was tested
            with open(os.path.join(outdir, "index.html")) as handle:
                content = handle.read()
                assert "ACN52291.1 leader / core peptide, putative Type II" in content

        config = build_config(["--minimal", "--enable-thiopeptides"],
                              isolated=True,
                              modules=antismash.get_all_modules())

        record_path = path.get_full_path(__file__, 'data',
                                         'thiostrepton_before_analysis.gbk')
        regenned_results = helpers.run_and_regenerate_results_for_module(
            record_path, thiopeptides, config, callback=callback)
        assert regenned_results
        assert len(regenned_results.motifs) == 1
        self.check_thiostrepton_values(regenned_results.motifs[0])
예제 #19
0
    def run_lanthi(self, genbank, html_snippet, expected_motifs=1):
        def callback(output_dir):
            with open(os.path.join(output_dir, "index.html")) as handle:
                content = handle.read()
                assert html_snippet in content

        rec = Record.from_genbank(genbank, taxon="bacteria")[0]
        assert not rec.get_cds_motifs()
        result = helpers.run_and_regenerate_results_for_module(
            genbank, lanthipeptides, self.options, callback=callback)
        assert len(result.clusters) == 1
        motifs = self.gather_all_motifs(result)
        assert len(motifs) == expected_motifs

        result.add_to_record(rec)
        assert len(rec.get_cds_motifs()) == expected_motifs

        return rec, result
예제 #20
0
 def test_full_blastp_use(self):
     test_file = path.get_full_path(__file__, 'data', 'GQ409537.1.gbk')
     results = helpers.run_and_regenerate_results_for_module(
         test_file, t2pks, self.options)
     assert list(results.cluster_predictions) == [1]
     pred = results.cluster_predictions[1]
     assert pred.starter_units == [
         t2pks.results.Prediction('malonamyl-CoA', 2319., 0.)
     ]
     assert pred.malonyl_elongations == [
         t2pks.results.Prediction('8|9', 661.0, 1.3e-201)
     ]
     assert pred.product_classes == {
         'angucycline', 'tetracycline', 'aureolic acid', 'anthracycline'
     }
     assert set(
         pred.molecular_weights) == {'malonamyl-CoA_8', 'malonamyl-CoA_9'}
     self.assertAlmostEqual(pred.molecular_weights['malonamyl-CoA_8'],
                            638.63534)
     self.assertAlmostEqual(pred.molecular_weights['malonamyl-CoA_9'],
                            680.67202)
예제 #21
0
    def test_NZ_CP015439(self):  # pylint: disable=invalid-name
        """ Tests that small ORFs are found and saved in results """
        record_path = path.get_full_path(__file__, 'data',
                                         'NZ_CP015439_section.gbk')
        results = helpers.run_and_regenerate_results_for_module(
            record_path, thiopeptides, self.config)
        assert results

        # check that the extra orf was found and stored correctly
        assert len(results.cds_features) == 1
        additions = list(results.cds_features.values())[0]
        assert len(additions) == 1
        assert isinstance(additions[0], secmet.features.CDSFeature)

        # also test the analysis results itself
        assert len(results.motifs) == 1
        prepeptide = results.motifs[0]
        self.assertAlmostEqual(1408.6, prepeptide.monoisotopic_mass, places=1)
        self.assertAlmostEqual(1409.5, prepeptide.molecular_weight, places=1)
        assert prepeptide.leader == "MRYMEGGENMQDIMLELYAEELPDITQYTAAGTSTLSTESSVLSASCP"
        assert prepeptide.core == "TSTASTYTSMSSVS"
예제 #22
0
    def test_reuse(self):
        raw_results = sideloader.loader.load_validated_json(
            GOOD_FILE, sideloader.general._SCHEMA_FILE)

        nisin = helpers.get_path_to_nisin_genbank()
        results = helpers.run_and_regenerate_results_for_module(
            nisin, sideloader, self.options)

        assert results.record_id == raw_results["records"][0]["name"]

        record_section = raw_results["records"][0]
        for result, raw in zip(results.subregions,
                               record_section["subregions"]):
            assert result.tool.name == raw_results["tool"]["name"]
            assert result.start == raw["start"]
            assert result.end == raw["end"]
            assert result.label == raw["label"]
            assert result.details == {
                "score": ["6.5"],
                "some_option_name": ["yes"],
                "some_other_detail": ["first", "second", "etc"]
            }
 def run_analysis(self, filename):
     datafile = path.get_full_path(__file__, "data", filename)
     return helpers.run_and_regenerate_results_for_module(datafile, lassopeptides, self.options)