public void writeOntologyData() { try { for (OWLOntology o : modifiedOntologies) { String filename = filenames.get(o); if (filename != null) { OntologyUtil.saveOntology(manager, o, filename); } else { System.err.println("the filename of the ontology " + o.getOntologyID().getOntologyIRI().toString() + " is null"); } } modifiedOntologies = new HashSet<OWLOntology>(); } catch (UnknownOWLOntologyException e) { e.printStackTrace(); } }
/** * Create an instance for the given graph and reasoner. * * @param graph * @param reasoner * @param disposeReasoner set to true, if the reasoner should also be disposed * @throws UnknownOWLOntologyException * @throws OWLOntologyCreationException * * @see #dispose() */ public EcoTools (OWLGraphWrapper graph, OWLReasoner reasoner, boolean disposeReasoner) throws UnknownOWLOntologyException, OWLOntologyCreationException { // This has bitten me, so let's try and bew specific... if( reasoner == null ){ throw new Error("No reasoner was specified for use with the EcoTools. Add a reasoner for the command line"); } // assume the graph wrapper is more than eco // try to find ECO by its purl Set<OWLOntology> allOntologies = graph.getAllOntologies(); OWLOntology eco = null; for (OWLOntology owlOntology : allOntologies) { OWLOntologyID id = owlOntology.getOntologyID(); Optional<IRI> ontologyIRI = id.getOntologyIRI(); if (ontologyIRI.isPresent()) { if (ECO_PURL.equals(ontologyIRI.get().toString())) { eco = owlOntology; } } } if (eco != null) { // found eco create new wrapper this.eco = new OWLGraphWrapper(eco); } else { // did not find eco, use whole wrapper this.eco = graph; } this.reasoner = reasoner; this.disposeReasonerP = disposeReasoner; }
protected LazyExpressionMaterializingReasoner(OWLOntology rootOntology, OWLReasonerConfiguration configuration, BufferingMode bufferingMode) { super(rootOntology, configuration, bufferingMode); try { this.ontology = rootOntology; manager = rootOntology.getOWLOntologyManager(); dataFactory = manager.getOWLDataFactory(); } catch (UnknownOWLOntologyException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
protected OWLGraphWrapperEdgesExtended(String iri) throws UnknownOWLOntologyException, OWLOntologyCreationException { super(iri); this.subPropertyCache = new HashMap<OWLObjectPropertyExpression, LinkedHashSet<OWLObjectPropertyExpression>>(); this.superPropertyCache = new HashMap<OWLObjectPropertyExpression, LinkedHashSet<OWLObjectPropertyExpression>>(); this.gciRelationBySource = null; this.gciRelationByTarget = null; this.outgoingEdgesClosureWithGCIBySource = null; }
/** * Create an instance for the given reasoner. * * @param reasoner * @param disposeReasoner set to true, if the reasoner should also be disposed * @throws UnknownOWLOntologyException * @throws OWLOntologyCreationException * * @see #dispose() */ public TaxonTools (OWLReasoner reasoner, boolean disposeReasoner) throws UnknownOWLOntologyException, OWLOntologyCreationException { // This has bitten me, so let's try and be specific... if( reasoner == null ){ throw new Error("No reasoner was specified for use with the TaxonTools. Add a reasoner for the command line"); } this.reasoner = reasoner; this.disposeReasonerP = disposeReasoner; }
/** * Create a new wrapper for an OWLOntology * * @param ontology * @param isMergeImportClosure * @throws UnknownOWLOntologyException * @throws OWLOntologyCreationException * @deprecated */ @Deprecated public OWLGraphWrapper(OWLOntology ontology, boolean isMergeImportClosure) throws UnknownOWLOntologyException, OWLOntologyCreationException { super(ontology); if (isMergeImportClosure) { // the query ontology is the source ontology plus the imports closure useImportClosureForQueries(); } }
/** * Constructor providing the {@code OWLOntology} on which modifications * will be performed, that will be wrapped in a {@code OWLGraphWrapper}. * * @param ont The {@code OWLOntology} on which the operations will be * performed. * @throws OWLOntologyCreationException If an error occurred while wrapping * the {@code OWLOntology} into a * {@code OWLGraphWrapper}. * @throws UnknownOWLOntologyException If an error occurred while wrapping * the {@code OWLOntology} into a * {@code OWLGraphWrapper}. */ public OWLGraphManipulator(OWLOntology ont) throws UnknownOWLOntologyException { this(new OWLGraphWrapper(ont)); }
/** * if called, copies all axioms from import closure into query ontology. * * @throws UnknownOWLOntologyException * @throws OWLOntologyCreationException */ @Deprecated public void useImportClosureForQueries() throws UnknownOWLOntologyException, OWLOntologyCreationException { this.ontology = OWLManager.createOWLOntologyManager().createOntology(sourceOntology.getOntologyID().getOntologyIRI().get(), sourceOntology.getImportsClosure()); }