py_hla_match.matching
- 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:
objectResult 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
AlleleMatchLevelvalues.allele_match_levels – Tuple of
AlleleMatchLevelvalues 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
ARDMatchLevelvalues refining ARD-equivalent allele pairs (NOT_APPLICABLEif not ARD-matched).ard_match_certainties – Tuple of
ARDMatchLevelCertaintyvalues indicating how certain the ARD refinement is given typing resolution.molecular_match_levels – Tuple of
MolecularMatchLevelvalues refining ARD-equivalent allele pairs at 1–4-field level (NOT_APPLICABLEif not ARD-matched).molecular_match_certainties – Tuple of
MolecularMatchLevelCertaintyvalues 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_patient –
Trueif the patient is homozygous at this locus at ARD-reduced level,Falseif heterozygous, orNoneif ARD-reduced alleles are not available.
- Parameters:
patient (HLAPair)
donor (HLAPair)
pairing_score (int)
allele_match_levels (Tuple[AlleleMatchLevel, AlleleMatchLevel])
ard_match_levels (Tuple[ARDMatchLevel, ARDMatchLevel] | None)
ard_match_level_certainty (Tuple[ARDMatchLevelCertainty, ARDMatchLevelCertainty] | None)
molecular_match_levels (Tuple[MolecularMatchLevel, MolecularMatchLevel] | None)
molecular_match_level_certainty (Tuple[MolecularMatchLevelCertainty, MolecularMatchLevelCertainty] | None)
- 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
- py_hla_match.matching.allele_match(hla1, hla2)[source]
Compares two HLA alleles and returns a MatchLevel
- Parameters:
- Returns:
MatchLevel enum value indicating position of matches and mismatch (cf. HLA nomenclature)
- Raises:
TypeError – If hla1 or hla2 is not an instance of HLA
InvalidLocusComparisonError – If hla1 and hla2 have incompatible loci
- Return type:
- py_hla_match.matching.allele_pair_match(patient, donor)[source]
Compute research match/mismatch levels for two HLA allele pairs, one in the ‘patient’ role and one in the ‘donor’ role.
Intended for research workflows.
- Parameters:
- Returns:
MatchResultobject storing allele-level match categories and all ARD and molecular refinements for the optimal pairing.- Return type:
Notes
The function assumes that both patient and donor have exactly two
HLA alleles
Uses _get_correct_allele_pairing to evaluate all possible
allele pairings and selects the one with the highest score
- py_hla_match.matching.multi_locus_match(patient, donor)[source]
Compute HLA match/mismatch categories between two Individuals for all loci that are typed in the first Individual.
Intended for research workflows.
- Parameters:
patient (Individual) – Patient object
donor (Individual) – Donor object
- Returns:
List of MatchResult objects for each locus
- Return type:
List[MatchResult]
Classes
|
Result object for comparing two HLA genotype pairs at a single locus. |
Functions
|
Compares two HLA alleles and returns a MatchLevel |
|
Compute research match/mismatch levels for two HLA allele pairs, one in the 'patient' role and one in the 'donor' role. |
|
Compute HLA match/mismatch categories between two Individuals for all loci that are typed in the first Individual. |