Java Code Examples for org.semanticweb.owlapi.model.OWLOntology#getOWLOntologyManager()

The following examples show how to use org.semanticweb.owlapi.model.OWLOntology#getOWLOntologyManager() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AssertInferenceTool.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static List<OWLOntologyChange> handleSupportOntologies(OWLGraphWrapper graph)
{
	OWLOntology ontology = graph.getSourceOntology();
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory factory = manager.getOWLDataFactory();
	
	List<OWLOntologyChange> removeImportChanges = new ArrayList<OWLOntologyChange>();
	Set<OWLOntology> supportOntologySet = graph.getSupportOntologySet();
	for (OWLOntology support : supportOntologySet) {
		Optional<IRI> supportIRI = support.getOntologyID().getOntologyIRI();
		if(supportIRI.isPresent()) {
			IRI ontologyIRI = supportIRI.get();
			OWLImportsDeclaration importDeclaration = factory.getOWLImportsDeclaration(ontologyIRI);
			ChangeApplied status = manager.applyChange(new AddImport(ontology, importDeclaration));
			if (ChangeApplied.SUCCESSFULLY == status) {
				// the change was successful, create remove import for later
				removeImportChanges.add(new RemoveImport(ontology, importDeclaration));
			}
		}
	}
	return removeImportChanges;
}
 
Example 2
Source File: FilterOperation.java    From robot with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Remove axioms from the input ontology. This version expects a set of OWLObjectProperties.
 *
 * @param ontology the ontology to filter
 * @param properties a set of OWLObjectProperties to retain
 */
public static void filter(OWLOntology ontology, Set<OWLObjectProperty> properties) {
  logger.debug("Filtering ontology for axioms with ObjectProperties " + properties);

  OWLOntologyManager manager = ontology.getOWLOntologyManager();
  Set<OWLAxiom> axioms = ontology.getAxioms();
  logger.debug("Ontology has {} axioms before filtering", axioms.size());

  // For each axiom, get all its object properties,
  // then remove the properties that we're looking for.
  // If there are no object properties left, then we keep this axiom.
  // All annotation axioms, declarations, and subClass relations remains.
  for (OWLAxiom axiom : axioms) {
    Set<OWLObjectProperty> ps = axiom.getObjectPropertiesInSignature();
    ps.removeAll(properties);
    if (ps.size() > 0) {
      manager.removeAxiom(ontology, axiom);
    }
  }

  logger.debug("Ontology has {} axioms after filtering", ontology.getAxioms().size());
}
 
Example 3
Source File: OWLConverter.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Add an synonym annotation, plus an annotation on that annotation
 * that specified the type of synonym. The second annotation has the
 * property oio:hasSynonymType.
 *
 * @param ontology the current ontology
 * @param subject the subject of the annotation
 * @param type the IRI of the type of synonym
 * @param property the IRI of the annotation property.
 * @param value the literal value of the synonym
 * @return the synonym annotation axiom
 */
protected static OWLAnnotationAssertionAxiom synonym(
		OWLOntology ontology, OWLEntity subject, 
		OWLAnnotationValue type,
		OWLAnnotationProperty property, 
		OWLAnnotationValue value) {
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory dataFactory = manager.getOWLDataFactory();
	OWLAnnotationProperty hasSynonymType =
		dataFactory.getOWLAnnotationProperty(
			format.getIRI("oio:hasSynonymType"));
	OWLAnnotation annotation = 
		dataFactory.getOWLAnnotation(hasSynonymType, type);
	Set<OWLAnnotation> annotations = new HashSet<OWLAnnotation>();
	annotations.add(annotation);
	OWLAnnotationAssertionAxiom axiom =
		dataFactory.getOWLAnnotationAssertionAxiom(
			property, subject.getIRI(), value,
			annotations);
	manager.addAxiom(ontology, axiom);
	return axiom;
}
 
Example 4
Source File: DiffOperationTest.java    From robot with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Compare one ontology to a modified copy.
 *
 * @throws IOException on file problem
 * @throws OWLOntologyCreationException on ontology problem
 */
@Test
public void testCompareModified() throws IOException, OWLOntologyCreationException {
  OWLOntology simple = loadOntology("/simple.owl");
  Set<OWLOntology> onts = new HashSet<>();
  onts.add(simple);
  OWLOntologyManager manager = simple.getOWLOntologyManager();
  OWLDataFactory df = manager.getOWLDataFactory();
  OWLOntology simple1 = manager.createOntology(IRI.create(base + "simple1.owl"), onts);
  IRI test1 = IRI.create(base + "simple.owl#test1");
  manager.addAxiom(
      simple1,
      df.getOWLAnnotationAssertionAxiom(df.getRDFSLabel(), test1, df.getOWLLiteral("TEST #1")));

  StringWriter writer = new StringWriter();
  boolean actual = DiffOperation.compare(simple, simple1, writer);
  System.out.println(writer.toString());
  assertFalse(actual);
  String expected = IOUtils.toString(this.getClass().getResourceAsStream("/simple1.diff"));
  assertEquals(expected, writer.toString());
}
 
Example 5
Source File: LazyExpressionMaterializingReasoner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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();
	}
}
 
Example 6
Source File: RenameOperation.java    From robot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Given an ontology, an IOHelper, and a map of old IRIs to new IRIs, rename each old IRI with the
 * new IRI.
 *
 * @param ontology OWLOntology to rename entities in
 * @param ioHelper IOHelper to create IRIs
 * @param mappings map of old IRI to new IRI
 * @throws Exception if the old IRI in a mapping does not exist
 */
public static void renameFull(
    OWLOntology ontology, IOHelper ioHelper, Map<String, String> mappings) throws Exception {
  OWLOntologyManager manager = ontology.getOWLOntologyManager();
  OWLEntityRenamer entityRenamer = new OWLEntityRenamer(manager, Sets.newHashSet(ontology));
  for (Map.Entry<String, String> mapping : mappings.entrySet()) {
    IRI oldIRI = ioHelper.createIRI(mapping.getKey());
    IRI newIRI = ioHelper.createIRI(mapping.getValue());
    if (!ontology.containsEntityInSignature(oldIRI)) {
      throw new Exception(String.format(missingEntityError, oldIRI.toString()));
    }
    manager.applyChanges(entityRenamer.changeIRI(oldIRI, newIRI));
  }
}
 
Example 7
Source File: AxiomAnnotationTools.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Append xref annotations onto an existing axiom
 * 
 * @param axiom
 * @param xrefs
 * @param ontology
 * @return
 */
public static OWLAxiom appendXrefAnnotations(OWLAxiom axiom, Set<String> xrefs, OWLOntology ontology) {
    // filter existing
    Set<OWLAnnotation> newAnnotations = new HashSet<OWLAnnotation>(axiom.getAnnotations());
       final OWLOntologyManager manager = ontology.getOWLOntologyManager();
    final OWLDataFactory factory = manager.getOWLDataFactory();

    for (String x : xrefs) {
        OWLAnnotationProperty p = factory.getOWLAnnotationProperty(IRI.create("http://www.geneontology.org/formats/oboInOwl#hasDbXref"));
        OWLLiteral v = factory.getOWLLiteral(x);
        newAnnotations.add(factory.getOWLAnnotation(p, v));
    }
    final OWLAxiom newAxiom = changeAxiomAnnotations(axiom, newAnnotations, ontology);
    return newAxiom;
}
 
Example 8
Source File: OWLConverter.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Convenience method for adding an annotation assertion to the
 * ontology itself, taking a CURIE for the property and an Boolean literal.
 *
 * @param ontology the current ontology
 * @param propertyCURIE will be expanded to the full annotation
 *	property IRI
 * @param value the literal value of the annotation
 * @return the annotation axiom
 */
protected static OWLAnnotation annotate(OWLOntology ontology,
		String propertyCURIE, IRI value) {
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory dataFactory = manager.getOWLDataFactory();
	IRI iri = format.getIRI(propertyCURIE);
	OWLAnnotationProperty property =
		dataFactory.getOWLAnnotationProperty(iri);
	OWLAnnotation annotation = dataFactory.getOWLAnnotation(
			property, value);
	manager.applyChange(
		new AddOntologyAnnotation(ontology, annotation));
	return annotation;
}
 
Example 9
Source File: GafCommandRunner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Created to mimic the translation to OWL for GAF checks
 * 
 * @param opts
 * @throws Exception
 */
@CLIMethod("--gaf2owl-simple")
public void gaf2OwlSimple(Opts opts) throws Exception {
	opts.info("-o FILE", "translates previously loaded GAF document into OWL, requires a loaded ontology to lookup ids");
	String out = null;
	while (opts.hasOpts()) {
		if (opts.nextEq("-o")) {
			out = opts.nextOpt();
		}
		else
			break;

	}
	if (g == null) {
		LOG.error("An ontology is required.");
		exit(-1);
	}
	else if (gafdoc == null) {
		LOG.error("A GAF document is required.");
		exit(-1);
	}
	else if (out == null) {
		LOG.error("An output file is required.");
		exit(-1);
	}
	LOG.info("Creating OWL represenation of annotations.");
	GAFOWLBridge bridge = new GAFOWLBridge(g);
	bridge.setGenerateIndividuals(false);
	bridge.setBasicAboxMapping(false);
	bridge.setBioentityMapping(BioentityMapping.CLASS_EXPRESSION);
	bridge.setSkipNotAnnotations(true);
	OWLOntology translated = bridge.translate(gafdoc);
	File outputFile = new File(out);
	OWLOntologyManager manager = translated.getOWLOntologyManager();
	OWLDocumentFormat ontologyFormat= new FunctionalSyntaxDocumentFormat();
	manager.saveOntology(translated, ontologyFormat, IRI.create(outputFile));
}
 
Example 10
Source File: OWLConverter.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Convenience method for adding an annotation assertion to the
 * ontology.
 *
 * @param ontology the current ontology
 * @param subject the subject of the annotation
 * @param property the annotation property
 * @param value the annotation value
 * @return the annotation axiom
 */
protected static OWLAnnotationAssertionAxiom annotate(
		OWLOntology ontology, 
		OWLEntity subject,
		OWLAnnotationProperty property, 
		OWLAnnotationValue value) {
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory dataFactory = manager.getOWLDataFactory();
	OWLAnnotationAssertionAxiom axiom =
		dataFactory.getOWLAnnotationAssertionAxiom(
			property, subject.getIRI(), value);
	manager.addAxiom(ontology, axiom);
	return axiom;
}
 
Example 11
Source File: ABoxUtils.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates a "fake" individual for every class.
 * 
 * ABox IRI = TBox IRI + suffix
 * 
 * if suffix == null, then we are punning
 * 
 * @param srcOnt
 * @param iriSuffix
 * @throws OWLOntologyCreationException
 */
public static void makeDefaultIndividuals(OWLOntology srcOnt, String iriSuffix) throws OWLOntologyCreationException {
	OWLOntologyManager m = srcOnt.getOWLOntologyManager();
	OWLDataFactory df = m.getOWLDataFactory();
	for (OWLClass c : srcOnt.getClassesInSignature(Imports.INCLUDED)) {
		IRI iri;
		if (iriSuffix == null || iriSuffix.equals(""))
		  iri = c.getIRI();
		else
			iri = IRI.create(c.getIRI().toString()+iriSuffix);
		OWLNamedIndividual ind = df.getOWLNamedIndividual(iri);
		m.addAxiom(srcOnt, df.getOWLDeclarationAxiom(ind));
		m.addAxiom(srcOnt, df.getOWLClassAssertionAxiom(c, ind));
	}
}
 
Example 12
Source File: SimpleOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @param sourceOntology
 */
public SimpleOwlSim(OWLOntology sourceOntology) {
	super();
	this.sourceOntology = sourceOntology;
	this.owlOntologyManager = sourceOntology.getOWLOntologyManager();
	this.owlDataFactory = owlOntologyManager.getOWLDataFactory();
	this.sourceOntology = sourceOntology;
	init();
}
 
Example 13
Source File: TransformationUtils.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Names all inner ObjectSomeValuesFrom expressions
 * 
 * @param srcOntology
 * @param tgtOntology
 * @param qmap
 * @param isAddLabels
 * @return
 */
public static Map<OWLClass, OWLClassExpression> nameObjectSomeValuesFrom(OWLOntology srcOntology,
		OWLOntology tgtOntology,
		Map<OWLClass,OWLClassExpression> qmap,
		boolean isAddLabels) {

	if (qmap == null) 
		qmap = new HashMap<OWLClass, OWLClassExpression>();
	OWLOntologyManager mgr = srcOntology.getOWLOntologyManager();
	OWLDataFactory df = mgr.getOWLDataFactory();
	for (OWLOntology ont : srcOntology.getImportsClosure()) {
		for (OWLAxiom ax : srcOntology.getAxioms()) {
			for (OWLClassExpression x : ax.getNestedClassExpressions()) {
				if (x instanceof OWLObjectSomeValuesFrom) {
					OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom)x;
					OWLClass filler = (OWLClass) svf.getFiller();
					OWLObjectProperty p = (OWLObjectProperty) svf.getProperty();
					IRI iri = getSkolemIRI(filler, p);
					OWLClass c = df.getOWLClass(iri);
					mgr.addAxiom(tgtOntology, df.getOWLEquivalentClassesAxiom(c, svf));
					qmap.put(c, svf);
					if (isAddLabels) {
						Set<OWLAnnotation> anns = OwlHelper.getAnnotations(filler, df.getRDFSLabel(), ont);
						for (OWLAnnotation ann : anns) {
							mgr.addAxiom(tgtOntology, df.getOWLAnnotationAssertionAxiom(c.getIRI(), ann));
						}
					}
				}
			}
		}
	}
	return qmap;

}
 
Example 14
Source File: RedundantAxiomTagger.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void tagRedundantAxioms(OWLReasoner reasoner) {
    OWLOntology ont = reasoner.getRootOntology();
    OWLOntologyManager mgr = ont.getOWLOntologyManager();
    OWLDataFactory df = mgr.getOWLDataFactory();
    OWLAnnotationProperty anProp = df.getOWLAnnotationProperty(IRI.create("http://www.geneontology.org/formats/oboInOwl#source"));
    for (OWLSubClassOfAxiom ax : ont.getAxioms(AxiomType.SUBCLASS_OF)) {
        if (!ax.getSuperClass().isAnonymous()) {
            OWLClass supc = (OWLClass) ax.getSuperClass();
            
            mgr.removeAxiom(ont, ax);
            reasoner.flush();
            NodeSet<OWLClass> ancs = reasoner.getSuperClasses(ax.getSubClass(), false);
            //LOG.info(ax + " ANCS="+ancs);
            if (ancs.containsEntity( supc)) {
                String direct = "indirect";
                if (reasoner.getSuperClasses(ax.getSubClass(), true).containsEntity( supc)) {
                    direct = "direct";
                }
                LOG.info("SCA = "+ax+" D="+direct);
                OWLAnnotation ann = df.getOWLAnnotation(anProp, df.getOWLLiteral(direct));
                OWLAxiom newAxiom = changeAxiomAnnotations(ax, Collections.singleton(ann), df);
                mgr.addAxiom(ont, newAxiom);
            }
            else {
                // put it back
                mgr.addAxiom(ont, ax);
            }
        }
    }
   
}
 
Example 15
Source File: PropertyViewOntologyBuilder.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @param sourceOntology
 * @param elementsOntology
 * @param viewProperty
 */
public PropertyViewOntologyBuilder(OWLOntology sourceOntology,
		OWLOntology elementsOntology, OWLObjectProperty viewProperty) {
	super();
	this.owlOntologyManager = sourceOntology.getOWLOntologyManager();
	this.owlDataFactory = owlOntologyManager.getOWLDataFactory();
	this.sourceOntology = sourceOntology;
	this.elementsOntology = elementsOntology;
	this.viewProperty = viewProperty;
	init();
}
 
Example 16
Source File: AssertInferenceTool.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static void  cleanupSupportOntologies(OWLGraphWrapper graph, List<OWLOntologyChange> remove)
{
	OWLOntology ontology = graph.getSourceOntology();
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	manager.applyChanges(remove);
}
 
Example 17
Source File: RemoveDirectivesTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test
public void testRemove() throws Exception {
	ParserWrapper pw = new ParserWrapper();
	OWLGraphWrapper g = pw.parseToOWLGraph(getResourceIRIString("mooncat/remove-directives-test1.obo"));
	
	System.out.println(g.getSourceOntology().getAxioms(AxiomType.EQUIVALENT_CLASSES));
	OWLOntology secondary = pw.parse(getResourceIRIString("mooncat/remove-directives-test2.obo"));
       System.out.println(secondary.getAxioms(AxiomType.EQUIVALENT_CLASSES));
	g.addSupportOntology(secondary);
	
	Mooncat mooncat = new Mooncat(g);
	
	//mooncat.mergeOntologies();
	g.mergeOntology(secondary);
	
	OWLOntology merged = g.getSourceOntology();

	System.out.println(merged.getAxioms(AxiomType.EQUIVALENT_CLASSES));

	Owl2Obo owl2Obo = new Owl2Obo();
	OBODoc mergedObo = owl2Obo.convert(merged);
	
	if (USE_SYSTEM_OUT) {
		System.out.println("------------------------");
		OWLOntologyManager manager = merged.getOWLOntologyManager();
		OWLOntologyDocumentTarget documentTarget = new SystemOutDocumentTarget();
		manager.saveOntology(merged, new RDFXMLDocumentFormat(), documentTarget);
		System.out.println("------------------------");
		String oboString = renderOBOtoString(mergedObo);
		System.out.println(oboString);
		System.out.println("------------------------");
	}
	
	Frame headerFrame = mergedObo.getHeaderFrame();
	String owlAxiomString = headerFrame.getTagValue(OboFormatTag.TAG_OWL_AXIOMS, String.class);
	assertNotNull(owlAxiomString);
	
	
	Frame frame = mergedObo.getTermFrame("X:1");
	Collection<Clause> clauses = frame.getClauses(OboFormatTag.TAG_INTERSECTION_OF);
	assertEquals(2, clauses.size());
}
 
Example 18
Source File: BioChebiGenerator.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Create the GCIs for BioChEBI. Add the axioms into the given ontology.
 * 
 * @param ontology
 * @param ignoredClasses
 */
public void expand(OWLOntology ontology, Set<OWLClass> ignoredClasses) {
	final OWLOntologyManager manager = ontology.getOWLOntologyManager();
	final OWLDataFactory factory = manager.getOWLDataFactory();
	
	// scan axioms
	Set<OWLSubClassOfAxiom> axioms = ontology.getAxioms(AxiomType.SUBCLASS_OF, Imports.INCLUDED);
	for (OWLSubClassOfAxiom axiom : axioms) {
		OWLClassExpression superCE = axiom.getSuperClass();
		OWLClassExpression subCE = axiom.getSubClass();
		if (subCE.isAnonymous()) {
			// sub class needs to be an named OWLClass
			continue;
		}

		if (superCE instanceof OWLObjectSomeValuesFrom == false) {
			continue;
		}
		OWLObjectSomeValuesFrom some = (OWLObjectSomeValuesFrom) superCE;

		OWLObjectPropertyExpression expression = some.getProperty();
		if (expression.isAnonymous()) {
			// object property expression needs to be a named OWLObjectProperty 
			continue;
		}

		OWLObjectProperty p = (OWLObjectProperty) expression;
		
		Set<OWLObjectProperty> expansions = expansionMap.get(p);
		if (expansions == null) {
			continue;
		}

		// get content for GCI
		OWLClassExpression y = some.getFiller();
		OWLClass x = subCE.asOWLClass();
		if (ignoredClasses.contains(x)) {
			continue;
		}
		for (OWLObjectProperty createProperty : expansions) {
			OWLClassExpression ce1 = factory.getOWLObjectSomeValuesFrom(createProperty, x);
			OWLClassExpression ce2 = factory.getOWLObjectSomeValuesFrom(createProperty, y);
			OWLEquivalentClassesAxiom eq = factory.getOWLEquivalentClassesAxiom(ce1, ce2);
			manager.addAxiom(ontology, eq);
		}
	}
	
	Set<OWLOntology> imports = ontology.getImports();
	StringBuilder sb = new StringBuilder();
	DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
	sb.append("Generated on ").append(dateFormat.format(new Date())).append(" using the following import chain:");
	for (OWLOntology owlOntology : imports) {
		OWLOntologyID ontologyID = owlOntology.getOntologyID();
		sb.append(" ");
		appendOntologyId(ontologyID, sb);
	}
	addComment(sb.toString(), ontology);
}
 
Example 19
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@Test
public void proofsUnderOntologyUpdate() throws Exception {
	// loading and classifying via the OWL API
	OWLOntology ontology = loadOntology(
			ProofTest.class.getClassLoader().getResourceAsStream(
					"ontologies/PropertyCompositionsWithHierarchy.owl"));
	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	OWLClass sub = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass sup = factory.getOWLClass(IRI.create("http://example.org/G"));

	// printInferences(reasoner, sub, sup);
	// OWLExpression root =
	// reasoner.getDerivedExpression(factory.getOWLSubClassOfAxiom(sub,
	// sup));
	// System.err.println(OWLProofUtils.printProofTree(root));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(sub, sup));

	// now convert C <= R3 some D to C < S3 some D
	OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
	OWLClass d = factory.getOWLClass(IRI.create("http://example.org/D"));
	OWLObjectProperty r3 = factory
			.getOWLObjectProperty(IRI.create("http://example.org/R3"));
	OWLObjectProperty s3 = factory
			.getOWLObjectProperty(IRI.create("http://example.org/S3"));
	OWLAxiom oldAx = factory.getOWLSubClassOfAxiom(c,
			factory.getOWLObjectSomeValuesFrom(r3, d));
	OWLAxiom newAx = factory.getOWLSubClassOfAxiom(c,
			factory.getOWLObjectSomeValuesFrom(s3, d));

	OWLOntologyManager manager = ontology.getOWLOntologyManager();

	manager.applyChanges(Arrays.asList(new RemoveAxiom(ontology, oldAx),
			new AddAxiom(ontology, newAx)));

	prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	// printInferences(reasoner, sub, sup);
	// root =
	// reasoner.getDerivedExpression(factory.getOWLSubClassOfAxiom(sub,
	// sup));
	// System.err.println(OWLProofUtils.printProofTree(root));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(sub, sup));
}
 
Example 20
Source File: AxiomAnnotationTools.java    From owltools with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Update the given axiom to a new set of axiom annotation.<br>
 * <b>Side effect</b>: This removes the old axiom and adds the new axiom to
 * the given ontology. The method also returns the new axiom to enable
 * chaining.
 * 
 * @param axiom
 * @param annotations
 * @param ontology
 * @return newAxiom
 */
public static OWLAxiom changeAxiomAnnotations(OWLAxiom axiom, Set<OWLAnnotation> annotations, OWLOntology ontology) {
	final OWLOntologyManager manager = ontology.getOWLOntologyManager();
	final OWLDataFactory factory = manager.getOWLDataFactory();
	final OWLAxiom newAxiom = changeAxiomAnnotations(axiom, annotations, factory);
	manager.removeAxiom(ontology, axiom);
	manager.addAxiom(ontology, newAxiom);
	return newAxiom;
}