ShuntGraphUtils { public static ShuntGraphPair createShuntGraphPair( OWLGraphWrapper ogw, OWLObject focusObject, Set<OWLPropertyExpression> props, boolean isIncludeDirectChildren) { OWLShuntGraph topologyGraph = new OWLShuntGraph(); OWLShuntGraph inferredGraph = new OWLShuntGraph(); Set<OWLObject> nodeSet = ogw.getAncestorsReflexive(focusObject, props); if (isIncludeDirectChildren) { for (OWLGraphEdge edge : ogw.getIncomingEdges(focusObject)) { OWLObject source = edge.getSource(); if (source instanceof OWLNamedObject) { nodeSet.add(source); OWLShuntEdge sge = createShuntEdge(edge, ogw); if (sge != null) { inferredGraph.addEdge(sge); inferredGraph.addNode(new OWLShuntNode(ogw, source)); } } } } for (OWLObject anc : nodeSet) { if ((anc instanceof OWLNamedObject) == false) { continue; } Set<OWLGraphEdge> edges = ogw.getOutgoingEdges(anc); for (OWLGraphEdge edge : edges) { if (!nodeSet.contains(edge.getTarget())) { continue; } OWLShuntEdge sge = createShuntEdge(edge, ogw); if (sge != null) { topologyGraph.addEdge(sge); } } topologyGraph.addNode(new OWLShuntNode(ogw, anc)); } Set<OWLGraphEdge> edgesClosure = ogw.getOutgoingEdgesClosure(focusObject, props); for (OWLGraphEdge edge : edgesClosure) { if ((edge.getTarget() instanceof OWLNamedObject) == false) { continue; } OWLShuntEdge sge = createShuntEdge(edge, ogw); if (sge != null) { inferredGraph.addEdge(sge); inferredGraph.addNode(new OWLShuntNode(ogw, edge.getTarget())); } } inferredGraph.addNode(new OWLShuntNode(ogw, focusObject)); return new ShuntGraphPair(topologyGraph, inferredGraph ); }  static ShuntGraphPair createShuntGraphPair(
			OWLGraphWrapper ogw,
			OWLObject focusObject,
			Set<OWLPropertyExpression> props,
			boolean isIncludeDirectChildren); static OWLShuntGraph createShuntGraph(
			OWLGraphWrapper ogw,
			OWLObject focusObject,
			Set<OWLPropertyExpression> props,
			boolean isIncludeDirectChildren);  }
@Test public void testSagaComplex() throws Exception { OWLObject focusObject = g.getOWLClassByIdentifier("GO:0000124"); Set<OWLPropertyExpression> props = new HashSet<OWLPropertyExpression>(); props.add(g.getOWLObjectProperty(OBOUpperVocabulary.BFO_part_of.getIRI())); ShuntGraphPair pair = ShuntGraphUtils.createShuntGraphPair(g, focusObject, props, true); OWLShuntGraph topology = pair.getTopologyGraph(); checkNodesSagaComplex(g, topology); checkTopologyRelationsSagaComplex(g, topology); OWLShuntGraph inferred = pair.getInferredGraph(); checkNodesSagaComplex(g, inferred); checkInferredRelationsSagaComplex(g, inferred); }
@Test public void testSagaTypeComplexWithChildren() throws Exception { OWLObject focusObject = g.getOWLClassByIdentifier("GO:0070461"); Set<OWLPropertyExpression> props = new HashSet<OWLPropertyExpression>(); props.add(g.getOWLObjectProperty(OBOUpperVocabulary.BFO_part_of.getIRI())); ShuntGraphPair pair = ShuntGraphUtils.createShuntGraphPair(g, focusObject, props, true); OWLShuntGraph topology = pair.getTopologyGraph(); checkNodesSagaTypeComplexWithChildren(g, topology); checkTopologyRelationsSagaTypeComplexWithChildren(g, topology); OWLShuntGraph inferred = pair.getInferredGraph(); checkNodesSagaTypeComplexWithChildren(g, inferred); checkInferredRelationsSagaTypeComplexWithChildren(g, inferred); }
@Test public void testSagaTypeComplexWithoutChildren() throws Exception { OWLObject focusObject = g.getOWLClassByIdentifier("GO:0070461"); 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); }