Search in sources :

Example 6 with ParserWrapper

use of owltools.io.ParserWrapper in project minerva by geneontology.

the class StartUpTool method startUp.

public static Server startUp(final MinervaStartUpConfig conf) throws Exception {
    // load ontology
    LOGGER.info("Start loading ontology: " + conf.ontology);
    ParserWrapper pw = new ParserWrapper();
    // if available, set catalog
    if (conf.catalog != null) {
        LOGGER.info("Adding catalog xml: " + conf.catalog);
        pw.addIRIMapper(new CatalogXmlIRIMapper(conf.catalog));
    }
    MinervaOWLGraphWrapper graph = pw.parseToOWLGraph(conf.ontology);
    // grab ontology metadata and store for status service
    Map<IRI, Set<OWLAnnotation>> ont_annos = new HashMap<IRI, Set<OWLAnnotation>>();
    OWLDataFactory factory = OWLManager.getOWLDataFactory();
    OWLAnnotationProperty versionIRI = factory.getOWLAnnotationProperty(OWLRDFVocabulary.OWL_VERSION_IRI.getIRI());
    for (OWLOntology ont : graph.getAllOntologies()) {
        Set<OWLAnnotation> maybeVersionAnnotation = ont.getOntologyID().getVersionIRI().transform(iri -> factory.getOWLAnnotation(versionIRI, iri)).asSet();
        Set<OWLAnnotation> annotations = ont.getAnnotations();
        annotations.addAll(maybeVersionAnnotation);
        ont_annos.put(ont.getOWLOntologyManager().getOntologyDocumentIRI(ont), annotations);
    }
    OWLOntology full_tbox = forceMergeImports(graph.getSourceOntology(), graph.getAllOntologies());
    graph.setSourceOntology(full_tbox);
    if (conf.importantRelationParent != null) {
        // try to find parent property
        OWLObjectProperty parentProperty = getRelation(conf.importantRelationParent, graph);
        if (parentProperty != null) {
            // find all asserted direct sub properties of the parent property
            conf.importantRelations = getAssertedSubProperties(parentProperty, graph);
            if (conf.importantRelations.isEmpty()) {
                LOGGER.warn("Could not find any asserted sub properties for parent: " + conf.importantRelationParent);
            }
        } else {
            LOGGER.warn("Could not find a property for rel: " + conf.importantRelationParent);
        }
    }
    // set folder to  models
    LOGGER.info("Model path: " + conf.journalFile);
    // create model manager
    LOGGER.info("Start initializing Minerva");
    UndoAwareMolecularModelManager models = new UndoAwareMolecularModelManager(graph.getSourceOntology(), conf.curieHandler, conf.modelIdPrefix, conf.journalFile, conf.exportFolder, conf.pathToOntologyJournal, true);
    // set pre and post file handlers
    models.addPostLoadOntologyFilter(ModelReaderHelper.INSTANCE);
    // conf.shex.tbox_reasoner = models.getTbox_reasoner();
    conf.shex.setGo_lego_repo(models.getGolego_repo());
    conf.shex.curieHandler = conf.curieHandler;
    // start server
    Server server = startUp(models, conf, ont_annos);
    return server;
}
Also used : ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) OWLRDFVocabulary(org.semanticweb.owlapi.vocab.OWLRDFVocabulary) java.util(java.util) org.semanticweb.owlapi.model(org.semanticweb.owlapi.model) CatalogXmlIRIMapper(owltools.io.CatalogXmlIRIMapper) URL(java.net.URL) SimpleEcoMapper(owltools.gaf.eco.SimpleEcoMapper) ExternalLookupService(org.geneontology.minerva.lookup.ExternalLookupService) OWLManager(org.semanticweb.owlapi.apibinding.OWLManager) Logger(org.apache.log4j.Logger) CachingInferenceProviderCreatorImpl(org.geneontology.minerva.server.inferences.CachingInferenceProviderCreatorImpl) CurieMappings(org.geneontology.minerva.curie.CurieMappings) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) LocalTime(java.time.LocalTime) Server(org.eclipse.jetty.server.Server) MinervaShexValidator(org.geneontology.minerva.server.validation.MinervaShexValidator) ParserWrapper(owltools.io.ParserWrapper) UndoAwareMolecularModelManager(org.geneontology.minerva.UndoAwareMolecularModelManager) org.geneontology.minerva.server.handler(org.geneontology.minerva.server.handler) EcoMapperFactory(owltools.gaf.eco.EcoMapperFactory) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) ServerConnector(org.eclipse.jetty.server.ServerConnector) MinervaOWLGraphWrapper(org.geneontology.minerva.MinervaOWLGraphWrapper) Opts(owltools.cli.Opts) CurieHandler(org.geneontology.minerva.curie.CurieHandler) LocalDate(java.time.LocalDate) DefaultCurieHandler(org.geneontology.minerva.curie.DefaultCurieHandler) ModelReaderHelper(org.geneontology.minerva.ModelReaderHelper) InferenceProviderCreator(org.geneontology.minerva.server.inferences.InferenceProviderCreator) MappedCurieHandler(org.geneontology.minerva.curie.MappedCurieHandler) Server(org.eclipse.jetty.server.Server) UndoAwareMolecularModelManager(org.geneontology.minerva.UndoAwareMolecularModelManager) CatalogXmlIRIMapper(owltools.io.CatalogXmlIRIMapper) MinervaOWLGraphWrapper(org.geneontology.minerva.MinervaOWLGraphWrapper) ParserWrapper(owltools.io.ParserWrapper)

Example 7 with ParserWrapper

use of owltools.io.ParserWrapper in project minerva by geneontology.

the class FindGoCodesTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    curieHandler = DefaultCurieHandler.getDefaultHandler();
    codes = new FindGoCodes(curieHandler);
    ParserWrapper pw = new ParserWrapper();
    eco = pw.parseOWL(IRI.create("http://purl.obolibrary.org/obo/eco.owl"));
}
Also used : ParserWrapper(owltools.io.ParserWrapper) BeforeClass(org.junit.BeforeClass)

Example 8 with ParserWrapper

use of owltools.io.ParserWrapper in project minerva by geneontology.

the class FindTaxonToolTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    ParserWrapper pw = new ParserWrapper();
    NEO = pw.parse("http://purl.obolibrary.org/obo/go/noctua/neo.owl");
    curieHandler = DefaultCurieHandler.getDefaultHandler();
}
Also used : ParserWrapper(owltools.io.ParserWrapper) BeforeClass(org.junit.BeforeClass)

Example 9 with ParserWrapper

use of owltools.io.ParserWrapper in project minerva by geneontology.

the class MolecularModelJsonRendererTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    ParserWrapper pw = new ParserWrapper();
    File file = new File("src/test/resources/mgi-go.obo").getCanonicalFile();
    OWLOntology ont = pw.parseOWL(IRI.create(file));
    g = new MinervaOWLGraphWrapper(ont);
    f = g.getDataFactory();
    m = g.getManager();
    partOf = g.getOWLObjectPropertyByIdentifier("BFO:0000050");
}
Also used : MinervaOWLGraphWrapper(org.geneontology.minerva.MinervaOWLGraphWrapper) ParserWrapper(owltools.io.ParserWrapper) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Aggregations

ParserWrapper (owltools.io.ParserWrapper)9 File (java.io.File)3 BeforeClass (org.junit.BeforeClass)3 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)3 URL (java.net.URL)2 MinervaOWLGraphWrapper (org.geneontology.minerva.MinervaOWLGraphWrapper)2 CurieHandler (org.geneontology.minerva.curie.CurieHandler)2 DefaultCurieHandler (org.geneontology.minerva.curie.DefaultCurieHandler)2 MappedCurieHandler (org.geneontology.minerva.curie.MappedCurieHandler)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 HttpURLConnection (java.net.HttpURLConnection)1 LocalDate (java.time.LocalDate)1 LocalTime (java.time.LocalTime)1