Skip to content

Commit

Permalink
Minor improvements in OBO output
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Dec 1, 2023
1 parent 9ad4a0d commit a840ac3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pyobo/struct/struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def iterate_obo_lines(self, *, ontology, typedefs) -> Iterable[str]:

parent_tag = "is_a" if self.type == "Term" else "instance_of"
for parent in sorted(self.parents, key=attrgetter("prefix", "identifier")):
yield f"{parent_tag}: {parent}"
yield f"{parent_tag}: {parent.preferred_curie}"

for typedef, references in sorted(self.relationships.items(), key=_sort_relations):
if (not typedefs or typedef not in typedefs) and (
Expand Down Expand Up @@ -666,6 +666,8 @@ def iterate_obo_lines(self) -> Iterable[str]:
yield f"idspace: {prefix} {url}"

for synonym_typedef in sorted((self.synonym_typedefs or []), key=attrgetter("curie")):
if synonym_typedef.curie == DEFAULT_SYNONYM_TYPE.curie:
continue
yield synonym_typedef.to_obo()

yield f"ontology: {self.ontology}"
Expand Down Expand Up @@ -1468,4 +1470,4 @@ def _convert_synonym_typedefs(synonym_typedefs: Optional[Iterable[SynonymTypeDef


def _convert_synonym_typedef(synonym_typedef: SynonymTypeDef) -> str:
return f'{synonym_typedef.curie} "{synonym_typedef.name}"'
return f'{synonym_typedef.preferred_curie} "{synonym_typedef.name}"'

0 comments on commit a840ac3

Please sign in to comment.