org.semanticweb.owlapi.model.OWLObjectProperty Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLObjectProperty. 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: ChEBIParser.java    From act with GNU General Public License v3.0 6 votes vote down vote up
private Set<OWLClass> get_has_role_parents(OWLClass clazz) {
  Set<OWLClass> roles = new HashSet<OWLClass>();
  for (OWLClassExpression sup: clazz.getSuperClasses(ontology)) {
    ClassExpressionType typ = sup.getClassExpressionType();
    switch (typ) {
      case OBJECT_SOME_VALUES_FROM:
        Set<OWLObjectProperty> properties = sup.getObjectPropertiesInSignature();
        Set<OWLClass> classes = sup.getClassesInSignature();
        if (singletonPropertyHasRole(properties) && classes.size() == 1) {
          OWLClass has_role_parent = classes.toArray(new OWLClass[0])[0];
          roles.add(has_role_parent);
          // err.println("\t\t Added parent: " + has_role_parent);
        }
        // else {
        //   err.println("Was expecting singleton sets for properties and classes.");
        //   err.println("Got more/less: " + properties + " " + classes);
        //   System.exit(-1);
        // }
        break;
      default:
        // err.println("\t Default (SubClassOf): " + sup);
        break;
    }
  }
  return roles;
}
 
Example #2
Source File: GraphOwlVisitor.java    From SciGraph with Apache License 2.0 6 votes vote down vote up
@Override
public Void visit(OWLEquivalentObjectPropertiesAxiom axiom) {
  Set<OWLObjectPropertyExpression> properties = axiom.getProperties();
  boolean anonymousPropertyExists = false;
  for (OWLObjectPropertyExpression property : properties) {
    anonymousPropertyExists = anonymousPropertyExists || property.isAnonymous();
  }

  // #217 - in case of EquivalentObjectProperties(:p ObjectInverseOf(:q))
  if (!anonymousPropertyExists) {
    Collection<Long> nodes = Collections2.transform(axiom.getObjectPropertiesInSignature(),
        new Function<OWLObjectProperty, Long>() {

          @Override
          public Long apply(OWLObjectProperty objectProperty) {
            return getOrCreateNode(getIri(objectProperty));
          }
        });

    getOrCreateRelationshipPairwise(nodes, OwlRelationships.OWL_EQUIVALENT_OBJECT_PROPERTY);
  }
  return null;
}
 
Example #3
Source File: RoleAxiomOWLAPILowLevelIncrementalClassTest.java    From elk-reasoner with Apache License 2.0 6 votes vote down vote up
@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());
	}
}
 
Example #4
Source File: ExtendedReasonerTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testQuery() throws Exception{
	g =  getOntologyWrapper("extended-reasoner-test.omn");
	parser = new ManchesterSyntaxTool(g.getSourceOntology(), g.getSupportOntologySet());
	reasoner = new ExpressionMaterializingReasoner(g.getSourceOntology(),
			new ElkReasonerFactory(), BufferingMode.NON_BUFFERING);
	reasoner.flush();
	IRI  piri;
	piri = IRI.create("http://x.org/part_of");
	OWLObjectProperty p = 
			g.getDataFactory().getOWLObjectProperty(piri);
	
	findAncestors("digit", p, true, 1);
	findAncestors("digit", p, false, 2);
	findAncestors("toe", p, true, 1);
	findAncestors("toe", p, false, 4);
	findAncestors("phalanx", p, true, 1);
	findAncestors("phalanx", p, false, 4);
	findAncestors("mouse_phalanx", p, true, 2);
	findAncestors("brachialis", p, true, 1);
	

}
 
Example #5
Source File: OWLGraphWrapperEdgesExtendedTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Test {@link OWLGraphWrapperEdgesExtended#getSubPropertyClosureOf(OWLObjectPropertyExpression)}.
 */
@Test
@Ignore("Disabling test due to lack of resources to debug")
public void shouldGetSubPropertyClosureOf()
{
	OWLObjectProperty fakeRel1 = 
			wrapper.getOWLObjectPropertyByIdentifier("fake_rel1");
	List<OWLObjectProperty> expectedSubProps = new ArrayList<OWLObjectProperty>();
	expectedSubProps.add(wrapper.getOWLObjectPropertyByIdentifier("fake_rel2"));
	expectedSubProps.add(wrapper.getOWLObjectPropertyByIdentifier("fake_rel3"));
	expectedSubProps.add(wrapper.getOWLObjectPropertyByIdentifier("fake_rel4"));
	//fake_rel3 and fake_rel4 are sub-properties of fake_rel2, 
	//which is the sub-property of fake_rel1
	//we also test the order of the returned properties
	LinkedHashSet<OWLObjectPropertyExpression> subprops = 
			wrapper.getSubPropertyClosureOf(fakeRel1);
	assertEquals("Incorrect sub-properties returned: ", 
			expectedSubProps, new ArrayList<OWLObjectPropertyExpression>(subprops));
	
}
 
Example #6
Source File: LinkMaker.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Check that the given subClass does not already has a matching subClass axiom.
 * 
 * @param subCls
 * @param p
 * @param superCls
 * @return existing axiom or null
 */
private OWLAxiom hasLinks(OWLClass subCls, OWLObjectProperty p, OWLClass superCls) {
	for(OWLOntology o : allOntologies) {
		Set<OWLSubClassOfAxiom> subClsAxioms = o.getSubClassAxiomsForSubClass(subCls);
		for (OWLSubClassOfAxiom subClsAxiom : subClsAxioms) {
			OWLClassExpression ce = subClsAxiom.getSuperClass();
			if (ce instanceof OWLObjectSomeValuesFrom) {
				OWLObjectSomeValuesFrom someValuesFrom = (OWLObjectSomeValuesFrom) ce;
				OWLObjectPropertyExpression property = someValuesFrom.getProperty();
				if (p.equals(property)) {
					OWLClassExpression filler = someValuesFrom.getFiller();
					if (superCls.equals(filler)) {
						return subClsAxiom;
					}
				}
			}
		}
	}
	return null;
}
 
Example #7
Source File: PhenoSimHQEPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void makeHasPhenotypeInstancesDirect() {
	// x Type has_phenotype some C ==> x Type C
	LOG.info("x Type has_phenotype some C ==> x Type C");
	OWLObjectProperty hasPhenotype = getOWLObjectPropertyViaOBOSuffix(HAS_PHENOTYPE);
	Set<OWLAxiom> rmAxioms = new HashSet<OWLAxiom>();
	Set<OWLAxiom> newAxioms = new HashSet<OWLAxiom>();
	for (OWLClassAssertionAxiom caa : outputOntology.getAxioms(AxiomType.CLASS_ASSERTION)) {
		OWLClassExpression ex = caa.getClassExpression();
		OWLIndividual i = caa.getIndividual();
		if (ex instanceof OWLObjectSomeValuesFrom) {
			OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom)ex;
			if (svf.getProperty().equals(hasPhenotype)) {
				rmAxioms.add(caa);
				newAxioms.add(getOWLDataFactory().getOWLClassAssertionAxiom(svf.getFiller(), i));
			}

		}
	}
	LOG.info("making instances direct: +"+newAxioms.size()+ " -"+rmAxioms.size());
	addAxiomsToOutput(newAxioms, false);
	removeAxiomsFromOutput(rmAxioms, false);
}
 
Example #8
Source File: OntologyHelper.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
public Set<String> getRestrictionProperties() {
	Set<String> properties = new HashSet<>();
	
	Set<OWLObjectProperty> objectProperties = ontology.getObjectPropertiesInSignature();
	for (OWLObjectProperty oop : objectProperties) {
		List<String> labels = new ArrayList<>(findLabels(oop.getIRI()));
		if (!labels.isEmpty()) {
			properties.add(labels.get(0));
		} else {
			Optional<String> shortForm = getShortForm(oop.getIRI());
			if (shortForm.isPresent()) {
				properties.add(shortForm.get());
			}
		}
	}
	
	return properties;
}
 
Example #9
Source File: OWLHandler.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Deprecated
public void deleteFactCommand() throws IOException, OWLOntologyCreationException, OWLOntologyStorageException, UnknownOWLClassException {
	if (isHelp()) {
		info("generates ClassAssertion");
		return;
	}
	OWLOntology ont = resolveOntology(Param.ontology);
	OWLIndividual i = resolveIndividual(Param.individualId);
	OWLIndividual j = resolveIndividual(Param.fillerId);
	OWLObjectProperty p = resolveObjectProperty(Param.propertyId);
	for (OWLObjectPropertyAssertionAxiom ax : ont.getAxioms(AxiomType.OBJECT_PROPERTY_ASSERTION)) {
		if (ax.getSubject().equals(i)) {
			if (p == null || ax.getProperty().equals(p)) {
				if (j == null || ax.getObject().equals(j)) {
					removeAxiom(ont, graph.getDataFactory().getOWLObjectPropertyAssertionAxiom(p, i, j));
				}
			}
		}
	}
	String jsonStr = "";
	response.getWriter().write(jsonStr);
}
 
Example #10
Source File: BasicAnnotationPropagator.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Retrieve the non redundant set of linked classes using the given
 * relation. The reasoner is used to infer the super and subsets for the
 * subClass hierarchy. Only return classes, which are in the given super set
 * (a.k.a. ontology branch).<br>
 * <br>
 * This can be an expensive operation, especially the
 * {@link #reduceToNonRedundant(Set, OWLReasoner)}. Therefore the results of
 * that method are cached in a map.<br>
 * For example, using the cache for GO, there was a reduction of the startup
 * time from 95 seconds to 10 seconds.
 * 
 * @param c
 * @param properties
 * @param g
 * @param reasoner
 * @param superSet
 * @param cache
 * @return set of linked classes, never null
 */
protected static Set<OWLClass> getNonRedundantLinkedClasses(OWLClass c, Set<OWLObjectProperty> properties, OWLGraphWrapper g, OWLReasoner reasoner, Set<OWLClass> superSet, Map<Set<OWLClass>, Set<OWLClass>> cache) {
	// get all superClasses for the current class
	Set<OWLClass> currentSuperClasses = reasoner.getSuperClasses(c, false).getFlattened();
	currentSuperClasses.add(c);
	Set<OWLClass> linkedClasses = new HashSet<OWLClass>();
	for (OWLClass currentSuperClass : currentSuperClasses) {
		if (currentSuperClass.isBuiltIn()) {
			continue;
		}
		// find all direct links via the property to the selected super set
		linkedClasses.addAll(getDirectLinkedClasses(currentSuperClass, properties, g, superSet));
	}
	// create remove redundant super classes from link set
	Set<OWLClass> nonRedundantLinks = cache.get(linkedClasses);
	if (nonRedundantLinks == null) {
		nonRedundantLinks = reduceToNonRedundant(linkedClasses, reasoner);
		cache.put(linkedClasses, nonRedundantLinks);
	}
	
	return nonRedundantLinks;
}
 
Example #11
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 #12
Source File: OWLGraphWrapperEdgesAdvanced.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
Set<OWLClass> getSvfClasses(OWLClass c, OWLObjectProperty p) {
	Set<OWLSubClassOfAxiom> axioms = new HashSet<OWLSubClassOfAxiom>();
	for(OWLOntology ont : getAllOntologies()) {
		axioms.addAll(ont.getSubClassAxiomsForSubClass(c));
	}
	Set<OWLClass> superClasses = new HashSet<OWLClass>();
	for (OWLSubClassOfAxiom axiom : axioms) {
		OWLClassExpression expr = axiom.getSuperClass();
		if (expr instanceof OWLObjectSomeValuesFrom) {
			OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom) expr;
			if (p.equals(svf.getProperty())) {
				OWLClassExpression filler = svf.getFiller();
				if (filler instanceof OWLClass) {
					superClasses.add((OWLClass) filler);
				}
			}
		}
	}
	return superClasses;
}
 
Example #13
Source File: EliminateEJVar.java    From quetzal with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * return named properties p such that c \subseteq \some inv(p) T
 * @param c
 * @return
 */
protected Set<URI> getNamedInverseSuperPropertiesOrSelf(OWLClassExpression c) {
	Set<OWLClassExpression> subs = taxo.getAllSubsumers(c);
	Set<URI> ret = new HashSet<URI>();
	for (OWLClassExpression ex: subs) {
		if (ex.getClassExpressionType().equals(ClassExpressionType.OBJECT_SOME_VALUES_FROM)) {
			OWLObjectSomeValuesFrom rest = (OWLObjectSomeValuesFrom) ex;
			OWLObjectPropertyExpression prop = rest.getProperty().getSimplified();
			if (prop.isAnonymous()) {
				OWLObjectProperty namedProp = prop.getNamedProperty();
				ret.add(namedProp.getIRI().toURI());
			}
			
		}
	}
	return ret;
	
}
 
Example #14
Source File: AbstractConverter.java    From OWL2VOWL with MIT License 6 votes vote down vote up
private void processObjectProperties(OWLOntology ontology, VowlData vowlData) {
	for (OWLObjectProperty owlObjectProperty : ontology.objectPropertiesInSignature(Imports.INCLUDED)
			.collect(Collectors.toSet())) {
		for (OWLObjectPropertyAxiom owlObjectPropertyAxiom : ontology.axioms(owlObjectProperty, Imports.INCLUDED)
				.collect(Collectors.toSet())) {
			try {
				owlObjectPropertyAxiom.accept(new ObjectPropertyVisitor(vowlData, owlObjectProperty));
			} catch (Exception e) {
				logger.info(
						"          @WORKAROUND: Failed to accept property with HAS_VALUE OR  SubObjectPropertyOf ... SKIPPING THIS");
				logger.info("          propertyName: " + owlObjectProperty);
				logger.info("          propertyAxiom: " + owlObjectPropertyAxiom);
			}
		}
	}
}
 
Example #15
Source File: OWLGraphWrapperEdges.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Get the human readable label for an edge.
 * Intended for use for things like the GO.
 * 
 * @param e
 * @return either the human readable edge label or null if none could be found
 */
public String getEdgeLabel(OWLGraphEdge e) {
	String retstr = null;

	// Figure edge out.
	OWLQuantifiedProperty sprop= e.getSingleQuantifiedProperty();
	if( sprop.isSubClassOf() ){
		retstr = "is_a";
	}else if( sprop.isSomeValuesFrom() ){
		OWLObjectProperty oprop = sprop.getProperty();
		String prop_label = getLabel(oprop);
		if( prop_label != null && ! prop_label.equals("") )
			retstr = prop_label;
	}else{
		// Not a relation in the sense that we want.
	}
	
	return retstr;
}
 
Example #16
Source File: OWLGraphWrapperEdges.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private Map<OWLObjectProperty,Set<List<OWLObjectProperty>>> getPropertyChainMap() {
	if (pcMap == null) {
		pcMap = new HashMap<OWLObjectProperty,Set<List<OWLObjectProperty>>>();
		for (OWLSubPropertyChainOfAxiom a : sourceOntology.getAxioms(AxiomType.SUB_PROPERTY_CHAIN_OF)) {
			//LOG.info("CHAIN:"+a+" // "+a.getPropertyChain().size());
			if (a.getPropertyChain().size() == 2) {
				OWLObjectPropertyExpression p1 = a.getPropertyChain().get(0);
				OWLObjectPropertyExpression p2 = a.getPropertyChain().get(1);
				//LOG.info("  xxCHAIN:"+p1+" o "+p2);
				if (p1 instanceof OWLObjectProperty && p2 instanceof OWLObjectProperty) {
					List<OWLObjectProperty> list = new Vector<OWLObjectProperty>();
					list.add((OWLObjectProperty) p2);
					list.add((OWLObjectProperty) a.getSuperProperty());
					if (!pcMap.containsKey(p1)) 
						pcMap.put((OWLObjectProperty) p1, new HashSet<List<OWLObjectProperty>>());
					pcMap.get((OWLObjectProperty) p1).add(list);
					//LOG.info("  xxxCHAIN:"+p1+" ... "+list);
				}
			}
			else {
				// TODO
			}
		}
	}
	return pcMap;
}
 
Example #17
Source File: CommandRunnerBase.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public List<OWLObjectProperty> resolveObjectPropertyListAsList(Opts opts) {
	List<String> ids = opts.nextList();
	List<OWLObjectProperty> objs = new ArrayList<OWLObjectProperty>();
	for (String id: ids) {
		if (id.equals("ALL-PROPERTIES"))
			return new ArrayList<OWLObjectProperty>(
					g.getSourceOntology().getObjectPropertiesInSignature());
		final OWLObjectProperty prop = this.resolveObjectProperty(id);
		if (prop != null) {
			objs.add(prop);
		}
	}
	return objs;
}
 
Example #18
Source File: OWLHandler.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Deprecated
public void assertFactCommand() throws IOException, OWLOntologyCreationException, OWLOntologyStorageException, UnknownOWLClassException {
	if (isHelp()) {
		info("generates ClassAssertion");
		return;
	}
	OWLOntology ont = resolveOntology(Param.ontology);
	OWLIndividual i = resolveIndividual(Param.individualId);
	OWLIndividual j = resolveIndividual(Param.fillerId);
	OWLObjectProperty p = resolveObjectProperty(Param.propertyId);
	addAxiom(ont, graph.getDataFactory().getOWLObjectPropertyAssertionAxiom(p, i, j));
	String jsonStr = "";
	response.getWriter().write(jsonStr);
}
 
Example #19
Source File: OntologyHelper.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve a map of related classes for a particular class.
 * 
 * @param owlClass
 * @return a map of relation type to a list of IRIs for nodes with that
 * relationship.
 */
public Map<String, List<String>> getRestrictions(OWLClass owlClass) {
	RestrictionVisitor visitor = new RestrictionVisitor(Collections.singleton(ontology));
	for (OWLSubClassOfAxiom ax : ontology.getSubClassAxiomsForSubClass(owlClass)) {
		OWLClassExpression superCls = ax.getSuperClass();
		// Ask our superclass to accept a visit from the RestrictionVisitor
		// - if it is an existential restriction then our restriction visitor
		// will answer it - if not our visitor will ignore it
		superCls.accept(visitor);
	}

	Map<String, List<String>> restrictions = new HashMap<>();
	for (OWLObjectSomeValuesFrom val : visitor.getSomeValues()) {
		OWLClassExpression exp = val.getFiller();

		// Get the shortname of the property expression
		String shortForm = null;
		Set<OWLObjectProperty> signatureProps = val.getProperty().getObjectPropertiesInSignature();
		for (OWLObjectProperty sigProp : signatureProps) {
			Collection<String> labels = findLabels(sigProp.getIRI());
			if (labels.size() > 0) {
				shortForm = new ArrayList<String>(labels).get(0);
			}
		}

		if (shortForm != null && !exp.isAnonymous()) {
			IRI iri = exp.asOWLClass().getIRI();

			if (!restrictions.containsKey(shortForm)) {
				restrictions.put(shortForm, new ArrayList<String>());
			}
			restrictions.get(shortForm).add(iri.toString());
		}
	}

	return restrictions;
}
 
Example #20
Source File: CellularLocationTools.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static OWLClassExpression searchCellularLocation(OWLClassExpression cls, OWLGraphWrapper graph, Set<OWLObjectProperty> occurs_in) {
	Queue<OWLClass> queue = new Queue<OWLClass>();
	if (cls instanceof OWLClass) {
		queue.add((OWLClass) cls);
	}
	else if (cls instanceof OWLObjectIntersectionOf) {
		OWLObjectIntersectionOf intersectionOf = (OWLObjectIntersectionOf) cls;
		for (OWLClassExpression ce : intersectionOf.getOperands()) {
			if (ce instanceof OWLClass) {
				queue.add((OWLClass) ce);
			}
		}
	}
	return searchCellularLocation(queue, graph, occurs_in);
}
 
Example #21
Source File: GoClassReferenceAnnotationRule.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public GoClassReferenceAnnotationRule(OWLGraphWrapper wrapper, String...idPrefixes){
	this.graph = wrapper; 
	owlObjectsByAltId = graph.getAllOWLObjectsByAltId();
	relByAltId = new HashMap<String, OWLObjectProperty>();
	for(String altId : owlObjectsByAltId.keySet()) {
		OWLObject owlObject = owlObjectsByAltId.get(altId);
		if (owlObject instanceof OWLObjectProperty) {
			OWLObjectProperty rel = (OWLObjectProperty) owlObject;
			relByAltId.put(altId, rel);
		}
	}
	c16PrefixWhiteList = Arrays.asList(idPrefixes);
}
 
Example #22
Source File: OldSimpleOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void init() {
	reasonerFactory = new ElkReasonerFactory();
	elementToAttributesMap = new HashMap<OWLEntity,Set<OWLClass>>();
	attributeToElementsMap = new HashMap<OWLClass,Set<OWLEntity>>();
	expressionToClassMap = new HashMap<OWLClassExpression, OWLClass>();
	viewClasses = new HashSet<OWLClass>();
	sourceViewProperties = new ArrayList<OWLObjectProperty>();
	simCache = new HashMap<OWLClassExpressionPair, ScoreAttributePair>();
	lcsCache = new HashMap<OWLClassExpressionPair, OWLClass>();
}
 
Example #23
Source File: OWLGraphWrapperEdgesAdvanced.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Set<OWLClass> getOnlyInTaxonSvfClasses(OWLObject x) {
	if (x != null && x instanceof OWLClass) {
		OWLClass c = (OWLClass) x;
		IRI onlyInTaxonIRI = IRI.create("http://purl.obolibrary.org/obo/RO_0002160");
		OWLObjectProperty onlyInTaxon = getDataFactory().getOWLObjectProperty(onlyInTaxonIRI);
		return getSvfClasses(c, onlyInTaxon);
	}
	return Collections.emptySet();
}
 
Example #24
Source File: ConjunctiveSetInformationContentRatioSimilarity.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public OWLClassExpression getLCS() {
	OWLDataFactory df = simEngine.getGraph().getDataFactory();
	OWLObjectProperty topRel = df.getOWLTopObjectProperty();
	Set<OWLClassExpression> ces = new HashSet<OWLClassExpression>();
	for (OWLObject obj : lcsIntersectionSet) {
		if (obj instanceof OWLClassExpression)
			ces.add(df.getOWLObjectSomeValuesFrom(topRel,
					(OWLClassExpression) obj));
	}
	OWLClassExpression ce =
		df.getOWLObjectIntersectionOf(ces);
	return ce;
}
 
Example #25
Source File: NormalizedOWLQLTbox.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
public Set<OWLObjectProperty> getReflexiveProperties() {
	if (reflexiveProps == null) {
		reflexiveProps = new HashSet<OWLObjectProperty>();
		for (OWLReflexiveObjectPropertyAxiom ax: normalizedOntology.getAxioms(AxiomType.REFLEXIVE_OBJECT_PROPERTY)) {
			reflexiveProps.add(ax.getProperty().getNamedProperty());
		}
	}
	return reflexiveProps;
}
 
Example #26
Source File: PropertyViewOntologyBuilder.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @param owlDataFactory
 * @param owlOntologyManager
 * @param sourceOntology
 * @param unitsOntology
 * @param viewProperty
 */
public PropertyViewOntologyBuilder(OWLDataFactory owlDataFactory,
		OWLOntologyManager owlOntologyManager, OWLOntology sourceOntology,
		OWLOntology unitsOntology, OWLObjectProperty viewProperty) {
	super();
	this.owlDataFactory = owlDataFactory;
	this.owlOntologyManager = owlOntologyManager;
	this.sourceOntology = sourceOntology;
	this.elementsOntology = unitsOntology;
	this.viewProperty = viewProperty;
	init();
}
 
Example #27
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * true if c is reflexive in the graph
 * 
 * @param c
 * @return boolean
 */
public boolean getIsReflexive(OWLObjectProperty c) {
	for(OWLOntology ont : getAllOntologies()) {
		Set<OWLReflexiveObjectPropertyAxiom> ax = ont.getReflexiveObjectPropertyAxioms(c);
		if (ax.isEmpty() == false) {
			return true;
		}
	}
	return false;
}
 
Example #28
Source File: TaxonCommandRunner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @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);
}
 
Example #29
Source File: GraphReasoner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Set<OWLClass> getSuperClassesOver(OWLClassExpression ce,
		OWLObjectProperty p, boolean direct)
		throws InconsistentOntologyException,
		ClassExpressionNotInProfileException, FreshEntitiesException,
		ReasonerInterruptedException, TimeOutException {
	// TODO Auto-generated method stub
	return null;
}
 
Example #30
Source File: OWLHandler.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void assertEnabledByCommand() throws IOException, OWLOntologyCreationException, OWLOntologyStorageException, UnknownOWLClassException {
	if (isHelp()) {
		info("generates ClassAssertion");
		return;
	}
	OWLOntology ont = resolveOntology(Param.ontology);
	OWLIndividual i = resolveIndividual(Param.individualId);
	OWLClass j = resolveClass(Param.fillerId);
	OWLObjectProperty p = 
			OBOUpperVocabulary.GOREL_enabled_by.getObjectProperty(graph.getDataFactory());
	addSomeValuesFromClassAssertion(ont, i, j, p);
	String jsonStr = "";
	response.getWriter().write(jsonStr);
}