parse_curie(curie: str, *, sep: str = ':', use_preferred: bool = False) Tuple[str, str] | Tuple[None, None][source]

Parse a CURIE, normalizing the prefix and identifier if necessary.

  • 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 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.


A tuple of the prefix, identifier. If not parsable, returns a tuple of None, None

The algorithm for parsing a CURIE is very simple: it splits the string on the leftmost occurrence of the separator (usually a colon “:” unless specified otherwise). The left part is the prefix, and the right part is the identifier.

>>> parse_curie('pdb:1234')
('pdb', '1234')

Address banana problem >>> parse_curie(’go:GO:1234’) (‘go’, ‘1234’) >>> parse_curie(’go:go:1234’) (‘go’, ‘1234’) >>> parse_curie(’go:1234’) (‘go’, ‘1234’)

Address banana problem with OBO banana >>> parse_curie(‘fbbt:FBbt:1234’) (‘fbbt’, ‘1234’) >>> parse_curie(‘fbbt:fbbt:1234’) (‘fbbt’, ‘1234’) >>> parse_curie(‘fbbt:1234’) (‘fbbt’, ‘1234’)

Address banana problem with explit banana >>> parse_curie(‘go.ref:GO_REF:1234’) (‘go.ref’, ‘1234’) >>> parse_curie(‘go.ref:1234’) (‘go.ref’, ‘1234’)

Parse OBO PURL curies >>> parse_curie(‘GO_1234’, sep=”_”) (‘go’, ‘1234’)

Banana with no peel: >>> parse_curie(“”) (‘’, ‘12345’)

Use preferred (available) >>> parse_curie(‘GO_1234’, sep=”_”, use_preferred=True) (‘GO’, ‘1234’)

Use preferred (unavailable) >>> parse_curie(‘pdb:1234’, use_preferred=True) (‘pdb’, ‘1234’)