org.semanticweb.owlapi.model.OWLObjectPropertyExpression Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLObjectPropertyExpression. 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: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Set<ObjectProperty> getAllClassObjectProperties(IRI iri) {
    org.semanticweb.owlapi.model.IRI classIRI = SimpleOntologyValues.owlapiIRI(iri);
    if (owlOntology.containsClassInSignature(classIRI)) {
        OWLClass owlClass = owlManager.getOWLDataFactory().getOWLClass(classIRI);
        Node<OWLClass> equivalentClasses = owlReasoner.getEquivalentClasses(owlClass);
        NodeSet<OWLClass> superClasses = owlReasoner.getSuperClasses(owlClass);
        return owlOntology.objectPropertiesInSignature(Imports.INCLUDED)
                .filter(property -> {
                    Set<OWLObjectPropertyDomainAxiom> domains = owlOntology.axioms(
                            OWLObjectPropertyDomainAxiom.class, OWLObjectPropertyExpression.class, property,
                            Imports.INCLUDED, Navigation.IN_SUB_POSITION).collect(Collectors.toSet());
                    return hasClassAsDomain(domains.stream(), classIRI, equivalentClasses, superClasses)
                            || hasNoDomain(domains.stream());
                })
                .map(SimpleOntologyValues::mobiObjectProperty)
                .collect(Collectors.toSet());
    }
    throw new IllegalArgumentException("Class not found in ontology");
}
 
Example #2
Source File: TaxonomyImpl.java    From quetzal with Eclipse Public License 2.0 6 votes vote down vote up
public Set<OWLPropertyExpression> getAllSubproperties(
		OWLPropertyExpression roleSup) {
	Set<OWLPropertyExpression> subs = new HashSet<OWLPropertyExpression>();
	for (OWLPropertyExpression sub : 
			roleSup.isDataPropertyExpression()? dataPropTaxo.getSubsumeesOrSelf(roleSup)
			: objPropTaxo.getSubsumeesOrSelf(roleSup)) {
		if (!sub.isAnonymous()) {
			subs.add(sub); 
		} else {
			//OWLObjectProperty op = ((OWLObjectPropertyExpression) c).getNamedProperty(); //fac.getOWLObjectProperty(IRI.create(sub.getInverse().getName().getAFun().getName()));
			//if (oprops.contains(op))
			{
				subs.add(sub);
			} 
			//else {
				// do nothing: inverse of a create role R, where R is defined as equivalent to the inverse of an existing role
			//}
		}
	}
	subs.remove(dataPropTaxo.getBottom());
	subs.remove(objPropTaxo.getBottom());
	subs.remove(fac.getOWLObjectInverseOf((OWLObjectPropertyExpression) objPropTaxo.getBottom()).getSimplified());

	return subs;
}
 
Example #3
Source File: Mooncat.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static Set<OWLObjectPropertyExpression> getSuperObjectProperties(OWLObjectPropertyExpression p, OWLReasoner reasoner, OWLOntology ont) {
    if (reasoner != null) {
        return reasoner.getSuperObjectProperties(p, false).getFlattened();
    }
    // Elk does not support this (sigh), so we do it ourselves
       Set<OWLObjectPropertyExpression> sups = new HashSet<>();
       Stack<OWLObjectPropertyExpression> seeds = new Stack<>();
       seeds.add(p);
    while (seeds.size() > 0) {
        OWLObjectPropertyExpression nextp = seeds.pop();
        Set<OWLObjectPropertyExpression> xset = 
                ont.getObjectSubPropertyAxiomsForSubProperty(nextp).stream().
                map(a -> a.getSuperProperty()).collect(Collectors.toSet());
        
        seeds.addAll(xset);
        seeds.removeAll(sups);
        sups.addAll(xset);       
    }
    return sups;
}
 
Example #4
Source File: LegoDotWriter.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void renderAdditionalNodeExpression(StringBuilder line, OWLClassExpression expression, OWLPrettyPrinter owlpp) {
	if (expression instanceof OWLObjectSomeValuesFrom) {
		OWLObjectSomeValuesFrom object = (OWLObjectSomeValuesFrom) expression;
		OWLObjectPropertyExpression property = object.getProperty();
		OWLClassExpression filler = object.getFiller();
		line.append("<TR><TD>");
		line.append(getLabel(property, owlpp));
		line.append("</TD><TD>");
		line.append(getLabel(filler, owlpp));
		line.append("</TD></TR>");
	}
	else {
		line.append("<TR><TD COLSPAN=\"2\">");
		line.append(getLabel(expression, owlpp));
		line.append("</TD></TR>");
	}
}
 
Example #5
Source File: OWLInAboxTranslator.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param i - source
 * @param supc - target expression (e.g. R some B)
 * @return OWLObjectPropertyAssertionAxiom or null
 */
private OWLObjectPropertyAssertionAxiom trEdge(OWLIndividual i, OWLClassExpression supc) {
	if (supc instanceof OWLObjectSomeValuesFrom) {
		OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom)supc;
		OWLObjectPropertyExpression p = trTypeLevel(svf.getProperty());
		OWLIndividual j;
		if (svf.getFiller().isAnonymous()) {
			j = anonClassToIndividual(svf.getFiller());
			add(trEdge(j, svf.getFiller()));
		}
		else {
			j = classToIndividual((OWLClass)svf.getFiller());
		}

		OWLObjectPropertyAssertionAxiom e = getOWLDataFactory().getOWLObjectPropertyAssertionAxiom(p, i, j); 
		return e;
	}
	return null;

}
 
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: LegoShuntGraphTool.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void renderAdditionalNodeExpression(StringBuilder line, OWLClassExpression expression, OWLPrettyPrinter owlpp, OWLGraphWrapper graph) {
	if (expression instanceof OWLObjectSomeValuesFrom) {
		OWLObjectSomeValuesFrom object = (OWLObjectSomeValuesFrom) expression;
		OWLObjectPropertyExpression property = object.getProperty();
		OWLClassExpression filler = object.getFiller();
		line.append("<TR><TD>");
		line.append(getLabel(property, owlpp, graph));
		line.append("</TD><TD>");
		line.append(getLabel(filler, owlpp, graph));
		line.append("</TD></TR>");
	}
	else {
		line.append("<TR><TD COLSPAN=\"2\">");
		line.append(getLabel(expression, owlpp, graph));
		line.append("</TD></TR>");
	}
}
 
Example #8
Source File: PropertyViewOntologyBuilder.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public Set<List<OWLObjectPropertyExpression>> getPropertyChains(OWLObjectProperty p) {
	LOG.info("Getting chains for: "+p);
	Set<List<OWLObjectPropertyExpression>> chains = new HashSet<List<OWLObjectPropertyExpression>>();
	for (OWLSubPropertyChainOfAxiom spca : sourceOntology.getAxioms(AxiomType.SUB_PROPERTY_CHAIN_OF)) {
		if (spca.getSuperProperty().equals(p)) {
			List<OWLObjectPropertyExpression> chain = spca.getPropertyChain();
			chains.add(chain);

			// note: limited form of cycle checking
			if (!chain.contains(p)) {
				chains.addAll(expandPropertyChain(chain));
			}
		}
	}
	LOG.info(p+" ==> "+chains);
	return chains;
}
 
Example #9
Source File: OWLGraphWrapperEdgesExtendedTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Test {@link OWLGraphWrapperEdgesExtended#getSubPropertyReflexiveClosureOf(OWLObjectPropertyExpression)}.
 */
@Test
@Ignore("Disabling test due to lack of resources to debug")
public void shouldGetSubPropertyReflexiveClosureOf()
{
	OWLObjectProperty fakeRel1 = 
			wrapper.getOWLObjectPropertyByIdentifier("fake_rel1");
	List<OWLObjectProperty> expectedSubProps = new ArrayList<OWLObjectProperty>();
	expectedSubProps.add(fakeRel1);
	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.getSubPropertyReflexiveClosureOf(fakeRel1);
	assertEquals("Incorrect sub-properties returned: ", 
			expectedSubProps, new ArrayList<OWLObjectPropertyExpression>(subprops));
	
}
 
Example #10
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 #11
Source File: OWLGraphWrapperEdgesExtendedTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Test {@link OWLGraphWrapperEdgesExtended#getSuperPropertyReflexiveClosureOf(OWLObjectPropertyExpression)}.
 */
@Test
@Ignore("Disabling test due to lack of resources to debug")
public void shouldGetSuperPropertyReflexiveClosureOf()
{
	OWLObjectProperty fakeRel3 = 
			wrapper.getOWLObjectPropertyByIdentifier("fake_rel3");
	List<OWLObjectProperty> expectedSubProps = new ArrayList<OWLObjectProperty>();
	expectedSubProps.add(fakeRel3);
	expectedSubProps.add(wrapper.getOWLObjectPropertyByIdentifier("fake_rel2"));
	expectedSubProps.add(wrapper.getOWLObjectPropertyByIdentifier("fake_rel1"));
	//fake_rel3 is sub-property of fake_rel2, 
	//which is the sub-property of fake_rel1
	//we also test the order of the returned properties
	LinkedHashSet<OWLObjectPropertyExpression> superProps = 
			wrapper.getSuperPropertyReflexiveClosureOf(fakeRel3);
	assertEquals("Incorrect super properties returned: ", 
			expectedSubProps, new ArrayList<OWLObjectPropertyExpression>(superProps));
	
}
 
Example #12
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Set<ObjectProperty> getAllNoDomainObjectProperties() {
    return owlOntology.objectPropertiesInSignature(Imports.INCLUDED)
            .filter(property -> hasNoDomain(owlOntology.axioms(OWLObjectPropertyDomainAxiom.class,
                    OWLObjectPropertyExpression.class, property, Imports.INCLUDED, Navigation.IN_SUB_POSITION)))
            .map(SimpleOntologyValues::mobiObjectProperty)
            .collect(Collectors.toSet());
}
 
Example #13
Source File: InferenceBuilder.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Check all classes for potential redundant subClass axioms of type:
 * <pre>
 *   A SubClassOf R some B
 *    and
 *   A SubClassOf B
 * </pre>
 * 
 * @return list of axiom pairs
 */
public List<PotentialRedundant> checkPotentialRedundantSubClassAxioms() {
	List<PotentialRedundant> result = new ArrayList<PotentialRedundant>();
	for(OWLClass cls : graph.getAllOWLClasses()) {
		Set<OWLSubClassOfAxiom> axioms = graph.getAllOWLSubClassOfAxiomsForSubClass(cls);
		if (axioms.size() > 1) {
			// only check sets with more than one axiom
			for (OWLSubClassOfAxiom main : axioms) {
				OWLClassExpression mainSuperClassCE = main.getSuperClass();
				if (mainSuperClassCE.isAnonymous()) {
					continue;
				}
				OWLClass mainSuperClass = mainSuperClassCE.asOWLClass();
				for (OWLSubClassOfAxiom current : axioms) {
					if (main == current) {
						continue;
					}
					OWLClassExpression currentSuperClass = current.getSuperClass();
					if (currentSuperClass.isAnonymous() && currentSuperClass instanceof OWLObjectSomeValuesFrom) {
						OWLObjectSomeValuesFrom someValuesFrom = (OWLObjectSomeValuesFrom) currentSuperClass;
						final OWLClassExpression filler = someValuesFrom.getFiller();
						if (mainSuperClass.equals(someValuesFrom.getFiller())) {
							final OWLObjectPropertyExpression property = someValuesFrom.getProperty();
							final OWLClassExpression subClass = current.getSubClass();
							final PotentialRedundant redundant = new PotentialRedundant(main, current, subClass.asOWLClass(), property.asOWLObjectProperty(), filler.asOWLClass());
							result.add(redundant);
						}
					}
				}
			}
		}
	}
	
	if (!result.isEmpty()) {
		return result;
	}
	return null;
}
 
Example #14
Source File: OwlApiUtils.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
public static String getIri(OWLObjectPropertyExpression property) {
  if (property.isAnonymous()) {
    return "_:" + hash(property.toString());
  } else {
    return property.asOWLObjectProperty().getIRI().toString();
  }
}
 
Example #15
Source File: OwlHelper.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Set<OWLObjectPropertyExpression> getSubProperties(OWLObjectPropertyExpression prop, OWLOntology ont) {
	Set<OWLObjectPropertyExpression> results = new HashSet<>();
	Set<OWLSubObjectPropertyOfAxiom> axioms = ont.getObjectSubPropertyAxiomsForSuperProperty(prop);
	for (OWLSubObjectPropertyOfAxiom axiom : axioms) {
		results.add(axiom.getSubProperty());
	}
	return results;
}
 
Example #16
Source File: OWLGraphWrapperEdgesExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
    * Returns all parent properties of <code>prop</code> in all ontologies, 
    * and <code>prop</code> itself as the first element (reflexive). 
    * Unlike the method <code>owltools.graph.OWLGraphWrapperEdges.getSuperPropertyReflexiveClosureOf</code>, 
    * the returned super properties here are ordered from the more precise to the more general 
    * (e.g., "in_deep_part_of", then "part_of", then "overlaps"). 
    * 
    * @param prop 	the <code>OWLObjectPropertyExpression</code> for which we want 
    * 				the ordered super properties. 
    * @return		A <code>LinkedHashSet</code> of <code>OWLObjectPropertyExpression</code>s 
    * 				ordered from the more precise to the more general, with <code>prop</code> 
    * 				as the first element. 
    */
//TODO: Remove if OWLGraphWrapper changes its implementation
   public LinkedHashSet<OWLObjectPropertyExpression> getSuperPropertyReflexiveClosureOf(
   		OWLObjectPropertyExpression prop) {
   	
   	//try to get the super properties from the cache
   	LinkedHashSet<OWLObjectPropertyExpression> superProps = 
   			this.superPropertyCache.get(prop);
   	if (superProps == null) {

   		superProps = new LinkedHashSet<OWLObjectPropertyExpression>();
   		Stack<OWLObjectPropertyExpression> stack = 
   				new Stack<OWLObjectPropertyExpression>();
   		stack.add(prop);
   		while (!stack.isEmpty()) {
   			OWLObjectPropertyExpression nextProp = stack.pop();
   			Set<OWLObjectPropertyExpression> directSupers = 
   					this.getSuperPropertiesOf(nextProp);
   			directSupers.removeAll(superProps);
   			directSupers.remove(prop);
   			stack.addAll(directSupers);
   			superProps.addAll(directSupers);
   		}
   		//put superProps in cache
   		this.superPropertyCache.put(prop, superProps);
   	}

   	
   	LinkedHashSet<OWLObjectPropertyExpression> superPropsReflexive = 
   			new LinkedHashSet<OWLObjectPropertyExpression>();
   	superPropsReflexive.add(prop);
	superPropsReflexive.addAll(superProps);
	return superPropsReflexive;
}
 
Example #17
Source File: OWLGraphWrapperEdgesExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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;
}
 
Example #18
Source File: GraphReasoner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public NodeSet<OWLObjectPropertyExpression> getSubObjectProperties(
		OWLObjectPropertyExpression pe, boolean direct)
		throws InconsistentOntologyException, FreshEntitiesException,
		ReasonerInterruptedException, TimeOutException {
	// TODO Auto-generated method stub
	return null;
}
 
Example #19
Source File: OWLGraphWrapperEdgesExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Default constructor. 
 * @param ontology 		The <code>OWLOntology</code> that this object wraps.
 */
public OWLGraphWrapperEdgesExtended(OWLOntology ontology) {
	super(ontology);
   	this.subPropertyCache = new HashMap<OWLObjectPropertyExpression, 
   			LinkedHashSet<OWLObjectPropertyExpression>>();
       this.subAnnotationPropertyCache = new HashMap<OWLAnnotationProperty, 
               LinkedHashSet<OWLAnnotationProperty>>();
   	this.superPropertyCache = new HashMap<OWLObjectPropertyExpression, 
   			LinkedHashSet<OWLObjectPropertyExpression>>();
   	this.gciRelationBySource = null;
       this.gciRelationByTarget = null;
       this.outgoingEdgesClosureWithGCIBySource = null;
}
 
Example #20
Source File: GraphOwlVisitor.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
@Override
public Void visit(OWLSubPropertyChainOfAxiom axiom) {
  long chain = getOrCreateNode(getIri(axiom.getSuperProperty()));
  int i = 0;
  for (OWLObjectPropertyExpression property : axiom.getPropertyChain()) {
    long link = getOrCreateNode(getIri(property));
    long relationship =
        getOrCreateRelationship(chain, link, OwlRelationships.OWL_PROPERTY_CHAIN_AXIOM);
    graph.setRelationshipProperty(relationship, "order", i++);
  }
  return null;
}
 
Example #21
Source File: OwlHelper.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Set<OWLObjectPropertyExpression> getSuperProperties(OWLObjectPropertyExpression prop, OWLOntology ont) {
	Set<OWLObjectPropertyExpression> result = new HashSet<>();
	Set<OWLSubObjectPropertyOfAxiom> axioms = ont.getObjectSubPropertyAxiomsForSubProperty(prop);
	for (OWLSubPropertyAxiom<OWLObjectPropertyExpression> axiom : axioms) {
		result.add(axiom.getSuperProperty());
	}
	return result;
}
 
Example #22
Source File: CompositionalClassPredictor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private boolean getReachableOWLClasses(OWLClassExpression c, Set<OWLClassExpression> elts) {
	if (c instanceof OWLObjectIntersectionOf) {
		for (OWLClassExpression x : ((OWLObjectIntersectionOf)c).getOperands()) {
			if (x instanceof OWLClass) {
				elts.add((OWLClass) x);
			}
			else if (x instanceof OWLObjectSomeValuesFrom) {
				OWLObjectPropertyExpression p = ((OWLObjectSomeValuesFrom)x).getProperty();
				String pLabel = getGraph().getLabel(p);
				if (pLabel != null && pLabel.contains("regulates")) {
					// fairly hacky:
					//  fail on this for now - no inference for regulates
					//elts.add(x);
					return false;
				}
				else {
					OWLClassExpression filler = ((OWLObjectSomeValuesFrom)x).getFiller();
					if (!getReachableOWLClasses( filler, elts)) {
						return false;
					}
				}
			}
			else {
				return false;
			}

		}
		return true;
	}
	else if (c instanceof OWLClass) {
		elts.add((OWLClass) c);
		return true;
	}
	return false;
}
 
Example #23
Source File: GraphOwlVisitor.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
long getObjectPropertyRelationship(
    OWLPropertyAssertionAxiom<OWLObjectPropertyExpression, OWLIndividual> axiom) {
  long subject = getOrCreateNode(getIri(axiom.getSubject()));
  String property = getIri(axiom.getProperty());
  long object = getOrCreateNode(getIri(axiom.getObject()));
  RelationshipType type = RelationshipType.withName(property.toString());

  long relationship = getOrCreateRelationship(subject, object, type);
  graph.setRelationshipProperty(relationship, CommonProperties.IRI, property.toString());
  return relationship;
}
 
Example #24
Source File: AbstractSimPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public String generateLabel(OWLClassExpression x) {
	StringBuffer sb = new StringBuffer();
	if (x instanceof OWLObjectSomeValuesFrom) {
		OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom) x;	
		OWLObjectPropertyExpression p = svf.getProperty();
		if (propertyToFormatMap.containsKey(p)) {
			return String.format(propertyToFormatMap.get(p), generateLabel(svf.getFiller()));
		}
		else {
			String pStr = p.toString();
			if (p instanceof OWLEntity) {
				pStr = getAnyLabel((OWLEntity)p);
			}
			return pStr + " some "+generateLabel(svf.getFiller());
		}
	}
	else if (x instanceof OWLObjectIntersectionOf) {
		OWLObjectIntersectionOf oio = (OWLObjectIntersectionOf) x;
		for (OWLClassExpression op : oio.getOperands()) {
			if (sb.length() > 0) {
				sb.append(" and ");
			}
			sb.append(generateLabel(op));
		}
		return sb.toString();
	}
	else if (x instanceof OWLClass) {
		return this.getAnyLabel((OWLClass) x);
	}
	return x.toString();
}
 
Example #25
Source File: OWLInAboxTranslator.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Transitive(R) ==> Transitive(R')
 * 
 * @param ax
 */
private void tr(OWLObjectPropertyCharacteristicAxiom ax) {
	if (ax instanceof OWLTransitiveObjectPropertyAxiom) {
		OWLObjectPropertyExpression pt = trTypeLevel(ax.getProperty());
		if (pt instanceof OWLObjectProperty) {
			add(getOWLDataFactory().getOWLTransitiveObjectPropertyAxiom(pt));
		}
	}
	add(ax); // pass-through
}
 
Example #26
Source File: OWLInAboxTranslator.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void tr(OWLSubPropertyChainOfAxiom ax) {
	List<OWLObjectPropertyExpression> chain = new ArrayList<OWLObjectPropertyExpression>();
	for (OWLObjectPropertyExpression p : ax.getPropertyChain()) {
		chain.add(trTypeLevel(p));
	}
	add(getOWLDataFactory().getOWLSubPropertyChainOfAxiom(chain, trTypeLevel(ax.getSuperProperty())));
}
 
Example #27
Source File: PropertyViewOntologyBuilder.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public OWLClassExpression expandPropertyChain(List<OWLObjectPropertyExpression> chain, OWLClassExpression t) {
	OWLClassExpression x = t;
	for (int i = chain.size()-1; i>=0;	i--) {
		x = this.owlDataFactory.getOWLObjectSomeValuesFrom(chain.get(i),t);
		t = x;
	}
	return x;
}
 
Example #28
Source File: AbstractOBOSimPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void addPropertyChain(String p1, String p2, String pInferred) {

		List<OWLObjectPropertyExpression> chain = new ArrayList<OWLObjectPropertyExpression>();
		chain.add(getOWLObjectPropertyViaOBOSuffix(p1));
		chain.add(getOWLObjectPropertyViaOBOSuffix(p2));
				// has_phenotype <- has_phenotype o has_part
		addAxiomToOutput(getOWLDataFactory().getOWLSubPropertyChainOfAxiom(chain , getOWLObjectPropertyViaOBOSuffix(pInferred)), false);
		
	}
 
Example #29
Source File: PhenoSimHQEPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void addPhenotypePropertyChain() {
	OWLObjectProperty hpart = getOWLObjectPropertyViaOBOSuffix(HAS_PART);
	OWLObjectProperty hphen = getOWLObjectPropertyViaOBOSuffix(HAS_PHENOTYPE);

	List<OWLObjectPropertyExpression> chain = new ArrayList<OWLObjectPropertyExpression>();
	chain.add(hphen);
	chain.add(hpart);
	// has_phenotype <- has_phenotype o has_part
	addAxiomToOutput(getOWLDataFactory().getOWLSubPropertyChainOfAxiom(chain , hphen), false);
}
 
Example #30
Source File: AutomaticSimPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void gatherProperties(OWLObjectPropertyExpression pe) {
	if (pe instanceof OWLObjectProperty) {
		viewProperties.add((OWLObjectProperty) pe);
	}
	else {
		// TODO
	}
	
}