Skip to content

Commit

Permalink
Fix definition source propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Jan 8, 2024
1 parent 58ab2b8 commit cb9f469
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/pyobo/obographs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from bioontologies.robot import ParseResults

from pyobo.struct import Obo, Reference, Term
from pyobo.struct.typedef import is_a
from pyobo.struct.typedef import definition_source, is_a

__all__ = [
"graph_from_obo",
Expand Down Expand Up @@ -61,12 +61,12 @@ def _rewire(r: Reference) -> curies.Reference:


def _get_class_node(term: Term) -> Node:
if not term.definition:
definition = None
else:
if term.definition or term.provenance:
definition = Definition.from_parsed(
value=term.definition, references=[_rewire(p) for p in term.provenance]
)
else:
definition = None

if term.xrefs:
if not term.xref_types:
Expand Down Expand Up @@ -126,3 +126,11 @@ def _iter_edges(term: Term) -> Iterable[Edge]:
_rewire(typedef.reference),
_rewire(target),
)

for provenance_reference in term.provenance:
yield Edge.from_parsed(
_rewire(term.reference),
_rewire(definition_source.reference),
_rewire(provenance_reference),
)
# TODO also look through xrefs and seealso to get provenance xrefs?

0 comments on commit cb9f469

Please sign in to comment.