anyvar.mapping.liftover

Defines functions used to lift over variants between GRCh37 & GRCh38

exception anyvar.mapping.liftover.AccessionConversionError[source]

Indicates a failure to convert a variant’s refget accession

error_details = 'Could not convert refget accession'[source]
exception anyvar.mapping.liftover.AmbiguousCoordinateConversionError[source]

Indicates AnyVar cannot lift over a variant because its start and/or end coordinates mapped to multiple possible locations

error_details = 'Start and/or end positions mapped to multiple possible locations'[source]
exception anyvar.mapping.liftover.CoordinateConversionFailureError[source]

Indicates a failure to lift over a variant’s coordinate

error_details = 'Could not convert start and/or end position(s)'[source]
exception anyvar.mapping.liftover.LiftoverError[source]

Indicates a failure to liftover a variant between GRCh37 & GRCh38

base_error_message = 'Unable to complete liftover'[source]
error_details = ''[source]
classmethod get_error_message()[source]

Return the error message associated with the Exception

Return type:

str

class anyvar.mapping.liftover.ReferenceAssembly(value)[source]

Supported reference assemblies

GRCH37 = 'GRCh37'[source]
GRCH38 = 'GRCh38'[source]
exception anyvar.mapping.liftover.RoundtripError[source]

Indicates failure to roundtrip a liftover between 37 and 38, suggesting ambiguous or unreliable liftover

error_details = 'Lifted-over coordinates could not be converted back to the original location'[source]
exception anyvar.mapping.liftover.UnsupportedReferenceAssemblyError[source]

Indicates a failure to retrieve alias data for a refget accession in any supported reference assembly.

error_details = 'Could not resolve reference assembly - accession not found in any supported assembly'[source]
exception anyvar.mapping.liftover.UnsupportedVariantLocationTypeError[source]

Indicates a variant with a ‘location’ type that is unsupported

error_details = 'Liftover is unsupported for variants without refget accession, start position, and end position'[source]
anyvar.mapping.liftover.convert_position(converter, chromosome, position)[source]

Convert a SequenceLocation position (i.e., start or end) to another reference Genome. position can either be a models.Range or an int - return type will match.

Parameters:
  • converter (Converter) – An AGCT Converter instance.

  • chromosome (str) – The chromosome number where the position is found. Must be a string consisting of a) the prefix “chr”, and b) a number OR “X” or “Y” -> e.g. “chr10”, “chrX”, etc.

  • position (TypeVar(_PositionType, int, Range)) – A SequenceLocation start or end position. Can be a models.Range or an int.

Return type:

TypeVar(_PositionType, int, Range)

Returns:

A lifted-over position. Type (models.Range or int) will match that of position

anyvar.mapping.liftover.liftover_and_register_variant(variation, storage, dataproxy)[source]

Perform liftover between GRCh37 <-> GRCh38. Store mappings between the original and lifted-over variants.

Don’t register lifted-over variant or mappings if * liftover fails in either direction * liftover is ambiguous in either direction * liftover fails to roundtrip accurately

This function is intended to be quite directly ‘user-facing’, i.e. it catches and suppresses major error cases and communicates results as they are to be transmitted in the REST API routes. Library users hoping for more direct control will want to employ get_liftover_variant to perform liftover and make their own decisions about when to register objects and mappings.

Parameters:
  • variation (Allele) – variation to attempt liftover upon

  • storage (Storage) – Storage instance

  • dataproxy (_DataProxy) – SeqRepo DataProxy instance, for normalizing lifted-over alleles

Return type:

Allele

Returns:

lifted-over variant

Raises:

RoundtripError – if liftover fails to roundtrip back to original variant

anyvar.mapping.liftover.liftover_variant(input_variant)[source]

Liftover a variant from GRCh37 or GRCH38 into the opposite assembly, and return the converted variant as a VrsVariation.

If liftover is unsuccessful, raise an Exception.

Parameters:

input_variant (Allele) – A VrsVariation.

Return type:

Allele

Returns:

The converted variant as a VrsVariation.

Raises: