normalize_curie

normalize_curie(curie: str, *, sep: str = ':', use_preferred: bool = False, strict: Literal[True] = True) str[source]
normalize_curie(curie: str, *, sep: str = ':', use_preferred: bool = False, strict: Literal[False] = False) str | None

Normalize a CURIE.

Parameters:
  • curie – A compact URI (CURIE) in the form of <prefix:identifier>

  • sep – The separator for the CURIE. Defaults to the colon “:” however the slash “/” is sometimes used in Identifiers.org and the underscore “_” is used for OBO PURLs.

  • use_preferred – If set to true, uses the “preferred prefix”, if available, instead of the canonicalized Bioregistry prefix.

  • strict – If true, raises an error if the prefix can’t be standardized

Returns:

A normalized CURIE, if possible using the colon as a separator

>>> normalize_curie("pdb:1234")
'pdb:1234'

Fix commonly mistaken prefix

>>> normalize_curie("pubchem:1234")
'pubchem.compound:1234'

Address banana problem

>>> normalize_curie("GO:GO:1234")
'go:1234'
>>> normalize_curie("go:GO:1234")
'go:1234'
>>> normalize_curie("go:go:1234")
'go:1234'
>>> normalize_curie("go:1234")
'go:1234'

Address banana problem with OBO banana

>>> normalize_curie("fbbt:FBbt:1234")
'fbbt:1234'
>>> normalize_curie("fbbt:fbbt:1234")
'fbbt:1234'
>>> normalize_curie("fbbt:1234")
'fbbt:1234'

Address banana problem with explit banana

>>> normalize_curie("go.ref:GO_REF:1234")
'go.ref:1234'
>>> normalize_curie("go.ref:1234")
'go.ref:1234'

Parse OBO PURL curies

>>> normalize_curie("GO_1234", sep="_")
'go:1234'

Use preferred

>>> normalize_curie("GO_1234", sep="_", use_preferred=True)
'GO:1234'