althonos / pronto

A Python frontend to (Open Biomedical) Ontologies.
https://pronto.readthedocs.io
MIT License
229 stars 48 forks source link

BaseIdent TypeError when saving obo files with property chains #175

Closed cmungall closed 2 years ago

cmungall commented 2 years ago

File with a property chain:

format-version: 1.4
ontology: test

[Typedef]
id: p
name: p
holds_over_chain: p p

(yes, this is just an odd way of writing transitive, but the same phenotype is observed with more realistic property chains)

Test code:

>>> from pronto import Ontology
>>> ont = Ontology("tests/input/pronto-test.obo")
>>> with open("out.obo", 'wb') as file:
...     ont.dump(file, format='obo')
... 
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/pronto/ontology.py", line 405, in dump
    cls(self).dump(file)  # type: ignore
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/pronto/serializers/obo.py", line 37, in dump
    frame = self._to_typedef_frame(Relationship(self.ont, data))
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/pronto/serializers/_fastobo.py", line 208, in _to_typedef_frame
    frame.append(fastobo.typedef.HoldsOverChainClause(*chain))
TypeError: argument 'first': expected BaseIdent instance, str found
althonos commented 2 years ago

Hi @cmungall, I just made a patch release (v2.4.6) to fix this issue.