Пример #1
0
    def test_antismash_comment(self):
        rec = DummyRecord()
        options = Namespace()
        options.start = -1
        options.end = -1
        options.version = "5.dummy"
        bio = rec.to_biopython()

        main.add_antismash_comments([(rec, bio)], options)
        assert "##antiSMASH-Data-START##" in bio.annotations["comment"]
        assert "##antiSMASH-Data-END##" in bio.annotations["comment"]
        assert "Version" in bio.annotations["comment"] and options.version in bio.annotations["comment"]
        assert "Original ID" not in bio.annotations["comment"]
        assert "Starting at" not in bio.annotations["comment"]
        assert "Ending at" not in bio.annotations["comment"]

        bio.annotations["comment"] = ""
        options.start = 7
        main.add_antismash_comments([(rec, bio)], options)
        assert "Original ID" not in bio.annotations["comment"]
        assert "Starting at  :: 7\n" in bio.annotations["comment"]

        bio.annotations["comment"] = ""
        options.start = -1
        options.end = 1000
        main.add_antismash_comments([(rec, bio)], options)
        assert "Original ID" not in bio.annotations["comment"]
        assert "Ending at    :: 1000\n" in bio.annotations["comment"]

        bio.annotations["comment"] = ""
        options.end = -1
        rec.original_id = "something else"
        main.add_antismash_comments([(rec, bio)], options)
        assert "Original ID" in bio.annotations["comment"] and "something else" in bio.annotations["comment"]
Пример #2
0
    def test_complex(self):
        protos = [
            helpers.DummyProtocluster(core_start=3,
                                      core_end=22,
                                      neighbourhood_range=1,
                                      product='a'),
            helpers.DummyProtocluster(core_start=33,
                                      core_end=48,
                                      neighbourhood_range=2,
                                      product='b'),
        ]
        candidates = [
            helpers.DummyCandidateCluster(clusters=protos[:1]),
            helpers.DummyCandidateCluster(
                clusters=protos,
                kind=helpers.DummyCandidateCluster.kinds.INTERLEAVED)
        ]
        subregion = helpers.DummySubRegion(start=55, end=90)
        regions = [
            helpers.DummyRegion(candidate_clusters=candidates, subregions=[]),
            helpers.DummyRegion(candidate_clusters=[], subregions=[subregion]),
        ]

        record = DummyRecord(record_id="test",
                             seq="A" * 90,
                             features=regions + [subregion] + candidates +
                             protos)
        results = serialiser.gather_record_areas(record)
        assert results
        assert len(results) == 2
        res = results[0]
        assert res["end"] == protos[1].location.end
        assert res["products"] == [p.product for p in protos]
        assert res["subregions"] == []
        assert len(res["protoclusters"]) == 2
        assert list(res["protoclusters"]) == [0, 1]
        assert res["protoclusters"][1]["product"] == protos[1].product
        assert len(res["candidates"]) == 2
        assert res["candidates"][0]["protoclusters"] == [0]
        assert res["candidates"][1]["protoclusters"] == [0, 1]

        res = results[1]
        assert res["start"] == subregion.location.start
        assert res["subregions"]
        assert res["subregions"][0]["start"] == subregion.location.start
        assert res["subregions"][0]["tool"] == subregion.tool
        assert res["subregions"][0]["label"] == subregion.label
        assert not res["protoclusters"]

        # lastly, check all this is properly embedded in the final JSON
        bio = record.to_biopython()
        full = serialiser.dump_records([bio], [{}], [record])
        assert full[0]["areas"] == results