anyvar.core.categorical_variants

Provide core typing/structure for categorical variants.

class anyvar.core.categorical_variants.CanonicalAllele(**data)[source]

CanonicalAllele catvar

Validates shape of input data, but does not validate values, ie that given defining allele is of the expected molecule type, because that requires external data access to SeqRepo (and that’s messy to inject in a FastAPI endpoint)

The validations performed do differ from the original Cat-VRS recipes, which is why we have a separate class.

It doesn’t need any additional code implemented beyond its parent class, but we still give it a separate class for mapping purposes in the ORM

class anyvar.core.categorical_variants.ProteinSequenceConsequence(**data)[source]

ProteinSequenceConsequence catvar

Validates shape of input data, but does not validate values, ie that given defining allele is of the expected molecule type, because that requires external data access to SeqRepo (and that’s messy to inject in a FastAPI endpoint).

The validations performed do differ from the original Cat-VRS recipes, which is why we have a separate class.

It doesn’t need any additional code implemented beyond its parent class, but we still give it a separate class for mapping purposes in the ORM

anyvar.core.categorical_variants.get_molecule_type(seq_ref, dp)[source]

Return the molecule type for a sequence reference, inferring it via SeqRepo if absent.

Return type:

MoleculeType | None

anyvar.core.categorical_variants.is_expected_molecule_type(seq_ref, expected_type, dp)[source]

Validate that the given sequence reference has the expected molecule type

No further validation is performed if the moleculeType property is defined; its value is accepted as authoritative and no additional sequence type lookup is performed.

Parameters:
  • seq_ref (SequenceReference) – defining allele context’s sequence reference object

  • expected_type (MoleculeType) – desired molecule type

  • dp (_DataProxy) – proxy for seq alias lookup

Return type:

bool

Returns:

whether the sequence reference’s molecule type can be validated as consistent with the expected molecule type