py_hla_match.matching.MatchResult

class py_hla_match.matching.MatchResult(patient, donor, pairing_score, allele_match_levels, ard_match_levels=None, ard_match_level_certainty=None, molecular_match_levels=None, molecular_match_level_certainty=None)[source]

Bases: object

Result object for comparing two HLA genotype pairs at a single locus.

This class is designed for research use to describe HLA match or mismatch categories between two individuals.

Variables:
  • patient – HLA allele pair in the ‘patient’ role.

  • donor – HLA allele pair in the ‘donor’ role.

  • pairing_score – Internal ordinal score summarising the two AlleleMatchLevel values.

  • allele_match_levels – Tuple of AlleleMatchLevel values for the two allele-level comparisons (patient allele 1 vs donor allele X, patient allele 2 vs donor allele Y).

  • ard_match_levels – Tuple of ARDMatchLevel values refining ARD-equivalent allele pairs (NOT_APPLICABLE if not ARD-matched).

  • ard_match_certainties – Tuple of ARDMatchLevelCertainty values indicating how certain the ARD refinement is given typing resolution.

  • molecular_match_levels – Tuple of MolecularMatchLevel values refining ARD-equivalent allele pairs at 1–4-field level (NOT_APPLICABLE if not ARD-matched).

  • molecular_match_certainties – Tuple of MolecularMatchLevelCertainty values indicating how certain the molecular refinement is given typing resolution.

  • dpb1_tce_status – Optional DPB1 permissive/non-permissive classification from the EBI TCE API (only populated for DPB1 loci).

  • is_homozygous_patientTrue if the patient is homozygous at this locus at ARD-reduced level, False if heterozygous, or None if ARD-reduced alleles are not available.

Parameters:
get_dpb1_tce_status(api_version='3.0', timeout=10)[source]

Calculate DPB1 permissive/non-permissive classification via EBI API.

Intended for research workflows.

WARNING: may slow things down significantly.

Sets self.dpb1_tce_result to one of: - DPB1Result

Parameters:
  • api_version (str) – The version of the EBI API to query (default “3.0”)

  • timeout (int) – Time in seconds to wait for the API response

Returns:

The DPB1Result object, or None if the locus is not DPB1

Return type:

DPB1Result | None

get_match_level_for_resolution(resolution)[source]

Get locus-level match category for a given resolution.

Parameters:

resolution (str) – Resolution level ("basic" or "high").

Returns:

Match level for the given resolution as a string.

Raises:

ValueError – If an unknown resolution level is requested.

Return type:

str

property loci_match_basic_resolution
property loci_match_high_resolution