diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..671af8a9
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,7 @@
+.git
+.github
+
+.dockerignore
+.gitignore
+Dockerfile
+README.md
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 00000000..d41242ab
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,89 @@
+name: analysis core ci
+
+
+on:
+ workflow_dispatch:
+
+ pull_request:
+ types:
+ - opened
+ - synchronize
+
+ push:
+ branches:
+ - main
+
+
+permissions:
+ id-token: write
+ contents: read
+
+
+jobs:
+ lint:
+ if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
+ runs-on: ubuntu-latest
+ env:
+ REPO_DIR : /opt/analysis-core
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Run lint
+ run: |
+ docker build --build-arg REPO_DIR="$REPO_DIR" --target setup-env -t lint-image .
+ docker run --name lint-container lint-image
+
+ - name: Display lint errors
+ if: failure()
+ run: |
+ docker cp lint-container:"$REPO_DIR"/lint.log .
+ while IFS= read -r LINT_MSG; do echo "::warning::${LINT_MSG}"; done < lint.log
+ exit 1
+
+ docker-build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: docker/setup-buildx-action@v3
+
+ - uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: Dockerfile
+ tags: tmp-tag
+ outputs: type=docker,dest=/tmp/image.tar
+
+ - uses: actions/upload-artifact@v4
+ with:
+ name: image-artifact
+ path: /tmp/image.tar
+
+ docker-push:
+ if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
+ needs: docker-build
+ runs-on: ubuntu-latest
+ steps:
+ - env:
+ AWS_REGION : us-east-1
+ uses: aws-actions/configure-aws-credentials@v4
+ with:
+ role-to-assume: ${{ vars.AWS_ROLE }}
+ aws-region: ${{ env.AWS_REGION }}
+
+ - id: login-ecr
+ uses: aws-actions/amazon-ecr-login@v2
+
+ - uses: actions/download-artifact@v4
+ with:
+ name: image-artifact
+ path: /tmp
+
+ - env:
+ AWS_REGISTRY : ${{ steps.login-ecr.outputs.registry }}
+ AWS_REPO : analysis-core
+ IMG_TAG : latest
+ run: |
+ docker load --input /tmp/image.tar
+ docker image tag tmp-tag $AWS_REGISTRY/$AWS_REPO:$IMG_TAG
+ docker push $AWS_REGISTRY/$AWS_REPO:$IMG_TAG
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..826f5887
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,39 @@
+ARG REPO_DIR=/opt/analysis-core
+
+
+# ===== stage 1 =====
+FROM maven:3.9.6-eclipse-temurin-11-focal AS setup-env
+
+ARG REPO_DIR
+
+WORKDIR ${REPO_DIR}
+
+COPY . .
+
+SHELL ["/bin/bash", "-c"]
+
+# run lint if container started
+ENTRYPOINT []
+
+CMD mvn -B -q checkstyle:check | \
+ grep -i --color=never '\.java\|failed to execute goal' > lint.log && \
+ exit 1 || \
+ exit 0
+
+
+# ===== stage 2 =====
+FROM setup-env AS build-jar
+
+RUN mvn clean package
+
+
+# ===== stage 3 =====
+FROM eclipse-temurin:11-jre-focal
+
+ARG REPO_DIR
+
+ARG JAR_FILE=target/analysis-core-exec.jar
+
+WORKDIR ${REPO_DIR}
+
+COPY --from=build-jar ${REPO_DIR}/${JAR_FILE} ./target/
diff --git a/checkstyle.xml b/checkstyle.xml
new file mode 100644
index 00000000..8506a80e
--- /dev/null
+++ b/checkstyle.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index 05d3f644..bbaa8569 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,6 +11,7 @@
The Reactome analysis-core extracts data from the graph-database to create the intermediate data format
to be kept in memory and used for the analysis-service
+
analysis-core
@@ -37,6 +38,7 @@
+ 11
org.reactome.server.analysis.core.Main
@@ -111,6 +113,7 @@
commons-fileupload
commons-fileupload
+
commons-codec
commons-codec
@@ -119,24 +122,28 @@
analysis-core
+
src/main/resources
true
+
src/test/resources
true
+
org.apache.maven.plugins
maven-resources-plugin
${maven.resources.version}
+
org.apache.maven.plugins
maven-compiler-plugin
@@ -208,6 +215,34 @@
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 3.1.1
+
+
+
+ com.puppycrawl.tools
+ checkstyle
+ 8.44
+
+
+
+
+ checkstyle-check
+
+ check
+
+
+
+
+ checkstyle.xml
+
+ UTF-8
+
+
+
@@ -224,6 +259,7 @@
false
+
nexus-ebi-snapshot-repo
@@ -237,5 +273,4 @@
-
diff --git a/src/main/java/org/reactome/server/analysis/core/Main.java b/src/main/java/org/reactome/server/analysis/core/Main.java
index 7a4a0b1f..9805f843 100644
--- a/src/main/java/org/reactome/server/analysis/core/Main.java
+++ b/src/main/java/org/reactome/server/analysis/core/Main.java
@@ -32,14 +32,15 @@ public static void main(String[] args) throws JSAPException {
// Program Arguments -h, -p, -u, -k
SimpleJSAP jsap = new SimpleJSAP(Main.class.getName(), "Connect to Reactome Graph Database",
- new Parameter[]{
- new FlaggedOption("host", JSAP.STRING_PARSER, "bolt://localhost:7687", JSAP.NOT_REQUIRED, 'h', "host", "The neo4j host")
- , new FlaggedOption("user", JSAP.STRING_PARSER, "neo4j", JSAP.NOT_REQUIRED, 'u', "user", "The neo4j user")
- , new FlaggedOption("password", JSAP.STRING_PARSER, "neo4jj", JSAP.REQUIRED, 'k', "password", "The neo4j password")
- , new FlaggedOption("output", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'o', "output", "The file where the results are written to")
- , new QualifiedSwitch("test", JSAP.BOOLEAN_PARSER, null, JSAP.NOT_REQUIRED, 't', "test", "Test main species")
- , new QualifiedSwitch("verbose", JSAP.BOOLEAN_PARSER, null, JSAP.NOT_REQUIRED, 'v', "verbose", "Requests verbose output")
- }
+ new Parameter[]{
+ new FlaggedOption("host", JSAP.STRING_PARSER, "bolt://localhost:7687", JSAP.NOT_REQUIRED, 'h', "host", "The neo4j host")
+ , new FlaggedOption("user", JSAP.STRING_PARSER, "neo4j", JSAP.NOT_REQUIRED, 'u', "user", "The neo4j user")
+ , new FlaggedOption("password", JSAP.STRING_PARSER, "neo4jj", JSAP.REQUIRED, 'k', "password", "The neo4j password")
+ , new FlaggedOption("output", JSAP.STRING_PARSER, JSAP.NO_DEFAULT,
+ JSAP.REQUIRED, 'o', "output", "The file where the results are written to")
+ , new QualifiedSwitch("test", JSAP.BOOLEAN_PARSER, null, JSAP.NOT_REQUIRED, 't', "test", "Test main species")
+ , new QualifiedSwitch("verbose", JSAP.BOOLEAN_PARSER, null, JSAP.NOT_REQUIRED, 'v', "verbose", "Requests verbose output")
+ }
);
JSAPResult config = jsap.parse(args);
@@ -132,4 +133,4 @@ private static void calculateNumbersInHierarchyNodesForMainResources(HierarchyBu
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/reactome/server/analysis/core/data/HierarchiesDataProducer.java b/src/main/java/org/reactome/server/analysis/core/data/HierarchiesDataProducer.java
index b022d2f1..54c7d955 100644
--- a/src/main/java/org/reactome/server/analysis/core/data/HierarchiesDataProducer.java
+++ b/src/main/java/org/reactome/server/analysis/core/data/HierarchiesDataProducer.java
@@ -36,7 +36,7 @@ static void initializeProducer(DataContainer data) {
if (producer == null) {
producer = new HierarchiesDataProducer(data);
} else {
- logger.warn("Already initialized. Please ensure you do not use two data containers or you do not initialise this object with the same twice.");
+ logger.warn("Already initialized. Ensure you do not use two data containers or you do not initialise this object with the same twice.");
}
}
diff --git a/src/main/java/org/reactome/server/analysis/core/importer/EntitiesBuilder.java b/src/main/java/org/reactome/server/analysis/core/importer/EntitiesBuilder.java
index bc4aef5b..949918a9 100644
--- a/src/main/java/org/reactome/server/analysis/core/importer/EntitiesBuilder.java
+++ b/src/main/java/org/reactome/server/analysis/core/importer/EntitiesBuilder.java
@@ -52,22 +52,25 @@ public void build(Map speciesMap) {
if (Main.VERBOSE) System.out.print(msgPrefix + speciesPrefix + " >> retrieving xrefs...");
//language=Cypher
- query = "MATCH (:Species{taxId:$taxId})<-[:species]-(:Pathway)-[:hasEvent]->(rle:ReactionLikeEvent), " +
- " (rle)-[:input|output|catalystActivity|physicalEntity|entityFunctionalStatus|diseaseEntity|regulatedBy|regulator|hasComponent|hasMember|hasCandidate|repeatedUnit|proteinMarker|RNAMarker*]->(pe:PhysicalEntity) " +
- "WHERE (pe)-[:referenceEntity]->() " +
- "WITH DISTINCT pe " +
- "MATCH (pe)-[:referenceEntity]->(re:ReferenceEntity) " +
- "OPTIONAL MATCH (re)-[:referenceGene]->(re2:ReferenceEntity)-[:referenceDatabase]->(rd:ReferenceDatabase) " +
- "OPTIONAL MATCH (pe)-[:referenceEntity|crossReference*]->(dbi:DatabaseIdentifier) " +
- "WITH DISTINCT re, " +
- "COLLECT(DISTINCT rd.displayName + \":\" + re2.identifier) AS reIdentifiers, " +
- "COLLECT(DISTINCT CASE dbi WHEN NULL THEN NULL ELSE {databaseName: dbi.databaseName, identifier: dbi.identifier} END) AS dbis, COUNT(DISTINCT dbi) AS n " +
- "RETURN re.dbId AS referenceEntity, " +
- " re.secondaryIdentifier AS secondaryIdentifiers, " +
- " re.geneName AS geneNames, " +
- " reIdentifiers + re.otherIdentifier AS otherIdentifiers, " +
- " [{databaseName: re.databaseName, " +
- " identifier: CASE WHEN re.variantIdentifier IS NOT NULL THEN re.variantIdentifier ELSE re.identifier END " +
+ query = "" +
+ "MATCH (:Species{taxId:$taxId})<-[:species]-(:Pathway)-[:hasEvent]->(rle:ReactionLikeEvent), " +
+ " (rle)-[:input|output|catalystActivity|physicalEntity|entityFunctionalStatus|" +
+ "diseaseEntity|regulatedBy|regulator|hasComponent|hasMember|hasCandidate|repeatedUnit|proteinMarker|RNAMarker*]->(pe:PhysicalEntity) " +
+ "WHERE (pe)-[:referenceEntity]->() " +
+ "WITH DISTINCT pe " +
+ "MATCH (pe)-[:referenceEntity]->(re:ReferenceEntity) " +
+ "OPTIONAL MATCH (re)-[:referenceGene]->(re2:ReferenceEntity)-[:referenceDatabase]->(rd:ReferenceDatabase) " +
+ "OPTIONAL MATCH (pe)-[:referenceEntity|crossReference*]->(dbi:DatabaseIdentifier) " +
+ "WITH DISTINCT re, " +
+ "COLLECT(DISTINCT rd.displayName + \":\" + re2.identifier) AS reIdentifiers, " +
+ "COLLECT(DISTINCT CASE dbi WHEN NULL THEN NULL ELSE {databaseName: dbi.databaseName, identifier: dbi.identifier} END) AS dbis, " +
+ "COUNT(DISTINCT dbi) AS n " +
+ "RETURN re.dbId AS referenceEntity, " +
+ " re.secondaryIdentifier AS secondaryIdentifiers, " +
+ " re.geneName AS geneNames, " +
+ " reIdentifiers + re.otherIdentifier AS otherIdentifiers, " +
+ " [{databaseName: re.databaseName, " +
+ " identifier: CASE WHEN re.variantIdentifier IS NOT NULL THEN re.variantIdentifier ELSE re.identifier END " +
" }] + CASE WHEN n = 0 THEN [] ELSE dbis END AS xrefs";
Map xrefMap = new HashMap<>();
@@ -82,17 +85,21 @@ public void build(Map speciesMap) {
if (Main.VERBOSE) System.out.print(msgPrefix + speciesPrefix + " >> retrieving participants...");
//language=Cypher
- query = "MATCH (:Species{taxId:$taxId})<-[:species]-(p:Pathway)-[:hasEvent]->(rle:ReactionLikeEvent), " +
- " (rle)-[:input|output|catalystActivity|physicalEntity|entityFunctionalStatus|diseaseEntity|regulatedBy|regulator|hasComponent|hasMember|hasCandidate|repeatedUnit|proteinMarker|RNAMarker*]->(pe:PhysicalEntity)-[:referenceEntity]->(re:ReferenceEntity) " +
- "WITH DISTINCT p, pe, re, COLLECT(DISTINCT {dbId: rle.dbId, stId: rle.stId}) AS rles " +
- "OPTIONAL MATCH (pe)-[:hasModifiedResidue]->(tm:TranslationalModification)-[:psiMod]->(mod:PsiMod) " +
- "WITH DISTINCT p, pe, re, rles, COLLECT(DISTINCT {coordinate: tm.coordinate, mod: mod.identifier}) AS tmods, COUNT(DISTINCT mod) AS n " +
- "RETURN p.dbId AS pathway, " +
- " pe.dbId AS physicalEntity, " +
- " pe.speciesName AS speciesName, " +
- " re.dbId as referenceEntity, " +
- " rles AS reactions, " +
- " CASE WHEN n = 0 THEN [] ELSE tmods END AS mods";
+ query = "" +
+ "MATCH (:Species{taxId:$taxId})<-[:species]-(p:Pathway)-[:hasEvent]->(rle:ReactionLikeEvent), " +
+ " (rle)-[:input|output|catalystActivity|physicalEntity|entityFunctionalStatus|diseaseEntity|" +
+ "regulatedBy|regulator|hasComponent|hasMember|hasCandidate|repeatedUnit|proteinMarker|RNAMarker*]" +
+ "->(pe:PhysicalEntity)-[:referenceEntity]->(re:ReferenceEntity) " +
+ "WITH DISTINCT p, pe, re, COLLECT(DISTINCT {dbId: rle.dbId, stId: rle.stId}) AS rles " +
+ "OPTIONAL MATCH (pe)-[:hasModifiedResidue]->(tm:TranslationalModification)-[:psiMod]->(mod:PsiMod) " +
+ "WITH DISTINCT p, pe, re, rles, " +
+ " COLLECT(DISTINCT {coordinate: tm.coordinate, mod: mod.identifier}) AS tmods, COUNT(DISTINCT mod) AS n " +
+ "RETURN p.dbId AS pathway, " +
+ " pe.dbId AS physicalEntity, " +
+ " pe.speciesName AS speciesName, " +
+ " re.dbId as referenceEntity, " +
+ " rles AS reactions, " +
+ " CASE WHEN n = 0 THEN [] ELSE tmods END AS mods";
Collection result;
try {
@@ -157,8 +164,12 @@ public void setOrthologous() {
if (Main.VERBOSE) System.out.print(msgPrefix + " retrieving relationships...");
String query = "" +
- "MATCH (re1:ReferenceEntity)<-[:referenceEntity]-(:PhysicalEntity)-[:inferredTo]->(:PhysicalEntity)-[:referenceEntity]->(re2:ReferenceEntity) " +
- "RETURN DISTINCT re1.databaseName AS originDatabaseName, re1.identifier AS originIdentifier, re2.databaseName AS inferredToDatabaseName, re2.identifier AS inferredToIdentifier";
+ "MATCH (re1:ReferenceEntity)<-[:referenceEntity]-(:PhysicalEntity)" +
+ "-[:inferredTo]->(:PhysicalEntity)-[:referenceEntity]->(re2:ReferenceEntity) " +
+ "RETURN DISTINCT re1.databaseName AS originDatabaseName, " +
+ "re1.identifier AS originIdentifier, " +
+ "re2.databaseName AS inferredToDatabaseName, "+
+ "re2.identifier AS inferredToIdentifier";
Map paramsMap = new HashMap<>();
Collection orthologyResults;
@@ -201,4 +212,4 @@ public EntitiesContainer getEntitiesContainer() {
public IdentifiersMap getEntitiesMap() {
return entitiesMap;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/reactome/server/analysis/core/importer/InteractorsBuilder.java b/src/main/java/org/reactome/server/analysis/core/importer/InteractorsBuilder.java
index 6c01ad46..17ad17cc 100644
--- a/src/main/java/org/reactome/server/analysis/core/importer/InteractorsBuilder.java
+++ b/src/main/java/org/reactome/server/analysis/core/importer/InteractorsBuilder.java
@@ -49,17 +49,20 @@ public void build(Set speciesNodes, EntitiesContainer entities, Int
paramsMap.put("taxId", species.getTaxID());
String speciesPrefix = "'" + species.getName() + "' (" + (++s) + "/" + st + ")";
- if (Main.VERBOSE) System.out.print("\rCreating the interactors container for " + speciesPrefix + " >> retrieving targets for interactors...");
-
- query = "MATCH (:Species{taxId:$taxId})<-[:species]-(p:Pathway)-[:hasEvent]->(rle:ReactionLikeEvent), " +
- " (rle)-[:input|output|catalystActivity|physicalEntity|entityFunctionalStatus|diseaseEntity|regulatedBy|regulator*]->(pe:PhysicalEntity)-[:referenceEntity]->(re:ReferenceEntity) " +
- "WHERE (p:TopLevelPathway) OR (:TopLevelPathway)-[:hasEvent*]->(p) " +
- //" AND NOT (pe)-[:hasModifiedResidue]->(:TranslationalModification) " +
- "WITH DISTINCT p, re, COLLECT(DISTINCT {dbId: rle.dbId, stId: rle.stId}) AS rles " +
- "RETURN DISTINCT re.databaseName AS databaseName, " +
- " CASE WHEN re.variantIdentifier IS NOT NULL THEN re.variantIdentifier ELSE re.identifier END AS identifier, " +
- " p.dbId AS pathway, " +
- " rles AS reactions";
+ if (Main.VERBOSE) System.out.print("\rCreating interactors container for " + speciesPrefix + " >> retrieving targets...");
+
+
+ query = "" +
+ "MATCH (:Species{taxId:$taxId})<-[:species]-(p:Pathway)-[:hasEvent]->(rle:ReactionLikeEvent), " +
+ " (rle)-[:input|output|catalystActivity|physicalEntity|entityFunctionalStatus|diseaseEntity|" +
+ "regulatedBy|regulator*]->(pe:PhysicalEntity)-[:referenceEntity]->(re:ReferenceEntity) " +
+ "WHERE (p:TopLevelPathway) OR (:TopLevelPathway)-[:hasEvent*]->(p) " +
+ //" AND NOT (pe)-[:hasModifiedResidue]->(:TranslationalModification) " +
+ "WITH DISTINCT p, re, COLLECT(DISTINCT {dbId: rle.dbId, stId: rle.stId}) AS rles " +
+ "RETURN DISTINCT re.databaseName AS databaseName, " +
+ " CASE WHEN re.variantIdentifier IS NOT NULL THEN re.variantIdentifier ELSE re.identifier END AS identifier, " +
+ " p.dbId AS pathway, " +
+ " rles AS reactions";
Collection its;
try {
@@ -148,7 +151,7 @@ private InteractorNode getOrCreate(Resource resource, String identifier) {
} else {
//Using IdentifiersMap causes this "oddity" here, but is a minor inconvenient
if (interactors.size() > 1)
- logger.error("Interactors duplication. There should not be more than one interactor for " + identifier + " [" + resource.getName() + "]");
+ logger.error("Duplicate interactors found for " + identifier + " [" + resource.getName() + "]");
return interactors.iterator().next();
}
}
diff --git a/src/main/java/org/reactome/server/analysis/core/importer/psimod/PsiModRetrieval.java b/src/main/java/org/reactome/server/analysis/core/importer/psimod/PsiModRetrieval.java
index ae30714e..b112f296 100755
--- a/src/main/java/org/reactome/server/analysis/core/importer/psimod/PsiModRetrieval.java
+++ b/src/main/java/org/reactome/server/analysis/core/importer/psimod/PsiModRetrieval.java
@@ -38,7 +38,16 @@
class PsiModRetrieval {
public enum Relations {
- self, parents, hierarchicalParents, hierarchicalAncestors, ancestors, children, hierarchicalChildren, hierarchicalDescendants, descendants, jstree
+ self,
+ parents,
+ hierarchicalParents,
+ hierarchicalAncestors,
+ ancestors,
+ children,
+ hierarchicalChildren,
+ hierarchicalDescendants,
+ descendants,
+ jstree
}
private static final int ONTOLOGY_SIZE = 20;
@@ -91,7 +100,8 @@ private static BufferedReader getContentBufferedReader(String uri) {
}
/**
- * Consults the web service at the Onthology Lookup Service (http://www.ebi.ac.uk/ols/docs/api) to get the other PSIMOD terms with the specified relation
+ * Consults the web service at the Onthology Lookup Service (http://www.ebi.ac.uk/ols/docs/api)
+ * to get the other PSIMOD terms with the specified relation
*
* @param id The PSIMOD id for the term. Ex. "00046"
* @param relation Any value of the enum {@link Relations} Ex. "parents", "children", "hierarchicalChildren", "hierarchicalAncestors"
@@ -158,7 +168,8 @@ private static String createUri(String ontologyName) {
}
private static String createUri(String ontologyName, String term, Relations relation) {
- return "http://www.ebi.ac.uk/ols/api/ontologies/" + ontologyName + "/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FMOD_" + term + "/" + relation + "?size=" + ONTOLOGY_SIZE;
+ return "http://www.ebi.ac.uk/ols/api/ontologies/" + ontologyName +
+ "/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FMOD_" + term + "/" + relation + "?size=" + ONTOLOGY_SIZE;
}
private static int getOntologySize(String onthologyName) {
diff --git a/src/main/java/org/reactome/server/analysis/core/methods/EnrichmentAnalysis.java b/src/main/java/org/reactome/server/analysis/core/methods/EnrichmentAnalysis.java
index c5411bcc..aefb54e2 100644
--- a/src/main/java/org/reactome/server/analysis/core/methods/EnrichmentAnalysis.java
+++ b/src/main/java/org/reactome/server/analysis/core/methods/EnrichmentAnalysis.java
@@ -57,8 +57,10 @@ private void analyse(HierarchiesData hierarchies, Set identi
IdentifiersMap entitiesMap = analysisData.getEntitiesMap();
IdentifiersMap interactorsMap = analysisData.getInteractorsMap();
- logger.trace("Analysing: " + originalSampleSize + " identifier(s). Including interactors: " + includeInteractors + ". Project to species: " + (speciesNode == null ? false : speciesNode.getName()));
- long start = System.currentTimeMillis();
+ logger.trace("Analysing: {} identifier(s). Including interactors: {}. Project to species: {}",
+ originalSampleSize, includeInteractors, (speciesNode == null ? false : speciesNode.getName()));
+
+ long start = System.currentTimeMillis();
Set newSample = new HashSet<>();
for (AnalysisIdentifier identifier : identifiers) {
@@ -126,7 +128,9 @@ private void analyse(HierarchiesData hierarchies, Set identi
logger.trace("Final sample size is " + finalSampleSize + " identifier(s)");
hierarchies.setResultStatistics(sampleSizePerResource, hierarchies.getNotFound().size(), includeInteractors);
long end = System.currentTimeMillis();
- logger.info("Analysis for " + originalSampleSize + " identifier(s) (" + finalSampleSize + " when expanded) performed in " + (end - start) + " ms");
+ logger.info("Analysis for {} identifier(s) ({} when expanded) performed in {} ms",
+ originalSampleSize, finalSampleSize, (end - start));
+
}
private void decreaseCounter() {
diff --git a/src/main/java/org/reactome/server/analysis/core/methods/IdentifiersMapping.java b/src/main/java/org/reactome/server/analysis/core/methods/IdentifiersMapping.java
index 7e30e924..6e0b498c 100644
--- a/src/main/java/org/reactome/server/analysis/core/methods/IdentifiersMapping.java
+++ b/src/main/java/org/reactome/server/analysis/core/methods/IdentifiersMapping.java
@@ -1,6 +1,5 @@
package org.reactome.server.analysis.core.methods;
-
import org.reactome.server.analysis.core.data.AnalysisData;
import org.reactome.server.analysis.core.model.EntityNode;
import org.reactome.server.analysis.core.model.IdentifiersMap;
@@ -58,7 +57,9 @@ private MapSet getMapping(Set identifiers, Spe
MapSet rtn = new MapSet<>();
final int originalSampleSize = identifiers.size();
- logger.trace("Mapping: " + originalSampleSize + " identifier(s). Including interactors: " + includeInteractors + ". Project to species: " + (speciesNode == null ? false : speciesNode.getName()));
+ logger.trace("Mapping: {} identifier(s). Including interactors: {}. Project to species: {}",
+ originalSampleSize, includeInteractors, (speciesNode == null ? false : speciesNode.getName()));
+
long start = System.currentTimeMillis();
IdentifiersMap entitiesMap = analysisData.getEntitiesMap();
@@ -78,7 +79,7 @@ private MapSet getMapping(Set identifiers, Spe
MapSet interactors = interactorsMap.get(identifier);
for (Resource resource : interactors.keySet()) {
for (InteractorNode interactorNode : interactors.getElements(resource)) {
- Set interactsWith = interactorNode.getInteractsWith(); //InteractorHelper.getInteractsWith(speciesNode, entitiesMap, interactorNode);
+ Set interactsWith = interactorNode.getInteractsWith();
rtn.add(identifier, new MappedIdentifier(resource, interactorNode.getAccession(), interactsWith));
}
}
@@ -91,8 +92,6 @@ private MapSet getMapping(Set identifiers, Spe
return rtn;
}
-
-
private void decreaseCounter() {
synchronized (MAPPING_SEMAPHORE) {
if (--MAPPING_COUNT == 0) {
diff --git a/src/main/java/org/reactome/server/analysis/core/model/PathwayNodeData.java b/src/main/java/org/reactome/server/analysis/core/model/PathwayNodeData.java
index 66134132..ff646b93 100644
--- a/src/main/java/org/reactome/server/analysis/core/model/PathwayNodeData.java
+++ b/src/main/java/org/reactome/server/analysis/core/model/PathwayNodeData.java
@@ -220,7 +220,9 @@ public Set getFoundEntities(MainResource resource) {
return rtn;
}
- private List> groupEntitiesExpressionValues(Collection identifiers, Collection interactors) {
+ private List> groupEntitiesExpressionValues(
+ Collection identifiers,
+ Collection interactors) {
List> evss = new LinkedList<>();
Collection aggregation = new HashSet<>();
aggregation.addAll(identifiers);
@@ -662,4 +664,4 @@ private Counter getOrCreateCounter(MainResource mainResource){
}
return counter;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/reactome/server/analysis/core/result/AnalysisStoredResult.java b/src/main/java/org/reactome/server/analysis/core/result/AnalysisStoredResult.java
index 9431c523..b87ed0bd 100644
--- a/src/main/java/org/reactome/server/analysis/core/result/AnalysisStoredResult.java
+++ b/src/main/java/org/reactome/server/analysis/core/result/AnalysisStoredResult.java
@@ -307,7 +307,8 @@ public AnalysisStoredResult filterPathways(String resource, Double pValue, boole
return filterPathways(null, resource, pValue, includeDisease, min, max);
}
- public AnalysisStoredResult filterPathways(List species, String resource, Double pValue, boolean includeDisease, Integer min, Integer max) {
+ public AnalysisStoredResult filterPathways(List species, String resource, Double pValue,
+ boolean includeDisease, Integer min, Integer max) {
final boolean includeInteractors = summary.isInteractors();
MainResource mr = ResourceFactory.getMainResource(resource);
List pathways = new LinkedList<>();
diff --git a/src/main/java/org/reactome/server/analysis/core/result/model/AnalysisSummary.java b/src/main/java/org/reactome/server/analysis/core/result/model/AnalysisSummary.java
index a006b4b0..02e49d41 100644
--- a/src/main/java/org/reactome/server/analysis/core/result/model/AnalysisSummary.java
+++ b/src/main/java/org/reactome/server/analysis/core/result/model/AnalysisSummary.java
@@ -22,7 +22,10 @@ public class AnalysisSummary {
private String gsaToken;
private String gsaMethod;
- AnalysisSummary(String token, Boolean projection, Boolean interactors, String sampleName, AnalysisType type, String server, Boolean includeDisease, String gsaToken, String gsaMethod) {
+ AnalysisSummary(String token, Boolean projection, Boolean interactors,
+ String sampleName, AnalysisType type, String server,
+ Boolean includeDisease, String gsaToken, String gsaMethod) {
+
this.token = token;
this.type = type.toString();
this.sampleName = sampleName;
@@ -34,24 +37,32 @@ public class AnalysisSummary {
this.gsaMethod = gsaMethod;
}
- public AnalysisSummary(String token, Boolean projection, Boolean interactors, String sampleName, AnalysisType type, String fileName, String server, Boolean includeDisease) {
+ public AnalysisSummary(String token, Boolean projection, Boolean interactors,
+ String sampleName, AnalysisType type, String fileName,
+ String server, Boolean includeDisease) {
this(token, projection, interactors, sampleName, type, server, includeDisease, null, null);
this.fileName = fileName;
if(this.fileName!=null) this.fileName = this.fileName.split("\\?")[0];
}
- public AnalysisSummary(String token, Boolean projection, Boolean interactors, String sampleName, AnalysisType type, Long species, String server, Boolean includeDisease) {
+ public AnalysisSummary(String token, Boolean projection, Boolean interactors,
+ String sampleName, AnalysisType type, Long species,
+ String server, Boolean includeDisease) {
this(token, projection, interactors, sampleName, type, server, includeDisease, null, null);
this.species = species;
}
- public AnalysisSummary(String token, Boolean projection, Boolean interactors, String sampleName, AnalysisType type, boolean text, String server, Boolean includeDisease) {
+ public AnalysisSummary(String token, Boolean projection, Boolean interactors,
+ String sampleName, AnalysisType type, boolean text,
+ String server, Boolean includeDisease) {
this(token, projection, interactors, sampleName, type, server, includeDisease, null, null);
this.text = text;
}
public AnalysisSummary(String token, ExternalAnalysisSummary summary) {
- this(token, summary.getProjection(), summary.getInteractors(), summary.getSampleName(), summary.getType(), summary.getServer(), summary.getIncludeDisease(), summary.getGsaToken(), summary.getGsaMethod());
+ this(token, summary.getProjection(), summary.getInteractors(), summary.getSampleName(),
+ summary.getType(), summary.getServer(), summary.getIncludeDisease(),
+ summary.getGsaToken(), summary.getGsaMethod());
}
public String getToken() {
diff --git a/src/main/java/org/reactome/server/analysis/core/result/model/FoundEntities.java b/src/main/java/org/reactome/server/analysis/core/result/model/FoundEntities.java
index fdaa73b9..b2e0d47a 100644
--- a/src/main/java/org/reactome/server/analysis/core/result/model/FoundEntities.java
+++ b/src/main/java/org/reactome/server/analysis/core/result/model/FoundEntities.java
@@ -20,7 +20,8 @@ public class FoundEntities {
private Integer totalEntitiesCount;
private Map resourceToMappedEntitiesCount;
- private FoundEntities(List identifiers, Set resources, List expNames, Integer found, Integer totalEntitiesCount, Map resourceToMappedEntitiesCount) {
+ private FoundEntities(List identifiers, Set resources, List expNames,
+ Integer found, Integer totalEntitiesCount, Map resourceToMappedEntitiesCount) {
this.identifiers = identifiers;
this.resources = resources;
this.expNames = expNames;
@@ -91,8 +92,16 @@ public Integer getTotalEntitiesCount() {
public Map getResourceToMappedEntitiesCount() {
if (resourceToMappedEntitiesCount == null) {
Map> resourceToIds = new HashMap<>();
- identifiers.forEach(foundEntity -> foundEntity.getMapsTo().forEach(identifierMap -> resourceToIds.computeIfAbsent(identifierMap.getResource(), s -> new HashSet<>()).addAll(identifierMap.getIds())));
- resourceToMappedEntitiesCount = resourceToIds.keySet().stream().collect(Collectors.toMap(resource -> resource, resource -> resourceToIds.get(resource).size()));
+ identifiers.forEach(foundEntity ->
+ foundEntity.getMapsTo().forEach(identifierMap ->
+ resourceToIds.computeIfAbsent(identifierMap.getResource(), s -> new HashSet<>())
+ .addAll(identifierMap.getIds())));
+ resourceToMappedEntitiesCount = resourceToIds.keySet().stream()
+ .collect(Collectors.toMap(
+ resource -> resource,
+ resource -> resourceToIds.get(resource).size()
+ ));
+
}
return resourceToMappedEntitiesCount;
}
@@ -116,7 +125,12 @@ public FoundEntities filter(String resource) {
} else {
identifiers = filterByResource(resource.toUpperCase());
}
- return new FoundEntities(identifiers, resources, expNames, identifiers.size(), this.getTotalEntitiesCount(), this.getResourceToMappedEntitiesCount());
+ return new FoundEntities(identifiers,
+ resources,
+ expNames,
+ identifiers.size(),
+ this.getTotalEntitiesCount(),
+ this.getResourceToMappedEntitiesCount());
}
public FoundEntities filter(String resource, Integer pageSize, Integer page) {
@@ -140,7 +154,12 @@ public FoundEntities filter(String resource, Integer pageSize, Integer page) {
int to = from + pageSize;
to = to > identifiers.size() ? identifiers.size() : to;
Set resources = resource.equals("TOTAL") ? this.resources : new HashSet<>(Arrays.asList(resource));
- return new FoundEntities(identifiers.subList(from, to), resources, this.expNames, identifiers.size(), this.getTotalEntitiesCount(), this.getResourceToMappedEntitiesCount());
+ return new FoundEntities(identifiers.subList(from, to),
+ resources,
+ this.expNames,
+ identifiers.size(),
+ this.getTotalEntitiesCount(),
+ this.getResourceToMappedEntitiesCount());
} else {
return null;
}
diff --git a/src/main/java/org/reactome/server/analysis/core/result/model/FoundInteractors.java b/src/main/java/org/reactome/server/analysis/core/result/model/FoundInteractors.java
index 7928ed99..01256dfe 100644
--- a/src/main/java/org/reactome/server/analysis/core/result/model/FoundInteractors.java
+++ b/src/main/java/org/reactome/server/analysis/core/result/model/FoundInteractors.java
@@ -50,7 +50,10 @@ public FoundInteractors(PathwayNodeSummary nodeSummary, List expNames) {
for (Resource resource : summaries.keySet()) {
for (IdentifierSummary identifier : summaries.getElements(resource)) {
- identifiers.add(new FoundInteractor(identifier, mapsTo.getElements(identifier), new IdentifierMap(resource.getName(), interactsWith.getElements(identifier))));
+ identifiers.add(new FoundInteractor(identifier,
+ mapsTo.getElements(identifier),
+ new IdentifierMap(resource.getName(),
+ interactsWith.getElements(identifier))));
}
}
diff --git a/src/main/java/org/reactome/server/analysis/core/result/utils/ExternalAnalysisResultCheck.java b/src/main/java/org/reactome/server/analysis/core/result/utils/ExternalAnalysisResultCheck.java
index b64d7871..e2111613 100644
--- a/src/main/java/org/reactome/server/analysis/core/result/utils/ExternalAnalysisResultCheck.java
+++ b/src/main/java/org/reactome/server/analysis/core/result/utils/ExternalAnalysisResultCheck.java
@@ -85,7 +85,8 @@ private void checkExpressionSummary(ExternalExpressionSummary expressionSummary,
}
}
- private void checkPathways(List pathways, ExternalExpressionSummary expressionSummary, final List messages) {
+ private void checkPathways(List pathways,
+ ExternalExpressionSummary expressionSummary, final List messages) {
if (pathways == null) return;
for (int i = 1; i <= pathways.size(); i++) {
@@ -107,7 +108,8 @@ private void checkPathways(List pathways, ExternalEx
}
}
- private void checkPathwayNodeData(ExternalPathwayNodeData data, ExternalExpressionSummary expressionSummary, final int i, final List messages) {
+ private void checkPathwayNodeData(ExternalPathwayNodeData data, ExternalExpressionSummary expressionSummary,
+ final int i, final List messages) {
//Statistics check
if (data.getStatistics() == null || data.getStatistics().isEmpty()) {
messages.add(String.format("'statistics' not found for pathway %d", i));
@@ -148,7 +150,8 @@ private void checkPathwayNodeData(ExternalPathwayNodeData data, ExternalExpressi
} else {
int aux = (exp == null) ? 0 : exp.size();
if (aux != expValues) {
- messages.add(String.format("'exp' field contains %d values but it must contain %d values in the entity %d for pathway %d", aux, expValues, j, i));
+ messages.add(String.format("'exp' field contains %d values but it must contain %d" +
+ " values in the entity %d for pathway %d", aux, expValues, j, i));
} else {
for (int k = 1; j <= exp.size(); j++) {
final Double value = exp.get(k - 1);
@@ -156,7 +159,8 @@ private void checkPathwayNodeData(ExternalPathwayNodeData data, ExternalExpressi
messages.add(String.format("The value in position %d in 'exp' field is null in entity %d for pathway %d",
k, j, i));
} else if (!expressionSummary.isValid(value)) {
- messages.add(String.format("The value in position %d in 'exp' field is not between the specified boundaries in of entity %d for pathway %d",
+ messages.add(String.format("The value in position %d in 'exp' field is not between the specified" +
+ " boundaries in of entity %d for pathway %d",
k, j, i));
}
}
@@ -197,7 +201,8 @@ private void checkPathwayNodeData(ExternalPathwayNodeData data, ExternalExpressi
} else {
int aux = (exp == null) ? 0 : exp.size();
if (aux != expValues) {
- messages.add(String.format("'exp' field contains %d values but it must contain %d values in the interactor %d for pathway %d", aux, expValues, j, i));
+ messages.add(String.format("'exp' field contains %d values but it must contain %d" +
+ " values in the interactor %d for pathway %d", aux, expValues, j, i));
} else {
for (int k = 1; j <= exp.size(); j++) {
final Double value = exp.get(k - 1);
@@ -205,7 +210,8 @@ private void checkPathwayNodeData(ExternalPathwayNodeData data, ExternalExpressi
messages.add(String.format("The value in position %d in 'exp' field is null in interactor %d for pathway %d",
k, j, i));
} else if (!expressionSummary.isValid(value)) {
- messages.add(String.format("The value in position %d in 'exp' field is not between the specified boundaries in of interactor %d for pathway %d",
+ messages.add(String.format("The value in position %d in 'exp' field is not between the specified" +
+ " boundaries in of interactor %d for pathway %d",
k, j, i));
}
}
@@ -221,15 +227,18 @@ private void checkPathwayNodeData(ExternalPathwayNodeData data, ExternalExpressi
messages.add(String.format("Identifier 'null' for the mapping %d of interactor %d for pathway %d", k, j, i));
}
if (in.getInteractsWith() == null || in.getInteractsWith().isEmpty()) {
- messages.add(String.format("No interacts with provided for mapping %d in the interactor %d for pathway %d", k, j, i));
+ messages.add(String.format("No interacts with provided for mapping %d" +
+ " in the interactor %d for pathway %d", k, j, i));
} else {
for (int l = 1; l <= in.getInteractsWith().size(); l++) {
ExternalMainIdentifier mi = in.getInteractsWith().get(l - 1);
if (mi.getId() == null || mi.getId().isEmpty()) {
- messages.add(String.format("Identifier 'null' for the interactsWith %d of the maps to %d of entity %d for pathway %d", l, k, j, i));
+ messages.add(String.format("Identifier 'null' for the interactsWith %d of the maps to %d " +
+ "of entity %d for pathway %d", l, k, j, i));
}
if (!isValidResource(mi.getResource())) {
- messages.add(String.format("'%s' for the interactsWith %d of the maps to %d of interactor %d for pathway %d is not a valid MainResource", mi.getResource(), l, k, j, i));
+ messages.add(String.format("'%s' for the interactsWith %d of the maps to %d of interactor %d " +
+ "for pathway %d is not a valid MainResource", mi.getResource(), l, k, j, i));
}
}
}
@@ -312,7 +321,8 @@ private void checkPathwayNodeStatistics(ExternalStatistics statistic, ExternalEx
messages.add(String.format("The value in position %d in 'exp' field is null in the statics (resource:%s) for pathway %d",
j, statistic.getResource(), i));
} else if (!expressionSummary.isValid(value)) {
- messages.add(String.format("The value in position %d in 'exp' field is not between the specified boundaries in the statics (resource:%s) for pathway %d",
+ messages.add(String.format("The value in position %d in 'exp' field is not between the specified " +
+ "boundaries in the statics (resource:%s) for pathway %d",
j, statistic.getResource(), i));
}
}
@@ -362,7 +372,8 @@ private void checkNotFound(List notFound, ExternalExpression
if (value == null) {
messages.add(String.format("The value in position %d in 'exp' field is null in not found entity %d", j, i));
} else if (!expressionSummary.isValid(value)) {
- messages.add(String.format("The value in position %d in 'exp' field is not between the specified boundaries in the not found entity %d", j, i));
+ messages.add(String.format("The value in position %d in 'exp' field is not between " +
+ "the specified boundaries in the not found entity %d", j, i));
}
}
}
@@ -382,4 +393,4 @@ public void setAnalysisData(AnalysisData analysisData) {
this.analysisData = analysisData;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/reactome/server/analysis/core/result/utils/TokenUtils.java b/src/main/java/org/reactome/server/analysis/core/result/utils/TokenUtils.java
index 2c93663f..605ead6d 100644
--- a/src/main/java/org/reactome/server/analysis/core/result/utils/TokenUtils.java
+++ b/src/main/java/org/reactome/server/analysis/core/result/utils/TokenUtils.java
@@ -48,7 +48,8 @@ public AnalysisStoredResult getFromToken(String token) {
throw new ResourceNotFoundException();
}
- public AnalysisSummary getAnalysisSummary(String token, Boolean projection, Boolean interactors, String sampleName, AnalysisType type, String userFileName, String serverName, boolean includeDisease) {
+ public AnalysisSummary getAnalysisSummary(String token, Boolean projection, Boolean interactors, String sampleName,
+ AnalysisType type, String userFileName, String serverName, boolean includeDisease) {
if (userFileName != null && !userFileName.isEmpty()) {
return new AnalysisSummary(token, projection, interactors, sampleName, type, userFileName, serverName, includeDisease);
} else {