https://github.com/flora-phenotype-ontology/flopoontology
Tip revision: cfb699302816405d6a7775ff377aaf5f05b510aa authored by Robert Hoehndorf on 06 September 2019, 01:20:44 UTC
FLOPO BioHackathon 2019 release
FLOPO BioHackathon 2019 release
Tip revision: cfb6993
ExtractLabels.groovy
import java.util.logging.Logger
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.*
import org.semanticweb.owlapi.reasoner.*
import org.semanticweb.owlapi.profiles.*
import org.semanticweb.owlapi.util.*
import org.semanticweb.owlapi.io.*
import org.semanticweb.elk.owlapi.*
import org.semanticweb.owlapi.vocab.OWLRDFVocabulary
OWLOntologyManager manager = OWLManager.createOWLOntologyManager()
OWLDataFactory fac = manager.getOWLDataFactory()
OWLDataFactory factory = fac
OWLOntology ont = manager.loadOntologyFromOntologyDocument(new File(args[0]))
def id2label = [:] // maps a name to an OWLClass
OWLAnnotationProperty label = fac.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI())
ont.getClassesInSignature(true).each { cl ->
def annos = cl.getAnnotations(ont, label)
annos.each { anno ->
if (anno.getValue() instanceof OWLLiteral) {
OWLLiteral val = (OWLLiteral) anno.getValue()
println cl.toString().replaceAll("<http://phenomebrowser.net/plant-phenotype.owl#","").replaceAll(">","") + "\t" + val.getLiteral()
}
}
}