If a variant description that does not match any of the supported formats is passed in to AlleleTranslator.translate_from(), a TypeError is thrown.
>>> tlr.translate_from('BRAF amplification')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/workspaces/gdh/vrs-python/src/ga4gh/vrs/extras/translator.py", line 98, in translate_from
o = t(var, **kwargs)
File "/workspaces/gdh/vrs-python/src/ga4gh/vrs/extras/translator.py", line 305, in _from_hgvs
return self._create_allele(allele_values, **kwargs)
File "/workspaces/gdh/vrs-python/src/ga4gh/vrs/extras/translator.py", line 167, in _create_allele
seq_ref = models.SequenceReference(refgetAccession=values["refget_accession"])
TypeError: 'NoneType' object is not subscriptable
This is because the hgvs_tools.extract_allele_values can return None when the description is not HGVS syntax. And there is no null defense in AlleleTranslator._create_allele.
Invoking AlleleTranslator.translate_from() with an invalid description should instead raise a ValueError with the message: "Unable to parse data as beacon, gnomad, hgvs, spdi, vrs"
If a variant description that does not match any of the supported formats is passed in to
AlleleTranslator.translate_from()
, aTypeError
is thrown.This is because the
hgvs_tools.extract_allele_values
can returnNone
when the description is not HGVS syntax. And there is no null defense inAlleleTranslator._create_allele
.Invoking
AlleleTranslator.translate_from()
with an invalid description should instead raise aValueError
with the message: "Unable to parse data as beacon, gnomad, hgvs, spdi, vrs"