Skip to content

Commit f997ff1

Browse files
committed
Fix serialization of holds_over_chain clauses with fastobo
1 parent ad6857f commit f997ff1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pronto/serializers/_fastobo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ def _to_typedef_frame(self, relationship: Relationship):
205205
if r.builtin:
206206
frame.append(fastobo.typedef.BuiltinClause(True))
207207
for chain in sorted(r.holds_over_chain):
208-
frame.append(fastobo.typedef.HoldsOverChainClause(*chain))
208+
c1, c2 = map(fastobo.id.parse, chain)
209+
frame.append(fastobo.typedef.HoldsOverChainClause(c1, c2))
209210
if r.antisymmetric:
210211
frame.append(fastobo.typedef.IsAntiSymmetricClause(True))
211212
if r.cyclic:

tests/test_issues.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,12 @@ def test_metadata_tag_serialization(self):
136136
is_metadata_tag: true
137137
""").strip()
138138
)
139+
140+
def test_relationship_chains(self):
141+
ont = pronto.Ontology()
142+
r1 = ont.create_relationship("r1")
143+
r2 = ont.create_relationship("r2")
144+
r3 = ont.create_relationship("r3")
145+
r3.holds_over_chain = { (r1, r2) }
146+
r3.equivalent_to_chain = { (r1, r2) }
147+
ont.dumps()

0 commit comments

Comments
 (0)