Skip to content

Commit

Permalink
Clients for release 2.12.2 #TASK-5445
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfeSanahuja committed Jan 30, 2024
1 parent 88c589a commit a3fcda0
Show file tree
Hide file tree
Showing 73 changed files with 340 additions and 144 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2023-12-15 OpenCB
* Copyright 2015-2024-01-30 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","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","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-2023-12-15 OpenCB
* Copyright 2015-2024-01-30 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 @@ -160,6 +160,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 @@ -198,6 +198,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 @@ -1445,4 +1448,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 @@ -66,6 +66,7 @@ public class AnalysisClinicalCommandOptions {
public DeleteInterpretationCommandOptions deleteInterpretationCommandOptions;
public RevertInterpretationCommandOptions revertInterpretationCommandOptions;
public UpdateInterpretationCommandOptions updateInterpretationCommandOptions;
public UpdateReportCommandOptions updateReportCommandOptions;


public AnalysisClinicalCommandOptions(CommonCommandOptions commonCommandOptions, JCommander jCommander) {
Expand Down Expand Up @@ -105,6 +106,7 @@ public AnalysisClinicalCommandOptions(CommonCommandOptions commonCommandOptions,
this.deleteInterpretationCommandOptions = new DeleteInterpretationCommandOptions();
this.revertInterpretationCommandOptions = new RevertInterpretationCommandOptions();
this.updateInterpretationCommandOptions = new UpdateInterpretationCommandOptions();
this.updateReportCommandOptions = new UpdateReportCommandOptions();

}

Expand Down Expand Up @@ -2274,4 +2276,63 @@ public class UpdateInterpretationCommandOptions {

}

@Parameters(commandNames = {"report-update"}, commandDescription ="Update clinical analysis report")
public class UpdateReportCommandOptions {

@ParametersDelegate
public CommonCommandOptions commonOptions = commonCommandOptions;

@Parameter(names = {"--json-file"}, description = "File with the body data in JSON format. Note, that using this parameter will ignore all the other parameters.", required = false, arity = 1)
public String jsonFile;

@Parameter(names = {"--json-data-model"}, description = "Show example of file structure for body data.", help = true, arity = 0)
public Boolean jsonDataModel = false;

@Parameter(names = {"--include", "-I"}, description = "Fields included in the response, whole JSON path must be provided", required = false, arity = 1)
public String include;

@Parameter(names = {"--exclude", "-E"}, description = "Fields excluded in the response, whole JSON path must be provided", required = false, arity = 1)
public String exclude;

@Parameter(names = {"--clinical-analysis"}, description = "Clinical analysis ID", required = true, arity = 1)
public String clinicalAnalysis;

@Parameter(names = {"--study", "-s"}, description = "Study [[user@]project:]study where study and project can be either the ID or UUID", required = false, arity = 1)
public String study;

@Parameter(names = {"--supporting-evidences-action"}, description = "Action to be performed if the array of supporting evidences is being updated.", required = false, arity = 1)
public String supportingEvidencesAction = "ADD";

@Parameter(names = {"--include-result"}, description = "Flag indicating to include the created or updated document result in the response", required = false, help = true, arity = 0)
public boolean includeResult = false;

@Parameter(names = {"--title"}, description = "Report title.", required = false, arity = 1)
public String title;

@Parameter(names = {"--overview"}, description = "Report overview.", required = false, arity = 1)
public String overview;

@Parameter(names = {"--discussion-author"}, description = "The body web service author parameter", required = false, arity = 1)
public String discussionAuthor;

@Parameter(names = {"--discussion-date"}, description = "The body web service date parameter", required = false, arity = 1)
public String discussionDate;

@Parameter(names = {"--discussion-text"}, description = "The body web service text parameter", required = false, arity = 1)
public String discussionText;

@Parameter(names = {"--logo"}, description = "Report logo.", required = false, arity = 1)
public String logo;

@Parameter(names = {"--signed-by"}, description = "Indicates who has signed the report.", required = false, arity = 1)
public String signedBy;

@Parameter(names = {"--signature"}, description = "Report signature.", required = false, arity = 1)
public String signature;

@Parameter(names = {"--date"}, description = "Report date.", required = false, arity = 1)
public String date;

}

}
2 changes: 1 addition & 1 deletion opencga-client/src/main/R/R/Admin-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-12-15
# Autogenerated on: 2024-01-30
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down
2 changes: 1 addition & 1 deletion opencga-client/src/main/R/R/Alignment-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-12-15
# Autogenerated on: 2024-01-30
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down
22 changes: 11 additions & 11 deletions opencga-client/src/main/R/R/AllGenerics.R
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
# ##############################################################################
## UserClient
setGeneric("userClient", function(OpencgaR, filterId, user, users, endpointName, params=NULL, ...)
setGeneric("userClient", function(OpencgaR, user, users, filterId, endpointName, params=NULL, ...)
standardGeneric("userClient"))

# ##############################################################################
## ProjectClient
setGeneric("projectClient", function(OpencgaR, projects, project, endpointName, params=NULL, ...)
setGeneric("projectClient", function(OpencgaR, project, projects, endpointName, params=NULL, ...)
standardGeneric("projectClient"))

# ##############################################################################
## StudyClient
setGeneric("studyClient", function(OpencgaR, members, templateId, group, studies, variableSet, study, endpointName, params=NULL, ...)
setGeneric("studyClient", function(OpencgaR, studies, members, templateId, study, variableSet, group, endpointName, params=NULL, ...)
standardGeneric("studyClient"))

# ##############################################################################
## FileClient
setGeneric("fileClient", function(OpencgaR, members, annotationSet, files, folder, file, endpointName, params=NULL, ...)
setGeneric("fileClient", function(OpencgaR, members, folder, file, files, annotationSet, endpointName, params=NULL, ...)
standardGeneric("fileClient"))

# ##############################################################################
## JobClient
setGeneric("jobClient", function(OpencgaR, members, job, jobs, endpointName, params=NULL, ...)
setGeneric("jobClient", function(OpencgaR, jobs, members, job, endpointName, params=NULL, ...)
standardGeneric("jobClient"))

# ##############################################################################
## SampleClient
setGeneric("sampleClient", function(OpencgaR, samples, members, sample, annotationSet, endpointName, params=NULL, ...)
setGeneric("sampleClient", function(OpencgaR, annotationSet, members, sample, samples, endpointName, params=NULL, ...)
standardGeneric("sampleClient"))

# ##############################################################################
## IndividualClient
setGeneric("individualClient", function(OpencgaR, annotationSet, members, individual, individuals, endpointName, params=NULL, ...)
setGeneric("individualClient", function(OpencgaR, members, annotationSet, individuals, individual, endpointName, params=NULL, ...)
standardGeneric("individualClient"))

# ##############################################################################
## FamilyClient
setGeneric("familyClient", function(OpencgaR, family, members, annotationSet, families, endpointName, params=NULL, ...)
setGeneric("familyClient", function(OpencgaR, members, annotationSet, families, family, endpointName, params=NULL, ...)
standardGeneric("familyClient"))

# ##############################################################################
## CohortClient
setGeneric("cohortClient", function(OpencgaR, members, cohort, annotationSet, cohorts, endpointName, params=NULL, ...)
setGeneric("cohortClient", function(OpencgaR, cohort, annotationSet, members, cohorts, endpointName, params=NULL, ...)
standardGeneric("cohortClient"))

# ##############################################################################
## PanelClient
setGeneric("panelClient", function(OpencgaR, members, panels, endpointName, params=NULL, ...)
setGeneric("panelClient", function(OpencgaR, panels, members, endpointName, params=NULL, ...)
standardGeneric("panelClient"))

# ##############################################################################
Expand All @@ -60,7 +60,7 @@ setGeneric("variantClient", function(OpencgaR, endpointName, params=NULL, ...)

# ##############################################################################
## ClinicalClient
setGeneric("clinicalClient", function(OpencgaR, members, annotationSet, interpretation, clinicalAnalyses, clinicalAnalysis, interpretations, endpointName, params=NULL, ...)
setGeneric("clinicalClient", function(OpencgaR, members, interpretations, clinicalAnalysis, interpretation, annotationSet, clinicalAnalyses, endpointName, params=NULL, ...)
standardGeneric("clinicalClient"))

# ##############################################################################
Expand Down
20 changes: 18 additions & 2 deletions opencga-client/src/main/R/R/Clinical-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-12-15
# Autogenerated on: 2024-01-30
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -53,14 +53,15 @@
#' | deleteInterpretation | /{apiVersion}/analysis/clinical/{clinicalAnalysis}/interpretation/{interpretations}/delete | study, clinicalAnalysis[*], interpretations[*], setAsPrimary |
#' | revertInterpretation | /{apiVersion}/analysis/clinical/{clinicalAnalysis}/interpretation/{interpretation}/revert | study, clinicalAnalysis[*], interpretation[*], version[*] |
#' | updateInterpretation | /{apiVersion}/analysis/clinical/{clinicalAnalysis}/interpretation/{interpretation}/update | include, exclude, study, primaryFindingsAction, methodsAction, secondaryFindingsAction, commentsAction, panelsAction, setAs, clinicalAnalysis[*], interpretation[*], includeResult, body[*] |
#' | updateReport | /{apiVersion}/analysis/clinical/{clinicalAnalysis}/report/update | include, exclude, clinicalAnalysis[*], study, commentsAction, supportingEvidencesAction, filesAction, includeResult, body[*] |
#'
#' @md
#' @seealso \url{http://docs.opencb.org/display/opencga/Using+OpenCGA} and the RESTful API documentation
#' \url{http://bioinfo.hpc.cam.ac.uk/opencga-prod/webservices/}
#' [*]: Required parameter
#' @export

setMethod("clinicalClient", "OpencgaR", function(OpencgaR, members, annotationSet, interpretation, clinicalAnalyses, clinicalAnalysis, interpretations, endpointName, params=NULL, ...) {
setMethod("clinicalClient", "OpencgaR", function(OpencgaR, members, interpretations, clinicalAnalysis, interpretation, annotationSet, clinicalAnalyses, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/analysis/clinical/acl/{members}/update:
Expand Down Expand Up @@ -715,5 +716,20 @@ setMethod("clinicalClient", "OpencgaR", function(OpencgaR, members, annotationSe
updateInterpretation=fetchOpenCGA(object=OpencgaR, category="analysis/clinical", categoryId=clinicalAnalysis,
subcategory="interpretation", subcategoryId=interpretation, action="update", params=params,
httpMethod="POST", as.queryParam=NULL, ...),

#' @section Endpoint /{apiVersion}/analysis/clinical/{clinicalAnalysis}/report/update:
#' Update clinical analysis report.
#' @param include Fields included in the response, whole JSON path must be provided.
#' @param exclude Fields excluded in the response, whole JSON path must be provided.
#' @param clinicalAnalysis Clinical analysis ID.
#' @param study Study [[user@]project:]study where study and project can be either the ID or UUID.
#' @param commentsAction Action to be performed if the array of comments is being updated. Allowed values: ['ADD REMOVE REPLACE']
#' @param supportingEvidencesAction Action to be performed if the array of supporting evidences is being updated. Allowed values: ['ADD SET REMOVE']
#' @param filesAction Action to be performed if the array of files is being updated. Allowed values: ['ADD SET REMOVE']
#' @param includeResult Flag indicating to include the created or updated document result in the response.
#' @param data JSON containing clinical report information.
updateReport=fetchOpenCGA(object=OpencgaR, category="analysis/clinical", categoryId=clinicalAnalysis,
subcategory="report", subcategoryId=NULL, action="update", params=params, httpMethod="POST",
as.queryParam=NULL, ...),
)
})
Loading

0 comments on commit a3fcda0

Please sign in to comment.