Skip to content

ROBOT convert is stripping prefixes #1101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dosumis opened this issue Feb 28, 2023 · 13 comments · Fixed by #1106
Closed

ROBOT convert is stripping prefixes #1101

dosumis opened this issue Feb 28, 2023 · 13 comments · Fixed by #1106
Labels

Comments

@dosumis
Copy link

dosumis commented Feb 28, 2023

robot convert -i cl-edit.owl -f ofn -o tmp.owl

Before

Prefix(:=<http://purl.obolibrary.org/obo/cl.owl#>)
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#>)

After

Prefix(:=<http://purl.obolibrary.org/obo/cl.owl#>)
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#>)

This can => massive changes in diffs when used to reserialize.

@matentzn
Copy link
Contributor

I can confirm this - and it is a bit annoying I must say; I am not sure if this was introduced with the latest OWLAPI update, but I would be surprised to not have noticed this issue in prior ROBOT versions.

Workaround for the hackers in the meantime:

After the conversion/serialisation, copy the old prefixes back, then open Protege and safe again. All good.

Should be fixed though in our next ROBOT push - if there is a fix. I will add it to the Tech Support board so than @jamesaoverton does not need to concern himself with this now (unless he wants to).

@jamesaoverton
Copy link
Member

@matentzn You're saying that ROBOT is changing prefixes but Protege isn't? That would be strange.

@matentzn
Copy link
Contributor

matentzn commented Feb 28, 2023

Yes. Exactly :)

This input:

Prefix(:=<http://purl.obolibrary.org/obo/cl.owl#>)
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/cl.owl>

Declaration(Class(obo:CL_0000000))
)

Results (with @dosumis command above) in this output:

Prefix(:=<http://purl.obolibrary.org/obo/cl.owl#>)
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#>)


Ontology(<http://purl.obolibrary.org/obo/cl.owl>

Declaration(Class(<http://purl.obolibrary.org/obo/CL_0000000>))

)

Or this, if you serialise it to another serialisation:

<?xml version="1.0"?>
<rdf:RDF xmlns="http://purl.obolibrary.org/obo/cl.owl#"
     xml:base="http://purl.obolibrary.org/obo/cl.owl"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="http://purl.obolibrary.org/obo/cl.owl"/>

    <!-- http://purl.obolibrary.org/obo/CL_0000000 -->

    <owl:Class rdf:about="http://purl.obolibrary.org/obo/CL_0000000"/>
</rdf:RDF>

<!-- Generated by the OWL API (version 4.5.25) https://github.com/owlcs/owlapi -->

@jamesaoverton
Copy link
Member

But those prefixes aren't used in the content of the input, so I would not expect them to be included in the output.

@matentzn
Copy link
Contributor

They are! obo!

@jamesaoverton
Copy link
Member

obo is used but oboInOwl is not.

I can confirm that this behaviour changed with the OWLAPI update in ROBOT 1.9.2. In 1.9.1 and earlier, for this example the convert output is the same as the input, except for a bit of whitespace.

@jamesaoverton
Copy link
Member

And Protege 5.6.1 is not dropping these prefixes. I don't understand.

@allenbaron
Copy link
Contributor

Prefixes are not lost when converting from .ofn or .owl to .owl (unless format is specified as something other than .owl) but they are for every other conversion I tested (.omn, .ofn, .owx., .ttl). I thought I might get around it by converting to .owl and then back to .ofn but that didn't work.

@gouttegd
Copy link
Contributor

As far as I can tell, the problem seems to have been introduced in OWL API 4.5.23.

The following code:

OWLOntologyManager man = OWLManager.createConcurrentOWLOntologyManager();
File inputFile = new File("issue-1101-input.ofn");
File outputFile = new File("issue-1101-output.ofn");

OWLOntology o = man.loadOntologyFromOntologyDocument(inputFile);
o.saveOntology(new FunctionalSyntaxDocumentFormat(), new FileOutputStream(outputFile));

yields no difference between input and output with OWL API 4.5.22 (I used as input the minimal example provided in this comment), while with OWL API 4.5.23 the oboInOwl and obo prefixes are stripped.

@matentzn
Copy link
Contributor

@ignazio1977 is there any change you can think of that could have caused this to happen?

Small oddity: Somehow the same does not happen with Protege.

@balhoff
Copy link
Contributor

balhoff commented Mar 28, 2023

I opened a PR that fixes the issue. I'm kind of pressed for time at the moment—is anyone else able to add a test case to the PR?

@ignazio1977
Copy link
Contributor

Prefixes are not lost when converting from .ofn or .owl to .owl (unless format is specified as something other than .owl) but they are for every other conversion I tested (.omn, .ofn, .owx., .ttl). I thought I might get around it by converting to .owl and then back to .ofn but that didn't work.

This comment from @allenbaron, and @balhoff's pull request to fix the issue, make me think the bug was there before. I remember writing similar fixes in the renderers for some formats, but not all. Basic issue is that, when converting formats, there are two format objects in play and the prefixes need copying across.

No recent changes in that area, unless the latest patches that tweaked some obo behaviours also made these prefixes appear/disappear more often than usual?

@gouttegd
Copy link
Contributor

gouttegd commented Mar 28, 2023

@balhoff Basic test case in #1107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants