Skip to content

Validate input + reference sequence in translate_from #151

Description

@korikuzma

Use this method:

def _is_valid_ref_seq(self, sequence_id: str, start_pos: int, end_pos: int,
ref: str) -> Tuple[bool, str]:
"""Return wether or not the expected reference sequence matches the actual reference sequence
:param str sequence_id: Sequence ID to use
:param int start_pos: Start pos (inter-residue) on the sequence_id
:param int end_pos: End pos (inter-residue) on the sequence_id
:param str ref: The expected reference sequence on the sequence_id given the
start_pos and end_pos
:return: Tuple containing whether or not actual reference sequence matches
the expected reference sequence and error message if mismatch
"""
actual_ref = self.data_proxy.get_sequence(sequence_id, start_pos, end_pos)
is_valid = actual_ref == ref
err_msg = ""
if not is_valid:
err_msg = f"Expected reference sequence {ref} on {sequence_id} at positions "\
f"({start_pos}, {end_pos}) but found {actual_ref}"
_logger.warning(err_msg)
return is_valid, err_msg

and update regex

for these from_translators (where applicable):

from_translators = {
"beacon": _from_beacon,
"gnomad": _from_gnomad,
"hgvs": _from_hgvs,
"spdi": _from_spdi,
"vrs": _from_vrs,

Similar to what was done in #147

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stale-exemptVRS translatorIssues relating to translation of other expressions to/from VRSbugSomething isn't workingpriority:highHigh priority

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions