org.semanticweb.owlapi.model.OWLNamedObject Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLNamedObject. 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: AbstractOWLOntologyLoader.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
private void indexEquivalentRelations(OWLClass owlClass) throws OWLOntologyCreationException {
    OWLReasoner reasoner = getOWLReasoner(ontology);

    // get direct children
    addEquivalentTerms(owlClass.getIRI(),
            reasoner.getEquivalentClasses(owlClass).getEntities().stream()
                    .map(OWLNamedObject::getIRI)
                    .collect(Collectors.toSet()));

    Set<String> relatedDescriptions = new HashSet<>();

    for (OWLClassExpression expression : owlClass.getEquivalentClasses(getManager().getOntologies())) {
        if (expression.isAnonymous()) {
            relatedDescriptions.add(manSyntaxRenderer.render(expression));
        }
    }

    if (!relatedDescriptions.isEmpty()) {
        addEquivalentClassDescriptions(owlClass.getIRI(), relatedDescriptions);
    }

}
 
Example #2
Source File: CompactGraphClosureRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void render(OWLGraphEdge e) {
	if (!(e.getTarget() instanceof OWLNamedObject)) {
		return;
	}
	sep();
	int n = 0;
	for (OWLQuantifiedProperty qp : e.getQuantifiedPropertyList()) {
		if (n>0) {
			stream.print(",");
		}
		if (qp.hasProperty()) {
			crender(qp.getProperty());
			stream.print(" ");
		}
		stream.print(qp.getQuantifier());

		n++;
	}
	stream.print(",");
	crender(e.getTarget());
	stream.print(","+e.getDistance());
}
 
Example #3
Source File: OWLGraphWrapperEdgesAdvanced.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Create a category for a given named object. There are three options:
 * <ol>
 *  <li>use id space to lookup category string in the id space map</li>
 *  <li>use OBO namespace, if the is space is in useNamespace set</li>
 *  <li>fallback: use id space prefix (string before first colon)</li>
 * </ol>
 * 
 * @param named
 * @param idspaceMappings
 * @param useNamespace
 * @param useFallback if false ignore fall-back
 * @return category or null
 */
public String categorizeObject(OWLNamedObject named,  Map<String,String> idspaceMappings, 
		Set<String> useNamespace, boolean useFallback){
	String result = null;
	String idSpace = getIdspace(named.getIRI());
	if (idSpace != null) {
		if (idspaceMappings.containsKey(idSpace)) {
			result = idspaceMappings.get(idSpace);
		}
		else if (useNamespace.contains(idSpace)) {
			result = getNamespace(named);
		}
		else if (useFallback){
			result = idSpace;
		}
		// normalize
		if (result != null) {
			// replace backslash, dash, underscore, or slash with a whitespace
			result = result.replaceAll("[\\-_/]", " ");
		}
	}
	return result;
}
 
Example #4
Source File: TableRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void render(OWLGraphWrapper g) {
	
	if (isWriteHeader) {
		print("IRI");
		sep();
		print("label");
		sep();
		print("definition");
		nl();
	}
	graph = g;
	
	Set<OWLObject> objs = new HashSet<OWLObject>(g.getSourceOntology().getClassesInSignature(Imports.EXCLUDED));
	objs.addAll(g.getSourceOntology().getIndividualsInSignature(Imports.EXCLUDED));

	for (OWLObject obj : objs) {
		if (obj.equals(g.getDataFactory().getOWLNothing()))
			continue;
		if (obj.equals(g.getDataFactory().getOWLThing()))
			continue;
		if (obj instanceof OWLNamedObject)
			render((OWLNamedObject)obj);
	}
	stream.close();
}
 
Example #5
Source File: GraphClosureRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void render(OWLGraphEdge e) {
	if (!(e.getTarget() instanceof OWLNamedObject)) {
		return;
	}
	print(e.getSource());
	sep();
	int n = 0;
	for (OWLQuantifiedProperty qp : e.getQuantifiedPropertyList()) {
		if (n>0) {
			stream.print(", ");
		}
		if (qp.hasProperty()) {
			print(qp.getProperty());
			stream.print(" ");
		}
		stream.print(qp.getQuantifier());

		n++;
	}
	sep();
	stream.print(e.getDistance());
	sep();
	print(e.getTarget());
	nl();

}
 
Example #6
Source File: EdgeTableRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void render(OWLGraphWrapper g) {
	graph = g;
	
	Set<OWLObject> objs = new HashSet<OWLObject>(g.getSourceOntology().getClassesInSignature(Imports.EXCLUDED));
	objs.addAll(g.getSourceOntology().getIndividualsInSignature(Imports.EXCLUDED));

	for (OWLObject obj : objs) {
		if (obj.equals(g.getDataFactory().getOWLNothing()))
			continue;
		if (obj.equals(g.getDataFactory().getOWLThing()))
			continue;
		if (obj instanceof OWLNamedObject)
			render((OWLNamedObject)obj);
	}
	stream.close();
}
 
Example #7
Source File: EdgeTableRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void render(OWLNamedObject obj) {
	String id = graph.getIdentifier(obj);
	for (OWLGraphEdge e : graph.getOutgoingEdges(obj)) {
		OWLQuantifiedProperty qp = e.getSingleQuantifiedProperty();
		String r;
		if (qp.getProperty() != null) {
			r = graph.getIdentifier(qp.getProperty());
		}
		else if (qp.isSubClassOf()) {
			r = "is_a";
		}
		else if (qp.isInstanceOf()) {
			r = "a";
		}
		else {
			continue;
		}
		print(id);
		sep();
		print(r);
		sep();
		print(graph.getIdentifier(e.getTarget()));
		nl();
		
	}
}
 
Example #8
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private <T extends OWLNamedObject> T getDeterministicRepresentative(Node<T> n) {
	T rep = null;
	// find lexical maximal entry as representative node
	for (T entry : n) {
		if (rep == null) {
			rep = entry;
		}
		else {
			// use IRI for comparison
			IRI repIRI = rep.getIRI();
			IRI entryIRI = entry.getIRI();
			if (entryIRI.compareTo(repIRI) > 0) {
				rep = entry;
			}
		}
	}
	return rep;
}
 
Example #9
Source File: OWLGraphGOTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testGOGraph2() throws Exception{

	// 
	OWLObject x2 = wrapper.getOWLClassByIdentifier("GO:0007399");

	// In this loop we're checking that GO:0007399, known from above, has GO:0022008 as a part_of child somewhere.
	// Anything else is an error.
	boolean kid_p = false;
	final Set<OWLGraphEdge> incomingEdges = wrapper.getIncomingEdges(x2);
	for (OWLGraphEdge e : incomingEdges) {
		OWLObject s = e.getSource();
		
		if (s instanceof OWLNamedObject){				

			// Figure out subject the bits.
			String subjectID = wrapper.getIdentifier(s);
			//String subjectLabel = wrapper.getLabel(s);
			String elabel = wrapper.getEdgeLabel(e);

			if( subjectID.equals("GO:0022008") ){
				assertEquals("GO:0022008 part_of child of GO_0007399 (saw: " + elabel + ")", elabel, "part_of");
				kid_p = true;
			}
		}
	}
	assertTrue("saw GO:0022008 as a child of GO_0007399:", kid_p);
}
 
Example #10
Source File: OWLGraphGOTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testGOGraph1() throws Exception{
	
	//
	OWLObject x1 = wrapper.getOWLClassByIdentifier("GO:0022008");

	// In this loop we're checking that GO:0022008 has two known parents, one is_a and one part_of.
	// Anything else is an error.
	for (OWLGraphEdge e : wrapper.getOutgoingEdges(x1)) {
		OWLObject t = e.getTarget();

		if (t instanceof OWLNamedObject){				

			// Figure out object the bits.
			String objectID = wrapper.getIdentifier(t);
			//String objectLabel = wrapper.getLabel(t);
			String elabel = wrapper.getEdgeLabel(e);

			if( objectID.equals("GO:0030154") ){
				assertEquals("GO:0030154 part_of parent of GO_0022008:", elabel, "is_a");					
			}else if( objectID.equals("GO:0007399") ){
				assertEquals("GO:0007399 part_of parent of GO_0022008:", elabel, "part_of");
			}else{
				fail("not a parent of GO_0022008: " + objectID);
			}
		}
	}
}
 
Example #11
Source File: OWLGraphWrapperEdgeTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testEdgesNR() throws Exception {
    OWLGraphWrapper wrapper = getGraph("graph/lf-apoptosis.obo");
    
    OWLObject x1 = wrapper.getOWLClassByIdentifier("GO:1990086");
    
    // we expect this to be true by default
    assertTrue(wrapper.config.isGraphReasonedAndRelaxed);
    
    int n=0;
    for (OWLGraphEdge e : wrapper.getOutgoingEdges(x1)) {
        n++;
        OWLObject t = e.getTarget();

        if (t instanceof OWLNamedObject){        
            

            // Figure out object the bits.
            String objectID = wrapper.getIdentifier(t);
            String elabel = wrapper.getEdgeLabel(e);
            
            if( objectID.equals("GO:1904019") ){
                assertEquals("expected direct superclass found", elabel, "is_a");                  
               } else if( objectID.equals("CL:0011004") ){
                   assertEquals("expected occurs_in link found", elabel, "occurs in");
               } else if( objectID.equals("GO:0006915") ){
                   fail("indirect superclasses not expcted with graph is reasoned and reduced");
            }else{
                fail("I didn't expect this: " + objectID);
            }
        }
    }
    assertEquals("I expected to get 2 links", 2, n);

    
}
 
Example #12
Source File: MarkdownRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void renderControlledAnnotations(OWLNamedObject c) {
	Set<OWLAnnotationAssertionAxiom> annotationAxioms = 
			ontology.getAnnotationAssertionAxioms(c.getIRI());
	renderAnnotationAxiom("Label", OWLRDFVocabulary.RDFS_LABEL.getIRI(), annotationAxioms);
	renderAnnotationAxiom("Definition", Obo2OWLVocabulary.IRI_IAO_0000115.getIRI(), annotationAxioms);
	renderAnnotationAxiom("Comment", OWLRDFVocabulary.RDFS_COMMENT.getIRI(), annotationAxioms);

	renderSection("Synonyms");

	renderAnnotationAxioms("", 
			Obo2OWLVocabulary.IRI_OIO_hasExactSynonym.getIRI(), 
			annotationAxioms);
	renderAnnotationAxioms("", 
			Obo2OWLVocabulary.IRI_OIO_hasBroadSynonym.getIRI(), 
			annotationAxioms);
	renderAnnotationAxioms("", 
			Obo2OWLVocabulary.IRI_OIO_hasNarrowSynonym.getIRI(), 
			annotationAxioms);
	renderAnnotationAxioms("", 
			Obo2OWLVocabulary.IRI_OIO_hasRelatedSynonym.getIRI(), 
			annotationAxioms);

	renderSection("Cross-references");

	renderAnnotationAxioms("", 
			Obo2OWLVocabulary.IRI_OIO_hasDbXref.getIRI(), 
			annotationAxioms);

	renderSection("Subsets");

	renderAnnotationAxioms("", 
			Obo2OWLVocabulary.IRI_OIO_inSubset.getIRI(), 
			annotationAxioms);		
}
 
Example #13
Source File: MarkdownRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private String getLabelOrId(OWLNamedObject ob) {
	String label = getLabel(ob);
	if (label == null) {
		return getId(ob);
	}
	else {
		return label;
	}
}
 
Example #14
Source File: MarkdownRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private String getLabel(OWLNamedObject ob) {
	String label = null;
	for (OWLAnnotationAssertionAxiom aaa : ontology.getAnnotationAssertionAxioms(ob.getIRI())) {
		if (aaa.getProperty().isLabel()) {
			label = generateText(aaa.getValue());
			break;
		}
	}
	return label;

}
 
Example #15
Source File: TableRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void render(OWLNamedObject obj) {
	print(obj.getIRI().toString());
	sep();
	print(graph.getLabel(obj));
	sep();
	print(graph.getDef(obj));
	nl();
}
 
Example #16
Source File: MarkdownRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private String getMarkdownLink(OWLObject obj, String pathToRoot) {
	if (obj instanceof OWLNamedObject) {
		OWLNamedObject s = (OWLNamedObject)obj;
		String id = getId(s);
		String rpath = pathToRoot+getRelativePath(id);
		if (rpath.length() == 0) {
			// everything is in same directory; no need for "/"
			return "["+getLabelOrId(s)+"]("+id+".md)";
		}
		return "["+getLabelOrId(s)+"]("+rpath+"/"+id+".md)";
	}
	else {
		return generateText(obj);
	}
}
 
Example #17
Source File: NormalizedOWLQLTbox.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * returns the key associated with a property expression
 * @param pe
 * @return
 */
public static String getKey(OWLPropertyExpression pe) {
	if (pe.isObjectPropertyExpression()) {
		pe = ((OWLObjectPropertyExpression) pe).getSimplified();
	}
	if (!pe.isAnonymous()) {
		return ((OWLNamedObject) pe).getIRI().toString();
	} else {
		OWLObjectInverseOf ope = (OWLObjectInverseOf) pe;
		OWLObjectProperty op = (OWLObjectProperty) ope.getInverse();
		return op.getIRI().toString();
		
	}
}
 
Example #18
Source File: ChadoGraphClosureRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void render(OWLGraphEdge e) {
	if (!(e.getTarget() instanceof OWLNamedObject)) {
		return;
	}
	if (e.getQuantifiedPropertyList().size() != 1 && !isChain) {
		return;
	}
	StringBuffer rel = new StringBuffer("");
	int n = 0;
	for (OWLQuantifiedProperty qp : e.getQuantifiedPropertyList()) {
		//OWLQuantifiedProperty qp = e.getQuantifiedPropertyList().get(0);
		if (n > 0) {
			rel.append(",");
		}
		if (qp.isSubClassOf()) {
			rel.append("OBO_REL:is_a");
		}
		else if (qp.isSomeValuesFrom()) {
			rel.append(graph.getIdentifier(qp.getProperty()));
		}
		else {
			return;
		}
		n++;
	}
	stream.print(graph.getIdentifier(e.getSource()));
	sep();

	stream.print(rel);
	sep();
	stream.print(e.getDistance());
	sep();
	stream.print(graph.getIdentifier(e.getTarget()));
	nl();

}
 
Example #19
Source File: CompactGraphClosureRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void crender(OWLObject obj) {
	String s = ((OWLNamedObject) obj).getIRI().toString();
	if (s.startsWith(base)) {
		stream.print(s.replaceFirst(base, ""));
	}
	else {
		stream.print(s);
	}
}
 
Example #20
Source File: OWLHandler.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void output(OWLObject obj) throws IOException {
	String fmt = getFormat();
	if (fmt.equals("pretty"))
		outputLine(owlpp.render(obj));
	else if (fmt.equals("json")) {
		//JSONPrinter jsonp = new JSONPrinter(response.getWriter());
		//jsonp.render(obj);
		cache(obj);
	}
	else if (isOWLOntologyFormat()) {
		// TODO - place objects into ontology, eg as subclass of result
		outputLine(obj.toString());
	}
	else {
		// TODO - do this more generically, e.g. within owlpp
		if (getParam("idstyle") != null && obj instanceof OWLNamedObject) {
			if (getParam("idstyle").toLowerCase().equals("obo")) {
				outputLine(graph.getIdentifier(obj));
			}
			else {
				outputLine(obj.toString());
			}
		}
		else 
			print(obj.toString());
	}
}
 
Example #21
Source File: OWLGraphWrapperEdgesExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Similar to {@link #getNamedAncestorsWithGCI(OWLObject)} but returning only 
 * {@code OWLClass}es.
 * @param sourceObject  An {@code OWLObject} for which we want to retrieve ancestors 
 *                      through classical relations and through OBO GCI relations.
 * @return  A {@code Set} of {@code OWLClass}s that are ancestors of 
 *          {@code sourceObject} through classical relations and through OBO GCI relations.
 */
public Set<OWLClass> getOWLClassAncestorsWithGCI(OWLObject sourceObject) {
    Set<OWLClass> ancestors = new HashSet<OWLClass>();
    for (OWLNamedObject anc: this.getNamedAncestorsWithGCI(sourceObject)) {
        if (anc instanceof OWLClass) {
            ancestors.add((OWLClass) anc);
        }
    }
    return ancestors;
}
 
Example #22
Source File: OWLGraphWrapperEdges.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Gets all ancestors that are OWLNamedObjects
 * <p>
 * i.e. excludes anonymous class expressions
 * 
 * @param x
 * @return set of named ancestors
 */
public Set<OWLObject> getNamedAncestors(OWLObject x) {
	Set<OWLObject> ancs = new HashSet<OWLObject>();
	for (OWLGraphEdge e : getOutgoingEdgesClosure(x)) {
		if (e.getTarget() instanceof OWLNamedObject)
			ancs.add(e.getTarget());
	}
	return ancs;
}
 
Example #23
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Generate a OboGraphs JSON ontology blob for the local axioms for an object.
 * 
 * This will include
 * 
 *  - all logical axioms about the object
 *  - all annotations for all entities in the signature
 *  
 * In other words, direct parents plus labels and other metadata on all entities
 * 
 * @param obj
 * @return JSON string
 * @throws JsonProcessingException
 * @throws OWLOntologyCreationException
 */
public String getOboGraphJSONString(OWLObject obj) throws JsonProcessingException, OWLOntologyCreationException {
	FromOwl fromOwl = new FromOwl();
	OWLOntologyManager m = sourceOntology.getOWLOntologyManager();
	if (obj instanceof OWLNamedObject) {
		OWLNamedObject nobj = (OWLNamedObject)obj;
		OWLOntology ont = m.createOntology(nobj.getIRI());
		Set<OWLAxiom> axioms = new HashSet<>();
		if (nobj instanceof OWLClass) {
			axioms.addAll(sourceOntology.getAxioms((OWLClass)nobj, Imports.INCLUDED));
		}
		else if (nobj instanceof OWLObjectProperty) {
			axioms.addAll(sourceOntology.getAxioms((OWLObjectProperty)nobj, Imports.INCLUDED));
		}
		m.addAxioms(ont, axioms);
		axioms = new HashSet<>();
		for (OWLEntity e : ont.getSignature()) {
			axioms.addAll(sourceOntology.getAnnotationAssertionAxioms(e.getIRI()));
		}
		axioms.addAll(sourceOntology.getAnnotationAssertionAxioms(nobj.getIRI()));
		m.addAxioms(ont, axioms);

		GraphDocument gd = fromOwl.generateGraphDocument(ont);
		return OgJsonGenerator.render(gd);
	}
	else {
		return "{}";
	}

}
 
Example #24
Source File: Sim2CommandRunner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * by default, i and j are comparable only if i>j (i.e. self and symmetric
 * comparisons not permitted). If {@link SimConfigurationProperty#bidirectional}
 * is true, then self and symmetric are permitted.
 * 
 * if {@link SimConfigurationProperty#compare} is set to a string "A, B" then
 * only comparisons between objects with ID spaces A and B are compared.
 * 
 * This method can be applied to classes or to individuals. It is designed
 * to be use in an all x all comparison of either classes or individuals
 * 
 * it can be called with a null value for j. If j==null, then isComparable
 * is true if i is comparable to anything. This will fail if the first
 * entry in the compare property does not match the ID space of i.
 * 
 * @param i - not null
 * @param j - may be null
 * @return true if i and j are comparable
 */
private boolean isComparable(OWLNamedObject i, OWLNamedObject j) {
	if (g.getIsObsolete(i))
		return false;
	if (j != null && g.getIsObsolete(j))
		return false;
	String cmp = getProperty(SimConfigurationProperty.compare);
	if (cmp == null) {
		if (j==null)
			return true;
		Boolean bidi = getPropertyAsBoolean(SimConfigurationProperty.bidirectional);
		if (bidi == null || !bidi) {
			return i.compareTo(j) > 0;
		}
		else {
			return true;
		}

	} else {
		String[] idspaces = cmp.split(",");
		if (i.getIRI().toString().contains("/" + idspaces[0] + "_")
				&& (j==null || j.getIRI().toString().contains("/" + idspaces[1] + "_"))) {
			return true;
		} else {
			return false;
		}
	}
}
 
Example #25
Source File: SimEngine.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Set<OWLObject> makeNonRedundant(Set<OWLObject> objs, boolean prioritizeNamedClasses) {
	// redundant set
	Set<OWLObject> rs = new HashSet<OWLObject>();

	// check each object to see if it's redundant
	for (OWLObject obj : objs) {
		Set<OWLObject> ancs = getAncestors(obj);
		ancs.retainAll(objs);
		ancs.remove(obj);

		for (OWLObject anc : ancs) {
			// we know that obj<anc,
			// anc is therefore redundant
			// (if it appears in the original set)

			// the exception is for cycles
			if (getAncestors(anc).contains(obj)) {
				// we have a cycle: anc subsumed by obj via the directly preceding test;
				//                  obj subsumed by anc via the getAncestors call

				// for cycles, keep both unless we want to prioritize named classes
				if (prioritizeNamedClasses) {
					if (anc instanceof OWLAnonymousClassExpression && obj instanceof OWLNamedObject) {
						rs.add(anc);
					}
				}
			}
			else {
				// not a cycle - schedule redundant class for removal
				rs.add(anc);
			}
		}
	}
	objs.removeAll(rs);
	return objs;
}
 
Example #26
Source File: Similarity.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void print(PrintStream s, OWLObject x) {
	if (x instanceof OWLNamedObject) {
		String label = simEngine.getGraph().getLabel(x);
		if (label == null)
			s.print(x.toString());
		else
			s.print(x.toString()+" \""+label+"\"");
	}
	else {
		printDescription(s,x);
	}
}
 
Example #27
Source File: Mooncat.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Check, if the named object has the annotation property IAO:0000412, 
 * declaring the object as imported.
 * 
 * @param named
 * @param ontology
 * @return true if the item has the annotation property IAO:0000412
 */
public static boolean isImportMarkedEntity(OWLNamedObject named, OWLOntology ontology) {
	for (OWLAnnotationAssertionAxiom axiom : ontology.getAnnotationAssertionAxioms(named.getIRI())) {
		OWLAnnotationProperty property = axiom.getProperty();
		if (importedMarkerIRI.equals(property.getIRI())) {
			return true;
		}
	}
	return false;
}
 
Example #28
Source File: BridgeExtractor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private String getOntId(OWLNamedObject c) {
	String iriStr = c.getIRI().toString();
	iriStr = iriStr.replaceAll(".*/", ""); // up to final slash
	iriStr = iriStr.replaceAll("_\\d+",""); // assumes obo-style
	//LOG.info(c + " ==> "+iriStr);
	return iriStr.toLowerCase();
}
 
Example #29
Source File: TemplatedTransformer.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private OWLClassExpression replaceVariables(OWLClassExpression inx,
		BindingSet bset) {
	if (inx instanceof OWLNamedObject) {
		IRI y = replaceIRI(((OWLNamedObject)inx).getIRI(), bset);
		if (inx instanceof OWLClass) {
			return getOWLDataFactory().getOWLClass(y);
		}
	}
	else if (inx instanceof OWLObjectSomeValuesFrom) {
		OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom)inx;
		return getOWLDataFactory().getOWLObjectSomeValuesFrom(
				replaceVariables(svf.getProperty(),bset),
				replaceVariables(svf.getFiller(),bset));

	}
	else if (inx instanceof OWLObjectIntersectionOf) {
		Set<OWLClassExpression> es = new HashSet<OWLClassExpression>();
		for (OWLClassExpression e : ((OWLObjectIntersectionOf)inx).getOperands()) {
			es.add(replaceVariables(e, bset));
		}
		return getOWLDataFactory().getOWLObjectIntersectionOf(es);
	}
	else {
		
	}
	return null;
}
 
Example #30
Source File: OWLGraphWrapperEdgesAdvanced.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Return the names of the asserted subClasses of the cls (Class) 
 * passed in the argument
 * 
 * 
 * @param cls
 * @return array of of strings
 */
@Deprecated
public String[] getSubClassesNames(OWLClass cls){
	Set<OWLClassExpression> st = OwlHelper.getSubClasses(cls, sourceOntology);


	List<String> ar = new ArrayList<String>();
	for(OWLClassExpression ce: st){
		if(ce instanceof OWLNamedObject)
			ar.add(getLabel(ce)); 
	}

	return ar.toArray(new String[ar.size()]);
}