diff --git a/mavehgvs/variant.py b/mavehgvs/variant.py index 362b70e..5ea55b0 100644 --- a/mavehgvs/variant.py +++ b/mavehgvs/variant.py @@ -181,7 +181,7 @@ def sort_key(x): else: # pragma: no cover raise ValueError("invalid variant count") - if targetseq is not None: + if targetseq is not None and not self.is_target_identical(): for vtype, pos, seq in self.variant_tuples(): if vtype == "sub": if self._prefix == "p": diff --git a/tests/test_variant.py b/tests/test_variant.py index d13b86d..bb8e274 100644 --- a/tests/test_variant.py +++ b/tests/test_variant.py @@ -403,6 +403,23 @@ def test_create_multivariant(self): class TestTargetSequenceValidation(unittest.TestCase): + def test_target_identity(self): + variant_tuples = [ + ("ACGT", "g.="), + ("ACGT", "m.="), + ("ACGT", "o.="), + ("ACGT", "c.="), + ("ACGT", "n.="), + ("ACGU", "r.="), + ("RCQY", "p.="), + ("RCQY", "p.(=)"), + ] + + for target, s in variant_tuples: + with self.subTest(target=target, s=s): + v = Variant(s, targetseq=target) + self.assertEqual(s, str(v)) + def test_matching_dna_substitution(self): variant_tuples = [ ("ACGT", "c.1A>T"),