Skip to content

Commit

Permalink
Merge pull request #18 from phenoscape/nexml-converter
Browse files Browse the repository at this point in the history
Add converter for NeXML files to OWL.
  • Loading branch information
balhoff committed Aug 28, 2018
2 parents c639c5f + cdf7934 commit 47a3e0e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/scala/org/phenoscape/owl/build/Command.scala
Expand Up @@ -17,6 +17,7 @@ object Command extends App {
case "sparql-select" => RunSPARQLQuery.main(commandArgs)
case "sparql-construct" => RunSPARQLConstruct.main(commandArgs)
case "sparql-update" => RunSPARQLUpdate.main(commandArgs)
case "convert-nexml" => ConvertNeXML.main(commandArgs)
case _ => println("""
Valid commands are:
Expand Down
23 changes: 23 additions & 0 deletions src/main/scala/org/phenoscape/owl/build/ConvertNeXML.scala
@@ -0,0 +1,23 @@
package org.phenoscape.owl.build

import java.io.File

import org.phenoscape.owl.PhenexToOWL
import org.phenoscape.owl.PropertyNormalizer
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat
import org.semanticweb.owlapi.model.IRI
import java.io.FileOutputStream

object ConvertNeXML extends App {

val ontologyPath = args(0)
val nexmlFiles = args.drop(1)
val manager = OWLManager.createOWLOntologyManager()
val ontology = manager.loadOntology(IRI.create(new File(ontologyPath)))
nexmlFiles.foreach { file =>
val nexmlOnt = PropertyNormalizer.normalize(PhenexToOWL.convert(new File(file), ontology))
manager.saveOntology(nexmlOnt, new FunctionalSyntaxDocumentFormat(), new FileOutputStream(new File(s"$file.ofn")))
}

}

0 comments on commit 47a3e0e

Please sign in to comment.