コード例 #1
0
    def test_other(self):
        location = CompoundLocation([FeatureLocation(5922, 6190, strand=1),
                                     FeatureLocation(5741, 5877, strand=1),
                                     FeatureLocation(4952, 5682, strand=1)])
        assert self.func(97, 336, location) == (5243, 6064)

        location = CompoundLocation([FeatureLocation(5922, 6190, strand=-1),
                                     FeatureLocation(5741, 5877, strand=-1),
                                     FeatureLocation(4952, 5682, strand=-1)])
        assert self.func(97, 336, location) == (5078, 5854)
コード例 #2
0
    def test_position_conversion_compound_reverse(self):
        location = CompoundLocation([FeatureLocation(0, 6, strand=-1),
                                     FeatureLocation(9, 18, strand=-1)])
        assert len(location) == 15
        assert self.func(0, 4, location) == (3, 18)
        assert self.func(1, 5, location) == (0, 15)

        location = CompoundLocation([FeatureLocation(0, 6, strand=-1),
                                     FeatureLocation(12, 15, strand=-1),
                                     FeatureLocation(21, 27, strand=-1)])
        assert len(location) == 15
        assert self.func(0, 4, location) == (3, 27)
        assert self.func(1, 5, location) == (0, 24)
        assert self.func(2, 3, location) == (12, 15)
コード例 #3
0
    def test_position_conversion_nonzero_compound(self):
        location = CompoundLocation([FeatureLocation(6, 18, strand=1),
                                     FeatureLocation(24, 27, strand=1)])
        assert len(location) == 15
        assert self.func(0, 2, location) == (6, 12)
        assert self.func(1, 4, location) == (9, 18)
        assert self.func(3, 5, location) == (15, 27)

        location = CompoundLocation([FeatureLocation(6, 15, strand=-1),
                                     FeatureLocation(21, 27, strand=-1)])
        assert len(location) == 15
        assert self.func(0, 2, location) == (21, 27)
        assert self.func(1, 4, location) == (9, 24)
        assert self.func(3, 5, location) == (6, 12)
コード例 #4
0
ファイル: test_region.py プロジェクト: stogqy/antismash
    def test_prepeptide_adjustment(self):
        dummy_record = Record(Seq("A"*400, generic_dna))
        subregion = DummySubRegion(start=100, end=300)
        dummy_record.add_subregion(subregion)
        region = Region(subregions=[subregion])
        dummy_record.add_region(region)

        dummy_prepeptide = DummyFeature(200, 230, 1, "CDS_motif")
        # ensure both FeatureLocation and CompoundLocations are handled appropriately
        leader_loc = FeatureLocation(200, 210, 1)
        tail_loc = CompoundLocation([FeatureLocation(220, 223, -1), FeatureLocation(227, 230, -1)])
        dummy_prepeptide._qualifiers["leader_location"] = [str(leader_loc)]
        dummy_prepeptide._qualifiers["tail_location"] = [str(tail_loc)]
        dummy_record.add_feature(dummy_prepeptide)
        # and add a CDS_motif without either qualifier (e.g. NRPS/PKS motif) to ensure that doesn't break
        dummy_record.add_feature(DummyFeature(250, 280, 1, "CDS_motif"))

        with NamedTemporaryFile(suffix=".gbk") as output:
            region.write_to_genbank(output.name)
            bio = list(seqio.parse(output.name))[0]
        assert len(bio.features) == 4
        found = False
        for feature in bio.features:
            tail = feature.qualifiers.get("tail_location")
            leader = feature.qualifiers.get("leader_location")
            if tail and leader:
                # the part locations should now be adjusted backwards 100 bases
                assert leader == ["[100:110](+)"]
                assert tail == ["join{[120:123](-), [127:130](-)}"]
                found = True
        assert found, "prepeptide feature missing in conversion"
コード例 #5
0
ファイル: test_locations.py プロジェクト: SBGlab/antismash
 def test_single_compound(self):
     for strand in [1, -1]:
         location = CompoundLocation([
             FeatureLocation(6, 9, strand),
             FeatureLocation(12, 16, strand)
         ])
         new = build_location_from_others([location])
         assert new == location
コード例 #6
0
 def setUp(self):
     self.seqrec = SeqRecord(UnknownSeq(21))
     loc = CompoundLocation([
         FeatureLocation(12, 21, strand=1),
         FeatureLocation(0, 9, strand=1)
     ],
                            operator="join")
     self.seqcds = SeqFeature(loc, type="CDS")
     self.seqgene = SeqFeature(loc, type="gene")
     self.seqrec.annotations["topology"] = "circular"
コード例 #7
0
 def test_some_merged(self):
     for strand in [1, -1]:
         locations = [FeatureLocation(1, 4, strand),
                      FeatureLocation(6, 9, strand),
                      FeatureLocation(9, 12, strand),
                      FeatureLocation(15, 18, strand)]
         new = build_location_from_others(locations)
         assert isinstance(new, CompoundLocation)
         assert new == CompoundLocation([FeatureLocation(1, 4, strand),
                                         FeatureLocation(6, 12, strand),
                                         FeatureLocation(15, 18, strand)])
コード例 #8
0
 def setUp(self):
     self.seqrec = SeqRecord(Seq("A" * 21))
     loc = CompoundLocation([
         FeatureLocation(12, 15, strand=1),
         FeatureLocation(18, 21, strand=1),
         FeatureLocation(0, 3, strand=1),
         FeatureLocation(6, 9, strand=1)
     ],
                            operator="join")
     self.seqcds = SeqFeature(loc, type="CDS")
     self.seqgene = SeqFeature(loc, type="gene")
     self.seqrec.annotations["topology"] = "circular"
     self.seqrec.annotations["molecule_type"] = "DNA"
コード例 #9
0
    def test_individual(self):
        loc = combine_locations(self.make(3, 7), self.make(5, 9))
        assert loc.start == 3 and loc.end == 9
        loc = combine_locations(self.make(3, 5), self.make(7, 9))
        assert loc.start == 3 and loc.end == 9
        loc = combine_locations(self.make(7, 9), self.make(3, 5))
        assert loc.start == 3 and loc.end == 9

        # it's silly, but since it theoretically is useful for CompoundLocation condensing
        loc = combine_locations(self.make(0, 5))
        assert loc.start == 0 and loc.end == 5
        loc = combine_locations(CompoundLocation([self.make(0, 3), self.make(6, 9)]))
        assert loc.start == 0 and loc.end == 9 and len(loc.parts) == 1
コード例 #10
0
ファイル: test_locations.py プロジェクト: SBGlab/antismash
    def test_compound(self):
        first = FeatureLocation(1, 6, strand=1)
        second = FeatureLocation(10, 16, strand=1)
        location = CompoundLocation([first, second], operator="join")
        assert 5 in location
        assert 7 not in location
        assert 15 in location

        new_location = self.convert(location, expected_type=CompoundLocation)
        assert location.start == 1
        assert 5 in new_location
        assert 7 not in new_location
        assert 15 in new_location
        assert location.end == 16
        assert new_location.operator == "join"
コード例 #11
0
    def test_compound_location(self):
        old = Prepeptide(CompoundLocation(
            [FeatureLocation(10, 50, 1),
             FeatureLocation(130, 180, 1)],
            operator="join"),
                         peptide_class="test_class",
                         core="coreseq...",
                         locus_tag="loc",
                         tool="test tool",
                         leader="10chleader",
                         tail="10chartail")

        leader, core, tail = old.to_biopython()
        assert leader.location.start == 10
        assert leader.location.end == 40
        assert isinstance(core.location, CompoundLocation)
        assert core.location.start == 40
        assert core.location.end == 150
        assert tail.location.start == 150
        assert tail.location.end == 180

        new = Prepeptide.from_biopython(core)
        assert str(new.location) == str(old.location)
コード例 #12
0
ファイル: test_locations.py プロジェクト: SBGlab/antismash
def build_compound(pairs, strand, operator="join"):
    assert len(pairs) >= 2, "invalid CompoundLocation would be created"
    parts = []
    for start, end in pairs:
        parts.append(FeatureLocation(start, end, strand))
    return CompoundLocation(parts, operator=operator)
コード例 #13
0
ファイル: test_locations.py プロジェクト: SBGlab/antismash
 def test_separate(self):
     locations = [FeatureLocation(6, 9, 1), FeatureLocation(12, 16, 1)]
     new = build_location_from_others(locations)
     assert isinstance(new, CompoundLocation)
     assert new == CompoundLocation(locations)