Beispiel #1
0
 def test_conversion_with_codon_start_reverse(self):
     seqf = SeqFeature(FeatureLocation(5, AfterPosition(12), -1))
     seqf.type = "test"
     for codon_start in "123":
         seqf.qualifiers["codon_start"] = [codon_start]
         feature = Feature.from_biopython(seqf)
         assert feature._original_codon_start == int(codon_start) - 1
         assert feature.location.end == AfterPosition(12 - feature._original_codon_start)
         new = feature.to_biopython()[0]
         assert new.qualifiers["codon_start"] == [codon_start]
         assert new.location.start == seqf.location.start
         assert new.location.end == seqf.location.end
Beispiel #2
0
 def test_invalid_codon_start(self):
     seqf = SeqFeature(FeatureLocation(5, AfterPosition(12), -1))
     seqf.type = "test"
     for codon_start in ["-1", "4", "NA"]:
         seqf.qualifiers["codon_start"] = [codon_start]
         with self.assertRaisesRegex(ValueError, "invalid codon_start"):
             Feature.from_biopython(seqf)
Beispiel #3
0
    def test_extends_past_after(self):
        self.sub_locations[-1] = FeatureLocation(21,
                                                 AfterPosition(29),
                                                 strand=1)
        self.cds.location = CompoundLocation(self.sub_locations)

        new = self.cds.get_sub_location_from_protein_coordinates(0, 7)
        assert new.end == 27
Beispiel #4
0
    def test_after_position(self):
        location = FeatureLocation(ExactPosition(1), AfterPosition(6), strand=1)
        new_location = self.convert(location)

        assert isinstance(new_location.start, ExactPosition)
        assert new_location.start == 1

        assert isinstance(new_location.end, AfterPosition)
        assert new_location.end == 6
Beispiel #5
0
    def test_simple(self):
        location = FeatureLocation(0, AfterPosition(3), 1)
        size = 9
        assert not self.run(size, location, size - 3)
        assert self.run(size, location, size - 2)  # single ambiguous amino
        assert self.run(size, location, size)

        location = FeatureLocation(BeforePosition(3), 9, -1)
        assert not self.run(size + 3, location, size)
        assert self.run(size + 2, location, size)  # single ambiguous amino
        assert self.run(size, location, size)
Beispiel #6
0
 def test_translation_outside_record(self):
     rec = DummyRecord(seq="A" * 10)
     for location in [
             FeatureLocation(0, AfterPosition(6), strand=1),
             FeatureLocation(BeforePosition(4), 10, strand=-1)
     ]:
         bio = SeqFeature(location, type="CDS")
         bio.qualifiers["translation"] = ["M" * 5]
         with self.assertRaisesRegex(SecmetInvalidInputError,
                                     "translation extends out of record"):
             CDSFeature.from_biopython(bio, record=rec)
Beispiel #7
0
 def test_compound(self):
     location = CompoundLocation(
         [FeatureLocation(0, 3),
          FeatureLocation(6, 9)])
     for good in ["A", "AA"]:
         assert _is_valid_translation_length(good, location)
     assert not _is_valid_translation_length("AAA", location)
     # and with an ambiguous end, that becomes ok
     location = CompoundLocation(
         [FeatureLocation(0, 3),
          FeatureLocation(6, AfterPosition(11))])
     assert _is_valid_translation_length("AAA", location)
     # and reversed ambiguous end
     location = CompoundLocation([
         FeatureLocation(BeforePosition(0), 3, -1),
         FeatureLocation(6, 9, -1)
     ])
     for good in ["A", "AA", "AAA"]:
         assert _is_valid_translation_length(good, location)