Skip to content

Commit

Permalink
client: generate client, #TASK-5795, #TASK-5343
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Mar 27, 2024
1 parent 48fe3b8 commit cb44d91
Show file tree
Hide file tree
Showing 80 changed files with 305 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class RohWrapperAnalysisExecutor extends DockerWrapperAnalysisExecutor {
private Integer homozygWindowSnp;
private Integer homozygWindowHet;
private Integer homozygWindowMissing;
private Float homozygWindowThreshold;
private Double homozygWindowThreshold;
private Integer homozygKb;
private Integer homozygSnp;
private Integer homozygHet;
Expand Down Expand Up @@ -110,7 +110,11 @@ public void run() throws ToolException {
cli.append(" --homozyg-snp ").append(getHomozygWindowSnp());
}
if (getHomozygHet() != null) {
cli.append(" --homozyg-het ").append(getHomozygHet());
if (getHomozygHet() == -1) {
cli.append(" --homozyg-het unlimited");
} else {
cli.append(" --homozyg-het ").append(getHomozygHet());
}
}
if (getHomozygDensity() != null) {
cli.append(" --homozyg-density ").append(getHomozygDensity());
Expand Down Expand Up @@ -224,11 +228,11 @@ public RohWrapperAnalysisExecutor setHomozygWindowMissing(Integer homozygWindowM
return this;
}

public Float getHomozygWindowThreshold() {
public Double getHomozygWindowThreshold() {
return homozygWindowThreshold;
}

public RohWrapperAnalysisExecutor setHomozygWindowThreshold(Float homozygWindowThreshold) {
public RohWrapperAnalysisExecutor setHomozygWindowThreshold(Double homozygWindowThreshold) {
this.homozygWindowThreshold = homozygWindowThreshold;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024-03-12 OpenCB
* Copyright 2015-2024-03-27 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 @@ -45,7 +45,7 @@ public abstract class OpenCgaCompleter implements Completer {
.map(Candidate::new)
.collect(toList());

private List<Candidate> variantList = asList( "aggregationstats","annotation-metadata","annotation-query","circos-run","cohort-stats-delete","cohort-stats-info","cohort-stats-run","exomiser-run","export-run","family-genotypes","family-qc-run","file-delete","gatk-run","genome-plot-run","gwas-run","hr-detect-run","index-run","individual-qc-run","inferred-sex-run","knockout-gene-query","knockout-individual-query","knockout-run","mendelian-error-run","metadata","mutational-signature-query","mutational-signature-run","plink-run","query","relatedness-run","rvtests-run","sample-aggregation-stats","sample-eligibility-run","sample-qc-run","sample-query","sample-run","sample-stats-query","sample-stats-run","stats-export-run","stats-run")
private List<Candidate> variantList = asList( "aggregationstats","annotation-metadata","annotation-query","circos-run","cohort-stats-delete","cohort-stats-info","cohort-stats-run","exomiser-run","export-run","family-genotypes","family-qc-run","file-delete","gatk-run","genome-plot-run","gwas-run","hr-detect-run","index-run","individual-qc-run","inferred-sex-run","knockout-gene-query","knockout-individual-query","knockout-run","mendelian-error-run","metadata","mutational-signature-query","mutational-signature-run","plink-run","query","relatedness-run","roh-run","rvtests-run","sample-aggregation-stats","sample-eligibility-run","sample-qc-run","sample-query","sample-run","sample-stats-query","sample-stats-run","stats-export-run","stats-run")
.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-12 OpenCB
* Copyright 2015-2024-03-27 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 @@ -90,6 +90,7 @@ public OpencgaCliOptionsParser() {
analysisVariantSubCommands.addCommand("plink-run", analysisVariantCommandOptions.runPlinkCommandOptions);
analysisVariantSubCommands.addCommand("query", analysisVariantCommandOptions.queryCommandOptions);
analysisVariantSubCommands.addCommand("relatedness-run", analysisVariantCommandOptions.runRelatednessCommandOptions);
analysisVariantSubCommands.addCommand("roh-run", analysisVariantCommandOptions.runRohCommandOptions);
analysisVariantSubCommands.addCommand("rvtests-run", analysisVariantCommandOptions.runRvtestsCommandOptions);
analysisVariantSubCommands.addCommand("sample-aggregation-stats", analysisVariantCommandOptions.aggregationStatsSampleCommandOptions);
analysisVariantSubCommands.addCommand("sample-eligibility-run", analysisVariantCommandOptions.runSampleEligibilityCommandOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.opencb.opencga.catalog.exceptions.CatalogAuthenticationException;
import org.opencb.opencga.client.exceptions.ClientException;
import org.opencb.opencga.core.common.JacksonUtils;
import org.opencb.opencga.core.models.alignment.RohWrapperParams;
import org.opencb.opencga.core.models.analysis.knockout.KnockoutByGene;
import org.opencb.opencga.core.models.analysis.knockout.KnockoutByIndividual;
import org.opencb.opencga.core.models.clinical.ExomiserWrapperParams;
Expand Down Expand Up @@ -177,6 +178,9 @@ public void execute() throws Exception {
case "relatedness-run":
queryResponse = runRelatedness();
break;
case "roh-run":
queryResponse = runRoh();
break;
case "rvtests-run":
queryResponse = runRvtests();
break;
Expand Down Expand Up @@ -1342,6 +1346,56 @@ private RestResponse<Job> runRelatedness() throws Exception {
return openCGAClient.getVariantClient().runRelatedness(relatednessAnalysisParams, queryParams);
}

private RestResponse<Job> runRoh() throws Exception {
logger.debug("Executing runRoh in Analysis - Variant command line");

AnalysisVariantCommandOptions.RunRohCommandOptions commandOptions = analysisVariantCommandOptions.runRohCommandOptions;

ObjectMap queryParams = new ObjectMap();
queryParams.putIfNotEmpty("study", commandOptions.study);
queryParams.putIfNotEmpty("jobId", commandOptions.jobId);
queryParams.putIfNotEmpty("jobDescription", commandOptions.jobDescription);
queryParams.putIfNotEmpty("jobDependsOn", commandOptions.jobDependsOn);
queryParams.putIfNotEmpty("jobTags", commandOptions.jobTags);
if (queryParams.get("study") == null && OpencgaMain.isShellMode()) {
queryParams.putIfNotEmpty("study", sessionManager.getSession().getCurrentStudy());
}


RohWrapperParams rohWrapperParams = null;
if (commandOptions.jsonDataModel) {
RestResponse<Job> res = new RestResponse<>();
res.setType(QueryType.VOID);
PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/roh/run"));
return res;
} else if (commandOptions.jsonFile != null) {
rohWrapperParams = JacksonUtils.getDefaultObjectMapper()
.readValue(new java.io.File(commandOptions.jsonFile), RohWrapperParams.class);
} else {
ObjectMap beanParams = new ObjectMap();
putNestedIfNotEmpty(beanParams, "sampleId",commandOptions.sampleId, true);
putNestedIfNotEmpty(beanParams, "chromosome",commandOptions.chromosome, true);
putNestedIfNotEmpty(beanParams, "filter",commandOptions.filter, true);
putNestedIfNotNull(beanParams, "genotypeQuality",commandOptions.genotypeQuality, true);
putNestedIfNotNull(beanParams, "skipGenotypeQuality",commandOptions.skipGenotypeQuality, true);
putNestedIfNotNull(beanParams, "homozygWindowSnp",commandOptions.homozygWindowSnp, true);
putNestedIfNotNull(beanParams, "homozygWindowHet",commandOptions.homozygWindowHet, true);
putNestedIfNotNull(beanParams, "homozygWindowMissing",commandOptions.homozygWindowMissing, true);
putNestedIfNotNull(beanParams, "homozygWindowThreshold",commandOptions.homozygWindowThreshold, true);
putNestedIfNotNull(beanParams, "homozygKb",commandOptions.homozygKb, true);
putNestedIfNotNull(beanParams, "homozygSnp",commandOptions.homozygSnp, true);
putNestedIfNotNull(beanParams, "homozygHet",commandOptions.homozygHet, true);
putNestedIfNotEmpty(beanParams, "homozygDensity",commandOptions.homozygDensity, true);
putNestedIfNotEmpty(beanParams, "homozygGap",commandOptions.homozygGap, true);
putNestedIfNotEmpty(beanParams, "outdir",commandOptions.outdir, true);

rohWrapperParams = JacksonUtils.getDefaultObjectMapper().copy()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
.readValue(beanParams.toJson(), RohWrapperParams.class);
}
return openCGAClient.getVariantClient().runRoh(rohWrapperParams, queryParams);
}

private RestResponse<Job> runRvtests() throws Exception {
logger.debug("Executing runRvtests in Analysis - Variant command line");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class AnalysisVariantCommandOptions {
public RunPlinkCommandOptions runPlinkCommandOptions;
public QueryCommandOptions queryCommandOptions;
public RunRelatednessCommandOptions runRelatednessCommandOptions;
public RunRohCommandOptions runRohCommandOptions;
public RunRvtestsCommandOptions runRvtestsCommandOptions;
public AggregationStatsSampleCommandOptions aggregationStatsSampleCommandOptions;
public RunSampleEligibilityCommandOptions runSampleEligibilityCommandOptions;
Expand Down Expand Up @@ -107,6 +108,7 @@ public AnalysisVariantCommandOptions(CommonCommandOptions commonCommandOptions,
this.runPlinkCommandOptions = new RunPlinkCommandOptions();
this.queryCommandOptions = new QueryCommandOptions();
this.runRelatednessCommandOptions = new RunRelatednessCommandOptions();
this.runRohCommandOptions = new RunRohCommandOptions();
this.runRvtestsCommandOptions = new RunRvtestsCommandOptions();
this.aggregationStatsSampleCommandOptions = new AggregationStatsSampleCommandOptions();
this.runSampleEligibilityCommandOptions = new RunSampleEligibilityCommandOptions();
Expand Down Expand Up @@ -1858,6 +1860,80 @@ public class RunRelatednessCommandOptions {

}

@Parameters(commandNames = {"roh-run"}, commandDescription ="Analysis to calculate and visualise regions of homozygosity (ROHs) for a given sample")
public class RunRohCommandOptions {

@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 = {"--study", "-s"}, description = "Study [[organization@]project:]study where study and project can be either the ID or UUID", required = false, arity = 1)
public String study;

@Parameter(names = {"--job-id"}, description = "Job ID. It must be a unique string within the study. An ID will be autogenerated automatically if not provided.", required = false, arity = 1)
public String jobId;

@Parameter(names = {"--job-description"}, description = "Job description", required = false, arity = 1)
public String jobDescription;

@Parameter(names = {"--job-depends-on"}, description = "Comma separated list of existing job IDs the job will depend on.", required = false, arity = 1)
public String jobDependsOn;

@Parameter(names = {"--job-tags"}, description = "Job tags", required = false, arity = 1)
public String jobTags;

@Parameter(names = {"--sample-id"}, description = "Sample to analyse", required = false, arity = 1)
public String sampleId;

@Parameter(names = {"--chromosome"}, description = "Chromosome to analyse", required = false, arity = 1)
public String chromosome;

@Parameter(names = {"--filter"}, description = "FILTER (VCF FILTER annotation field) category to filter in variants in the ROH analysis. Default: PASS.", required = false, arity = 1)
public String filter = "PASS";

@Parameter(names = {"--genotype-quality"}, description = "GQ (VCF genotype quality annotation field) threshold to filter in variants in the ROH analysis. Default: 40 (GQ>40).", required = false, arity = 1)
public Integer genotypeQuality = 40;

@Parameter(names = {"--skip-genotype-quality"}, description = "Flag to not use the GQ (VCF genotype quality annotation field) to filter in variants in the ROH analysis. Default: false", required = false, arity = 1)
public Boolean skipGenotypeQuality;

@Parameter(names = {"--homozyg-window-snp"}, description = "Plink's parameter to set the scanning window size to look for ROHs. Default: 50", required = false, arity = 1)
public Integer homozygWindowSnp = 50;

@Parameter(names = {"--homozyg-window-het"}, description = "Plink's parameter to set the maximum number of heterozygous calls in a scanning window hit. Default: 1", required = false, arity = 1)
public Integer homozygWindowHet = 1;

@Parameter(names = {"--homozyg-window-missing"}, description = "Plink's parameter to set the maximum number of missing calls in a scanning window hit. Default: 5", required = false, arity = 1)
public Integer homozygWindowMissing = 5;

@Parameter(names = {"--homozyg-window-threshold"}, description = "Plink's parameter to set the minimum scanning window rate. Default: 0.05", required = false, arity = 1)
public Double homozygWindowThreshold = 0.05;

@Parameter(names = {"--homozyg-kb"}, description = "Plink's parameter to set the minimum ROH length in kilobases (kb). Default: 1000", required = false, arity = 1)
public Integer homozygKb = 1000;

@Parameter(names = {"--homozyg-snp"}, description = "Plink's parameter to set the minimum number of snps in a ROH. Default: 100", required = false, arity = 1)
public Integer homozygSnp = 100;

@Parameter(names = {"--homozyg-het"}, description = "Plink's parameter to set the maximum number of heterozygous calls in a ROH. Default: -1 that means 'unlimited'.", required = false, arity = 1)
public Integer homozygHet = -1;

@Parameter(names = {"--homozyg-density"}, description = "Plink's parameter to set the maximum inverse ROH density (kb/SNP). Minimum ROH density: 1 SNP per X kb. Default: 50", required = false, arity = 1)
public String homozygDensity = "50";

@Parameter(names = {"--homozyg-gap"}, description = "Plink's parameter to set the maximum gap length in kb between two consecutive SNPs to be considered part of the same ROH. Default: 1000", required = false, arity = 1)
public String homozygGap = "1000";

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

}

@Parameters(commandNames = {"rvtests-run"}, commandDescription ="Rvtests is a flexible software package for genetic association studies. Supported RvTests commands: rvtest, vcf2kinship")
public class RunRvtestsCommandOptions {

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 @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2024-03-12
# Autogenerated on: 2024-03-27
#
# 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: 2024-03-12
# Autogenerated on: 2024-03-27
#
# 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
Loading

0 comments on commit cb44d91

Please sign in to comment.