org.semanticweb.owlapi.model.OWLObject Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLObject. 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: GafCommandRunner.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@CLIMethod("--gaf-query")
public void gafQuery(Opts opts) {
	opts.info("LABEL", "extracts lines from a GAF file where the ontology term is a reflexive descendant of the query");
	OWLObject obj = resolveEntity(opts);
	// TODO - allow selection of relations
	Set<OWLObject> descs = g.getDescendantsReflexive(obj);
	List<GeneAnnotation> filtered = new ArrayList<GeneAnnotation>();
	for (GeneAnnotation a : gafdoc.getGeneAnnotations()) {
		OWLObject c = g.getOWLObjectByIdentifier(a.getCls());
		if (descs.contains(c)) {
			filtered.add(a);
			// TODO: option to write entire GAF line
			//System.out.println(a.getBioentityObject()+"\t"+a.getBioentityObject().getSymbol()+"\t"+g.getIdentifier(c)+"\t"+g.getLabel(c));
		}
	}
	gafdoc.setGeneAnnotations(filtered);
}
 
Example #2
Source File: SimEngine.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * A class is excluded from the analysis if:
 * 
 * it is a named entity, and the label for that entity matches the exclude labels list
 * OR: it is a class expression, and the signature contains an excluded class
 * @param att
 * @return boolean
 */
public boolean isExcludedFromAnalysis(OWLObject att) {
	if (att instanceof OWLAnonymousClassExpression) {
		for (OWLClass cls : ((OWLAnonymousClassExpression)att).getClassesInSignature()) {
			if (isExcludedFromAnalysis(cls))
				return true;
		}
		/*
		for (OWLGraphEdge e : graph.getOutgoingEdges(att)) {
			if (!(e.getTarget() instanceof OWLAnonymousClassExpression)) {
				if (isExcludedFromAnalysis(e.getTarget()))
					return true;
			}
		}
		 */
		return false;
	}
	String label = getGraph().getLabelOrDisplayId(att);
	if (label != null && getExcludedLabels().contains(label)) {
		return true;
	}
	return false;
}
 
Example #3
Source File: AbstractSimEngineTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void run(OWLGraphWrapper  wrapper, Similarity sim, OWLObject a, OWLObject b) throws Exception{
	OWLPrettyPrinter pp = new OWLPrettyPrinter(wrapper);
	SimEngine se = new SimEngine(wrapper);
	LOG.debug("Comparing "+pp.render(a)+" -vs- "+pp.render(b));
	/*
	for (OWLObject x : wrapper.getDescendantsReflexive(a)) {
		System.out.println("d="+x);
	}
	*/
	
	OWLClassExpression lcs = se.getLeastCommonSubsumerSimpleClassExpression(a, b);
	if (lcs != null) {
		LOG.debug(" LCS: "+pp.render(lcs));
	}
	
	se.calculateSimilarity(sim, a, b);

	LOG.debug(sim);
	for (OWLAxiom ax : sim.translateResultsToOWLAxioms()) {
		LOG.debug("  Ax: "+pp.render(ax));
	}
	
}
 
Example #4
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 #5
Source File: OWLGraphUtil.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static Set<OWLGraphEdge> findLeastCommonSubsumersAsEdges(OWLGraphWrapper g,
		OWLObject x, OWLObject y) {
	Set<OWLGraphEdge> cses = findCommonSubsumersAsEdges(g,x,y);
	Set<OWLGraphEdge> lcses = new HashSet<OWLGraphEdge>();
	lcses.addAll(cses);
	for (OWLGraphEdge cse: cses) {
		Set<OWLObject> zs = g.getAncestors(cse.getSource());
		for (OWLObject z : zs) {
			for (OWLGraphEdge lcse: lcses) {
				if (lcse.getSource().equals(z))
					lcses.remove(lcse);
			}
		}
	}
	return lcses;
}
 
Example #6
Source File: PhenologSimTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
	@Ignore("This test requires an external resource. This can lead to false positive failures.")
//	@Ignore("takes a long time, add to separate test suite") // uncomment this line to deactivate the test
	public void testSim() throws Exception{
		OWLGraphWrapper  wrapper = 
			getOntologyWrapperFromURL("http://obo.svn.sourceforge.net/viewvc/obo/phenotype-commons/ontology/mp-hp-ext-merged-uberon.owl?revision=3905");
		DescriptionTreeSimilarity sa = 
			new DescriptionTreeSimilarity();
		OWLObject a = wrapper.getOWLObject("http://purl.obolibrary.org/obo/MP_0005391");
		OWLObject b = wrapper.getOWLObject("http://purl.obolibrary.org/obo/HP_0000478");
		SimEngine se = new SimEngine(wrapper);
		//sa.forceReflexivePropertyCreation = true;
		sa.calculate(se, b, a);
		sa.print();
		System.out.println(sa.getScore());
		
	}
 
Example #7
Source File: OWLHandler.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * tests which of a set of input classes (specified using id) is applicable for a set of taxa
 * (specified using taxid)
 * 
 * @throws OWLOntologyCreationException 
 * @throws OWLOntologyStorageException 
 * @throws IOException 
 */
public void isClassApplicableForTaxonCommand() throws OWLOntologyCreationException, OWLOntologyStorageException, IOException {
	headerOWL();
	TaxonConstraintsEngine tce = new TaxonConstraintsEngine(graph);
	Set<OWLClass> testClsSet = resolveClassList();
	Set<OWLClass> testTaxSet = resolveClassList(Param.taxid);
	for (OWLClass testTax : testTaxSet) {
		Set<OWLObject> taxAncs = graph.getAncestorsReflexive(testTax);
		LOG.info("Tax ancs: "+taxAncs);
		for (OWLClass testCls : testClsSet) {
			Set<OWLGraphEdge> edges = graph.getOutgoingEdgesClosure(testCls);
			boolean isOk = tce.isClassApplicable(testCls, testTax, edges, taxAncs);
			// TODO - other formats
			output(testCls);
			print("\t");
			output(testTax);
			outputLine("\t"+isOk);
		}
	}
}
 
Example #8
Source File: ShuntGraphUtilsTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testSagaTypeComplexWithoutChildren() throws Exception {
	OWLObject focusObject = g.getOWLClassByIdentifier("GO:0070461"); // SAGA-type complex
	Set<OWLPropertyExpression> props = new HashSet<OWLPropertyExpression>();
	props.add(g.getOWLObjectProperty(OBOUpperVocabulary.BFO_part_of.getIRI()));
	
	ShuntGraphPair pair = ShuntGraphUtils.createShuntGraphPair(g, focusObject, props, false);
	
	OWLShuntGraph topology = pair.getTopologyGraph();
	
	checkNodesSagaTypeComplexWithoutChildren(g, topology);
	checkTopologyRelationsSagaTypeComplexWithoutChildren(g, topology);
	
	OWLShuntGraph inferred = pair.getInferredGraph();
	
	checkNodesSagaTypeComplexWithoutChildren(g, inferred);
	checkInferredRelationsSagaTypeComplexWithoutChildren(g, inferred);
}
 
Example #9
Source File: OWLGraphWrapperEdges.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void cacheReverseUnionMap() {
	synchronized (edgeCacheMutex) {
	    extraSubClassOfEdges = new HashMap<OWLObject, Set<OWLGraphEdge>>();
           if (!config.isGraphReasonedAndRelaxed) {
	        for (OWLOntology o : getAllOntologies()) {
	            for (OWLClass cls : o.getClassesInSignature()) {
	                for (OWLEquivalentClassesAxiom eca : o.getEquivalentClassesAxioms(cls)) {
	                    for (OWLClassExpression ce : eca.getClassExpressions()) {
	                        if (ce instanceof OWLObjectUnionOf) {
	                            for (OWLObject child : ((OWLObjectUnionOf)ce).getOperands()) {
	                                if (!extraSubClassOfEdges.containsKey(child)) {
	                                    extraSubClassOfEdges.put(child, new OWLGraphEdgeSet());
	                                }
	                                extraSubClassOfEdges.get(child).add(
	                                        createSubClassOfEdge(child,cls,o,eca));
	                            }
	                        }
	                    }
	                }
	            }
	        }
	    }
	}
}
 
Example #10
Source File: AbstractSimEngineTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void runAll(OWLGraphWrapper  wrapper, OWLObject a, OWLObject b) throws Exception{
	OWLPrettyPrinter pp = new OWLPrettyPrinter(wrapper);
	SimEngine se = new SimEngine(wrapper);
	LOG.debug("Comparing "+pp.render(a)+" -vs- "+pp.render(b));
	/*
	for (OWLObject x : wrapper.getDescendantsReflexive(a)) {
		System.out.println("d="+x);
	}
	*/
	
	OWLClassExpression lcs = se.getLeastCommonSubsumerSimpleClassExpression(a, b);
	if (lcs != null) {
		LOG.debug(" LCS: "+pp.render(lcs));
	}
	
	Set<Similarity> r = se.calculateAllSimilarity(a, b);
	for (Similarity sim : r) {

		LOG.debug(sim);
		for (OWLAxiom ax : sim.translateResultsToOWLAxioms()) {
			LOG.debug("  Ax: "+pp.render(ax));
		}
	}
	
}
 
Example #11
Source File: CycleTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
@Ignore("This test requires an external resource. This can lead to false positive failures.")
public void testConvertXPs() throws Exception {
	ParserWrapper pw = new ParserWrapper();
	OWLGraphWrapper g =
		pw.parseToOWLGraph("http://purl.obolibrary.org/obo/fbbt.obo");
	OWLObject c = g.getOWLObjectByIdentifier("FBbt:00005048"); // tracheolar cell
	
	Set<OWLObject> ancs = g.getAncestorsReflexive(c);
	//assertTrue(ancs.contains(wmb)); // reflexivity test
	//assertTrue(ancs.contains(eso)); //wing margin bristle --> external sensory organ
	
	for (OWLObject a : ancs) {
		System.out.println(g.getIdentifier(a)+" "+g.getLabel(a));
	}
}
 
Example #12
Source File: MPClosureTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testConvertXPs() throws Exception {
	ParserWrapper pw = new ParserWrapper();
	OWLGraphWrapper g =
		pw.parseToOWLGraph("http://purl.obolibrary.org/obo/mp.owl");
	//OWLOntology ont = g.getOntology();

	OWLObject aer = g.getOWLObjectByIdentifier("MP:0001676"); // apical ectoderm ridge
	OWLObject emb = g.getOWLObjectByIdentifier("MP:0001672"); // abnormal embryogenesis/ development
	
	Set<OWLObject> ancs = g.getAncestorsReflexive(aer);
	assertTrue(ancs.contains(aer)); // reflexivity test
	
	for (OWLObject c : ancs) {
		System.out.println(g.getIdentifier(c));
	}
}
 
Example #13
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 #14
Source File: OWLGraphWrapperEdgesAdvanced.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Gets all ancestors that are OWLNamedObjects.
 * i.e. excludes anonymous class expressions
 * <p>
 * This graph information is concerned almost exclusively with the arguments transitive relations with all of its ancestors.
 * 
 * @param x
 * @param rel_ids
 * @return set of named ancestors and direct descendents
 */
public OWLShuntGraph getLineageShuntGraph(OWLObject x, List<String> rel_ids) {

	// Collection depot.
	OWLShuntGraph graphSegment = new OWLShuntGraph();

	// Add this node, our seed.
	String topicID = getIdentifier(x);
	String topicLabel = getLabel(x);
	OWLShuntNode tn = new OWLShuntNode(topicID, topicLabel);
	graphSegment.addNode(tn);

	// Next, get all of the named ancestors and add them to our shunt graph.
	graphSegment = addTransitiveAncestorsToShuntGraph(x, graphSegment, rel_ids);

	//		
	return graphSegment;
}
 
Example #15
Source File: DescriptionTreeSimilarity.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void calculate(SimEngine simEngine, OWLObject a, OWLObject b) throws SimilarityAlgorithmException {
	this.a = a;
	this.b = b;
	this.simEngine = simEngine;
	se = simEngine; // TODO - fix
	graph = simEngine.getGraph();
	ConvergentPath cp = buildDescription(a,b);
	lcs = combinePathsToMakeExpression(cp);
	if (cp == null)
		score = 0.0;
	else {
		Set<OWLObject> csl = graph.getAncestorsReflexive(lcs);
		Set<OWLObject> usl = se.getUnionSubsumers(a,b);
		
		score = ((double)csl.size()) / usl.size();
	}
}
 
Example #16
Source File: AltIdInSignature.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Collection<CheckWarning> check(OWLGraphWrapper graph, Collection<OWLObject> allOwlObjects) {
	OWLPrettyPrinter pp = new OWLPrettyPrinter(graph);
	List<CheckWarning> out = new ArrayList<CheckWarning>();
	
	Map<String, OWLObject> altIds = graph.getAllOWLObjectsByAltId();
	
	for (OWLObject owlObject : allOwlObjects) {
		if (owlObject instanceof OWLClass) {
			OWLClass owlClass = (OWLClass) owlObject;
			if (graph.isObsolete(owlClass) == false) {
				check(owlClass, graph, altIds, out, pp);
			}
		}
	}
	return out;
}
 
Example #17
Source File: SimEngine.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public int getCorpusSize() {
	if (corpusSize != null)
		return corpusSize;
	// TODO - option for individuals; for now this is hardcoded
	int n = 0;
	LOG.info("calculating corpus size:");
	for (OWLObject x : graph.getAllOWLObjects()) {
		if (x instanceof OWLIndividual) {
			// exclude individuals that have no attributes from corpus.
			// note: comparisonProperty should be set
			int numAtts = getAttributesForWithRedundant(x).size();
			if (numAtts > 0) {
				//LOG.info("  num atts["+x+"] = "+numAtts);
				n++;
			}
		}
	}
	LOG.info("corpus size:"+n);
	corpusSize = n;
	return n;
}
 
Example #18
Source File: OWLGraphWrapperTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testSubset() throws Exception {
	OWLGraphWrapper graph = getOBO2OWLOntologyWrapper("omma.obo");
	Set<String> subsets = graph.getAllUsedSubsets();
	assertEquals(5, subsets.size());
	boolean ok = true;
	boolean isFound = false;
	for (String s : subsets) {
		Set<OWLObject> objs = graph.getOWLObjectsInSubset(s);
		System.out.println("# "+s+" = "+objs.size());
		if (s.equals("cur")) {
			isFound = true;
			assertEquals(90, objs.size());
		}
		for (OWLObject obj : objs) {
			List<String> subsetsToCheck = graph.getSubsets(obj);
			if (!subsetsToCheck.contains(s)) {
				ok = false;
			}
		}
	}
	
	assertTrue(isFound);
	assertTrue(ok);
}
 
Example #19
Source File: ShuntGraphUtilsTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void containsNotNode(String id, OWLShuntGraph shuntGraph, OWLGraphWrapper graph) {
	boolean found = false;
	OWLObject c = graph.getOWLObjectByIdentifier(id);
	for (OWLShuntNode node: shuntGraph.nodes) {
		if(id.equals(node.id)) {
			found = true;
			break;
		}
	}
	assertFalse("Did not expect to find node for id: "+graph.getLabelOrDisplayId(c), found);
}
 
Example #20
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 #21
Source File: OWLGraphLayoutRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * fetch a layout node via the cognate OWLObject
 * 
 * make private?
 * @param ob
 * @return {@link OWLGraphLayoutNode}
 */
public OWLGraphLayoutNode getNode(OWLObject ob) {
	OWLGraphLayoutNode node = nodemap.get(ob);
	if (node == null) {
		node = new OWLGraphLayoutNode(owlGraphWrapper, ob, style);
		nodemap.put(ob, node);
		g.nodes.add(node);
	}
	return node;
}
 
Example #22
Source File: OWLGraphWrapperEdges.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Set<OWLGraphEdge> getPrimitiveIncomingEdges(OWLObject t) {
	ensureEdgesCached();
	if (edgeByTarget.containsKey(t)) {
		return new OWLGraphEdgeSet(edgeByTarget.get(t));
	}
	
	return new OWLGraphEdgeSet();
}
 
Example #23
Source File: OntologyGeneralSolrDocumentLoader.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public SolrInputDocument collect(OWLObject obj, OWLGraphWrapper graph) {

		//
		if (obj instanceof OWLClass)
			 return collectClass(graph, (OWLClass)obj);
		else
			return null;
	}
 
Example #24
Source File: ModelAnnotationSolrDocumentLoader.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private String getId(OWLObject cls, OWLGraphWrapper graph) {
	String shortId = "???";
	if (cls != null) {
		shortId = graph.getAnnotationValue(cls, shortIdProp);
		if (shortId == null) {
			shortId = graph.getIdentifier(cls);
		}
	}
	return shortId;
}
 
Example #25
Source File: JaccardSimilarity.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void calculate(SimEngine simEngine, OWLObject a, OWLObject b) {
	this.simEngine = simEngine;
	ci = simEngine.getCommonSubsumersSize(a, b);
	cu = simEngine.getUnionSubsumersSize(a, b);
	setScore( ((double)ci) / cu );
}
 
Example #26
Source File: OWLGraphGOTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testGOGraph3() throws Exception{
	
	// 
	OWLObject x3 = wrapper.getOWLClassByIdentifier("GO:0022008");
	Map<String, String> closure_map = wrapper.getRelationClosureMap(x3, RelationSets.getRelationSet(RelationSets.ISA_PARTOF));
	
	
	// And make sure they are the right ones.
	int tally = 0;
	for( String key : closure_map.keySet() ){
		//LOG.info("key: " + key + ", label: " + closure_map.get(key));
		assertNotNull("the closure ids should never be null", key);
		if( key != null ){
			if( key.equals("GO:0022008") ||
				key.equals("GO:0030154") ||
				key.equals("GO:0007399") ||
				key.equals("GO:0048731") ||
				key.equals("GO:0048869") ||
				key.equals("GO:0048856") ||
				key.equals("GO:0007275") ||
				key.equals("GO:0009987") ||
				key.equals("GO:0032502") ||
				key.equals("GO:0032501") ||
				key.equals("GO:0008150") ){
				tally++;
			}
		}
	}
	// Do we have the right number and right allocation of ancestors?
	assertEquals("have 11 ids in closure", 11, closure_map.keySet().size());
	assertEquals("have correct 11 ids in closure", 11, tally);
}
 
Example #27
Source File: ShuntGraphUtilsNRTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void containsNode(String id, OWLShuntGraph shuntGraph, OWLGraphWrapper graph, Set<OWLShuntNode> remaining) {
	boolean found = false;
	OWLObject c = graph.getOWLObjectByIdentifier(id);
	for (OWLShuntNode node: shuntGraph.nodes) {
		if(id.equals(node.id)) {
			found = true;
			remaining.remove(node);
			break;
		}
	}
	assertTrue("Did not find node for id: "+graph.getLabelOrDisplayId(c), found);
}
 
Example #28
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 #29
Source File: MultiSimilarity.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @param s
 * @param att  -- attribute matched
 * @param bestMap
 * @param bestMap2 -- map in opposite direction
 * @param bestMapObj -- opposite attribute
 */
private void printX(PrintStream s, OWLObject att, Map<OWLObject, Similarity> bestMap, Map<OWLObject, Similarity> bestMap2, OWLObject bestMapObj) {
	Similarity bestmatch = bestMap.get(att);
	s.println("  Attr Pair Score: "+bestmatch.getScore());
	//if (bestMap2.get(att).score == bestmatch.getScore())
	//	s.println("  **reciprocal**");
	s.print("  ");
	printDescription(s,att);
	s.print(" -vs- ");
	printDescription(s,bestMapObj);
	s.println();
	s.print("  A:");
	s.println(att);
	s.print("  B:");
	s.print(bestMapObj);
	s.println();
	printSubSim(s, bestmatch);
	OWLObjectPair pair = new OWLObjectPair(att,bestMapObj);
	Set<Similarity> alreadyPrinted = new HashSet<Similarity>();
	if (deepSimMap != null && deepSimMap.containsKey(pair)) {
		for (Similarity ds : deepSimMap.get(pair)) {
			if (alreadyPrinted.contains(ds))
				continue;
			printSubSim(s, ds);
			alreadyPrinted.add(ds);
		}
	}
	s.println();

}
 
Example #30
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get the definition xrefs (IAO_0000115)
 * 
 * @param c
 * @return list of definition xrefs
 */
public List<String> getDefXref(OWLObject c){
	OWLAnnotationProperty lap = getDataFactory().getOWLAnnotationProperty(Obo2OWLVocabulary.IRI_IAO_0000115.getIRI()); 
	OWLAnnotationProperty xap = getAnnotationProperty(OboFormatTag.TAG_XREF.getTag());

	if (c instanceof OWLEntity) {
		List<String> list = new ArrayList<String>();
		for (OWLOntology ont : getAllOntologies()) {
			Set<OWLAnnotationAssertionAxiom> axioms = ont.getAnnotationAssertionAxioms(((OWLEntity) c).getIRI());
			for (OWLAnnotationAssertionAxiom axiom :axioms){
				if(lap.equals(axiom.getProperty())){
					for(OWLAnnotation annotation: axiom.getAnnotations(xap)){
						OWLAnnotationValue value = annotation.getValue();
						if(value instanceof OWLLiteral){
							list.add(((OWLLiteral)value).getLiteral());
						}
					}
				}

			}
		}
		return list;
	}
	else {
		return null;
	}
}