biocommons / hgvs

Python library to parse, format, validate, normalize, and map sequence variants. `pip install hgvs`
https://hgvs.readthedocs.io/
Apache License 2.0
240 stars 94 forks source link

p type cannot be validated #727

Open markgene opened 7 months ago

markgene commented 7 months ago

Describe the bug

I get an error message of AttributeError: 'AARefAlt' object has no attribute 'ref_n' when using validate() against a protein variant.

To Reproduce Steps to reproduce the behavior, invoke hgvs-shell (v1.5.4):

hgvs_t = hp.parse_hgvs_variant('NM_001330729.1(CTNNB1):c.15_398del')
hgvs_p = c_to_p(hgvs_t)
validate(hgvs_p)

It raised the error:

AttributeError: 'AARefAlt' object has no attribute 'ref_n'

Expected behavior I expect a boolean returned value.

Additional context

The traceback pointed the error to posedit.py:

    101 # Check del length
    102 if self.edit.type in ["del", "delins"]:
--> 103     ref_len = self.edit.ref_n
    104     if ref_len is not None and ref_len != self.pos.end - self.pos.start + 1:
    105         return (
    106             ValidationLevel.ERROR,
    107             "Length implied by coordinates must equal sequence deletion length",
    108         )

It seems we can solve the problem by adding ref_n to AARefAltdecorated by@property`. I made a patch at here. It fixes the problem from my side, but am not sure if it fits well to the whole package. Thanks!

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.