Skip to content

Commit

Permalink
Bug fix to correctly identify ontology format
Browse files Browse the repository at this point in the history
OBO ontologies that imported OWL ontologies were getting incorrectly
tagged as OWL format.
  • Loading branch information
jvendetti committed May 15, 2017
1 parent b72af83 commit 44a0277
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/java/org/stanford/ncbo/oapiwrapper/OntologyParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ private void findLocalOntologies() {
}
}

private boolean isOBO() {
private boolean isOBO(OWLOntology ontology) {
boolean isOBO = false;
for (OWLOntology sourceOnt : sourceOwlManager.getOntologies()) {
OWLDocumentFormat format = sourceOwlManager.getOntologyFormat(sourceOnt);
isOBO = (format instanceof OBODocumentFormat) || (format instanceof OBO12DocumentFormat);
log.info("Ontology document format: {}", format.getClass().getName());
OWLDocumentFormat format = sourceOwlManager.getOntologyFormat(ontology);
if ((format instanceof OBODocumentFormat) || (format instanceof OBO12DocumentFormat)) {
isOBO = true;
}
log.info("Ontology document format: {}", format.getClass().getName());
return isOBO;
}

Expand Down Expand Up @@ -176,10 +176,9 @@ private void addGroundMetadata(IRI documentIRI, OWLDataFactory factory, OWLOntol
}
}

private boolean buildOWLOntology() {
private boolean buildOWLOntology(boolean isOBO) {

Set<OWLAxiom> allAxioms = new HashSet<OWLAxiom>();
boolean isOBO = false;

OWLDataFactory fact = sourceOwlManager.getOWLDataFactory();
try {
Expand All @@ -190,8 +189,6 @@ private boolean buildOWLOntology() {
return false;
}

isOBO = this.isOBO();

Set<OWLClass> toDelete = new HashSet<OWLClass>();
for (OWLOntology sourceOnt : sourceOwlManager.getOntologies()) {
IRI documentIRI = sourceOwlManager.getOntologyDocumentIRI(sourceOnt);
Expand Down Expand Up @@ -589,6 +586,7 @@ private boolean internalParse() {
findLocalOntologies();

OWLOntology ontology = findMasterFile();

if (ontology == null) {
String msg = String.format("Can't find %s in input folder!", parserInvocation.getMasterFileName());
parserLog.addError(ParserError.MASTER_FILE_MISSING, msg);
Expand All @@ -599,7 +597,9 @@ private boolean internalParse() {
OntologyMetrics metrics = new OntologyMetrics(ontology, parserInvocation);
metrics.generate();

if (!buildOWLOntology()) return false;
boolean isOBO = isOBO(ontology);

if (!buildOWLOntology(isOBO)) return false;

if (!serializeOntology()) return false;

Expand Down

0 comments on commit 44a0277

Please sign in to comment.