Skip to content

Commit

Permalink
analysis: Fix VariantStatsAnalysis when using a cohort instead of a l…
Browse files Browse the repository at this point in the history
…ist of samples. #1376
  • Loading branch information
j-coll committed Nov 26, 2019
1 parent 7bc5d18 commit 2451070
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
Expand Up @@ -334,7 +334,8 @@ public DataResult<ProjectMetadata.VariantAnnotationMetadata> getAnnotationMetada
public void stats(String study, List<String> cohorts, List<String> samples,
String outDir, boolean index, ObjectMap config, String sessionId)
throws AnalysisException {
stats(study, cohorts, new Query(SampleDBAdaptor.QueryParams.ID.key(), samples), outDir, index, config, sessionId);
Query samplesQuery = CollectionUtils.isEmpty(samples) ? new Query() : new Query(SampleDBAdaptor.QueryParams.ID.key(), samples);
stats(study, cohorts, samplesQuery, outDir, index, config, sessionId);
}

public void stats(String study, List<String> cohorts, Query samplesQuery,
Expand Down
Expand Up @@ -284,7 +284,12 @@ protected void run() throws Exception {
});

if (!emptyCohorts.isEmpty()) {
throw new AnalysisException("Unable to compute variant stats for cohorts " + emptyCohorts);
if (dynamicCohort) {
throw new AnalysisException("Missing cohort or samples. "
+ "Use cohort " + StudyEntry.DEFAULT_COHORT + " to compute stats for all indexed samples");
} else {
throw new AnalysisException("Unable to compute variant stats for cohorts " + emptyCohorts);
}
}

// check read permission
Expand Down
Expand Up @@ -385,7 +385,7 @@ private void stats() throws AnalysisException {

options.putAll(cliOptions.commonOptions.params);

List<String> cohorts = cliOptions.cohorts;
List<String> cohorts = cliOptions.cohort;
List<String> samples = cliOptions.samples;
variantManager.stats(cliOptions.study, cohorts, samples, cliOptions.outdir, cliOptions.index, options, sessionId);
}
Expand Down
Expand Up @@ -547,12 +547,12 @@ public class VariantStatsCommandOptions extends GeneralCliOptions.StudyOption {
@ParametersDelegate
public GeneralCliOptions.CommonCommandOptions commonOptions = commonCommandOptions;

@Parameter(names = {"--cohorts"}, description = "Cohort Ids for the cohorts to be calculated.")
public List<String> cohorts;
@Parameter(names = {"--cohort"}, description = "Cohort Ids for the cohorts to be calculated.")
public List<String> cohort;

@Parameter(names = {"--cohort-ids"}, hidden = true)
public void setCohortIds(List<String> cohortIds) {
this.cohorts = cohortIds;
this.cohort = cohortIds;
}

@Parameter(names = {"-o", "--outdir"}, description = "Output directory outside catalog boundaries.", required = false, arity = 1)
Expand Down
Expand Up @@ -133,7 +133,7 @@ public void execute() throws Exception {

private DataResponse stats() throws IOException {
ObjectMap params = new VariantAnalysisWSService.StatsRunParams(
variantCommandOptions.statsVariantCommandOptions.cohorts,
variantCommandOptions.statsVariantCommandOptions.cohort,
variantCommandOptions.statsVariantCommandOptions.samples,
variantCommandOptions.statsVariantCommandOptions.index,
variantCommandOptions.statsVariantCommandOptions.outdir,
Expand Down
Expand Up @@ -577,10 +577,10 @@ public Response getAnnotationMetadata(@ApiParam(value = "Annotation identifier")
public static class StatsRunParams extends RestBodyParams {
public StatsRunParams() {
}
public StatsRunParams(List<String> cohorts, List<String> samples, boolean index, String outdir, String outputFileName,
public StatsRunParams(List<String> cohort, List<String> samples, boolean index, String outdir, String outputFileName,
String region, boolean overwriteStats, boolean updateStats, boolean resume, Aggregation aggregated,
String aggregationMappingFile) {
this.cohorts = cohorts;
this.cohort = cohort;
this.samples = samples;
this.index = index;
this.outdir = outdir;
Expand All @@ -593,7 +593,7 @@ public StatsRunParams(List<String> cohorts, List<String> samples, boolean index,
this.aggregationMappingFile = aggregationMappingFile;
}

public List<String> cohorts;
public List<String> cohort;
public List<String> samples;
public boolean index;
public String region;
Expand Down

0 comments on commit 2451070

Please sign in to comment.