Python library for parsing MHC nomenclature in the wild
mhcgnomes: Parsing MHC nomenclature in the wild
MHCgnomes is a parsing library for multi-species MHC nomenclature which aims to correctly parse every name in IEDB, IMGT/HLA, IPD/MHC, and the allele lists for both NetMHCpan and NetMHCIIpan predictors. This allows for standardization between immune databases and tools, which often use different naming conventions.
In : mhcgnomes.parse("HLA-A0201") Out: Allele( gene=Gene( species=Species(name="Homo sapiens', prefix="HLA"), name="A"), allele_fields=("02", "01"), annotations=(), mutations=()) In : mhcgnomes.parse("HLA-A0201").to_string() Out: 'HLA-A*02:01' In : mhcgnomes.parse("HLA-A0201").compact_string() Out: 'A0201'
The problem: MHC nomenclature is nuts
Despite the valiant efforts of groups such as the Comparative MHC Nomenclature Committee, the names of MHC alleles you might encounter in different datasets (or accepted by immunoinformatics tools) are frustratingly ill specified. It's not uncommon to see dozens of different forms for the same allele.
For example, these all refer to the same MHC protein sequence:
Additionally, for human alleles, the species prefix is often omitted:
Sometimes, alleles are bundled with modifier suffixes which specify the functionality or abundance of the MHC. Here's an example with an allele which is secreted instead of membrane-bound:
These are collected in the
annotations field of an
MHC proteins are sometimes described in terms of mutations to a known allele.
- "HLA-B*08:01 N80I mutant"
These mutations are collected in the
mutations field of an
To make things worse, several model organisms (like mice and rats) use archaic naming systems, where there is no notion of allele groups or four/six/eight digit alleles but every allele is simply given a name, such as:
In the above example "H2"/"RT1" correspond to species, "K"/"9.5" are the gene names and "k"/"f" are the allele names.
To make these even worse, the name of a species is subject to variation (e.g. "H2" vs. "H-2") as well as drift over time (e.g. ChLA -> MhcPatr -> Patr).
Serotypes, haplotypes, and other named entitites
Besides alleles are also other named MHC related entities you'll encounter in immunological data. Closely related to alleles are serotypes, which effectively denote a grouping of alleles that are all recognized by the same antibody:
In many datasets the exact allele is not known but an experiment might note the genetic background of a model animal, resulting in loose haplotype restrictions such as:
- "H2-k class I"
Yes, good luck disambiguating "H2-k" the haplotype from "H2-K" the gene, especially since capitalization is not stable enough to be relied on for parsing.
In some cases immunological data comes only with a denoted species (e.g. "mouse"), a gene (e.g. "HLA-A"), or an MHC class ("human class I"). MHCgnomes has a structured representation for all of these cases and more.
It is a fool's errand to curate all possible MHC allele names since that list grows daily as the MHC loci of more people (and non-human animals) are sequenced. Instead, MHCgnomes contains an ontology of curated species and genes and then attempts to parse any given string into a multiple candidates of the following types:
The set of candidate interpretations for each string are then
ranked according to heuristic rules. For example, a string will be
preferentially interpreted as an
How many digits per field?
Originally alleles for many genes were numbered with two digits:
But as the number of identified alleles increased, the number of fields specifying a distinct protein increase to two. This became conventionally called a "four digit" format, since each field has two digits. Yet, as the number of identified alleles continued to increase, then the number of digits per field has often increased from two to three:
These are not always currently treated as equivalent to allele strings with two digits in their first field, but that feature is in the works.
However, if databases such as IPD-MHC or IMGT-HLA recorded an older form of an allele, then MHCgnomes can optionally map it onto the modern version (including capturing differences in numbers of digits per field).
- IPD-MHC: nomenclature requirements for the non-human major histocompatibility complex in the next-generation sequencing era
- Comparative MHC nomenclature: report from the ISAG/IUIS-VIC committee 2018
- ISAG/IUIS-VIC Comparative MHC Nomenclature Committee report, 2005
- Marsupial MHC Class II β Genes Are Not Orthologous to the Eutherian β Gene Families
- Nomenclature for factors of the SLA system, update 2008
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for mhcgnomes-1.8.4-py3-none-any.whl