|
1 | 1 | """Translates various external formats into VRS models. |
2 | 2 |
|
3 | | -Input formats: VRS (serialized), hgvs, spdi, gnomad (vcf), beacon |
| 3 | +Input formats: VRS (serialized), hgvs, spdi, gnomad (vcf) |
4 | 4 | Output formats: VRS (serialized), hgvs, spdi, gnomad (vcf) |
5 | 5 |
|
6 | 6 | """ |
|
11 | 11 | from collections.abc import Mapping |
12 | 12 | from typing import Protocol |
13 | 13 |
|
14 | | -from typing_extensions import deprecated |
15 | | - |
16 | 14 | from ga4gh.core import ga4gh_identify |
17 | 15 | from ga4gh.vrs import models, normalize |
18 | 16 | from ga4gh.vrs.dataproxy import SequenceProxy, _DataProxy |
@@ -58,9 +56,6 @@ class _Translator(ABC): # noqa: B024 |
58 | 56 |
|
59 | 57 | """ |
60 | 58 |
|
61 | | - beacon_re = re.compile( |
62 | | - r"(?P<chr>[^-]+)\s*:\s*(?P<pos>\d+)\s*(?P<ref>\w+)\s*>\s*(?P<alt>\w+)" |
63 | | - ) |
64 | 59 | gnomad_re = re.compile( |
65 | 60 | r"(?P<chr>[^-]+)-(?P<pos>\d+)-(?P<ref>[ACGTURYKMSWBDHVN]+)-(?P<alt>[ACGTURYKMSWBDHVN]+)", |
66 | 61 | re.IGNORECASE, |
@@ -101,7 +96,7 @@ def translate_from( |
101 | 96 | EFO:0030067 for deletions and EFO:0030070 for duplications |
102 | 97 | For AlleleTranslator |
103 | 98 | assembly_name (str): Assembly used for `var`. Defaults to the |
104 | | - `default_assembly_name`. Only used for beacon and gnomad. |
| 99 | + `default_assembly_name`. Only used for gnomad. |
105 | 100 | require_validation (bool): If `True` then validation checks must pass in |
106 | 101 | order to return a VRS object. A `DataProxyValidationError` will be |
107 | 102 | raised if validation checks fail. If `False` then VRS object will be |
@@ -180,7 +175,6 @@ def __init__( |
180 | 175 | super().__init__(data_proxy, default_assembly_name, identify) |
181 | 176 |
|
182 | 177 | self.from_translators = { |
183 | | - "beacon": self._from_beacon, |
184 | 178 | "gnomad": self._from_gnomad, |
185 | 179 | "hgvs": self._from_hgvs, |
186 | 180 | "spdi": self._from_spdi, |
@@ -215,68 +209,6 @@ def _create_allele(self, values: dict, **kwargs) -> models.Allele: |
215 | 209 | allele = models.Allele(location=location, state=state) |
216 | 210 | return self._post_process_imported_allele(allele, **kwargs) |
217 | 211 |
|
218 | | - @deprecated("This method does not match the Beacon spec and will be removed in v3.") |
219 | | - def _from_beacon(self, beacon_expr: str, **kwargs) -> models.Allele | None: |
220 | | - """Parse beacon expression into VRS Allele |
221 | | -
|
222 | | - kwargs: |
223 | | - assembly_name (str): Assembly used for `beacon_expr`. |
224 | | - rle_seq_limit Optional(int): If RLE is set as the new state after |
225 | | - normalization, this sets the limit for the length of the `sequence`. |
226 | | - To exclude `sequence` from the response, set to 0. |
227 | | - For no limit, set to `None`. |
228 | | - Defaults value set in instance variable, `rle_seq_limit`. |
229 | | - do_normalize (bool): `True` if fully justified normalization should be |
230 | | - performed. `False` otherwise. Defaults to `True` |
231 | | -
|
232 | | - #>>> a = tlr.from_beacon("19 : 44908822 C > T") |
233 | | - #>>> a.model_dump() |
234 | | - { |
235 | | - 'location': { |
236 | | - 'end': 44908822, |
237 | | - 'start': 44908821, |
238 | | - 'sequenceReference': { |
239 | | - 'type': 'SequenceReference', |
240 | | - 'refgetAccession': 'SQ.IIB53T8CNeJJdUqzn9V_JnRtQadwWCbl' |
241 | | - }, |
242 | | - 'type': 'SequenceLocation' |
243 | | - }, |
244 | | - 'state': { |
245 | | - 'sequence': 'C', |
246 | | - 'type': 'LiteralSequenceExpression' |
247 | | - }, |
248 | | - 'type': 'Allele' |
249 | | - } |
250 | | -
|
251 | | - """ |
252 | | - if not isinstance(beacon_expr, str): |
253 | | - return None |
254 | | - |
255 | | - m = self.beacon_re.match(beacon_expr.replace(" ", "")) |
256 | | - if not m: |
257 | | - return None |
258 | | - |
259 | | - g = m.groupdict() |
260 | | - assembly_name = kwargs.get("assembly_name", self.default_assembly_name) |
261 | | - sequence = assembly_name + ":" + g["chr"] |
262 | | - refget_accession = self.data_proxy.derive_refget_accession(sequence) |
263 | | - if not refget_accession: |
264 | | - return None |
265 | | - |
266 | | - start = int(g["pos"]) - 1 |
267 | | - ref = g["ref"] |
268 | | - alt = g["alt"] |
269 | | - end = start + len(ref) |
270 | | - ins_seq = alt |
271 | | - |
272 | | - values = { |
273 | | - "refget_accession": refget_accession, |
274 | | - "start": start, |
275 | | - "end": end, |
276 | | - "literal_sequence": ins_seq, |
277 | | - } |
278 | | - return self._create_allele(values, **kwargs) |
279 | | - |
280 | 212 | def _from_gnomad(self, gnomad_expr: str, **kwargs) -> models.Allele | None: |
281 | 213 | """Parse gnomAD-style VCF expression into VRS Allele |
282 | 214 |
|
|
0 commit comments