anyvar.translate.vrs_python

Normalize incoming variation descriptions with the VRS-Python library.

class anyvar.translate.vrs_python.VrsPythonTranslator(seqrepo_proxy=None, disable_healthcheck=False)[source]

Translator layer using VRS-Python Translator class.

__init__(seqrepo_proxy=None, disable_healthcheck=False)[source]

Initialize VRS-Python translator.

If an existing SeqRepo data proxy is not provided, use the VRS-Python create_dataproxy function to construct one. The following URI patterns can be used to specify a local file instance or an address to REST service:

  • seqrepo+file:///path/to/seqrepo/root

  • seqrepo+:../relative/path/to/seqrepo/root

  • seqrepo+http://localhost:5000/seqrepo

  • seqrepo+https://somewhere:5000/seqrepo

We’ll pass the value defined under the environment variable SEQREPO_DATAPROXY_URI, and default to local service ("seqrepo+http://localhost:5000/seqrepo") if it’s undefined.

Parameters:
  • seqrepo_proxy (_DataProxy | None) – existing SR proxy instance if available.

  • disable_healthcheck (bool) – Whether or not to disable the health check for REST dataproxy

get_sequence_id(accession_id)[source]

Get GA4GH sequence identifier for provided accession ID

Parameters:

accession_id (str) – ID to convert

Return type:

str

Returns:

equivalent GA4GH sequence ID

Raise:

KeyError if no equivalent ID is available

translate_allele(var, **kwargs)[source]

Translate provided variation text into a VRS Allele object.

Parameters:

var (str) – user-provided string describing or referencing a variation.

Kwargs:

assembly_name(str) -> Assembly name for var. Only used when var uses gnomad format. Defaults to “GRCh38”. Must be “GRCh38” or “GRCh7” VRS-Python sets a default, but we should set a default just in case VRS-Python ever changes the default.

Return type:

Allele

Returns:

VRS variation object if able to translate

Raises:

TranslationError – if translation is unsuccessful, either because the submitted variation is malformed, or because VRS-Python doesn’t support its translation.

translate_variation(var, **kwargs)[source]

Translate provided variation text into a VRS Variation object.

Parameters:
  • var (str) – user-provided string describing or referencing a variation.

  • input_type (types.VrsVariation) – The type of variation for var.

  • input_type – The type of variation for var. If not provided, will first try to translate to allele and then copy number

  • copies (int) – The number of copies for VRS Copy Number Count

  • copy_change (models.CopyChange) – The EFO code for VRS COpy Number Change

  • assembly_name (ReferenceAssembly) – Assembly name for var. Only used when var uses gnomad format.

Return type:

Allele

Returns:

VRS variation object

Raises:

TranslationError – if translation is unsuccessful, either because the submitted variation is malformed, or because VRS-Python doesn’t support its translation.

class anyvar.translate.vrs_python.WindowedSeqRepoDataProxy(sr)[source]

SeqRepo proxy with fixed-size window caching.

Optimizes repeated small range queries by caching a single fixed-size sequence window and serving subsequent sub-range requests from memory when possible.

Warning

This API is still experimental, and is subject to change.

If a request falls outside the cached window or exceeds the configured chunk size, it is delegated directly to SeqRepo.

__init__(sr)[source]

Initialize DataProxy instance.

Parameters:

sr (SeqRepo) – SeqRepo instance