From a840ac38dc174ed5ab24afd3e992b9627f8597d1 Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Fri, 1 Dec 2023 14:55:39 +0100 Subject: [PATCH] Minor improvements in OBO output --- src/pyobo/struct/struct.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pyobo/struct/struct.py b/src/pyobo/struct/struct.py index 2aadf59f..d8f5224b 100644 --- a/src/pyobo/struct/struct.py +++ b/src/pyobo/struct/struct.py @@ -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 ( @@ -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}" @@ -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}"'