normalize_prefix
- normalize_prefix(prefix: str, *, use_preferred: bool = False, strict: Literal[True] = True) str [source]
- normalize_prefix(prefix: str, *, use_preferred: bool = False, strict: Literal[False] = False) str | None
Get the normalized prefix, or return None if not registered.
- Parameters:
prefix – The prefix to normalize, which could come from Bioregistry, OBO Foundry, OLS, or any of the curated synonyms in the Bioregistry
strict – If true and the prefix could not be looked up, raises an error
use_preferred – If set to true, uses the “preferred prefix”, if available, instead of the canonicalized Bioregistry prefix.
- Returns:
The canonical Bioregistry prefix, it could be looked up. This will usually take precedence: MIRIAM, OBO Foundry / OLS, Custom except in a few cases, such as NCBITaxon.
This works for synonym prefixes, like:
>>> assert "ncbitaxon" == normalize_prefix("taxonomy")
This works for common mistaken prefixes, like:
>>> assert "pubchem.compound" == normalize_prefix("pubchem")
This works for prefixes that are often written many ways, like:
>>> assert "ec" == normalize_prefix("ec-code") >>> assert "ec" == normalize_prefix("EC_CODE")
Get a “preferred” prefix:
>>> normalize_prefix("go", use_preferred=True) 'GO'