@Test public void smokeTest() { AnalyzeRequest request = new AnalyzeRequest(); request.getSamples() .addAll(newHashSet("pizza:FourSeasons", "pizza:AmericanHot", "pizza:Cajun")); request.setOntologyClass("pizza:Pizza"); request.setPath("-[:pizza:hasTopping]->"); assertThat(analyzer.analyze(request), is(not(empty()))); }
public List<AnalyzerResult> analyze(AnalyzeRequest request) { List<AnalyzerResult> pValues = new ArrayList<>(); try (Transaction tx = graphDb.beginTx()) { AnalyzeRequest processedRequest = processRequest(request); Set<AnalyzerInnerNode> sampleSetNodes = getSampleSetNodes(processedRequest); Set<AnalyzerInnerNode> completeSetNodes = getCompleteSetNodes(processedRequest); double bonferroniCoeff = computeBonferroniCoeff(completeSetNodes); int totalCount = getTotalCount(processedRequest.getOntologyClass()); for (AnalyzerInnerNode n : sampleSetNodes) { HypergeometricDistribution hypergeometricDistribution = new HypergeometricDistribution(totalCount, (int) getCountFrom(completeSetNodes, n.getNodeId()), processedRequest.getSamples().size()); double p = hypergeometricDistribution.upperCumulativeProbability((int) n.getCount()) * bonferroniCoeff; String iri = graph.getNodeProperty(n.getNodeId(), CommonProperties.IRI, String.class).get(); String curie = curieUtil.getCurie(iri).orElse(iri); String labels = StringUtils.join( graph.getNodeProperties(n.getNodeId(), NodeProperties.LABEL, String.class), ", "); pValues.add(new AnalyzerResult(labels, curie, p)); } Collections.sort(pValues, new AnalyzerResultComparator()); tx.success(); } catch (Exception e) { e.printStackTrace(); } return pValues; }
HyperGeometricAnalyzer { public List<AnalyzerResult> analyze(AnalyzeRequest request) { List<AnalyzerResult> pValues = new ArrayList<>(); try (Transaction tx = graphDb.beginTx()) { AnalyzeRequest processedRequest = processRequest(request); Set<AnalyzerInnerNode> sampleSetNodes = getSampleSetNodes(processedRequest); Set<AnalyzerInnerNode> completeSetNodes = getCompleteSetNodes(processedRequest); double bonferroniCoeff = computeBonferroniCoeff(completeSetNodes); int totalCount = getTotalCount(processedRequest.getOntologyClass()); for (AnalyzerInnerNode n : sampleSetNodes) { HypergeometricDistribution hypergeometricDistribution = new HypergeometricDistribution(totalCount, (int) getCountFrom(completeSetNodes, n.getNodeId()), processedRequest.getSamples().size()); double p = hypergeometricDistribution.upperCumulativeProbability((int) n.getCount()) * bonferroniCoeff; String iri = graph.getNodeProperty(n.getNodeId(), CommonProperties.IRI, String.class).get(); String curie = curieUtil.getCurie(iri).orElse(iri); String labels = StringUtils.join( graph.getNodeProperties(n.getNodeId(), NodeProperties.LABEL, String.class), ", "); pValues.add(new AnalyzerResult(labels, curie, p)); } Collections.sort(pValues, new AnalyzerResultComparator()); tx.success(); } catch (Exception e) { e.printStackTrace(); } return pValues; } }
HyperGeometricAnalyzer { public List<AnalyzerResult> analyze(AnalyzeRequest request) { List<AnalyzerResult> pValues = new ArrayList<>(); try (Transaction tx = graphDb.beginTx()) { AnalyzeRequest processedRequest = processRequest(request); Set<AnalyzerInnerNode> sampleSetNodes = getSampleSetNodes(processedRequest); Set<AnalyzerInnerNode> completeSetNodes = getCompleteSetNodes(processedRequest); double bonferroniCoeff = computeBonferroniCoeff(completeSetNodes); int totalCount = getTotalCount(processedRequest.getOntologyClass()); for (AnalyzerInnerNode n : sampleSetNodes) { HypergeometricDistribution hypergeometricDistribution = new HypergeometricDistribution(totalCount, (int) getCountFrom(completeSetNodes, n.getNodeId()), processedRequest.getSamples().size()); double p = hypergeometricDistribution.upperCumulativeProbability((int) n.getCount()) * bonferroniCoeff; String iri = graph.getNodeProperty(n.getNodeId(), CommonProperties.IRI, String.class).get(); String curie = curieUtil.getCurie(iri).orElse(iri); String labels = StringUtils.join( graph.getNodeProperties(n.getNodeId(), NodeProperties.LABEL, String.class), ", "); pValues.add(new AnalyzerResult(labels, curie, p)); } Collections.sort(pValues, new AnalyzerResultComparator()); tx.success(); } catch (Exception e) { e.printStackTrace(); } return pValues; } @Inject  HyperGeometricAnalyzer(GraphDatabaseService graphDb, CurieUtil curieUtil, Graph graph,
      CypherUtil cypherUtil); }
HyperGeometricAnalyzer { public List<AnalyzerResult> analyze(AnalyzeRequest request) { List<AnalyzerResult> pValues = new ArrayList<>(); try (Transaction tx = graphDb.beginTx()) { AnalyzeRequest processedRequest = processRequest(request); Set<AnalyzerInnerNode> sampleSetNodes = getSampleSetNodes(processedRequest); Set<AnalyzerInnerNode> completeSetNodes = getCompleteSetNodes(processedRequest); double bonferroniCoeff = computeBonferroniCoeff(completeSetNodes); int totalCount = getTotalCount(processedRequest.getOntologyClass()); for (AnalyzerInnerNode n : sampleSetNodes) { HypergeometricDistribution hypergeometricDistribution = new HypergeometricDistribution(totalCount, (int) getCountFrom(completeSetNodes, n.getNodeId()), processedRequest.getSamples().size()); double p = hypergeometricDistribution.upperCumulativeProbability((int) n.getCount()) * bonferroniCoeff; String iri = graph.getNodeProperty(n.getNodeId(), CommonProperties.IRI, String.class).get(); String curie = curieUtil.getCurie(iri).orElse(iri); String labels = StringUtils.join( graph.getNodeProperties(n.getNodeId(), NodeProperties.LABEL, String.class), ", "); pValues.add(new AnalyzerResult(labels, curie, p)); } Collections.sort(pValues, new AnalyzerResultComparator()); tx.success(); } catch (Exception e) { e.printStackTrace(); } return pValues; } @Inject  HyperGeometricAnalyzer(GraphDatabaseService graphDb, CurieUtil curieUtil, Graph graph,
      CypherUtil cypherUtil); List<AnalyzerResult> analyze(AnalyzeRequest request); }
HyperGeometricAnalyzer { public List<AnalyzerResult> analyze(AnalyzeRequest request) { List<AnalyzerResult> pValues = new ArrayList<>(); try (Transaction tx = graphDb.beginTx()) { AnalyzeRequest processedRequest = processRequest(request); Set<AnalyzerInnerNode> sampleSetNodes = getSampleSetNodes(processedRequest); Set<AnalyzerInnerNode> completeSetNodes = getCompleteSetNodes(processedRequest); double bonferroniCoeff = computeBonferroniCoeff(completeSetNodes); int totalCount = getTotalCount(processedRequest.getOntologyClass()); for (AnalyzerInnerNode n : sampleSetNodes) { HypergeometricDistribution hypergeometricDistribution = new HypergeometricDistribution(totalCount, (int) getCountFrom(completeSetNodes, n.getNodeId()), processedRequest.getSamples().size()); double p = hypergeometricDistribution.upperCumulativeProbability((int) n.getCount()) * bonferroniCoeff; String iri = graph.getNodeProperty(n.getNodeId(), CommonProperties.IRI, String.class).get(); String curie = curieUtil.getCurie(iri).orElse(iri); String labels = StringUtils.join( graph.getNodeProperties(n.getNodeId(), NodeProperties.LABEL, String.class), ", "); pValues.add(new AnalyzerResult(labels, curie, p)); } Collections.sort(pValues, new AnalyzerResultComparator()); tx.success(); } catch (Exception e) { e.printStackTrace(); } return pValues; } @Inject  HyperGeometricAnalyzer(GraphDatabaseService graphDb, CurieUtil curieUtil, Graph graph,
      CypherUtil cypherUtil); List<AnalyzerResult> analyze(AnalyzeRequest request);  }