Xref

class pronto.Xref[source]

A cross-reference to another document or resource.

Cross-references (xrefs for short) can be used to back-up definitions of entities, synonyms, or to link ontological entities to other resources they may have been derived from. Although originally intended to provide links to databases, cross-references in OBO ontologies gained additional purposes, such as helping for header macros expansion, or being used to alias external relationships with local unprefixed IDs.

The OBO format version 1.4 expects references to be proper OBO identifiers that can be translated to actual IRIs, which is a breaking change from the previous format. Therefore, cross-references are encouraged to be given as plain IRIs or as prefixed IDs using an ID from the IDspace mapping defined in the header.

Example

A cross-reference in the Mammalian Phenotype ontology linking a term to some related Web resource:

>>> mp = pronto.Ontology.from_obo_library("mp.obo")
>>> mp["MP:0030151"].name
'abnormal buccinator muscle morphology'
>>> mp["MP:0030151"].xrefs
frozenset({Xref('https://en.wikipedia.org/wiki/Buccinator_muscle')})

Caution

Xref instances compare only using their identifiers; this means it is not possible to have several cross-references with the same identifier and different descriptions in the same set.

Todo

Make sure to resolve header macros for xrefs expansion (such as treat-xrefs-as-is_a) when creating an ontology, or provide a method on Ontology doing so when called.

__init__(id: str, description: str | None = None)[source]

Create a new cross-reference.

Parameters:
  • id (str) – the identifier of the cross-reference, either as a URL, a prefixed identifier, or an unprefixed identifier.

  • description (str or None) – a human-readable description of the cross-reference, if any.

__eq__(other: object) bool[source]

Return self==value.

__gt__(other: object) bool[source]

Return self>value.

__ge__(other: object) bool[source]

Return self>=value.

__lt__(other: object) bool[source]

Return self<value.

__le__(other: object) bool[source]

Return self<=value.

__repr__()

Return a repr string that roundtrips. Computed by @roundrepr.

__hash__()[source]

Return hash(self).