Java Code Examples for org.semanticweb.owlapi.model.OWLObject#equals()

The following examples show how to use org.semanticweb.owlapi.model.OWLObject#equals() . 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: SimEngine.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void calculateSimilarityAllByAll(String similarityAlgorithmName, Double minScore) throws SimilarityAlgorithmException {
	Set<OWLObject> objs = graph.getAllOWLObjects();
	if (comparisonSuperclass != null) {
		System.out.println("finding descendants of :"+comparisonSuperclass);
		objs = graph.getDescendants(comparisonSuperclass);
		System.out.println("  descendants  :"+objs.size());
	}
	for (OWLObject a : objs) {
		if (excludeObjectFromComparison(a))
			continue;
		for (OWLObject b : graph.getAllOWLObjects()) {
			if (a.equals(b))
				continue;
			if (excludeObjectFromComparison(b))
				continue;
			System.out.println("COMPARE:"+label(a)+" -vs- "+label(b));
			Similarity s = this.getSimilarityAlgorithm(similarityAlgorithmName);
			calculateSimilarity(s,a,b);
			Double sc = s.score;
			if (minScore == null || sc > minScore) {
				System.out.println(a+" "+b+" = "+sc);
				s.print();
			}
		}
	}
}
 
Example 2
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 3
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 4
Source File: OWLGraphWrapperEdges.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public boolean isExcludeEdge(OWLGraphEdge edge) {

		if (config.graphEdgeExcludeSet != null ||
				config.graphEdgeIncludeSet != null) {
			for (OWLQuantifiedProperty qp : edge.getQuantifiedPropertyList()) {
				if (isExcluded(qp)) {
					LOG.debug("excluded:"+edge+" based on: "+qp);
					return true;
				}
			}
		}

		OWLObject t = edge.getTarget();
		if (t != null) {
			if (t instanceof OWLNamedObject) {
				OWLNamedObject nt = (OWLNamedObject) t;
				// TODO
				if (nt.getIRI().toString().startsWith("http://www.ifomis.org/bfo"))
					return true;
				if (t instanceof OWLClass && t.equals(getDataFactory().getOWLThing())) {
					return true;
				}

			}
		}
		return false;
	}
 
Example 5
Source File: Ancestors2Test.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testDescendantsQuery() throws Exception {
	OWLGraphWrapper  g =  getOntologyWrapper();
	OWLClass c = g.getOWLClass("http://example.org#organism");
	OWLObject i = g.getOWLObject("http://example.org#o1");
	boolean ok = false;
	for (OWLObject e : g.queryDescendants(c)) {
		if (RENDER_ONTOLOGY_FLAG) {
			System.out.println("ORG:" + e);
		}
		if (e.equals(i))
			ok = true;
	}
	assertTrue(ok);
}
 
Example 6
Source File: AncestorsTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testDescendantsQuery() throws Exception {
	OWLGraphWrapper  g =  getOntologyWrapper();
	OWLClass c = g.getOWLClass("http://purl.obolibrary.org/obo/NCBITaxon_10090");
	OWLObject i = g.getOWLObject("http://purl.obolibrary.org/obo/MGI_101761");
	System.out.println("Expecting "+i);
	boolean ok = false;
	for (OWLObject e : g.queryDescendants(c)) {
		System.out.println("ORG:"+e);
		if (e.equals(i))
			ok = true;
	}
	assertTrue(ok);
}
 
Example 7
Source File: ReleaseInferenceTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testDescendantsQuery() throws Exception {
	OWLGraphWrapper  g =  getOntologyWrapper();
	OWLClass c = g.getOWLClass("http://purl.obolibrary.org/obo/NCBITaxon_10090");
	OWLObject i = g.getOWLObject("http://purl.obolibrary.org/obo/MGI_101761");
	System.out.println("Expecting "+i);
	boolean ok = false;
	for (OWLObject e : g.queryDescendants(c)) {
		System.out.println("ORG:"+e);
		if (e.equals(i))
			ok = true;
	}
	assertTrue(ok);
}
 
Example 8
Source File: AncestorsTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testDescendantsQuery() throws Exception {
	OWLGraphWrapper  g =  getOntologyWrapper();
	OWLClass c = g.getOWLClass("http://purl.obolibrary.org/obo/NCBITaxon_10090");
	OWLObject i = g.getOWLObject("http://purl.obolibrary.org/obo/MGI_101761");
	System.out.println("Expecting "+i);
	boolean ok = false;
	for (OWLObject e : g.queryDescendants(c)) {
		System.out.println("ORG:"+e);
		if (e.equals(i))
			ok = true;
	}
	assertTrue(ok);
}
 
Example 9
Source File: SimSearch.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Given a query object (e.g. organism, disorder, gene), find candidate hit objects based
 * on simple attribute overlap
 * 
 * @param queryObj
 * @return list of objects
 */
public List<OWLObject> search(OWLObject queryObj) {
	List<OWLObject> hits = new ArrayList<OWLObject>(maxHits);
	System.out.println("gettings atts for "+queryObj+" -- "+simEngine.comparisonProperty);
	Set<OWLObject> atts = simEngine.getAttributeClosureFor(queryObj);
	System.out.println("all atts: "+atts.size());
	if (atts.size() == 0)
		return hits;
	
	// only compare using significant atts;
	// we don't do the same test on candidates as these will be removed by the
	// intersection operation. they will have a small effect on the score, as
	// we don't divide by the union, but instead the sum of sizes
	atts = filterNonSignificantAttributes(atts);
	System.out.println("filtered atts: "+atts.size());

	//bloomFilter = new BloomFilter<OWLObject>(0.05, atts.size());
	//bloomFilter.addAll(atts);
			
	SortedMap<Integer,Set<OWLObject>> scoreCandidateMap = new TreeMap<Integer,Set<OWLObject>>();
	
	for (OWLObject candidate : getCandidates()) {
		if (candidate.equals(queryObj))
			continue;
		Set<OWLObject> iAtts = simEngine.getAttributeClosureFor(candidate);
		//Set<OWLObject> iAtts = simEngine.getGraph().getAncestors(candidate);

		if (iAtts.size() == 0)
			continue;
		int cAttsSize = iAtts.size();

		iAtts.retainAll(atts);
		//Collection<OWLObject> iAtts = bloomFilter.intersection(cAtts);
		
		// simJ, one-sided, scaled by 1000
		// negate to ensure largest first
		//Integer score = - (iAtts.size() * 1000 / cAttsSize);
		
		// this biases us towards genes with large numbers of annotations,
		// but it is better at finding the models that share all features
		Integer score = - iAtts.size();
		if (!scoreCandidateMap.containsKey(score)) 
			scoreCandidateMap.put(score, new HashSet<OWLObject>());
		scoreCandidateMap.get(score).add(candidate);
		reporter.report(this,"query_candidate_overlap_total",queryObj,candidate,iAtts.size(),cAttsSize);
	}
	
	int n = 0;
	for (Set<OWLObject> cs : scoreCandidateMap.values()) {
		n += cs.size();
		hits.addAll(cs);
	}
	
	n = 0;
	for (OWLObject hit : hits) {
		n++;
		reporter.report(this,"query_hit_rank_threshold",queryObj,hit,n,maxHits);
	}
	if (hits.size() > maxHits)
		hits = hits.subList(0, maxHits);
	


	return hits;
}