Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
b77afa7
add IDE files to gitignore (IntelliJ IDE)
vemonet Oct 6, 2015
0a99d60
adding sonatype-snapshots maven repository to pom.xml to be able to r…
vemonet Oct 7, 2015
a9f04cd
Changing the place where the owlapi_wrapper.jar is built
vemonet Oct 7, 2015
6425179
New method addOntologyURI that add the ontology URI to the submission…
vemonet Oct 7, 2015
c30f9e7
add the ontology used to import
vemonet Apr 29, 2016
9666288
rename test file
vemonet Apr 29, 2016
0c4b238
change extension of skos file to owl because owlapi_wrapper could onl…
vemonet Apr 29, 2016
d512d2f
extracting ontology IRI directly from localMaster ontology to avoid g…
vemonet Apr 30, 2016
876947e
fix bug where omv:URI was considered as a annotation property
vemonet Jun 2, 2016
3a39914
merge with NCBO master (a lot of change, with metrics extracted from …
vemonet Jun 2, 2016
b462ca2
Merge branch 'master' into sifr_owlapi
vemonet Sep 20, 2016
7b73cab
Merge branch 'master' of https://github.com/ncbo/owlapi_wrapper into …
vemonet Apr 5, 2017
92d24e4
reformate OntologyParser Class
vemonet Apr 5, 2017
6b590ac
add comments
vemonet Apr 5, 2017
5b7c533
add comments. And comment a block where we create a now useless tripl…
vemonet Apr 5, 2017
5a12888
stop using addGroundMetadata (was getting metadata for imports also),…
vemonet Apr 5, 2017
34a4cfc
add a test for SIFR (to test ontology parsing)
vemonet Apr 5, 2017
952c19a
add a repertory and foodon.owl to do test for SIFR project (to test o…
vemonet Apr 5, 2017
42456a5
add comment on test output redirection in the pom.xml
vemonet Apr 5, 2017
0dbbcfc
merge with NCBO owlapi_wrapper after update
vemonet Apr 12, 2017
b12f5e5
remove useless tests files (wrong place)
vemonet Apr 21, 2017
e285151
fix how we get versionInfo for OBO ontologies
vemonet May 6, 2017
cb97bae
now adding all ontologies metadata to the output file (even imported …
vemonet May 8, 2017
9e6fbca
Fixing merge conflicts with NCBO master
Apr 28, 2020
7374627
Reinjecting previous commit (5a128888588e3655acaa1d52f01c86e827f38442)
May 13, 2020
528b50b
Reinjecting previous commit (e2851510d659155afc873174c58e495fe737295f)
May 13, 2020
763d048
Reinjecting previous commit (cb97bae50534dce7dea67227be6139a8ed33c99a)
May 13, 2020
0ef64a4
Merge branch 'master' of https://github.com/ncbo/owlapi_wrapper into …
ontoportal-bot-lirmm Jul 7, 2020
8107d8b
Merge branch 'master' of https://github.com/ncbo/owlapi_wrapper into …
ontoportal-bot-lirmm Jul 10, 2020
98ac732
Fixing missing dependency while parsing a file extracted from an arch…
Jul 22, 2020
268aad5
Merge branch 'virtual-appliance-3.0-merge'
Sep 10, 2020
e6bc50c
merge to upstream v1.3.8
syphax-bouazzouni May 12, 2022
1e5be4c
Merge remote-tracking branch 'upstream/master'
syphax-bouazzouni Jul 29, 2022
652b428
Merge branch 'pr/feature/add-ontology-iri-triple'
syphax-bouazzouni Aug 3, 2022
56e1684
add omv:useImports
syphax-bouazzouni Aug 3, 2022
6ff3a96
Merge remote-tracking branch 'upstream/master'
syphax-bouazzouni Sep 26, 2022
b58dfce
Merge remote-tracking branch 'upstream/master' into upstream
syphax-bouazzouni Dec 21, 2022
5a17c74
add test to count annotions of the source ontology vs generated one
syphax-bouazzouni Dec 21, 2022
e0ad8c7
remove sourceOwlManager.getOntologies() loops
syphax-bouazzouni Dec 21, 2022
10c4525
Merge branch 'pr/fix/add-only-master-ontology-annotations'
syphax-bouazzouni Dec 24, 2022
168cb9b
remove sourceOwlManager.getOntologies() loop for addOntologyAnnotations
syphax-bouazzouni Dec 21, 2022
177277d
Merge branch 'pr/fix/add-only-master-ontology-annotations'
syphax-bouazzouni Dec 24, 2022
62808e1
add guard to avoid .get() of absent value
RaimiSol May 24, 2023
fb407d6
Merge pull request #5 from BiodivPortal/master
syphax-bouazzouni May 25, 2023
894594b
Add IRIMapper for SKOS Core Vocabulary
jvendetti Nov 2, 2023
1182b98
Update developer details
jvendetti Nov 2, 2023
495f671
Fix insecure link warning
jvendetti Nov 2, 2023
1d0c0b0
Remove defunct support list archive
jvendetti Nov 2, 2023
d4f29ca
Bump commons-csv from 1.9.0 to 1.10.0
jvendetti Nov 3, 2023
9dcbcc0
Bump logback-classic from 1.2.11 to 1.4.11
jvendetti Nov 3, 2023
93e58e3
Update developer and contributor details
jvendetti Nov 3, 2023
fe5bc78
[maven-release-plugin] prepare release owlapi-wrapper-1.4.2
jvendetti Nov 3, 2023
159d7bd
[maven-release-plugin] prepare for next development iteration
jvendetti Nov 3, 2023
7c3c4e3
[maven-release-plugin] rollback the release of owlapi-wrapper-1.4.2
jvendetti Nov 3, 2023
f9e74b6
[maven-release-plugin] prepare release v1.4.2
jvendetti Nov 3, 2023
2856e0b
[maven-release-plugin] prepare for next development iteration
jvendetti Nov 3, 2023
8cd3885
move sub.get() after the check to prevent expection
syphax-bouazzouni May 21, 2024
68379d3
Merge remote-tracking branch 'upstream/master' into fix/resource-with…
syphax-bouazzouni May 21, 2024
d70cd40
Revert "Merge branch 'pr/fix/add-only-master-ontology-annotations'"
syphax-bouazzouni May 28, 2024
e6792c4
Merge pull request #6 from ontoportal-lirmm/fix/resource-with-no-owl-…
syphax-bouazzouni Sep 30, 2024
ba18bbd
Merge branch 'master' into pr/fix/add-only-master-ontology-annotations
syphax-bouazzouni Mar 20, 2025
1d25128
add code coverage reports
alexskr May 2, 2025
0301a3a
update build status badge
alexskr May 2, 2025
f8212ea
Merge pull request #23 from ncbo/ci/codecov-integration
alexskr May 2, 2025
419489d
bump logback from 1.4.11 to 1.4.14
alexskr May 2, 2025
282dc07
fix the parsing to import the axiom of the imported ontologies withou…
syphax-bouazzouni Jun 19, 2025
81eb188
Merge branch 'master' into fix/ontology-level-annotation-imports
syphax-bouazzouni Jun 19, 2025
3f4033f
Merge remote-tracking branch 'ontoportal/master' into fix/ontology-le…
syphax-bouazzouni Jun 19, 2025
9156d1c
Merge branch 'fix/ontology-level-annotation-imports' into pr/fix/add-…
syphax-bouazzouni Jun 19, 2025
72117fa
Merge branch 'ontoportal-lirmm-pr/fix/add-only-master-ontology-annota…
mdorf Jun 19, 2025
ec9b6a7
updated OWLAPI Wrapper to support mixed ontology level annotations, p…
mdorf Jun 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/maven.yml → .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI with Maven
name: Java Unit Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Prepare all dependencies
run: mvn -B dependency:go-offline
- name: Run tests
run: mvn -B test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# owlapi_wrapper

[![Build Status](https://travis-ci.org/ncbo/owlapi_wrapper.svg?branch=master)](https://travis-ci.org/ncbo/owlapi_wrapper)
[![codecov](https://codecov.io/gh/ncbo/owlapi_wrapper/graph/badge.svg?token=HEt3yP8T0i)](https://codecov.io/gh/ncbo/owlapi_wrapper)

A command line utility that wraps the Java [OWL API](https://github.com/owlcs/owlapi) for parsing RDFS, OWL, and OBO ontologies.

2 changes: 1 addition & 1 deletion build_install.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mvn assembly:assembly -DskipTests && cp target/owlapi_wrapper-0.0.1-SNAPSHOT-jar-with-dependencies.jar ../ontologies_linked_data/bin/owlapi_wrapper.jar
mvn assembly:assembly -DskipTests && cp target/owlapi_wrapper-0.0.1-SNAPSHOT-jar-with-dependencies.jar ../owlapi_wrapper.jar
32 changes: 29 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.4.11</version>
<version>1.4.14</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.4.11</version>
<version>1.4.14</version>
</dependency>

<dependency>
Expand All @@ -153,6 +153,12 @@
<version>1.10.0</version>
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -222,7 +228,27 @@
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.13</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

</build>
</project>
107 changes: 69 additions & 38 deletions src/main/java/org/stanford/ncbo/owlapi/wrapper/OntologyParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

public class OntologyParser {
private final static Logger log = LoggerFactory.getLogger(OntologyParser.class.getName());
public static final String USE_IMPORTS_IRI = "http://omv.ontoware.org/2005/05/ontology#useImports";
public static final String VERSION_SUBJECT = "http://bioportal.bioontology.org/ontologies/versionSubject";

protected ParserInvocation parserInvocation = null;
Expand Down Expand Up @@ -169,6 +170,33 @@ private void addOntologyIRI(OWLOntology sourceOnt) {
}
}

/**
* Get ontology imports and them to <ONTOLOGY_URI>
* omv:useImports <import_URI>
*
* @param fact
* @param sourceOnt
*/
private void addOntologyImports(OWLDataFactory fact, OWLOntology sourceOnt){
Optional<IRI> sub = sourceOnt.getOntologyID().getOntologyIRI();

if(!sub.isPresent()){
return;
}

IRI ontologyIRI = sub.get();

// Get imports and add them as omv:useImports
OWLAnnotationProperty useImportProp = fact.getOWLAnnotationProperty(IRI.create(USE_IMPORTS_IRI));
for (OWLOntology imported : sourceOnt.getImports()) {
if (!imported.getOntologyID().isAnonymous()) {
log.info("useImports: " + imported.getOntologyID().getOntologyIRI().get());
OWLAnnotationAssertionAxiom useImportAxiom = fact.getOWLAnnotationAssertionAxiom(useImportProp, ontologyIRI, imported.getOntologyID().getOntologyIRI().get());
this.targetOwlManager.addAxiom(targetOwlOntology, useImportAxiom);
}
}
}

/**
* Copies ontology-level annotation axioms from the source ontology to the target ontology.
* <p>
Expand All @@ -188,6 +216,7 @@ private void addGroundMetadata(IRI documentIRI, OWLDataFactory factory, OWLOntol
}

for (OWLAnnotation annotation : sourceOntology.getAnnotations()) {

IRI subjectIRI = ontologyID.getOntologyIRI().get();
OWLAnnotationProperty annotationProperty = annotation.getProperty();
OWLAnnotationValue annotationValue = annotation.getValue();
Expand All @@ -212,6 +241,7 @@ private boolean buildOWLOntology(OWLOntology masterOntology, boolean isOBO) {
try {
targetOwlOntology = targetOwlManager.createOntology();
addOntologyIRI(masterOntology);
addOntologyImports(fact, masterOntology);
} catch (OWLOntologyCreationException e) {
log.error(e.getMessage());
parserLog.addError(ParserError.OWL_CREATE_ONTOLOGY_EXCEPTION, "Error buildOWLOntology" + e.getMessage());
Expand All @@ -232,51 +262,52 @@ private boolean buildOWLOntology(OWLOntology masterOntology, boolean isOBO) {

boolean isPrefixedOWL = sourceOwlManager.getOntologyFormat(sourceOnt).isPrefixOWLOntologyFormat();
log.info("isPrefixOWLOntologyFormat: {}", isPrefixedOWL);
if (isPrefixedOWL == true && !isOBO) {
if (isPrefixedOWL && !isOBO) {
generateSKOSInOwl(allAxioms, fact, sourceOnt);
}
}

targetOwlManager.addAxioms(targetOwlOntology, allAxioms);
for (OWLAnnotation ann : targetOwlOntology.getAnnotations()) {

targetOwlManager.addAxioms(targetOwlOntology, allAxioms);
for (OWLAnnotation ann : targetOwlOntology.getAnnotations()) {
AddOntologyAnnotation addAnn = new AddOntologyAnnotation(targetOwlOntology, ann);
targetOwlManager.applyChange(addAnn);
}

if (isOBO) {
String oboVersion = parserInvocation.getOBOVersion();
if (oboVersion != null) {
log.info("Adding version: {}", oboVersion);
OWLAnnotationProperty prop = fact.getOWLAnnotationProperty(IRI.create(OWLRDFVocabulary.OWL_VERSION_INFO.toString()));
IRI versionSubjectIRI = IRI.create(VERSION_SUBJECT);
OWLAnnotationAssertionAxiom annVersion = fact.getOWLAnnotationAssertionAxiom(prop, versionSubjectIRI, fact.getOWLLiteral(oboVersion));
targetOwlManager.addAxiom(targetOwlOntology, annVersion);
}
}

addOntologyAnnotations(masterOntology);
escapeXMLLiterals(targetOwlOntology);

OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(targetOwlOntology);
InferredSubClassAxiomGenerator isc = new InferredSubClassAxiomGenerator();
Set<OWLSubClassOfAxiom> subAxs = isc.createAxioms(targetOwlOntology.getOWLOntologyManager().getOWLDataFactory(), reasoner);
targetOwlManager.addAxioms(targetOwlOntology, subAxs);
deprecateBranch();

log.info("isOBO: {}", isOBO);
if (isOBO) {
replicateHierarchyAsTreeview(fact);
}
return true;
}

private void addOntologyAnnotations(OWLOntology masterOntology){
for (OWLAnnotation ann : masterOntology.getAnnotations()) {
AddOntologyAnnotation addAnn = new AddOntologyAnnotation(targetOwlOntology, ann);
targetOwlManager.applyChange(addAnn);
}

if (isOBO) {
String oboVersion = parserInvocation.getOBOVersion();
if (oboVersion != null) {
log.info("Adding version: {}", oboVersion);
OWLAnnotationProperty prop = fact.getOWLAnnotationProperty(IRI.create(OWLRDFVocabulary.OWL_VERSION_INFO.toString()));
IRI versionSubjectIRI = IRI.create(VERSION_SUBJECT);
OWLAnnotationAssertionAxiom annVersion = fact.getOWLAnnotationAssertionAxiom(prop, versionSubjectIRI, fact.getOWLLiteral(oboVersion));
targetOwlManager.addAxiom(targetOwlOntology, annVersion);
}
}

for (OWLOntology sourceOnt : sourceOwlManager.getOntologies()) {
for (OWLAnnotation ann : sourceOnt.getAnnotations()) {
AddOntologyAnnotation addAnn = new AddOntologyAnnotation(targetOwlOntology, ann);
targetOwlManager.applyChange(addAnn);
}
}

escapeXMLLiterals(targetOwlOntology);

OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(targetOwlOntology);
InferredSubClassAxiomGenerator isc = new InferredSubClassAxiomGenerator();
Set<OWLSubClassOfAxiom> subAxs = isc.createAxioms(targetOwlOntology.getOWLOntologyManager().getOWLDataFactory(), reasoner);
targetOwlManager.addAxioms(targetOwlOntology, subAxs);
deprecateBranch();

log.info("isOBO: {}", isOBO);
if (isOBO) {
replicateHierarchyAsTreeview(fact);
}
return true;
}

private void replicateHierarchyAsTreeview(OWLDataFactory fact) {
Set<OWLAxiom> treeViewAxs = new HashSet<OWLAxiom>();
for (OWLAxiom axiom : targetOwlOntology.getAxioms()) {
Expand Down Expand Up @@ -449,7 +480,7 @@ private void escapeXMLLiterals(OWLOntology target) {
targetOwlManager.addAxiom(target, annAsse);
Set<OWLAnnotationAssertionAxiom> del = new HashSet<OWLAnnotationAssertionAxiom>();
del.add(ann);
targetOwlManager.removeAxioms(target,del);
targetOwlManager.removeAxioms(target,del);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.stanford.ncbo.owlapi.wrapper.preferred_labels;

import org.semanticweb.owlapi.model.OWLOntology;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.stanford.ncbo.owlapi.wrapper.ParserInvocation;
import org.stanford.ncbo.owlapi.wrapper.metrics.OntologyMetrics;

public class PreferredLabels {
private static final Logger logger = LoggerFactory.getLogger(OntologyMetrics.class);

private OWLOntology ontology;

private ParserInvocation parserInvocation;

public PreferredLabels(OWLOntology ontology, ParserInvocation parserInvocation) {
this.ontology = ontology;
this.parserInvocation = parserInvocation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ public class OntologyParserTest {
public void setUp() throws Exception {

}

// Run this test: mvn -Dtest=OntologyParserTest#sifrTestParse test
// parse_OntologyENVO_ReturnsTrue fonctionne pour comparer
@Test
public void sifrTestParse() throws Exception {
ParserInvocation pi = new ParserInvocation("./src/test/resources/repo/input/sifr",
"./src/test/resources/repo/output/sifr", "foodon.owl", true);
// SKOS: anaee-france-thesaurus.rdf
// OWL: AnimalDiseasesOntology.owl.xml
OntologyParser parser = new OntologyParser(pi);
parser.parse();
//assertFalse(parser.parse());
}

@Test
public void getLocalOntologies_MultipleOntologies_Found() throws Exception {
Expand Down Expand Up @@ -165,6 +178,25 @@ public void parse_ImportSKOSCoreVocab_ShouldLoad() throws Exception {
OWLClass skosConceptClass = factory.getOWLClass(skosConceptIRI);
assertNotNull(skosConceptClass);
}
@Test
public void parse_OntologyAnnotationCount_ReturnsTrue() throws Exception {
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());

OWLOntology targetOwlOntology = parser.getTargetOwlOntology();
OWLOntology sourceOntology = parser.getParsedOntologies().stream().findFirst().orElse(null);

assertNotNull(sourceOntology);
assertEquals(sourceOntology.getAnnotations().size(), targetOwlOntology.getAnnotations().size());

}


@After
public void tearDown() throws Exception {
Expand Down
Loading