Skip to content

Validation mode for typing #348

@michaelaagapiouAN

Description

@michaelaagapiouAN

For phycus, we'd like to use py-ard to check that the resolution declared for a locus is what has been provided in the haplotype. The output from ard.redux() works well for checking that the provided input is correct when the resolution is 'G' or 'P' but not for 'lg'. For example:

>>> import pyard
>>> ard = pyard.init()

>>> ard.redux("A*30:02:01:01","G")
'A*30:02:01G'
>>> ard.redux("A*30:02:01G","G")
'A*30:02:01G'

>>> ard.redux("A*30:02:01:01","P")
'A*30:02P'
>>> ard.redux("A*30:02P","P")
'A*30:02P'

>>> ard.redux("A*30:02:01:01","lg")
'A*30:02g'
>>> ard.redux("A*30:02g","lg")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/miniconda3/envs/py3.12/lib/python3.12/site-packages/pyard/ard.py", line 421, in redux
    self.validate(glstring)
  File "/opt/miniconda3/envs/py3.12/lib/python3.12/site-packages/pyard/ard.py", line 526, in validate
    return self._is_valid_gl(glstring)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/py3.12/lib/python3.12/site-packages/pyard/ard.py", line 853, in _is_valid_gl
    raise InvalidAlleleError(f"{glstring} is not a valid Allele")
pyard.exceptions.InvalidAlleleError: Invalid Allele: A*30:02g is not a valid Allele

Would it be possible for this to not raise an invalid allele error here or add some other functionality for checking if something is a valid output from ard.redux()?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions