From f997ff1d1960f0524eba5bc6edc402c47e6258b5 Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Sat, 18 Jun 2022 16:29:31 +0200 Subject: [PATCH] Fix serialization of `holds_over_chain` clauses with `fastobo` --- pronto/serializers/_fastobo.py | 3 ++- tests/test_issues.py | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pronto/serializers/_fastobo.py b/pronto/serializers/_fastobo.py index 643824a..b5b9b94 100644 --- a/pronto/serializers/_fastobo.py +++ b/pronto/serializers/_fastobo.py @@ -205,7 +205,8 @@ def _to_typedef_frame(self, relationship: Relationship): if r.builtin: frame.append(fastobo.typedef.BuiltinClause(True)) for chain in sorted(r.holds_over_chain): - frame.append(fastobo.typedef.HoldsOverChainClause(*chain)) + c1, c2 = map(fastobo.id.parse, chain) + frame.append(fastobo.typedef.HoldsOverChainClause(c1, c2)) if r.antisymmetric: frame.append(fastobo.typedef.IsAntiSymmetricClause(True)) if r.cyclic: diff --git a/tests/test_issues.py b/tests/test_issues.py index 0f62ebc..29f928e 100644 --- a/tests/test_issues.py +++ b/tests/test_issues.py @@ -136,3 +136,12 @@ def test_metadata_tag_serialization(self): is_metadata_tag: true """).strip() ) + + def test_relationship_chains(self): + ont = pronto.Ontology() + r1 = ont.create_relationship("r1") + r2 = ont.create_relationship("r2") + r3 = ont.create_relationship("r3") + r3.holds_over_chain = { (r1, r2) } + r3.equivalent_to_chain = { (r1, r2) } + ont.dumps()