Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/SciGraph/SciGraph into up…
Browse files Browse the repository at this point in the history
…stream
  • Loading branch information
tgbugs committed Jun 15, 2017
2 parents 3e1c0e1 + 46049b9 commit 4633a79
Show file tree
Hide file tree
Showing 197 changed files with 3,365 additions and 14,059 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
@@ -1,8 +1,6 @@
language: java
jdk:
- oraclejdk8
- oraclejdk7
- openjdk7

before_install:
- "export DISPLAY=:99.0"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -100,7 +100,7 @@ Also browse the [generated REST documentation](http://localhost:9000/scigraph/do
to see some of the other resources.

-------
<img src="http://github.nfsdb.org/images/yklogo.png" />
<img src="https://www.yourkit.com/images/yklogo.png" />
-------
Thanks to YourKit for providing an Open Source license.

Expand Down
4 changes: 2 additions & 2 deletions SciGraph-analysis/pom.xml
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>io.scigraph</groupId>
<artifactId>scigraph</artifactId>
<version>1.5-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<artifactId>scigraph-analysis</artifactId>
<name>SciGraph - analysis</name>
Expand All @@ -41,7 +41,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.5</version>
<version>3.6.1</version>
</dependency>
</dependencies>

Expand Down
Expand Up @@ -15,19 +15,14 @@
*/
package io.scigraph.analyzer;

import io.scigraph.frames.CommonProperties;
import io.scigraph.frames.NodeProperties;
import io.scigraph.internal.CypherUtil;
import io.scigraph.neo4j.Graph;
import io.scigraph.owlapi.curies.CurieUtil;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import javax.inject.Inject;
Expand All @@ -38,8 +33,12 @@
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Result;
import org.neo4j.graphdb.Transaction;
import org.prefixcommons.CurieUtil;

import com.google.common.base.Optional;
import io.scigraph.frames.CommonProperties;
import io.scigraph.frames.NodeProperties;
import io.scigraph.internal.CypherUtil;
import io.scigraph.neo4j.Graph;

public class HyperGeometricAnalyzer {

Expand Down Expand Up @@ -206,7 +205,7 @@ public List<AnalyzerResult> analyze(AnalyzeRequest request) {
hypergeometricDistribution.upperCumulativeProbability((int) n.getCount())
* bonferroniCoeff;
String iri = graph.getNodeProperty(n.getNodeId(), CommonProperties.IRI, String.class).get();
String curie = curieUtil.getCurie(iri).or(iri);
String curie = curieUtil.getCurie(iri).orElse(iri);
String labels =
StringUtils.join(
graph.getNodeProperties(n.getNodeId(), NodeProperties.LABEL, String.class), ", ");
Expand Down
Expand Up @@ -26,7 +26,6 @@
import io.scigraph.internal.CypherUtil;
import io.scigraph.owlapi.GraphOwlVisitor;
import io.scigraph.owlapi.OwlPostprocessor;
import io.scigraph.owlapi.curies.CurieUtil;
import io.scigraph.owlapi.loader.OwlLoadConfiguration.MappedProperty;
import io.scigraph.util.GraphTestBase;

Expand All @@ -38,6 +37,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.neo4j.graphdb.Transaction;
import org.prefixcommons.CurieUtil;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntologyManager;
Expand Down
28 changes: 19 additions & 9 deletions SciGraph-core/pom.xml
Expand Up @@ -20,13 +20,13 @@
<parent>
<artifactId>scigraph</artifactId>
<groupId>io.scigraph</groupId>
<version>1.5-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<artifactId>scigraph-core</artifactId>
<name>SciGraph - core</name>

<properties>
<lucene.version>3.6.2</lucene.version>
<lucene.version>5.5.0</lucene.version>
<openrdf.version>2.7.6</openrdf.version>
</properties>

Expand Down Expand Up @@ -68,34 +68,39 @@

<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers</artifactId>
<artifactId>lucene-suggest</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-spellchecker</artifactId>
<artifactId>lucene-analyzers-common</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-misc</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>${lucene.version}</version>
</dependency>

<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.3.1</version>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
<version>3.5</version>
</dependency>

<dependency>
Expand All @@ -114,7 +119,7 @@
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.4.1</version>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.semanticweb.elk</groupId>
Expand All @@ -126,6 +131,11 @@
<artifactId>mapdb</artifactId>
<version>1.0.9</version>
</dependency>
<dependency>
<groupId>org.prefixcommons</groupId>
<artifactId>curie-util</artifactId>
<version>0.0.2</version>
</dependency>
</dependencies>

<build>
Expand Down
37 changes: 24 additions & 13 deletions SciGraph-core/src/main/java/io/scigraph/bbop/BbopGraphUtil.java
Expand Up @@ -16,10 +16,6 @@
package io.scigraph.bbop;

import static com.google.common.collect.Iterables.getFirst;
import io.scigraph.frames.CommonProperties;
import io.scigraph.frames.NodeProperties;
import io.scigraph.internal.TinkerGraphUtil;
import io.scigraph.owlapi.curies.CurieUtil;

import java.util.Collection;

Expand All @@ -31,35 +27,43 @@
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;

import io.scigraph.frames.CommonProperties;
import io.scigraph.frames.NodeProperties;
import io.scigraph.internal.TinkerGraphUtil;
import org.prefixcommons.CurieUtil;

public class BbopGraphUtil {

private final CurieUtil curieUtil;

private static final ImmutableSet<String> IGNORED_PROPERTY_KEYS =
ImmutableSet.of(CommonProperties.IRI, NodeProperties.LABEL, CommonProperties.CURIE);
private static final ImmutableSet<String> IGNORED_PROPERTY_KEYS_FOR_EDGES =
ImmutableSet.of(CommonProperties.IRI);

@Inject
public BbopGraphUtil(CurieUtil curieUtil) {
this.curieUtil = curieUtil;
}

String getCurieOrIri(Vertex vertex) {
String iri = (String)vertex.getProperty(CommonProperties.IRI);
return curieUtil.getCurie(iri).or(iri);
String iri = (String) vertex.getProperty(CommonProperties.IRI);
return curieUtil.getCurie(iri).orElse(iri);
}

/***
* @param graph The graph to convert
* @return a bbop representation of a {@link Graph}
*/
public BbopGraph convertGraph(Graph graph) {
BbopGraph bbopGraph = new BbopGraph();
for (Vertex vertex: graph.getVertices()) {
for (Vertex vertex : graph.getVertices()) {
BbopNode bbopNode = new BbopNode();
bbopNode.setId(getCurieOrIri(vertex));
String label = getFirst(TinkerGraphUtil.getProperties(vertex, NodeProperties.LABEL, String.class), null);
String label =
getFirst(TinkerGraphUtil.getProperties(vertex, NodeProperties.LABEL, String.class), null);
bbopNode.setLbl(label);
for (String key: vertex.getPropertyKeys()) {
for (String key : vertex.getPropertyKeys()) {
if (IGNORED_PROPERTY_KEYS.contains(key)) {
continue;
}
Expand All @@ -68,13 +72,20 @@ public BbopGraph convertGraph(Graph graph) {
}
bbopGraph.getNodes().add(bbopNode);
}
for (Edge edge: graph.getEdges()) {
for (Edge edge : graph.getEdges()) {
BbopEdge bbopEdge = new BbopEdge();
Vertex subject= edge.getVertex(Direction.OUT);
Vertex object= edge.getVertex(Direction.IN);
Vertex subject = edge.getVertex(Direction.OUT);
Vertex object = edge.getVertex(Direction.IN);
bbopEdge.setSub(getCurieOrIri(subject));
bbopEdge.setObj(getCurieOrIri(object));
bbopEdge.setPred(edge.getLabel());
for (String key : edge.getPropertyKeys()) {
if (IGNORED_PROPERTY_KEYS_FOR_EDGES.contains(key)) {
continue;
}
Collection<Object> values = TinkerGraphUtil.getProperties(edge, key, Object.class);
bbopEdge.getMeta().put(key, values);
}
bbopGraph.getEdges().add(bbopEdge);
}
return bbopGraph;
Expand Down
11 changes: 5 additions & 6 deletions SciGraph-core/src/main/java/io/scigraph/internal/CypherUtil.java
Expand Up @@ -19,7 +19,6 @@
import static com.google.common.collect.Collections2.transform;
import static com.google.common.collect.Iterables.getFirst;
import static com.google.common.collect.Sets.newHashSet;
import io.scigraph.owlapi.curies.CurieUtil;

import java.util.Collection;
import java.util.Collections;
Expand All @@ -35,7 +34,6 @@

import org.apache.commons.lang3.text.StrLookup;
import org.apache.commons.lang3.text.StrSubstitutor;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Result;
Expand All @@ -45,6 +43,7 @@
import com.google.common.base.Splitter;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import org.prefixcommons.CurieUtil;

/***
* A utility for more expressive Cypher queries.
Expand Down Expand Up @@ -101,7 +100,7 @@ public Set<RelationshipType> getEntailedRelationshipTypes(Collection<String> par
relationshipTypes = transform(relationshipNames, new Function<String, RelationshipType>() {
@Override
public RelationshipType apply(String name) {
return DynamicRelationshipType.withName(name);
return RelationshipType.withName(name);
}
});
tx.success();
Expand Down Expand Up @@ -136,7 +135,7 @@ Collection<String> resolveTypes(String types, boolean entail) {
new Function<String, String>() {
@Override
public String apply(String type) {
return curieUtil.getIri(type).or(type);
return curieUtil.getIri(type).orElse(type);
}
});
if (entail) {
Expand All @@ -161,7 +160,7 @@ public String resolveStartQuery(String cypher) {
Matcher m = p.matcher(cypher);
while (m.find()) {
String curie = m.group(1);
String iri = curieUtil.getIri(curie).or(curie);
String iri = curieUtil.getIri(curie).orElse(curie);
resolvedCypher = resolvedCypher.replace(curie, iri);
}

Expand Down Expand Up @@ -196,7 +195,7 @@ public String apply(Object input) {
throw new IllegalArgumentException(
"Cypher relationship templates must not contain spaces");
}
return curieUtil.getIri(input.toString()).or(input.toString());
return curieUtil.getIri(input.toString()).orElse(input.toString());
}

});
Expand Down

0 comments on commit 4633a79

Please sign in to comment.