Java源码示例:org.semanticweb.owlapi.model.OWLDataFactory
示例1
@Override
void prepare() {
final OWLDataFactory factory = new OWLDataFactoryImpl();
A = factory.getOWLClass(IRI.create("A"));
B = factory.getOWLClass(IRI.create("B"));
OWLObjectProperty R = factory.getOWLObjectProperty(IRI.create("R"));
OWLObjectProperty S = factory.getOWLObjectProperty(IRI.create("S"));
OWLAxiom axExSsomeAsubB = factory.getOWLSubClassOfAxiom(
factory.getOWLObjectSomeValuesFrom(S, A), B);
OWLAxiom axReflR = factory.getOWLReflexiveObjectPropertyAxiom(R);
axRsubS = factory.getOWLSubObjectPropertyOfAxiom(R, S);
// from these three axioms it should follow A subclass B
ontologyManager = TestOWLManager.createOWLOntologyManager();
try {
ont = ontologyManager.createOntology(new HashSet<OWLAxiom>(Arrays
.asList(axExSsomeAsubB, axReflR, axRsubS)));
} catch (OWLOntologyCreationException e) {
fail(e.toString());
}
}
示例2
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;
}
示例3
/**
* 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());
}
示例4
private void testExactSynonym(OWLOntology ontology) {
IRI iri = IRI.create("http://www.geneontology.org/formats/oboInOwl#hasExactSynonym");
OWLDataFactory df = ontology.getOWLOntologyManager().
getOWLDataFactory();
OWLAnnotationProperty property = df.getOWLAnnotationProperty(iri);
assertTrue("Exact Synonym property in signature",
ontology.containsAnnotationPropertyInSignature(iri));
// Check axioms
Set<OWLAnnotationAxiom> axioms = ontology.getAxioms(property, Imports.EXCLUDED);
assertEquals("Count class axioms", 0, axioms.size());
// Check annotations
List<String> values = new ArrayList<String>();
values.add("AnnotationAssertion(rdfs:label <http://www.geneontology.org/formats/oboInOwl#hasExactSynonym> \"has_exact_synonym\"^^xsd:string)");
Set<OWLAnnotationAssertionAxiom> annotations =
ontology.getAnnotationAssertionAxioms(iri);
assertEquals("Count annotations for Exact", 1, annotations.size());
checkAnnotations(annotations, values);
}
示例5
protected void translateBioentity(Bioentity e) {
OWLDataFactory fac = graph.getDataFactory();
Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
IRI iri = graph.getIRIByIdentifier(e.getId());
OWLNamedIndividual cls = graph.getDataFactory().getOWLNamedIndividual(iri);
emap.put(e.getId(), cls);
// --label---
axioms.add(fac.getOWLAnnotationAssertionAxiom(fac.getRDFSLabel(),
cls.getIRI(),
fac.getOWLLiteral(e.getSymbol())));
/*
// --taxon--
OWLClass taxCls = getOWLClass(e.getNcbiTaxonId()); // todo - cache
axioms.add(fac.getOWLSubClassOfAxiom(cls,
fac.getOWLObjectSomeValuesFrom(getGeneAnnotationObjectProperty(Vocab.IN_TAXON),
taxCls)));
// TODO - other properties
*/
addAxioms(axioms);
}
示例6
protected void translateBioentity(Bioentity e) {
OWLDataFactory fac = graph.getDataFactory();
Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
OWLClass cls = getOWLClass(e.getId());
// --label---
axioms.add(fac.getOWLAnnotationAssertionAxiom(fac.getRDFSLabel(),
cls.getIRI(),
fac.getOWLLiteral(e.getSymbol())));
// --taxon--
OWLClass taxCls = getOWLClass(e.getNcbiTaxonId()); // todo - cache
axioms.add(fac.getOWLSubClassOfAxiom(cls,
fac.getOWLObjectSomeValuesFrom(getGeneAnnotationObjectProperty(Vocab.IN_TAXON),
taxCls)));
// TODO - other properties
addAxioms(axioms);
}
示例7
public OWLQLToNonRecursiveDatalogCompiler(OWLOntology originalOntTbox, Set<String> conceptURIsInAbox, Set<String> propertyURIsInAbox) {
super();
try {
Set<OWLAxiom> tboxAxioms = NormalizedOWLQLTbox.getTboxRboxAxioms(originalOntTbox.getAxioms());
/*if (completeTbox) {
OWLOntology ontTbox = OWLManager.createOWLOntologyManager().createOntology();
ontTbox.getOWLOntologyManager().addAxioms(ontTbox, tboxAxioms);
PelletBasedTaxonomy.addImpliedTaxonomy(ontTbox);
tboxAxioms = NormalizedOWLQLTbox.getTboxRboxAxioms(ontTbox.getAxioms());
}*/
tbox = new NormalizedOWLQLTbox(tboxAxioms);
OWLDataFactory fac = tbox.getFactory();
rename = new RuleRenaming(tbox);
splitter = new Split(fac);
taxo = new TaxonomyImpl(tbox);
taxo.build();
ejVarEliminator = new EliminateEJVar(tbox, taxo, fac);
zeroArityAtomsEliminator = new DeleteRuleWithUnsatifiableAtoms(taxo,tbox);
conceptsAndPropertiesNotInAboxEliminator = new DeleteRuleWithConceptOrPropertyNotInAbox(taxo, tbox, conceptURIsInAbox, propertyURIsInAbox);
redundantAtomsEliminator = new DeleteRedundantAtoms(taxo, fac);
unboundVarsEliminator = new DeleteUnboundVariables(fac);
atomViewDef = new DefineAtomView(taxo, fac);
} catch (OWLOntologyCreationException e) {
throw new RuntimeException(e);
}
}
示例8
/**
* adds additional axioms specific to this method.
* Creates a named LCS class equivalent to the generated expression
*
* @param id
* @param result
* @param axioms
*/
@Override
protected void translateResultsToOWLAxioms(String id, OWLNamedIndividual result, Set<OWLAxiom> axioms) {
OWLDataFactory df = graph.getDataFactory();
// declare a named class for the LCS and make this equivalent to the anonymous expression
OWLClass namedLCS = df.getOWLClass(IRI.create(id+"_LCS"));
axioms.add(df.getOWLAnnotationAssertionAxiom(df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()),
namedLCS.getIRI(),
df.getOWLLiteral("LCS of "+simEngine.label(a)+" and "+simEngine.label(b))));
axioms.add(df.getOWLEquivalentClassesAxiom(namedLCS, lcs));
// link the similarity object to the named LCS
OWLAnnotationProperty lcsp = df.getOWLAnnotationProperty(annotationIRI("has_least_common_subsumer"));
axioms.add(df.getOWLAnnotationAssertionAxiom(lcsp, result.getIRI(), namedLCS.getIRI()));
}
示例9
public void addImportsFromSupportOntologies() {
OWLOntology sourceOntology = getSourceOntology();
OWLDataFactory factory = getDataFactory();
for (OWLOntology o : getSupportOntologySet()) {
Optional<IRI> ontologyIRI = o.getOntologyID().getOntologyIRI();
if (ontologyIRI.isPresent()) {
OWLImportsDeclaration importsDeclaration = factory.getOWLImportsDeclaration(ontologyIRI.get());
AddImport ai = new AddImport(sourceOntology, importsDeclaration);
LOG.info("Applying: "+ai);
getManager().applyChange(ai);
}
else {
String msg = "Could not add import due to missing ontology id: "+o;
LOG.error(msg);
throw new RuntimeException(msg);
}
}
this.setSupportOntologySet(new HashSet<OWLOntology>());
}
示例10
public static TaxonomyBuilder<OWLPropertyExpression> buildDataPropertyHierarchy(NormalizedOWLQLTbox tbox, Collection<? extends OWLPropertyExpression> additionalPropertyExpressions) {
OWLOntology ont = tbox.getNormalizedOntology();
OWLDataFactory fac = ont.getOWLOntologyManager().getOWLDataFactory();
Set< OWLPropertyExpression> props;
if (additionalPropertyExpressions!=null) {
props = new HashSet<OWLPropertyExpression>(additionalPropertyExpressions);
props.addAll(ont.getDataPropertiesInSignature());
} else {
props = new HashSet<OWLPropertyExpression>( ont.getDataPropertiesInSignature());
}
SubPropertyComputation subcomp = new SubPropertyComputation(tbox);
TaxonomyBuilder<OWLPropertyExpression> taxoBuilder = new TaxonomyBuilder<OWLPropertyExpression>(
props,
fac.getOWLTopDataProperty(),
fac.getOWLBottomDataProperty(),
subcomp);
taxoBuilder.build();
logger.debug("Number of direct subsumption tests performed: {}", subcomp.numOfDirectSubsumptionTests);
long size = props.size();
logger.debug("Worst Case number of direct subsumption tests performed: {}^2 = {}",size, size*size);
return taxoBuilder;
}
示例11
public static void addElementLabels(OWLOntology ont, File file) throws IOException {
OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLDataFactory df = m.getOWLDataFactory();
List<String> lines = FileUtils.readLines(file);
for (String line : lines) {
if (line.startsWith("#"))
continue;
String[] colVals = line.split("\t");
if (colVals.length != 2) {
throw new IOException("Incorrect number of value: "+line);
}
IRI i = getIRIById(colVals[0]);
OWLAnnotation ann = df.getOWLAnnotation(df.getRDFSLabel(), df.getOWLLiteral(colVals[1]));
m.addAxiom(ont, df.getOWLAnnotationAssertionAxiom(i, ann));
}
}
示例12
@Override
public OWLOntology cacheInformationContentInOntology() throws OWLOntologyCreationException, UnknownOWLClassException {
OWLOntologyManager mgr = getSourceOntology().getOWLOntologyManager();
OWLDataFactory df = mgr.getOWLDataFactory();
OWLOntology o = mgr.createOntology();
OWLAnnotationProperty p = df.getOWLAnnotationProperty(IRI.create(icIRIString));
for (OWLClass c : getSourceOntology().getClassesInSignature()) {
Double ic = getInformationContentForAttribute(c);
if (ic != null) {
mgr.addAxiom(o,
df.getOWLAnnotationAssertionAxiom(p,
c.getIRI(),
df.getOWLLiteral(ic)));
}
}
return o;
}
示例13
public static TaxonomyBuilder<OWLPropertyExpression> buildObjectPropertyHierarchy(NormalizedOWLQLTbox tbox, Collection<? extends OWLPropertyExpression> additionalPropertyExpressions) {
OWLOntology ont = tbox.getNormalizedOntology();
OWLDataFactory fac = ont.getOWLOntologyManager().getOWLDataFactory();
Set< OWLPropertyExpression> props;
if (additionalPropertyExpressions!=null) {
props = new HashSet<OWLPropertyExpression>(additionalPropertyExpressions);
props.addAll(ont.getObjectPropertiesInSignature());
} else {
props = new HashSet<OWLPropertyExpression>( ont.getObjectPropertiesInSignature());
}
SubPropertyComputation subcomp = new SubPropertyComputation(tbox);
TaxonomyBuilder<OWLPropertyExpression> taxoBuilder = new TaxonomyBuilder<OWLPropertyExpression>(
props,
fac.getOWLTopObjectProperty(),
fac.getOWLBottomObjectProperty(),
subcomp);
taxoBuilder.build();
logger.debug("Number of direct subsumption tests performed: {}", subcomp.numOfDirectSubsumptionTests);
long size = props.size();
logger.debug("Worst Case number of direct subsumption tests performed: {}^2 = {}",size, size*size);
return taxoBuilder;
}
示例14
public static TaxonomyBuilder<OWLClassExpression> buildClassHierarchy(NormalizedOWLQLTbox tbox, Collection<OWLClassExpression> additionalClassExpression) {
OWLOntology ont = tbox.getNormalizedOntology();
OWLDataFactory fac = ont.getOWLOntologyManager().getOWLDataFactory();
Set<OWLClassExpression> classes;
if (additionalClassExpression!=null) {
classes = new HashSet<OWLClassExpression>(additionalClassExpression);
classes.addAll(ont.getClassesInSignature());
} else {
classes = new HashSet<OWLClassExpression>(ont.getClassesInSignature());
}
SubClassComputation subcomp = new SubClassComputation(tbox);
TaxonomyBuilder<OWLClassExpression> taxoBuilder = new TaxonomyBuilder<OWLClassExpression>(
classes,
fac.getOWLThing(),
fac.getOWLNothing(),
subcomp);
taxoBuilder.build();
logger.debug("Number of direct subsumption tests performed: {}", subcomp.numOfDirectSubsumptionTests);
long size = classes.size();
logger.debug("Worst Case number of direct subsumption tests performed: {}^2 = {}",size, size*size);
return taxoBuilder;
}
示例15
protected DescriptiveStatistics computeDescriptiveStatistics(Set<OWLClass> attributes) throws UnknownOWLClassException {
DescriptiveStatistics statsPerAttSet = new DescriptiveStatistics();
OWLDataFactory g = sourceOntology.getOWLOntologyManager().getOWLDataFactory();
for (OWLClass c : attributes) {
Double ic;
try {
ic = owlsim.getInformationContentForAttribute(c);
if (ic == null) {
if (g.getOWLClass(c.getIRI()) != null) {
ic = owlsim.getSummaryStatistics().max.getMax();
} else {
throw new UnknownOWLClassException(c); }
}
if (ic.isInfinite() || ic.isNaN()) {
ic = owlsim.getSummaryStatistics().max.getMax();
}
statsPerAttSet.addValue(ic);
} catch (UnknownOWLClassException e) {
LOG.info("Unknown class "+c.toStringID()+" submitted for summary stats. Removed from calculation.");
continue;
}
}
return statsPerAttSet;
}
示例16
public static OWLOntology createOWLThingTypeDeclForIndividuals(OWLOntology ont) throws OWLOntologyCreationException, IOException {
OWLOntology ret = ont.getOntologyID()!=null && ont.getOntologyID().getOntologyIRI()!=null?
ont.getOWLOntologyManager().createOntology(ont.getOntologyID().getOntologyIRI()):
ont.getOWLOntologyManager().createOntology();
OWLDataFactory fac = ret.getOWLOntologyManager().getOWLDataFactory();
OWLClass owlThing = ret.getOWLOntologyManager().getOWLDataFactory().getOWLThing();
for (OWLNamedIndividual ind: ont.getIndividualsInSignature()) {
OWLNamedIndividual ni = fac.getOWLNamedIndividual(ind.getIRI());
OWLAxiom ax = fac.getOWLClassAssertionAxiom(owlThing, ni);
ret.getOWLOntologyManager().addAxiom(ret, ax);
}
return ret;
}
示例17
private static OWLAxiom getEntailment() {
// Let's pick some class subsumption we want to explain
OWLDataFactory factory = OWLManager.getOWLDataFactory();
OWLClass subsumee = factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#LiquidFood"));
OWLClass subsumer = factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#Food"));
return factory.getOWLSubClassOfAxiom(subsumee, subsumer);
}
示例18
public static void main(String[] args) throws OWLOntologyStorageException,
OWLOntologyCreationException {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
// Load your ontology
OWLOntology ont = manager.loadOntologyFromOntologyDocument(new File("path-to-ontology"));
// Create an ELK reasoner.
OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(ont);
// Classify the ontology.
reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);
OWLDataFactory factory = manager.getOWLDataFactory();
OWLClass subClass = factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#AbsoluteShapeState"));
OWLAxiom removed = factory.getOWLSubClassOfAxiom(subClass, factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#ShapeState")));
OWLAxiom added = factory.getOWLSubClassOfAxiom(subClass, factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#GeneralisedStructure")));
// Remove an existing axiom, add a new axiom
manager.addAxiom(ont, added);
manager.removeAxiom(ont, removed);
// This is a buffering reasoner, so you need to flush the changes
reasoner.flush();
// Re-classify the ontology, the changes should be accommodated
// incrementally (i.e. without re-inferring all subclass relationships)
// You should be able to see it from the log output
reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);
// Terminate the worker threads used by the reasoner.
reasoner.dispose();
}
示例19
@Override
void prepare() {
final OWLDataFactory factory = new OWLDataFactoryImpl();
A = factory.getOWLClass(IRI.create("A"));
B = factory.getOWLClass(IRI.create("B"));
axAsubB = factory.getOWLSubClassOfAxiom(A, B);
axBsubA = factory.getOWLSubClassOfAxiom(B, A);
ontologyManager = TestOWLManager.createOWLOntologyManager();
try {
ont = ontologyManager.createOntology(new HashSet<OWLAxiom>(Arrays
.asList(axAsubB, axBsubA)));
} catch (OWLOntologyCreationException e) {
fail(e.toString());
}
}
示例20
@Test
public void proofCompletenessTest() throws Exception {
final OWLDataFactory factory = manager_.getOWLDataFactory();
// loading and classifying via the OWL API
final OWLOntology ontology = loadOntology(
manifest_.getInput().getUrl().openStream());
final OWLProver prover = OWLAPITestUtils.createProver(ontology);
try {
prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);
} catch (final InconsistentOntologyException e) {
// we will explain it, too
}
try {
// now do testing
ProofTestUtils.visitAllSubsumptionsForProofTests(prover, factory,
new ProofTestVisitor() {
@Override
public void visit(final OWLClassExpression subsumee,
final OWLClassExpression subsumer) {
ProofTestUtils.proofCompletenessTest(prover, factory
.getOWLSubClassOfAxiom(subsumee, subsumer));
}
});
} finally {
prover.dispose();
}
}
示例21
/**
* Convenience method for asserting a subClass relation between
* a parent and child class in an ontology.
*
* @param ontology the current ontology
* @param child the child class
* @param parent the parent class
* @return the axiom
*/
protected static OWLSubClassOfAxiom assertSubClass(
OWLOntology ontology, OWLClass child, OWLClass parent) {
OWLOntologyManager manager = ontology.getOWLOntologyManager();
OWLDataFactory dataFactory = manager.getOWLDataFactory();
OWLSubClassOfAxiom axiom =
dataFactory.getOWLSubClassOfAxiom(child, parent);
ontology.getOWLOntologyManager().addAxiom(ontology, axiom);
return axiom;
}
示例22
/**
* 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, String value) {
OWLOntologyManager manager = ontology.getOWLOntologyManager();
OWLDataFactory dataFactory = manager.getOWLDataFactory();
IRI iri = format.getIRI(propertyCURIE);
OWLAnnotationProperty property =
dataFactory.getOWLAnnotationProperty(iri);
OWLLiteral literal = dataFactory.getOWLLiteral(value);
OWLAnnotation annotation = dataFactory.getOWLAnnotation(
property, literal);
manager.applyChange(
new AddOntologyAnnotation(ontology, annotation));
return annotation;
}
示例23
@Override
protected void addAxioms(
@Nonnull OWLObjectProperty entity,
@Nonnull OWLReasoner reasoner,
@Nonnull OWLDataFactory dataFactory,
@Nonnull Set<OWLSubObjectPropertyOfAxiom> result,
@Nonnull Set<OWLObjectPropertyExpression> nonSimpleProperties) {
for (OWLObjectPropertyExpression prop :
reasoner.getSuperObjectProperties(entity, false).getFlattened()) {
result.add(dataFactory.getOWLSubObjectPropertyOfAxiom(entity, prop));
}
}
示例24
@Override
protected void addAxioms(
@Nonnull OWLNamedIndividual entity,
@Nonnull OWLReasoner reasoner,
@Nonnull OWLDataFactory dataFactory,
@Nonnull Set<OWLClassAssertionAxiom> result) {
for (OWLClass type : reasoner.getTypes(entity, true).getFlattened()) {
result.add(dataFactory.getOWLClassAssertionAxiom(type, entity));
}
}
示例25
/**
* Convenience method for asserting a subAnnotationProperty relation
* between a parent and child property in an ontology.
*
* @param ontology the current ontology
* @param child the child property
* @param parent the parent property
* @return the axiom
*/
protected static OWLSubAnnotationPropertyOfAxiom
assertSubAnnotationProperty(
OWLOntology ontology, OWLAnnotationProperty child,
OWLAnnotationProperty parent) {
OWLOntologyManager manager = ontology.getOWLOntologyManager();
OWLDataFactory dataFactory = manager.getOWLDataFactory();
OWLSubAnnotationPropertyOfAxiom axiom =
dataFactory.getOWLSubAnnotationPropertyOfAxiom(
child, parent);
manager.addAxiom(ontology, axiom);
return axiom;
}
示例26
@Test
public void testEdgeCache() throws Exception {
OWLGraphWrapper g = getGraph("graph/cache-test.obo");
OWLOntology o = g.getSourceOntology();
OWLOntologyManager m = o.getOWLOntologyManager();
OWLDataFactory f = m.getOWLDataFactory();
OWLClass orphan = g.getOWLClassByIdentifier("FOO:0004");
OWLClass root = g.getOWLClassByIdentifier("FOO:0001");
g.getEdgesBetween(orphan, root); //just to trigger the cache
OWLSubClassOfAxiom ax = f.getOWLSubClassOfAxiom(orphan, root);
AddAxiom addAx = new AddAxiom(o, ax);
m.applyChange(addAx);
Set<OWLGraphEdge> edges = g.getEdgesBetween(orphan, root);
assertNotNull(edges);
assertEquals(0, edges.size());
g.clearCachedEdges(); // test clear cache method
edges = g.getEdgesBetween(orphan, root);
assertNotNull(edges);
assertEquals(1, edges.size());
}
示例27
private void addSomeValuesFromClassAssertion(OWLOntology ont,
OWLIndividual i, OWLClass j, OWLObjectProperty p) {
OWLDataFactory df = ont.getOWLOntologyManager().getOWLDataFactory();
OWLObjectSomeValuesFrom svf =
df.getOWLObjectSomeValuesFrom(p, j);
addAxiom(ont, df.getOWLClassAssertionAxiom(svf, i));
}
示例28
/**
* @param f
* @param siblings
* @param inTaxon
* @return axiom
*/
protected OWLAxiom createDisjoint(OWLDataFactory f, Set<OWLClass> siblings, OWLObjectProperty inTaxon) {
Set<OWLClassExpression> expressions = new HashSet<OWLClassExpression>();
for (OWLClass cls : siblings) {
expressions.add(f.getOWLObjectSomeValuesFrom(inTaxon, cls));
}
return f.getOWLDisjointClassesAxiom(expressions);
}
示例29
public ModelAnnotationSolrDocumentLoader(SolrServer server, OWLOntology model, OWLReasoner r, String modelUrl,
Set<String> modelFilter, boolean skipDeprecatedModels, boolean skipTemplateModels) {
super(server);
this.model = model;
this.reasoner = r;
this.requiredModelStates = modelFilter;
this.skipDeprecatedModels = skipDeprecatedModels;
this.skipTemplateModels = skipTemplateModels;
this.graph = new OWLGraphWrapper(model);
this.modelUrl = modelUrl;
current_doc_number = 0;
OWLDataFactory df = graph.getDataFactory();
partOf = OBOUpperVocabulary.BFO_part_of.getObjectProperty(df);
occursIn = OBOUpperVocabulary.BFO_occurs_in.getObjectProperty(df);
defaultClosureRelations = new ArrayList<String>(1);
defaultClosureRelations.add(graph.getIdentifier(partOf));
enabledBy = OBOUpperVocabulary.GOREL_enabled_by.getObjectProperty(df);
title = df.getOWLAnnotationProperty(IRI.create("http://purl.org/dc/elements/1.1/title"));
source = df.getOWLAnnotationProperty(IRI.create("http://purl.org/dc/elements/1.1/source"));
contributor = df.getOWLAnnotationProperty(IRI.create("http://purl.org/dc/elements/1.1/contributor"));
date = df.getOWLAnnotationProperty(IRI.create("http://purl.org/dc/elements/1.1/date"));
evidence = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/evidence"));
modelState = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/modelstate"));
comment = df.getRDFSComment();
with = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/evidence-with"));
layoutHintX = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/hint/layout/x"));
layoutHintY = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/hint/layout/y"));
templatestate = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/templatestate"));
displayLabelProp = df.getRDFSLabel();
shortIdProp = df.getOWLAnnotationProperty(IRI.create(Obo2OWLConstants.OIOVOCAB_IRI_PREFIX+"id"));
jsonProp = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/json-model"));
bpSet = getAspect(graph, "biological_process");
}
示例30
/**
* Create a class for an NCBI Taxonomy ID and add it to the ontology.
*
* @param ontology the current ontology
* @param id the NCBI Taxonomy ID, will be expanded into an IRI of the
* form http://purl.obolibrary.org/obo/NCBITaxon_1
* @return the new class
*/
public static OWLClass createTaxon(OWLOntology ontology, String id) {
IRI iri = createNCBIIRI(id);
OWLDataFactory dataFactory = ontology.getOWLOntologyManager().
getOWLDataFactory();
OWLClass taxon = dataFactory.getOWLClass(iri);
declare(ontology, taxon);
annotate(ontology, taxon, "oio:hasOBONamespace",
"ncbi_taxonomy");
return taxon;
}