Skip to content

Remove Beacon Translator #622

@korikuzma

Description

@korikuzma

Remove Beacon Translator (and all references to Beacon)

@deprecated("This method does not match the Beacon spec and will be removed in v3.")
def _from_beacon(self, beacon_expr: str, **kwargs) -> models.Allele | None:
"""Parse beacon expression into VRS Allele
kwargs:
assembly_name (str): Assembly used for `beacon_expr`.
rle_seq_limit Optional(int): If RLE is set as the new state after
normalization, this sets the limit for the length of the `sequence`.
To exclude `sequence` from the response, set to 0.
For no limit, set to `None`.
Defaults value set in instance variable, `rle_seq_limit`.
do_normalize (bool): `True` if fully justified normalization should be
performed. `False` otherwise. Defaults to `True`
#>>> a = tlr.from_beacon("19 : 44908822 C > T")
#>>> a.model_dump()
{
'location': {
'end': 44908822,
'start': 44908821,
'sequenceReference': {
'type': 'SequenceReference',
'refgetAccession': 'SQ.IIB53T8CNeJJdUqzn9V_JnRtQadwWCbl'
},
'type': 'SequenceLocation'
},
'state': {
'sequence': 'C',
'type': 'LiteralSequenceExpression'
},
'type': 'Allele'
}
"""
if not isinstance(beacon_expr, str):
return None
m = self.beacon_re.match(beacon_expr.replace(" ", ""))
if not m:
return None
g = m.groupdict()
assembly_name = kwargs.get("assembly_name", self.default_assembly_name)
sequence = assembly_name + ":" + g["chr"]
refget_accession = self.data_proxy.derive_refget_accession(sequence)
if not refget_accession:
return None
start = int(g["pos"]) - 1
ref = g["ref"]
alt = g["alt"]
end = start + len(ref)
ins_seq = alt
values = {
"refget_accession": refget_accession,
"start": start,
"end": end,
"literal_sequence": ins_seq,
}
return self._create_allele(values, **kwargs)

In #568 (PR #578) we added a deprecation warning that the translator does not match the Beacon spec and will be removed in v3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions