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)
def test_biopython_conversion(self): bio = SeqFeature(FeatureLocation(1, 5)) bio.qualifiers["foo"] = ["bar"] bio.qualifiers["key_only"] = None # check that features without types are caught with self.assertRaisesRegex(ValueError, "invalid length"): sec = Feature.from_biopython(bio) bio.type = "test" sec = Feature.from_biopython(bio) assert sec.get_qualifier("foo") == tuple(["bar"]) assert sec.get_qualifier("bar") is None assert sec.get_qualifier("key_only") is True
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