Пример #1
0
 def test_probabilities(self):
     loc = FeatureLocation(0, 10)
     candidates = [DummyCandidateCluster([create_protocluster(0, 10)])]
     assert Region(candidate_clusters=candidates).probabilities == []
     subs = [SubRegion(loc, "testtool", probability=None)]
     assert Region(candidate_clusters=candidates, subregions=subs).probabilities == []
     subs.append(SubRegion(loc, "testtool", probability=0.1))
     assert Region(candidate_clusters=candidates, subregions=subs).probabilities == [0.1]
     subs.append(SubRegion(loc, "testtool", probability=0.7))
     assert Region(candidate_clusters=candidates, subregions=subs).probabilities == [0.1, 0.7]
Пример #2
0
 def test_probabilities(self):
     loc = FeatureLocation(0, 10)
     supers = [
         SuperCluster(SuperCluster.kinds.SINGLE, [create_cluster(0, 10)])
     ]
     assert Region(superclusters=supers).probabilities == []
     subs = [SubRegion(loc, "testtool", probability=None)]
     assert Region(superclusters=supers,
                   subregions=subs).probabilities == []
     subs.append(SubRegion(loc, "testtool", probability=0.1))
     assert Region(superclusters=supers,
                   subregions=subs).probabilities == [0.1]
     subs.append(SubRegion(loc, "testtool", probability=0.7))
     assert Region(superclusters=supers,
                   subregions=subs).probabilities == [0.1, 0.7]
Пример #3
0
 def test_genbank(self):
     dummy_record = Record(Seq("A" * 100, generic_dna))
     clusters = [
         create_cluster(3, 20, "prodA"),
         create_cluster(25, 41, "prodB")
     ]
     for cluster in clusters:
         dummy_record.add_cluster(cluster)
     subregion = SubRegion(FeatureLocation(35, 71), "test", 0.7)
     dummy_record.add_subregion(subregion)
     supercluster = SuperCluster(SuperCluster.kinds.NEIGHBOURING, clusters)
     dummy_record.add_supercluster(supercluster)
     region = Region(superclusters=[supercluster], subregions=[subregion])
     dummy_record.add_region(region)
     with NamedTemporaryFile(suffix=".gbk") as output:
         region.write_to_genbank(output.name)
         bio = list(seqio.parse(output.name))
     assert len(bio) == 1
     rec = Record.from_biopython(bio[0], taxon="bacteria")
     assert len(rec.get_regions()) == 1
     new = rec.get_region(0)
     assert new.location.start == 3 - region.location.start
     assert new.location.end == 71 - region.location.start
     assert new.products == region.products
     assert new.probabilities == region.probabilities
Пример #4
0
    def test_limited_add_cds_propagation(self):
        cds = DummyCDS(0, 10)
        self.sub = SubRegion(FeatureLocation(20, 30), "testtool")
        self.region = Region(superclusters=[self.super], subregions=[self.sub])

        # ensure all empty to start with
        assert not self.cluster.cds_children
        assert not self.super.cds_children
        assert not self.sub.cds_children
        assert not self.region.cds_children
        assert not cds.region

        self.region.add_cds(cds)
        assert self.cluster.cds_children == (cds, )
        assert self.super.cds_children == (cds, )
        assert not self.sub.cds_children
        assert self.region.cds_children == (cds, )
        assert cds.region is self.region
Пример #5
0
    def test_sideloaded(self):
        clusters = [
            create_protocluster(3, 20, "prodA"),
            SideloadedProtocluster(FeatureLocation(25, 41),
                                   FeatureLocation(25, 41), "external",
                                   "prodB")
        ]
        candidate = CandidateCluster(CandidateCluster.kinds.NEIGHBOURING,
                                     clusters)

        subregions = [
            SubRegion(FeatureLocation(35, 71), "test", 0.7),
            SideloadedSubRegion(FeatureLocation(45, 61), "external")
        ]

        region = Region(candidate_clusters=[candidate], subregions=subregions)
        sideloaded = region.get_sideloaded_areas()
        assert len(sideloaded) == 2
        assert sideloaded[0] is clusters[1]
        assert sideloaded[1] is subregions[1]
Пример #6
0
 def test_orphaned(self):
     sub = SubRegion(FeatureLocation(0, 10), tool="test")
     assert not sub.parent_record
     with self.assertRaisesRegex(ValueError, "not in a record"):
         sub.get_subregion_number()
Пример #7
0
 def test_anchor(self):
     loc = FeatureLocation(0, 10)
     assert SubRegion(loc, tool="test").anchor == ""
     assert SubRegion(loc, tool="test", anchor="anch").anchor == "anch"
Пример #8
0
 def test_probability(self):
     loc = FeatureLocation(0, 10)
     assert SubRegion(loc, tool="test").probability is None
     assert SubRegion(loc, tool="test", probability=9.5).probability == 9.5
     assert SubRegion(loc, tool="test", probability=.5).probability == .5
Пример #9
0
 def setUp(self):
     self.cluster = create_cluster(0, 10)
     self.super = SuperCluster(SuperCluster.kinds.SINGLE, [self.cluster])
     self.sub = SubRegion(self.cluster.location, "testtool")
     self.region = Region(superclusters=[self.super], subregions=[self.sub])
Пример #10
0
 def setUp(self):
     self.protocluster = DummyProtocluster()
     self.candidate = DummyCandidateCluster([self.protocluster])
     self.sub = SubRegion(self.protocluster.location, "testtool")
     self.region = Region(candidate_clusters=[self.candidate],
                          subregions=[self.sub])