Skip to content

Commit

Permalink
Merge pull request #2408 from opencb/TASK-5618
Browse files Browse the repository at this point in the history
TASK-5618 - Port Patch 1.10.2 -> 2.0.0
  • Loading branch information
juanfeSanahuja authored Mar 7, 2024
2 parents 9136a3a + df495c1 commit d45f95d
Show file tree
Hide file tree
Showing 94 changed files with 845 additions and 1,074 deletions.
57 changes: 4 additions & 53 deletions opencga-app/app/analysis/resources/README
Original file line number Diff line number Diff line change
@@ -1,55 +1,6 @@
README


In this folder, users should store external files to be used by some OpenCGA analysis.

1) roleInCancer.txt[.gz]

This file is used by interpretation clinical analysis, e.g., Tiering and TEAM analysis.

It stores those genes which contain mutations that have been casually implicated in cancer. This information can be downloaded
from the Cancer Gene Census (CGC) at https://cancer.sanger.ac.uk/census

The file consists of two tab-separated columns: the first one contains the gene name, and the second, the role in cancer, i.e.: oncogne,
TSG, fusion. In addition, lines starting with # are considered comments and will be ignored.

Sample of a roleInCancer file:

#Gene name Role in Cancer
A1CF oncogene
ABI1 TSG, fusion
ABL1 oncogene, fusion
ABL2 oncogene, fusion
ACKR3 oncogene, fusion
ACSL3 fusion
...
...


2) actionableVariants_xxx.txt[.gz] where xxx = assembly, e.g.: grch37

This file is used by interpretation clinical analysis, e.g., TEAM analysis.

It stores variants that were identified as clinically actionable variants. The file consists of the following twelve tab-separated columns:
- Chromosome
- Start
- Stop
- Reference allele
- Alternate allele
- dbSNP ID
- ClinVar Variant ID
- HGVS
- Phenotype list
- Clinical significance
- Review status
- Submitter categories

In addition, lines starting with # are considered comments and will be ignored.

Sample fo an actionableVariants file:

#Chromosome Start Stop ReferenceAllele AlternateAllele dbSNP ID ClinVar Variant ID hgvs PhenotypeList ClinicalSignificance ReviewStatus SubmitterCategories
2 47702269 47702269 C T rs28929483 1753 NM_000251.2(MSH2):c.1865C>T (p.Pro622Leu) Hereditary cancer-predisposing syndrome;Hereditary nonpolyposis colon cancer;Lynch syndrome;Lynch syndrome I Pathogenic reviewed by expert panel 3
2 47657020 47657020 C T rs63751108 1755 NM_000251.2(MSH2):c.1216C>T (p.Arg406Ter) Carcinoma of colon;Hereditary cancer-predisposing syndrome;Hereditary nonpolyposis colon cancer;Lynch syndrome;Lynch syndrome I;not provided Pathogenic reviewed by expert panel 3
...
...
This directory is designated for OpenCGA analyses to download the necessary external data.
For instance, during the first Exomiser analysis, the files '2109_hg38.zip' and '2109_phenotype.zip' will be downloaded
from the OpenCGA analysis URL and stored in the 'exomiser' folder within this directory. Subsequent Exomiser analyses will
then access this folder to read these files.
4 changes: 2 additions & 2 deletions opencga-app/app/cloud/docker/opencga-ext-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ RUN apt-get update -y && DEBIAN_FRONTEND="noninteractive" TZ="Europe/London" apt
WORKDIR /opt/opencga/signature.tools.lib

RUN git fetch origin --tags && \
git checkout tags/v2.4.2 && \
git checkout tags/v2.4.4 && \
sed -i '/Mmusculus/d' DESCRIPTION && \
sed -i '/Cfamiliaris/d' DESCRIPTION && \
sed -i '/1000genomes/d' DESCRIPTION && \
R -e 'options(timeout = 300);devtools::install(repos="https://www.stats.bris.ac.uk/R/")' && \
R -e 'options(timeout = 3600);devtools::install(repos="https://www.stats.bris.ac.uk/R/")' && \
## Clean up
rm -rf /var/lib/apt/lists/* /tmp/* /opt/opencga/signature.tools.lib/.git && \
strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
Expand Down
18 changes: 9 additions & 9 deletions opencga-app/app/misc/scripts/hadoop-ssh.sh
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
#!/usr/bin/env sh


if [ -z ${HADOOP_SSH_USER} ] ; then
if [ -z "${HADOOP_SSH_USER}" ] ; then
echo "Undefined HADOOP_SSH_USER" 1>&2
exit 1
fi

if [ -z ${HADOOP_SSH_HOST} ] ; then
if [ -z "${HADOOP_SSH_HOST}" ] ; then
echo "Undefined HADOOP_SSH_HOST" 1>&2
exit 1
fi

SSHPASS_CMD=
if [ -z ${SSHPASS} ] ; then
if [ -z "${SSHPASS}" ] ; then
# If empty, assume ssh-key exists in the system
SSHPASS_CMD=""
else
# If non zero, use sshpass command
SSHPASS_CMD="sshpass -e"
SSHPASS_CMD="sshpass -e "
fi

SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=60"
if [ ! -z ${HADOOP_SSH_KEY} ] && [ -f ${HADOOP_SSH_KEY} ] ; then
if [ -n "${HADOOP_SSH_KEY}" ] && [ -f "${HADOOP_SSH_KEY}" ] ; then
SSH_OPTS="${SSH_OPTS} -i ${HADOOP_SSH_KEY}"
fi

echo "Connect to Hadoop edge node ${HADOOP_SSH_USER}@${HADOOP_SSH_HOST}" 1>&2

echo "${SSHPASS_CMD} ssh ${SSH_OPTS} ${HADOOP_SSH_USER}@${HADOOP_SSH_HOST}" 1>&2
echo "${SSHPASS_CMD}ssh ${SSH_OPTS} ${HADOOP_SSH_USER}@${HADOOP_SSH_HOST}" 1>&2

# Escape args with single quotes
CMD=
for arg in $@ ; do
for arg in "$@" ; do
# Escape single quote, if any :
# arg=`echo $arg | sed "s/'/'\"'\"'/g"` # aaa'aaa --> 'aaa'"'"'aaa'
arg=`echo $arg | sed "s/'/'\\\\\\''/g"` # aaa'aaa --> 'aaa'\''aaa'
arg=$(echo "$arg" | sed "s/'/'\\\\\\''/g") # aaa'aaa --> 'aaa'\''aaa'
CMD="${CMD}'${arg}' "
done
echo ${CMD}

${SSHPASS_CMD} ssh ${SSH_OPTS} ${HADOOP_SSH_USER}@${HADOOP_SSH_HOST} /bin/bash << EOF
${SSHPASS_CMD} ssh ${SSH_OPTS} "${HADOOP_SSH_USER}@${HADOOP_SSH_HOST}" /bin/bash << EOF
export HADOOP_CLASSPATH=${HADOOP_CLASSPATH}
export HADOOP_USER_CLASSPATH_FIRST=${HADOOP_USER_CLASSPATH_FIRST}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,25 @@
package org.opencb.opencga.app.cli;

import com.beust.jcommander.JCommander;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.opencb.commons.datastore.core.ObjectMap;
import org.opencb.commons.utils.FileUtils;
import org.opencb.commons.utils.PrintUtils;
import org.opencb.opencga.app.cli.main.utils.CommandLineUtils;
import org.opencb.opencga.app.cli.session.SessionManager;
import org.opencb.opencga.client.config.ClientConfiguration;
import org.opencb.opencga.client.exceptions.ClientException;
import org.opencb.opencga.client.rest.OpenCGAClient;
import org.opencb.opencga.core.config.Configuration;
import org.opencb.opencga.core.config.storage.StorageConfiguration;
import org.opencb.opencga.core.response.RestResponse;
import org.opencb.opencga.server.generator.models.RestCategory;
import org.opencb.opencga.server.generator.models.RestEndpoint;
import org.opencb.opencga.server.generator.models.RestParameter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -36,6 +45,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

/**
* Created by imedina on 19/04/16.
Expand Down Expand Up @@ -281,6 +291,95 @@ public CommandExecutor setSessionManager(SessionManager sessionManager) {
return this;
}


public String getObjectAsJSON(String objectCategory, String objectPath, OpenCGAClient openCGAClient) throws Exception {
StringBuilder jsonInString = new StringBuilder("\n");
try {
ObjectMap queryParams = new ObjectMap();
queryParams.putIfNotEmpty("category", objectCategory);
RestResponse<List> response = openCGAClient.getMetaClient().api(queryParams);
ObjectMapper jsonObjectMapper = new ObjectMapper();
for (List list : response.getResponses().get(0).getResults()) {
List<RestCategory> categories = jsonObjectMapper.convertValue(list, new TypeReference<List<RestCategory>>() {});
for (RestCategory category : categories) {
for (RestEndpoint endpoint : category.getEndpoints()) {
if (objectPath.equals(endpoint.getPath())) {
boolean enc = false;
for (RestParameter parameter : endpoint.getParameters()) {
//jsonInString += parameter.getName()+":"+parameter.getAllowedValues()+"\n";
if (parameter.getData() != null) {
enc = true;
jsonInString.append(printBody(parameter.getData(), ""));
}
}
if (!enc) {
jsonInString.append("No model available");
}
//
}
}
}
}
} catch (Exception e) {
jsonInString = new StringBuilder("Data model not found.");
CommandLineUtils.error(e);
}
return jsonInString.toString();
}

private String printBody(List<RestParameter> data, String tabs) {
String res = "";
res += "{\n";
String tab = " " + tabs;
for (RestParameter parameter : data) {
if (parameter.getData() == null) {
res += printParameter(parameter, tab);
} else {
res += tab + "\"" +parameter.getName() + "\"" + ": [" + printBody(parameter.getData(), tab) + "],\n";
}
}
res += tabs + "}";
return res;

}

private String printParameter(RestParameter parameter, String tab) {

return tab + "\"" + parameter.getName() + "\"" + ":" + printParameterValue(parameter) + ",\n";
}

private String printParameterValue(RestParameter parameter) {

if(!StringUtils.isEmpty(parameter.getAllowedValues())){
return parameter.getAllowedValues().replace(" ", "|");
}
switch (parameter.getType()) {
case "Boolean":
case "java.lang.Boolean":
return "false";
case "Long":
case "Float":
case "Double":
case "Integer":
case "int":
case "double":
case "float":
case "long":
return "0";
case "List":
return "[\"\"]";
case "Date":
return "\"dd/mm/yyyy\"";
case "Map":
return "{\"key\": \"value\"}";
case "String":
return "\"\"";
default:
return "\"-\"";
}
}


public Logger getLogger() {
return logger;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024-03-04 OpenCB
* Copyright 2015-2024-03-06 OpenCB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,7 +60,7 @@ public abstract class OpenCgaCompleter implements Completer {
.map(Candidate::new)
.collect(toList());

private List<Candidate> clinicalList = asList( "acl-update","annotation-sets-load","clinical-configuration-update","create","distinct","interpretation-distinct","interpretation-search","interpretation-info","interpreter-cancer-tiering-run","interpreter-exomiser-run","interpreter-team-run","interpreter-tiering-run","interpreter-zetta-run","load","rga-aggregation-stats","rga-gene-query","rga-gene-summary","rga-index-run","rga-individual-query","rga-individual-summary","rga-variant-query","rga-variant-summary","search","variant-query","acl","delete","update","annotation-sets-annotations-update","info","interpretation-create","interpretation-clear","interpretation-delete","interpretation-revert","interpretation-update")
private List<Candidate> clinicalList = asList( "acl-update","annotation-sets-load","clinical-configuration-update","create","distinct","interpretation-distinct","interpretation-search","interpretation-info","interpreter-cancer-tiering-run","interpreter-exomiser-run","interpreter-team-run","interpreter-tiering-run","interpreter-zetta-run","load","rga-aggregation-stats","rga-gene-query","rga-gene-summary","rga-index-run","rga-individual-query","rga-individual-summary","rga-variant-query","rga-variant-summary","search","variant-query","acl","delete","update","annotation-sets-annotations-update","info","interpretation-create","interpretation-clear","interpretation-delete","interpretation-revert","interpretation-update","report-update")
.stream()
.map(Candidate::new)
.collect(toList());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024-03-04 OpenCB
* Copyright 2015-2024-03-06 OpenCB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -161,6 +161,7 @@ public OpencgaCliOptionsParser() {
analysisClinicalSubCommands.addCommand("interpretation-delete", analysisClinicalCommandOptions.deleteInterpretationCommandOptions);
analysisClinicalSubCommands.addCommand("interpretation-revert", analysisClinicalCommandOptions.revertInterpretationCommandOptions);
analysisClinicalSubCommands.addCommand("interpretation-update", analysisClinicalCommandOptions.updateInterpretationCommandOptions);
analysisClinicalSubCommands.addCommand("report-update", analysisClinicalCommandOptions.updateReportCommandOptions);

jobsCommandOptions = new JobsCommandOptions(commonCommandOptions, jCommander);
jCommander.addCommand("jobs", jobsCommandOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ public void execute() throws Exception {
case "interpretation-update":
queryResponse = updateInterpretation();
break;
case "report-update":
queryResponse = updateReport();
break;
default:
logger.error("Subcommand not valid");
break;
Expand Down Expand Up @@ -1485,4 +1488,48 @@ private RestResponse<Interpretation> updateInterpretation() throws Exception {
}
return openCGAClient.getClinicalAnalysisClient().updateInterpretation(commandOptions.clinicalAnalysis, commandOptions.interpretation, interpretationUpdateParams, queryParams);
}

private RestResponse<ClinicalReport> updateReport() throws Exception {
logger.debug("Executing updateReport in Analysis - Clinical command line");

AnalysisClinicalCommandOptions.UpdateReportCommandOptions commandOptions = analysisClinicalCommandOptions.updateReportCommandOptions;

ObjectMap queryParams = new ObjectMap();
queryParams.putIfNotEmpty("include", commandOptions.include);
queryParams.putIfNotEmpty("exclude", commandOptions.exclude);
queryParams.putIfNotEmpty("study", commandOptions.study);
queryParams.putIfNotNull("supportingEvidencesAction", commandOptions.supportingEvidencesAction);
queryParams.putIfNotNull("includeResult", commandOptions.includeResult);
if (queryParams.get("study") == null && OpencgaMain.isShellMode()) {
queryParams.putIfNotEmpty("study", sessionManager.getSession().getCurrentStudy());
}


ClinicalReport clinicalReport = null;
if (commandOptions.jsonDataModel) {
RestResponse<ClinicalReport> res = new RestResponse<>();
res.setType(QueryType.VOID);
PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/{clinicalAnalysis}/report/update"));
return res;
} else if (commandOptions.jsonFile != null) {
clinicalReport = JacksonUtils.getDefaultObjectMapper()
.readValue(new java.io.File(commandOptions.jsonFile), ClinicalReport.class);
} else {
ObjectMap beanParams = new ObjectMap();
putNestedIfNotEmpty(beanParams, "title",commandOptions.title, true);
putNestedIfNotEmpty(beanParams, "overview",commandOptions.overview, true);
putNestedIfNotEmpty(beanParams, "discussion.author",commandOptions.discussionAuthor, true);
putNestedIfNotEmpty(beanParams, "discussion.date",commandOptions.discussionDate, true);
putNestedIfNotEmpty(beanParams, "discussion.text",commandOptions.discussionText, true);
putNestedIfNotEmpty(beanParams, "logo",commandOptions.logo, true);
putNestedIfNotEmpty(beanParams, "signedBy",commandOptions.signedBy, true);
putNestedIfNotEmpty(beanParams, "signature",commandOptions.signature, true);
putNestedIfNotEmpty(beanParams, "date",commandOptions.date, true);

clinicalReport = JacksonUtils.getDefaultObjectMapper().copy()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
.readValue(beanParams.toJson(), ClinicalReport.class);
}
return openCGAClient.getClinicalAnalysisClient().updateReport(commandOptions.clinicalAnalysis, clinicalReport, queryParams);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ private RestResponse<String> model() throws Exception {
logger.debug("Executing model in Meta command line");

MetaCommandOptions.ModelCommandOptions commandOptions = metaCommandOptions.modelCommandOptions;
return openCGAClient.getMetaClient().model();

ObjectMap queryParams = new ObjectMap();
queryParams.putIfNotEmpty("model", commandOptions.model);

return openCGAClient.getMetaClient().model(queryParams);
}

private RestResponse<String> ping() throws Exception {
Expand Down
Loading

0 comments on commit d45f95d

Please sign in to comment.