alleleTools.format.hla_group module
- class alleleTools.format.hla_group.GrouperHLA(reference_file: str = 'g-group')[source]
Bases:
object- lookup(gene: str, allele_stripped: str) str | None[source]
Lookup g-group for the given allele. If exact match is not found, attempt to find a partial match.
- lookup_exact(gene: str, allele_stripped: str) str | None[source]
Finds a g-group for the exact allele provided.
- lookup_partial(gene: str, allele_stripped: str) str | None[source]
Finds a g-group for the partial allele provided. The index does not contain all posible combinations of alleles. It only has the highest resolution alleles, so looking for a partial match is necessary.
A g-group is returned only if one possible match is found.
- alleleTools.format.hla_group.quick_lookup(group: GrouperHLA, df: DataFrame) DataFrame[source]
This optimization was not comprehensibly tested to see if it improves performance, but in theory it should be faster than doing individual lookups. It only does exact matches though.
- Parameters:
group (GrouperHLA) – The GrouperHLA instance with the g-group/p-group index.
df (pd.DataFrame) – DataFrame with ‘gene’ and ‘allele_stripped’ columns.
- Returns:
DataFrame with an added ‘group’ column.
- Return type:
pd.DataFrame