Skip to content

Commit

Permalink
Merge branch 'TASK-6442' of https://github.com/opencb/opencga into TA…
Browse files Browse the repository at this point in the history
…SK-6442
  • Loading branch information
jtarraga committed Oct 14, 2024
2 parents 0e80c4d + 2fd7678 commit 8673ebd
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.List;

import static org.opencb.opencga.core.tools.ResourceManager.RESOURCES_FOLDER_NAME;

Expand All @@ -24,21 +22,14 @@
priority = Enums.Priority.HIGH)
public class DownloadResourcesTool extends OpenCgaTool {

public static final String ID = "resource-download-all";
public static final String DESCRIPTION = "Download all resources";

public static final String DOWNLOAD_RESOURCES_STEP = "download-resources";
public static final String MOVE_RESOURCES_STEP = "move-resources";
public static final String ID = "resource-downloader";
public static final String DESCRIPTION = "Download all resources from the server";

private Path resourcePath;

@ToolParams
protected final DownloadResourcesToolParams analysisParams = new DownloadResourcesToolParams();

protected List<String> getSteps() {
return Arrays.asList(DOWNLOAD_RESOURCES_STEP, MOVE_RESOURCES_STEP);
}

@Override
protected void check() throws Exception {
super.check();
Expand All @@ -53,21 +44,12 @@ protected void check() throws Exception {
@Override
protected void run() throws Exception {
// Download all resources
step(DOWNLOAD_RESOURCES_STEP, this::downloadResources);

// Move resources to the installation folder
step(MOVE_RESOURCES_STEP, this::moveResources);
step(ID, this::downloadResources);
}

private void downloadResources() throws IOException, NoSuchAlgorithmException {
ResourceManager resourceManager = new ResourceManager(getOpencgaHome(), analysisParams.getBaseurl());
ResourceManager resourceManager = new ResourceManager(getOpencgaHome(), analysisParams.getBaseUrl());
resourceManager.downloadAllResources(getOutDir().resolve(RESOURCES_FOLDER_NAME),
Boolean.TRUE.equals(analysisParams.getOverwrite()));
}

private void moveResources() {

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,8 @@ private RestResponse<Job> downloadAllResource() throws Exception {
.readValue(new java.io.File(commandOptions.jsonFile), DownloadResourcesToolParams.class);
} else {
ObjectMap beanParams = new ObjectMap();
putNestedIfNotEmpty(beanParams, "baseurl", commandOptions.baseurl, true);
putNestedIfNotEmpty(beanParams, "baseUrl", commandOptions.baseUrl, true);
putNestedIfNotNull(beanParams, "overwrite", commandOptions.overwrite, true);
putNestedIfNotEmpty(beanParams, "outdir", commandOptions.outdir, true);

downloadResourcesToolParams = JacksonUtils.getDefaultObjectMapper().copy()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public class JwtCatalogCommandOptions {

}

@Parameters(commandNames = {"resource-download-all"}, commandDescription ="Download all resources")
@Parameters(commandNames = {"resource-download-all"}, commandDescription ="Download all resources from the server")
public class DownloadAllResourceCommandOptions {

@ParametersDelegate
Expand Down Expand Up @@ -170,15 +170,12 @@ public class DownloadAllResourceCommandOptions {
@Parameter(names = {"--job-dry-run"}, description = "Flag indicating that the job will be executed in dry-run mode. In this mode, OpenCGA will validate that all parameters and prerequisites are correctly set for successful execution, but the job will not actually run.", required = false, arity = 1)
public Boolean jobDryRun;

@Parameter(names = {"--baseurl"}, description = "Base URL where the resources are located", required = false, arity = 1)
public String baseurl;
@Parameter(names = {"--base-url"}, description = "Base URL where the resources are located, this is an optional parameter, by default the resources will be downloaded from the OpenCB repository.", required = false, arity = 1)
public String baseUrl;

@Parameter(names = {"--overwrite"}, description = "Download and overwrite previously downloaded resources", required = false, arity = 1)
@Parameter(names = {"--overwrite"}, description = "Download and overwrite previously downloaded resources if they already exist.", required = false, arity = 1)
public Boolean overwrite;

@Parameter(names = {"--outdir"}, description = "Output dir for the job.", required = false, arity = 1)
public String outdir;

}

@Parameters(commandNames = {"users-create"}, commandDescription ="Create a new user")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ public class RunInterpreterExomiserCommandOptions {
@Parameter(names = {"--job-dry-run"}, description = "Flag indicating that the job will be executed in dry-run mode. In this mode, OpenCGA will validate that all parameters and prerequisites are correctly set for successful execution, but the job will not actually run.", required = false, arity = 1)
public Boolean jobDryRun;

@Parameter(names = {"--clinical-analysis"}, description = "Clinical analysis ID.", required = false, arity = 1)
@Parameter(names = {"--clinical-analysis"}, description = "Clinical analysis ID to be analysed.", required = false, arity = 1)
public String clinicalAnalysis;

@Parameter(names = {"--exomiser-version"}, description = "Exomiser version in the format X.Y where X is the major version and Y the minor version, e.g.: 14.0. If the version is not specified, the default version will be used. Refer to the configuration file to view all installed Exomiser versions and identify the default version.", required = false, arity = 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public class RunExomiserCommandOptions {
@Parameter(names = {"--job-dry-run"}, description = "Flag indicating that the job will be executed in dry-run mode. In this mode, OpenCGA will validate that all parameters and prerequisites are correctly set for successful execution, but the job will not actually run.", required = false, arity = 1)
public Boolean jobDryRun;

@Parameter(names = {"--sample"}, description = "Sample ID.", required = false, arity = 1)
@Parameter(names = {"--sample"}, description = "Sample ID to be analysed.", required = false, arity = 1)
public String sample;

@Parameter(names = {"--exomiser-version"}, description = "Exomiser version in the format X.Y where X is the major version and Y the minor version, e.g.: 14.0. If the version is not specified, the default version will be used. Refer to the configuration file to view all installed Exomiser versions and identify the default version.", required = false, arity = 1)
Expand Down
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 @@ -67,7 +67,7 @@ setMethod("adminClient", "OpencgaR", function(OpencgaR, user, endpointName, para
subcategoryId=NULL, action="jwt", params=params, httpMethod="POST", as.queryParam=NULL, ...),

#' @section Endpoint /{apiVersion}/admin/resource/downloadAll:
#' Download all resources.
#' Download all resources from the server.
#' @param jobId Job ID. It must be a unique string within the study. An ID will be autogenerated automatically if not provided.
#' @param jobDescription Job description.
#' @param jobDependsOn Comma separated list of existing job IDs the job will depend on.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public RestResponse<ObjectMap> jwtCatalog(JWTParams data, ObjectMap params) thro
}

/**
* Download all resources.
* Download all resources from the server.
* @param data Download-resources tool parameters.
* @param params Map containing any of the following optional parameters.
* jobId: Job ID. It must be a unique string within the study. An ID will be autogenerated automatically if not provided.
Expand Down
2 changes: 1 addition & 1 deletion opencga-client/src/main/javascript/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class Admin extends OpenCGAParentClass {
return this._post("admin", null, "catalog", null, "jwt", data, params);
}

/** Download all resources
/** Download all resources from the server
* @param {Object} data - Download-resources tool parameters.
* @param {Object} [params] - The Object containing the following optional parameters:
* @param {String} [params.jobId] - Job ID. It must be a unique string within the study. An ID will be autogenerated automatically if not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def jwt_catalog(self, data=None, **options):

def download_all_resource(self, data=None, **options):
"""
Download all resources.
Download all resources from the server.
PATH: /{apiVersion}/admin/resource/downloadAll
:param dict data: Download-resources tool parameters. (REQUIRED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,14 +549,16 @@ public class FieldConstants {
public static final String ALIGNMENT_QC_OVERWRITE_DESCRIPTION = "To overwrite the QC metrics already computed.";

// Exomiser
public static final String EXOMISER_CLINICAL_ANALYSIS_DESCRIPTION = "Clinical analysis ID.";
public static final String EXOMISER_SAMPLE_DESCRIPTION = "Sample ID.";
public static final String EXOMISER_CLINICAL_ANALYSIS_DESCRIPTION = "Clinical analysis ID to be analysed.";
public static final String EXOMISER_SAMPLE_DESCRIPTION = "Sample ID to be analysed.";
public static final String EXOMISER_CLINICAL_ANALYSIS_TYPE_DESCRIPTION = "Clinical analysis type: SINGLE or FAMILY.";
public static final String EXOMISER_VERSION_DESCRIPTION = "Exomiser version in the format X.Y where X is the major version and Y the"
+ " minor version, e.g.: 14.0. If the version is not specified, the default version will be used. Refer to the configuration"
+ " file to view all installed Exomiser versions and identify the default version.";

// Download all resources
public static final String DOWNLOAD_ALL_RESOURCES_BASEURL_DESCRIPTION = "Base URL where the resources are located";
public static final String DOWNLOAD_ALL_RESOURCES_OVERWRITE_DESCRIPTION = "Download and overwrite previously downloaded resources";
public static final String DOWNLOAD_ALL_RESOURCES_BASEURL_DESCRIPTION = "Base URL where the resources are located, this is an optional"
+ " parameter, by default the resources will be downloaded from the OpenCB repository.";
public static final String DOWNLOAD_ALL_RESOURCES_OVERWRITE_DESCRIPTION = "Download and overwrite previously downloaded resources if"
+ " they already exist.";
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,39 @@
import org.opencb.opencga.core.api.FieldConstants;
import org.opencb.opencga.core.tools.ToolParams;

import java.util.List;

public class DownloadResourcesToolParams extends ToolParams {

public static final String DESCRIPTION = "Download-resources tool parameters";

@DataField(id = "baseurl", description = FieldConstants.DOWNLOAD_ALL_RESOURCES_BASEURL_DESCRIPTION)
private String baseurl;
@DataField(id = "baseUrl", description = FieldConstants.DOWNLOAD_ALL_RESOURCES_BASEURL_DESCRIPTION)
private String baseUrl;

@DataField(id = "overwrite", description = FieldConstants.DOWNLOAD_ALL_RESOURCES_OVERWRITE_DESCRIPTION)
private Boolean overwrite;

@DataField(id = "outdir", description = FieldConstants.JOB_OUT_DIR_DESCRIPTION)
private String outdir;

public DownloadResourcesToolParams() {
}

public DownloadResourcesToolParams(String baseurl, Boolean overwrite, String outdir) {
this.baseurl = baseurl;
public DownloadResourcesToolParams(String baseUrl, Boolean overwrite) {
this.baseUrl = baseUrl;
this.overwrite = overwrite;
this.outdir = outdir;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("DownloadResourcesToolParams{");
sb.append("baseurl='").append(baseurl).append('\'');
final StringBuilder sb = new StringBuilder("DownloadResourcesParams{");
sb.append("baseUrl='").append(baseUrl).append('\'');
sb.append(", overwrite=").append(overwrite);
sb.append(", outdir='").append(outdir).append('\'');
sb.append('}');
return sb.toString();
}

public String getBaseurl() {
return baseurl;
public String getBaseUrl() {
return baseUrl;
}

public DownloadResourcesToolParams setBaseurl(String baseurl) {
this.baseurl = baseurl;
public DownloadResourcesToolParams setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
return this;
}

Expand All @@ -71,13 +64,4 @@ public DownloadResourcesToolParams setOverwrite(Boolean overwrite) {
this.overwrite = overwrite;
return this;
}

public String getOutdir() {
return outdir;
}

public DownloadResourcesToolParams setOutdir(String outdir) {
this.outdir = outdir;
return this;
}
}

0 comments on commit 8673ebd

Please sign in to comment.