Skip to content
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

Save and copy Ontology IRI of parsed ontologies #17

Merged

Conversation

syphax-bouazzouni
Copy link

@syphax-bouazzouni syphax-bouazzouni commented Jul 29, 2022

Issue

The issue is that when the owlapi_wrapper parse an ontology doesn't copy the original IRI and just creates anonymous ontology

You can test it using this

String outputRepositoryFolder = "./src/test/resources/repo/output/cno";
ParserInvocation pi = new ParserInvocation("./src/test/resources/repo/input/cno",
outputRepositoryFolder, "cnov0_5.owl", true);
assertTrue(pi.valid());

OntologyParser parser = new OntologyParser(pi);
assertTrue(parser.parse());
assertEquals(1, parser.getLocalOntologies().size());

IRI targetIRI = parser.getTargetOwlOntology().getOntologyID().getOntologyIRI().orNull();
IRI sourceIRI = parser.getParsedOntologies().stream().findFirst().get().getOntologyID().getOntologyIRI().orNull();
assertNotNull(targetIRI);
assertEquals(sourceIRI, targetIRI);

In the original file, we have

 <owl:Ontology rdf:about="http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl">
        <dc:date rdf:datatype="&xsd;string">13/03/2012</dc:date>
        <dc:subject rdf:datatype="&xsd;string">An ontology to describe the field of Computational Neurosciences</dc:subject>
        <dc:contributor rdf:datatype="&xsd;string">Birgit Kriener</dc:contributor>

The created file contains the following (does not more contain the rdf:about)

<owl:Ontology >
        <dc:contributor rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Alan Ruttenberg</dc:contributor>
        <dc:contributor rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Andrew Spear</dc:contributor>
        <dc:contributor rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Birgit Kriener</dc:contributor>
        <dc:contributor rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Erik De Schutter</dc:contributor>
        <dc:contributor rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Fahim T. Imam</dc:contributor>

Solution

This PR, by just adding these lines

Optional<IRI> ontologyIRI = sourceOnt.getOntologyID().getOntologyIRI();
Optional<IRI> versionIRI =  sourceOnt.getOntologyID().getVersionIRI();
if (ontologyIRI.isPresent()) {
        OWLOntologyID newOntologyID = new OWLOntologyID(ontologyIRI, versionIRI);
	SetOntologyID setOntologyID = new SetOntologyID(targetOwlOntology, newOntologyID);
	this.targetOwlManager.applyChange(setOntologyID);
}

Why do we need the ontology IRI

ncbo/ontologies_linked_data#152

Copy link
Member

@jvendetti jvendetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @syphax-bouazzouni. Thank you very much for the pull request. I've added some comments for your consideration.

@jvendetti jvendetti self-assigned this Aug 26, 2022
@syphax-bouazzouni
Copy link
Author

Hi @jvendetti , thanks for the reviews. I have just answered them.

@jvendetti jvendetti merged commit 002e608 into ncbo:master Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants