Harold-Solbrig / funowl

Pythonic representation of OWL through the OWL functional syntax
Creative Commons Zero v1.0 Universal
50 stars 5 forks source link

Presence of ':=' in literal confuses functional syntax parsing #39

Closed cmungall closed 2 years ago

cmungall commented 2 years ago
Prefix(so:=<http://purl.obolibrary.org/obo/so#>)
Prefix(obo:=<http://purl.obolibrary.org/obo/>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Prefix(oboInOwl:=<http://www.geneontology.org/formats/oboInOwl#>)

Ontology(<http://purl.obolibrary.org/obo/so/subsets/SOFA.owl>

AnnotationAssertion(oboInOwl:hasDbXref obo:SO_0000394 "PMID:=12409455")
)

yields

AssertionError: Quote expected in string at ^ in Schema#> . xsd:f a "^PMID .

stack trace:

  File "/Users/cjm/repos/linkml-model-enrichment/linkml_model_enrichment/importers/owl_import_engine.py", line 29, in convert
    doc = to_python(file)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/funowl/converters/functional_converter.py", line 349, in to_python
    fparse(to_bytes_array(defn), 0, consumer)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/funowl/converters/functional_converter.py", line 297, in fparse
    start = fparse(inp, start, lambda f: o.add_arg(f))
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/funowl/converters/functional_converter.py", line 306, in fparse
    consumer(OWLFunc(m.group(1).decode(), parse_args(body.decode())).decl)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/funowl/converters/functional_converter.py", line 64, in __init__
    self.decl = self.eval(function, body)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/funowl/converters/functional_converter.py", line 115, in eval
    return method_to_call(*args)
  File "<string>", line 5, in __init__
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/funowl/base/fun_owl_base.py", line 26, in __setattr__
    key, cast(hint, value, getattr(self, '_coercion_allowed', None)) if hint else value)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/funowl/base/cast_function.py", line 145, in cast
    elif isinstance_(v, typ):
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/funowl/terminals/TypingHelper.py", line 94, in isinstance_
    return get_origin(test_type) is None and isinstance(x, test_type)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/funowl/base/fun_owl_base.py", line 89, in __instancecheck__
    return cls._is_valid(cls, instance)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/funowl/base/fun_owl_choice.py", line 96, in _is_valid
    elif cls._coercion_allowed and isinstance(v, choice_type):
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/funowl/base/fun_owl_base.py", line 89, in __instancecheck__
    return cls._is_valid(cls, instance)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/funowl/literals.py", line 187, in _is_valid
    return Literal._to_n3(instance) is not None
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/funowl/literals.py", line 174, in _to_n3
    g.parse(data=stmt, format="turtle")
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/graph.py", line 1252, in parse
    parser.parse(source, self, **args)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 1921, in parse
    p.loadStream(stream)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 438, in loadStream
    return self.loadBuf(stream.read())  # Not ideal
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 444, in loadBuf
    self.feed(buf)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 470, in feed
    i = self.directiveOrStatement(s, j)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 490, in directiveOrStatement
    j = self.statement(argstr, i)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 740, in statement
    j = self.property_list(argstr, i, r[0])
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 1088, in property_list
    i = self.objectList(argstr, j, objs)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 1132, in objectList
    i = self.object(argstr, i, res)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 1418, in object
    j = self.subject(argstr, i, res)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 747, in subject
    return self.item(argstr, i, res)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 839, in item
    return self.path(argstr, i, res)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 846, in path
    j = self.nodeOrLiteral(argstr, i, res)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 1489, in nodeOrLiteral
    j, s = self.strconst(argstr, i, delim)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/linkml-model-enrichment-SoxTXfjD-py3.9/lib/python3.9/site-packages/rdflib/plugins/parsers/notation3.py", line 1557, in strconst
    assert m, "Quote expected in string at ^ in %s^%s" % (
AssertionError: Quote expected in string at ^ in Schema#> . xsd:f a "^PMID .