diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/ClinicalInterpretationManager.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/ClinicalInterpretationManager.java index 50e6d32da75..3ca18fe0eb9 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/ClinicalInterpretationManager.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/ClinicalInterpretationManager.java @@ -824,7 +824,7 @@ public ClinicalAnalyst getAnalyst(String token) throws ToolException { OpenCGAResult userQueryResult = catalogManager.getUserManager().get(userId, new QueryOptions(QueryOptions.INCLUDE, Arrays.asList(UserDBAdaptor.QueryParams.EMAIL.key(), UserDBAdaptor.QueryParams.ORGANIZATION.key())), token); User user = userQueryResult.first(); - return new ClinicalAnalyst(userId, user.getName(), user.getEmail(), "", ""); + return new ClinicalAnalyst(userId, user.getName(), user.getEmail(), "", Collections.emptyMap()); } catch (CatalogException e) { throw new ToolException(e); } diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/ClinicalTsvAnnotationLoader.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/ClinicalTsvAnnotationLoader.java new file mode 100644 index 00000000000..1d2be95e82e --- /dev/null +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/ClinicalTsvAnnotationLoader.java @@ -0,0 +1,53 @@ +/* + * Copyright 2015-2020 OpenCB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opencb.opencga.analysis.clinical; + +import org.opencb.commons.datastore.core.ObjectMap; +import org.opencb.commons.datastore.core.Query; +import org.opencb.commons.datastore.core.QueryOptions; +import org.opencb.opencga.analysis.annotations.TsvAnnotationLoader; +import org.opencb.opencga.catalog.exceptions.CatalogException; +import org.opencb.opencga.catalog.managers.AnnotationSetManager; +import org.opencb.opencga.catalog.utils.Constants; +import org.opencb.opencga.catalog.utils.ParamUtils; +import org.opencb.opencga.core.models.clinical.ClinicalAnalysisUpdateParams; +import org.opencb.opencga.core.models.common.AnnotationSet; +import org.opencb.opencga.core.models.common.Enums; +import org.opencb.opencga.core.tools.annotations.Tool; + +import java.util.Collections; + +@Tool(id = ClinicalTsvAnnotationLoader.ID, resource = Enums.Resource.CLINICAL_ANALYSIS, type = Tool.Type.OPERATION, + description = "Load annotations from TSV file.") +public class ClinicalTsvAnnotationLoader extends TsvAnnotationLoader { + public final static String ID = "clinical-tsv-load"; + + @Override + public int count(Query query) throws CatalogException { + return catalogManager.getClinicalAnalysisManager().count(study, query, token).getNumResults(); + } + + @Override + public void addAnnotationSet(String entryId, AnnotationSet annotationSet, QueryOptions options) throws CatalogException { + ClinicalAnalysisUpdateParams updateParams = new ClinicalAnalysisUpdateParams() + .setAnnotationSets(Collections.singletonList(annotationSet)); + QueryOptions queryOptions = options != null ? new QueryOptions(options) : new QueryOptions(); + queryOptions.put(Constants.ACTIONS, new ObjectMap(AnnotationSetManager.ANNOTATION_SETS, ParamUtils.BasicUpdateAction.ADD)); + + catalogManager.getClinicalAnalysisManager().update(study, entryId, updateParams, queryOptions, token); + } +} diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosAnalysis.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosAnalysis.java index 2ed3cf65913..96bf18034c0 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosAnalysis.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosAnalysis.java @@ -16,6 +16,7 @@ package org.opencb.opencga.analysis.variant.circos; +import org.opencb.opencga.analysis.ResourceUtils; import org.opencb.opencga.analysis.tools.OpenCgaTool; import org.opencb.opencga.core.exceptions.ToolException; import org.opencb.opencga.core.models.common.Enums; @@ -34,6 +35,8 @@ public class CircosAnalysis extends OpenCgaTool { private String study; private CircosAnalysisParams circosParams; + private String assembly; + @Override protected void check() throws Exception { super.check(); @@ -58,6 +61,8 @@ protected void check() throws Exception { // } // // addAttribute("sampleName", sampleName); + + assembly = ResourceUtils.getAssembly(catalogManager, study, token); } @Override diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosLocalAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosLocalAnalysisExecutor.java index 40f829ecd6c..356d53d1d84 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosLocalAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosLocalAnalysisExecutor.java @@ -28,8 +28,10 @@ import org.opencb.commons.datastore.core.Query; import org.opencb.commons.datastore.core.QueryOptions; import org.opencb.commons.utils.DockerUtils; +import org.opencb.opencga.analysis.ResourceUtils; import org.opencb.opencga.analysis.StorageToolExecutor; import org.opencb.opencga.analysis.variant.manager.VariantStorageManager; +import org.opencb.opencga.catalog.exceptions.CatalogException; import org.opencb.opencga.core.common.GitRepositoryState; import org.opencb.opencga.core.common.TimeUtils; import org.opencb.opencga.core.exceptions.ToolException; @@ -93,7 +95,7 @@ public VariantStorageManager getVariantStorageManager() throws ToolExecutorExcep } @Override - public void run() throws ToolException, IOException { + public void run() throws ToolException, IOException, CatalogException { // Create query Query query = new Query(); @@ -128,7 +130,6 @@ public void run() throws ToolException, IOException { throw new ToolException("Error launching threads when executing the Circos analysis", e); } - if (MapUtils.isEmpty(errors)) { // Execute R script // circos.R ./snvs.tsv ./indels.tsv ./cnvs.tsv ./rearrs.tsv SampleId @@ -138,10 +139,19 @@ public void run() throws ToolException, IOException { AbstractMap.SimpleEntry outputBinding = new AbstractMap.SimpleEntry<>(getOutDir() .toAbsolutePath().toString(), DOCKER_OUTPUT_PATH); + + // Get genome version + String genomeVersion = "hg38"; + String assembly = ResourceUtils.getAssembly(storageManager.getCatalogManager(), getStudy(), getToken()); + if (StringUtils.isNotEmpty(assembly) && assembly.toUpperCase(Locale.ROOT).equals("GRCH37")) { + genomeVersion = "hg19"; + } + String scriptParams = "R CMD Rscript --vanilla " + DOCKER_INPUT_PATH + "/circos.R" + (plotCopynumber ? "" : " --no_copynumber") + (plotIndels ? "" : " --no_indels") + (plotRearrangements ? "" : " --no_rearrangements") + + " --genome_version " + genomeVersion + " --out_path " + DOCKER_OUTPUT_PATH + " " + DOCKER_OUTPUT_PATH + "/" + snvsFile.getName() + " " + DOCKER_OUTPUT_PATH + "/" + indelsFile.getName() diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotAnalysis.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotAnalysis.java index f7f63f37706..04a5241623f 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotAnalysis.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotAnalysis.java @@ -21,6 +21,7 @@ import org.opencb.biodata.models.clinical.qc.GenomePlotConfig; import org.opencb.commons.datastore.core.QueryOptions; import org.opencb.opencga.analysis.AnalysisUtils; +import org.opencb.opencga.analysis.ResourceUtils; import org.opencb.opencga.analysis.tools.OpenCgaToolScopeStudy; import org.opencb.opencga.core.common.JacksonUtils; import org.opencb.opencga.core.exceptions.ToolException; diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotLocalAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotLocalAnalysisExecutor.java index 4246e142d55..a86cc797287 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotLocalAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotLocalAnalysisExecutor.java @@ -30,8 +30,10 @@ import org.opencb.commons.datastore.core.Query; import org.opencb.commons.datastore.core.QueryOptions; import org.opencb.commons.utils.DockerUtils; +import org.opencb.opencga.analysis.ResourceUtils; import org.opencb.opencga.analysis.StorageToolExecutor; import org.opencb.opencga.analysis.variant.manager.VariantStorageManager; +import org.opencb.opencga.catalog.exceptions.CatalogException; import org.opencb.opencga.core.common.GitRepositoryState; import org.opencb.opencga.core.common.JacksonUtils; import org.opencb.opencga.core.common.TimeUtils; @@ -46,10 +48,7 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.*; import static org.opencb.opencga.analysis.wrappers.executors.DockerWrapperAnalysisExecutor.DOCKER_INPUT_PATH; @@ -79,7 +78,7 @@ public class GenomePlotLocalAnalysisExecutor extends GenomePlotAnalysisExecutor private Logger logger = LoggerFactory.getLogger(this.getClass()); @Override - public void run() throws ToolException, IOException { + public void run() throws ToolException, IOException, CatalogException { plotConfig = JacksonUtils.getDefaultObjectMapper().readerFor(GenomePlotConfig.class).readValue(getConfigFile()); @@ -125,10 +124,19 @@ public void run() throws ToolException, IOException { inputBindings.add(new AbstractMap.SimpleEntry<>(rScriptPath, DOCKER_INPUT_PATH)); AbstractMap.SimpleEntry outputBinding = new AbstractMap.SimpleEntry<>(getOutDir() .toAbsolutePath().toString(), DOCKER_OUTPUT_PATH); + + // Get genome version + String genomeVersion = "hg38"; + String assembly = ResourceUtils.getAssembly(storageManager.getCatalogManager(), getStudy(), getToken()); + if (StringUtils.isNotEmpty(assembly) && assembly.toUpperCase(Locale.ROOT).equals("GRCH37")) { + genomeVersion = "hg19"; + } + String scriptParams = "R CMD Rscript --vanilla " + DOCKER_INPUT_PATH + "/circos.R" + (plotCopynumber ? "" : " --no_copynumber") + (plotIndels ? "" : " --no_indels") + (plotRearrangements ? "" : " --no_rearrangements") + + " --genome_version " + genomeVersion + " --out_path " + DOCKER_OUTPUT_PATH + " " + DOCKER_OUTPUT_PATH + "/" + snvsFile.getName() + " " + DOCKER_OUTPUT_PATH + "/" + indelsFile.getName() diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/wrappers/exomiser/ExomiserWrapperAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/wrappers/exomiser/ExomiserWrapperAnalysisExecutor.java index 099d3c6c7db..86bb3760b3c 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/wrappers/exomiser/ExomiserWrapperAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/wrappers/exomiser/ExomiserWrapperAnalysisExecutor.java @@ -147,7 +147,15 @@ public void run() throws ToolException { Path openCgaHome = getOpencgaHomePath(); Path exomiserDataPath = getAnalysisDataPath(ExomiserWrapperAnalysis.ID); - // And copy the application.properties + // Copy the analysis + try { + FileUtils.copyFile(openCgaHome.resolve("analysis/exomiser/" + EXOMISER_ANALYSIS_TEMPLATE_FILENAME).toFile(), + getOutDir().resolve(EXOMISER_ANALYSIS_TEMPLATE_FILENAME).toFile()); + } catch (IOException e) { + throw new ToolException("Error copying Exomiser analysis file", e); + } + + // Copy the application.properties try { FileUtils.copyFile(openCgaHome.resolve("analysis/exomiser/" + EXOMISER_PROPERTIES_TEMPLATE_FILENAME).toFile(), getOutDir().resolve(EXOMISER_PROPERTIES_TEMPLATE_FILENAME).toFile()); @@ -155,7 +163,7 @@ public void run() throws ToolException { throw new ToolException("Error copying Exomiser properties file", e); } - // And copy the output options + // Copy the output options try { FileUtils.copyFile(openCgaHome.resolve("analysis/exomiser/" + EXOMISER_OUTPUT_OPTIONS_FILENAME).toFile(), getOutDir().resolve(EXOMISER_OUTPUT_OPTIONS_FILENAME).toFile()); @@ -174,7 +182,7 @@ public void run() throws ToolException { appendCommand("", sb); // Append input file params -// sb.append(" --analysis /jobdir/").append(EXOMISER_ANALYSIS_TEMPLATE_FILENAME) + sb.append(" --analysis /jobdir/").append(EXOMISER_ANALYSIS_TEMPLATE_FILENAME); sb.append(" --sample /jobdir/").append(sampleFile.getName()); if (pedigreeFile != null && pedigreeFile.exists()) { sb.append(" --ped /jobdir/").append(pedigreeFile.getName()); diff --git a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/clinical/exomiser/ExomiserInterpretationAnalysisTest.java b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/clinical/exomiser/ExomiserInterpretationAnalysisTest.java index 9889af6e563..001e44792cf 100644 --- a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/clinical/exomiser/ExomiserInterpretationAnalysisTest.java +++ b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/clinical/exomiser/ExomiserInterpretationAnalysisTest.java @@ -31,6 +31,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeThat; @Category(MediumTests.class) @@ -93,7 +94,7 @@ public void singleExomiserAnalysis() throws IOException, CatalogException, ToolE clinicalAnalysis = clinicalTest.catalogManager.getClinicalAnalysisManager() .get(clinicalTest.studyFqn, clinicalTest.CA_ID2, QueryOptions.empty(), clinicalTest.token).first(); assertEquals(1, clinicalAnalysis.getSecondaryInterpretations().size()); - assertEquals(22, clinicalAnalysis.getSecondaryInterpretations().get(0).getPrimaryFindings().size()); + assertTrue(clinicalAnalysis.getSecondaryInterpretations().get(0).getPrimaryFindings().size() > 0); } @Test @@ -119,7 +120,7 @@ public void familyExomiserAnalysis() throws IOException, CatalogException, ToolE clinicalAnalysis = clinicalTest.catalogManager.getClinicalAnalysisManager() .get(clinicalTest.studyFqn, clinicalTest.CA_ID3, QueryOptions.empty(), clinicalTest.token).first(); assertEquals(1, clinicalAnalysis.getSecondaryInterpretations().size()); - assertEquals(2, clinicalAnalysis.getSecondaryInterpretations().get(0).getPrimaryFindings().size()); + assertTrue(clinicalAnalysis.getSecondaryInterpretations().get(0).getPrimaryFindings().size() > 0); System.out.println("results at out dir = " + outDir.toAbsolutePath()); } diff --git a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/variant/OpenCGATestExternalResource.java b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/variant/OpenCGATestExternalResource.java index 95f0ef297d5..38782aef1f0 100644 --- a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/variant/OpenCGATestExternalResource.java +++ b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/variant/OpenCGATestExternalResource.java @@ -49,7 +49,9 @@ import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.text.SimpleDateFormat; +import java.util.Arrays; import java.util.Date; +import java.util.List; import java.util.Map; /** @@ -260,6 +262,14 @@ public Path isolateOpenCGA() throws IOException { inputStream = new FileInputStream("../opencga-app/app/analysis/pedigree-graph/ped.R"); Files.copy(inputStream, analysisPath.resolve("ped.R"), StandardCopyOption.REPLACE_EXISTING); + // Exomiser analysis files + analysisPath = Files.createDirectories(opencgaHome.resolve("analysis/exomiser")).toAbsolutePath(); + List exomiserFiles = Arrays.asList("application.properties", "exomiser-analysis.yml", "output.yml"); + for (String exomiserFile : exomiserFiles) { + inputStream = new FileInputStream("../opencga-app/app/analysis/exomiser/" + exomiserFile); + Files.copy(inputStream, analysisPath.resolve(exomiserFile), StandardCopyOption.REPLACE_EXISTING); + } + return opencgaHome; } diff --git a/opencga-app/app/analysis/exomiser/exomiser-analysis.yml b/opencga-app/app/analysis/exomiser/exomiser-analysis.yml new file mode 100644 index 00000000000..5ec7d93d508 --- /dev/null +++ b/opencga-app/app/analysis/exomiser/exomiser-analysis.yml @@ -0,0 +1,70 @@ +--- +analysisMode: PASS_ONLY +inheritanceModes: { + AUTOSOMAL_DOMINANT: 0.1, + AUTOSOMAL_RECESSIVE_HOM_ALT: 0.1, + AUTOSOMAL_RECESSIVE_COMP_HET: 2.0, + X_DOMINANT: 0.1, + X_RECESSIVE_HOM_ALT: 0.1, + X_RECESSIVE_COMP_HET: 2.0, + MITOCHONDRIAL: 0.2 +} +frequencySources: [ + THOUSAND_GENOMES, + TOPMED, + UK10K, + + ESP_AFRICAN_AMERICAN, ESP_EUROPEAN_AMERICAN, ESP_ALL, + + EXAC_AFRICAN_INC_AFRICAN_AMERICAN, EXAC_AMERICAN, + EXAC_SOUTH_ASIAN, EXAC_EAST_ASIAN, + EXAC_FINNISH, EXAC_NON_FINNISH_EUROPEAN, + EXAC_OTHER, + + GNOMAD_E_AFR, + GNOMAD_E_AMR, + # GNOMAD_E_ASJ, + GNOMAD_E_EAS, + GNOMAD_E_FIN, + GNOMAD_E_NFE, + GNOMAD_E_OTH, + GNOMAD_E_SAS, + + GNOMAD_G_AFR, + GNOMAD_G_AMR, + # GNOMAD_G_ASJ, + GNOMAD_G_EAS, + GNOMAD_G_FIN, + GNOMAD_G_NFE, + GNOMAD_G_OTH, + GNOMAD_G_SAS +] +# Possible pathogenicitySources: (POLYPHEN, MUTATION_TASTER, SIFT), (REVEL, MVP), CADD, REMM +# REMM is trained on non-coding regulatory regions +# *WARNING* if you enable CADD or REMM ensure that you have downloaded and installed the CADD/REMM tabix files +# and updated their location in the application.properties. Exomiser will not run without this. +pathogenicitySources: [ REVEL, MVP ] +#this is the standard exomiser order. +steps: [ + failedVariantFilter: { }, + variantEffectFilter: { + remove: [ + FIVE_PRIME_UTR_EXON_VARIANT, + FIVE_PRIME_UTR_INTRON_VARIANT, + THREE_PRIME_UTR_EXON_VARIANT, + THREE_PRIME_UTR_INTRON_VARIANT, + NON_CODING_TRANSCRIPT_EXON_VARIANT, + NON_CODING_TRANSCRIPT_INTRON_VARIANT, + CODING_TRANSCRIPT_INTRON_VARIANT, + UPSTREAM_GENE_VARIANT, + DOWNSTREAM_GENE_VARIANT, + INTERGENIC_VARIANT, + REGULATORY_REGION_VARIANT + ] + }, + frequencyFilter: { maxFrequency: 2.0 }, + pathogenicityFilter: { keepNonPathogenic: true }, + inheritanceFilter: { }, + omimPrioritiser: { }, + hiPhivePrioritiser: { } +] diff --git a/opencga-app/pom.xml b/opencga-app/pom.xml index 59e15247036..2572f498caf 100644 --- a/opencga-app/pom.xml +++ b/opencga-app/pom.xml @@ -221,7 +221,6 @@ commons-io commons-io - test junit @@ -612,6 +611,9 @@ * + + * + diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalCliOptionsParser.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalCliOptionsParser.java index 132ad854c82..0079461d25a 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalCliOptionsParser.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalCliOptionsParser.java @@ -226,6 +226,7 @@ public InternalCliOptionsParser() { clinicalSubCommands.addCommand(RGA_INDEX_RUN_COMMAND, clinicalCommandOptions.rgaSecondaryIndexCommandOptions); clinicalSubCommands.addCommand(RGA_AUX_INDEX_RUN_COMMAND, clinicalCommandOptions.rgaAuxiliarSecondaryIndexCommandOptions); clinicalSubCommands.addCommand(EXOMISER_INTERPRETATION_RUN_COMMAND, clinicalCommandOptions.exomiserInterpretationCommandOptions); + clinicalSubCommands.addCommand("tsv-load", clinicalCommandOptions.tsvLoad); fileCommandOptions = new FileCommandOptions(commonCommandOptions, jCommander); jCommander.addCommand("files", fileCommandOptions); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/executors/ClinicalCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/executors/ClinicalCommandExecutor.java index e0785c79fee..14256ac1652 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/executors/ClinicalCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/executors/ClinicalCommandExecutor.java @@ -24,6 +24,7 @@ import org.opencb.commons.datastore.core.ObjectMap; import org.opencb.commons.datastore.core.Query; import org.opencb.commons.datastore.core.QueryOptions; +import org.opencb.opencga.analysis.clinical.ClinicalTsvAnnotationLoader; import org.opencb.opencga.analysis.clinical.exomiser.ExomiserInterpretationAnalysis; import org.opencb.opencga.analysis.clinical.rga.AuxiliarRgaAnalysis; import org.opencb.opencga.analysis.clinical.rga.RgaAnalysis; @@ -96,6 +97,9 @@ public void execute() throws Exception { case EXOMISER_INTERPRETATION_RUN_COMMAND: exomiserInterpretation(); break; + case "tsv-load": + tsvLoad(); + break; default: logger.error("Subcommand not valid"); break; @@ -314,4 +318,19 @@ private void exomiserInterpretation() throws Exception { // exomiserInterpretationAnalysis.setPrimary(cliOptions.primary); exomiserInterpretationAnalysis.start(); } + + private void tsvLoad() throws ToolException { + ClinicalCommandOptions.TsvLoad options = clinicalCommandOptions.tsvLoad; + + Path outDir = Paths.get(options.outDir); + + ClinicalTsvAnnotationLoader annotationLoader = new ClinicalTsvAnnotationLoader(); + annotationLoader.setAnnotationSetId(options.annotationSetId); + annotationLoader.setVariableSetId(options.variableSetId); + annotationLoader.setPath(options.filePath); + annotationLoader.setStudy(options.study); + + annotationLoader.setUp(opencgaHome.toString(), new ObjectMap(), outDir, options.commonOptions.token); + annotationLoader.start(); + } } diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/options/ClinicalCommandOptions.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/options/ClinicalCommandOptions.java index 2663f3c7c5e..9c7f8806fc7 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/options/ClinicalCommandOptions.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/options/ClinicalCommandOptions.java @@ -5,6 +5,7 @@ import com.beust.jcommander.Parameters; import com.beust.jcommander.ParametersDelegate; import org.opencb.biodata.models.clinical.ClinicalProperty; +import org.opencb.opencga.analysis.clinical.ClinicalTsvAnnotationLoader; import org.opencb.opencga.analysis.clinical.exomiser.ExomiserInterpretationAnalysis; import org.opencb.opencga.analysis.clinical.rga.AuxiliarRgaAnalysis; import org.opencb.opencga.analysis.clinical.rga.RgaAnalysis; @@ -14,6 +15,7 @@ import org.opencb.opencga.analysis.clinical.zetta.ZettaInterpretationAnalysis; import org.opencb.opencga.app.cli.GeneralCliOptions; import org.opencb.opencga.app.cli.internal.InternalCliOptionsParser; +import org.opencb.opencga.core.api.ParamConstants; import org.opencb.opencga.core.models.clinical.RgaAnalysisParams; import org.opencb.opencga.storage.app.cli.client.options.StorageVariantCommandOptions.BasicVariantQueryOptions; @@ -33,6 +35,7 @@ public class ClinicalCommandOptions { public final RgaSecondaryIndexCommandOptions rgaSecondaryIndexCommandOptions; public final RgaAuxiliarSecondaryIndexCommandOptions rgaAuxiliarSecondaryIndexCommandOptions; public final ExomiserInterpretationCommandOptions exomiserInterpretationCommandOptions; + public final TsvLoad tsvLoad; public JCommander jCommander; public GeneralCliOptions.CommonCommandOptions commonCommandOptions; @@ -53,6 +56,7 @@ public ClinicalCommandOptions(GeneralCliOptions.CommonCommandOptions commonComma this.rgaSecondaryIndexCommandOptions = new RgaSecondaryIndexCommandOptions(); this.rgaAuxiliarSecondaryIndexCommandOptions = new RgaAuxiliarSecondaryIndexCommandOptions(); this.exomiserInterpretationCommandOptions = new ExomiserInterpretationCommandOptions(); + this.tsvLoad = new TsvLoad(); } @Parameters(commandNames = {TieringCommandOptions.TIERING_INTERPRETATION_RUN_COMMAND}, commandDescription = @@ -335,4 +339,29 @@ public class ExomiserInterpretationCommandOptions extends GeneralCliOptions.Stud @Parameter(names = {"-o", "--outdir"}, description = "Directory where output files will be saved", arity = 1) public String outdir; } + + @Parameters(commandNames = {"tsv-load"}, commandDescription = "Load annotations from a TSV file") + public class TsvLoad extends GeneralCliOptions.StudyOption { + + public static final String TSV_LOAD_COMMAND = ClinicalTsvAnnotationLoader.ID; + + @ParametersDelegate + public GeneralCliOptions.CommonCommandOptions commonOptions = commonCommandOptions; + + @ParametersDelegate + public InternalCliOptionsParser.JobOptions jobOptions = internalJobOptions; + + @Parameter(names = {"--file"}, description = "Path to the TSV file.", required = true, arity = 1) + public String filePath; + + @Parameter(names = {"--variable-set-id"}, description = ParamConstants.VARIABLE_SET_DESCRIPTION, required = true, arity = 1) + public String variableSetId; + + @Parameter(names = {"--annotation-set-id"}, description = "AnnotationSet id that will be given to the new annotations.", + required = true, arity = 1) + public String annotationSetId; + + @Parameter(names = {"-o", "--outdir"}, description = "Directory where output files will be saved", required = true, arity = 1) + public String outDir; + } } diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpenCgaCompleter.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpenCgaCompleter.java index 5be356863c5..bff9940dd94 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpenCgaCompleter.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpenCgaCompleter.java @@ -1,5 +1,5 @@ /* -* Copyright 2015-2023-11-16 OpenCB +* Copyright 2015-2023-12-04 OpenCB * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ public abstract class OpenCgaCompleter implements Completer { .map(Candidate::new) .collect(toList()); - private List clinicalList = asList( "acl-update","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","info","interpretation-create","interpretation-clear","interpretation-delete","interpretation-revert","interpretation-update") + private List 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") .stream() .map(Candidate::new) .collect(toList()); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpencgaCliOptionsParser.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpencgaCliOptionsParser.java index b6d665b76a8..4ef7b9f3244 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpencgaCliOptionsParser.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpencgaCliOptionsParser.java @@ -1,5 +1,5 @@ /* -* Copyright 2015-2023-11-16 OpenCB +* Copyright 2015-2023-12-04 OpenCB * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -128,6 +128,7 @@ public OpencgaCliOptionsParser() { jCommander.addCommand("clinical", analysisClinicalCommandOptions); JCommander analysisClinicalSubCommands = jCommander.getCommands().get("clinical"); analysisClinicalSubCommands.addCommand("acl-update", analysisClinicalCommandOptions.updateAclCommandOptions); + analysisClinicalSubCommands.addCommand("annotation-sets-load", analysisClinicalCommandOptions.loadAnnotationSetsCommandOptions); analysisClinicalSubCommands.addCommand("clinical-configuration-update", analysisClinicalCommandOptions.updateClinicalConfigurationCommandOptions); analysisClinicalSubCommands.addCommand("create", analysisClinicalCommandOptions.createCommandOptions); analysisClinicalSubCommands.addCommand("distinct", analysisClinicalCommandOptions.distinctCommandOptions); @@ -152,6 +153,7 @@ public OpencgaCliOptionsParser() { analysisClinicalSubCommands.addCommand("acl", analysisClinicalCommandOptions.aclCommandOptions); analysisClinicalSubCommands.addCommand("delete", analysisClinicalCommandOptions.deleteCommandOptions); analysisClinicalSubCommands.addCommand("update", analysisClinicalCommandOptions.updateCommandOptions); + analysisClinicalSubCommands.addCommand("annotation-sets-annotations-update", analysisClinicalCommandOptions.updateAnnotationSetsAnnotationsCommandOptions); analysisClinicalSubCommands.addCommand("info", analysisClinicalCommandOptions.infoCommandOptions); analysisClinicalSubCommands.addCommand("interpretation-create", analysisClinicalCommandOptions.createInterpretationCommandOptions); analysisClinicalSubCommands.addCommand("interpretation-clear", analysisClinicalCommandOptions.clearInterpretationCommandOptions); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AdminCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AdminCommandExecutor.java index 19efed930b2..9126d2a3a7b 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AdminCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AdminCommandExecutor.java @@ -44,6 +44,7 @@ */ public class AdminCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "admin"; public AdminCommandOptions adminCommandOptions; public AdminCommandExecutor(AdminCommandOptions adminCommandOptions) throws CatalogAuthenticationException { @@ -131,10 +132,9 @@ private RestResponse installCatalog() throws Exception { InstallationParams installationParams = null; if (commandOptions.jsonDataModel) { - installationParams = new InstallationParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(installationParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/admin/catalog/install")); return res; } else if (commandOptions.jsonFile != null) { installationParams = JacksonUtils.getDefaultObjectMapper() @@ -160,10 +160,9 @@ private RestResponse jwtCatalog() throws Exception { JWTParams jWTParams = null; if (commandOptions.jsonDataModel) { - jWTParams = new JWTParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(jWTParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/admin/catalog/jwt")); return res; } else if (commandOptions.jsonFile != null) { jWTParams = JacksonUtils.getDefaultObjectMapper() @@ -186,10 +185,9 @@ private RestResponse createUsers() throws Exception { UserCreateParams userCreateParams = null; if (commandOptions.jsonDataModel) { - userCreateParams = new UserCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(userCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/admin/users/create")); return res; } else if (commandOptions.jsonFile != null) { userCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -217,10 +215,9 @@ private RestResponse importUsers() throws Exception { UserImportParams userImportParams = null; if (commandOptions.jsonDataModel) { - userImportParams = new UserImportParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(userImportParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/admin/users/import")); return res; } else if (commandOptions.jsonFile != null) { userImportParams = JacksonUtils.getDefaultObjectMapper() @@ -265,10 +262,9 @@ private RestResponse syncUsers() throws Exception { GroupSyncParams groupSyncParams = null; if (commandOptions.jsonDataModel) { - groupSyncParams = new GroupSyncParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(groupSyncParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/admin/users/sync")); return res; } else if (commandOptions.jsonFile != null) { groupSyncParams = JacksonUtils.getDefaultObjectMapper() @@ -301,10 +297,9 @@ private RestResponse usersUpdateGroups() throws Exception { UserUpdateGroup userUpdateGroup = null; if (commandOptions.jsonDataModel) { - userUpdateGroup = new UserUpdateGroup(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(userUpdateGroup)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/admin/users/{user}/groups/update")); return res; } else if (commandOptions.jsonFile != null) { userUpdateGroup = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AnalysisAlignmentCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AnalysisAlignmentCommandExecutor.java index c1e5a5e0b7c..fcbbfdfc789 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AnalysisAlignmentCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AnalysisAlignmentCommandExecutor.java @@ -44,6 +44,7 @@ */ public class AnalysisAlignmentCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "alignment"; public AnalysisAlignmentCommandOptions analysisAlignmentCommandOptions; public AnalysisAlignmentCommandExecutor(AnalysisAlignmentCommandOptions analysisAlignmentCommandOptions) throws CatalogAuthenticationException { @@ -127,10 +128,9 @@ private RestResponse runBwa() throws Exception { BwaWrapperParams bwaWrapperParams = null; if (commandOptions.jsonDataModel) { - bwaWrapperParams = new BwaWrapperParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(bwaWrapperParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/alignment/bwa/run")); return res; } else if (commandOptions.jsonFile != null) { bwaWrapperParams = JacksonUtils.getDefaultObjectMapper() @@ -169,10 +169,9 @@ private RestResponse runCoverageIndex() throws Exception { CoverageIndexParams coverageIndexParams = null; if (commandOptions.jsonDataModel) { - coverageIndexParams = new CoverageIndexParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(coverageIndexParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/alignment/coverage/index/run")); return res; } else if (commandOptions.jsonFile != null) { coverageIndexParams = JacksonUtils.getDefaultObjectMapper() @@ -208,10 +207,9 @@ private RestResponse coverageQcGeneCoverageStatsRun() throws Exception { AlignmentGeneCoverageStatsParams alignmentGeneCoverageStatsParams = null; if (commandOptions.jsonDataModel) { - alignmentGeneCoverageStatsParams = new AlignmentGeneCoverageStatsParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(alignmentGeneCoverageStatsParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/alignment/coverage/qc/geneCoverageStats/run")); return res; } else if (commandOptions.jsonFile != null) { alignmentGeneCoverageStatsParams = JacksonUtils.getDefaultObjectMapper() @@ -304,10 +302,9 @@ private RestResponse runDeeptools() throws Exception { DeeptoolsWrapperParams deeptoolsWrapperParams = null; if (commandOptions.jsonDataModel) { - deeptoolsWrapperParams = new DeeptoolsWrapperParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(deeptoolsWrapperParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/alignment/deeptools/run")); return res; } else if (commandOptions.jsonFile != null) { deeptoolsWrapperParams = JacksonUtils.getDefaultObjectMapper() @@ -343,10 +340,9 @@ private RestResponse runFastqc() throws Exception { FastqcWrapperParams fastqcWrapperParams = null; if (commandOptions.jsonDataModel) { - fastqcWrapperParams = new FastqcWrapperParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(fastqcWrapperParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/alignment/fastqc/run")); return res; } else if (commandOptions.jsonFile != null) { fastqcWrapperParams = JacksonUtils.getDefaultObjectMapper() @@ -382,10 +378,9 @@ private RestResponse runIndex() throws Exception { AlignmentIndexParams alignmentIndexParams = null; if (commandOptions.jsonDataModel) { - alignmentIndexParams = new AlignmentIndexParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(alignmentIndexParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/alignment/index/run")); return res; } else if (commandOptions.jsonFile != null) { alignmentIndexParams = JacksonUtils.getDefaultObjectMapper() @@ -420,10 +415,9 @@ private RestResponse runPicard() throws Exception { PicardWrapperParams picardWrapperParams = null; if (commandOptions.jsonDataModel) { - picardWrapperParams = new PicardWrapperParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(picardWrapperParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/alignment/picard/run")); return res; } else if (commandOptions.jsonFile != null) { picardWrapperParams = JacksonUtils.getDefaultObjectMapper() @@ -459,10 +453,9 @@ private RestResponse runQc() throws Exception { AlignmentQcParams alignmentQcParams = null; if (commandOptions.jsonDataModel) { - alignmentQcParams = new AlignmentQcParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(alignmentQcParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/alignment/qc/run")); return res; } else if (commandOptions.jsonFile != null) { alignmentQcParams = JacksonUtils.getDefaultObjectMapper() @@ -531,10 +524,9 @@ private RestResponse runSamtools() throws Exception { SamtoolsWrapperParams samtoolsWrapperParams = null; if (commandOptions.jsonDataModel) { - samtoolsWrapperParams = new SamtoolsWrapperParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(samtoolsWrapperParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/alignment/samtools/run")); return res; } else if (commandOptions.jsonFile != null) { samtoolsWrapperParams = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AnalysisClinicalCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AnalysisClinicalCommandExecutor.java index ff9f4431ca4..fd4a6c7e226 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AnalysisClinicalCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AnalysisClinicalCommandExecutor.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.util.HashMap; import java.util.List; +import java.util.Map; import org.opencb.biodata.models.clinical.ClinicalDiscussion; import org.opencb.biodata.models.clinical.ClinicalProperty; import org.opencb.biodata.models.clinical.interpretation.ClinicalVariant; @@ -18,6 +19,7 @@ import org.opencb.opencga.catalog.utils.ParamUtils.AclAction; import org.opencb.opencga.catalog.utils.ParamUtils.AddRemoveReplaceAction; import org.opencb.opencga.catalog.utils.ParamUtils.BasicUpdateAction; +import org.opencb.opencga.catalog.utils.ParamUtils.CompleteUpdateAction; import org.opencb.opencga.catalog.utils.ParamUtils.SaveInterpretationAs; import org.opencb.opencga.catalog.utils.ParamUtils.UpdateAction; import org.opencb.opencga.client.exceptions.ClientException; @@ -38,6 +40,8 @@ import org.opencb.opencga.core.models.clinical.ClinicalAnalysisUpdateParams; import org.opencb.opencga.core.models.clinical.ClinicalAnalystParam; import org.opencb.opencga.core.models.clinical.ClinicalReport; +import org.opencb.opencga.core.models.clinical.ClinicalRequest; +import org.opencb.opencga.core.models.clinical.ClinicalResponsible; import org.opencb.opencga.core.models.clinical.DisorderReferenceParam; import org.opencb.opencga.core.models.clinical.ExomiserInterpretationAnalysisParams; import org.opencb.opencga.core.models.clinical.FamilyParam; @@ -51,7 +55,9 @@ import org.opencb.opencga.core.models.clinical.TieringInterpretationAnalysisParams; import org.opencb.opencga.core.models.clinical.ZettaInterpretationAnalysisParams; import org.opencb.opencga.core.models.common.StatusParam; +import org.opencb.opencga.core.models.common.TsvAnnotationParams; import org.opencb.opencga.core.models.job.Job; +import org.opencb.opencga.core.models.sample.Sample; import org.opencb.opencga.core.models.study.configuration.ClinicalAnalysisStudyConfiguration; import org.opencb.opencga.core.models.study.configuration.ClinicalConsentAnnotationParam; import org.opencb.opencga.core.models.study.configuration.ClinicalConsentConfiguration; @@ -75,6 +81,7 @@ */ public class AnalysisClinicalCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "clinical"; public AnalysisClinicalCommandOptions analysisClinicalCommandOptions; public AnalysisClinicalCommandExecutor(AnalysisClinicalCommandOptions analysisClinicalCommandOptions) throws CatalogAuthenticationException { @@ -95,6 +102,9 @@ public void execute() throws Exception { case "acl-update": queryResponse = updateAcl(); break; + case "annotation-sets-load": + queryResponse = loadAnnotationSets(); + break; case "clinical-configuration-update": queryResponse = updateClinicalConfiguration(); break; @@ -167,6 +177,9 @@ public void execute() throws Exception { case "update": queryResponse = update(); break; + case "annotation-sets-annotations-update": + queryResponse = updateAnnotationSetsAnnotations(); + break; case "info": queryResponse = info(); break; @@ -209,10 +222,9 @@ private RestResponse updateAcl() throws Exception ClinicalAnalysisAclUpdateParams clinicalAnalysisAclUpdateParams = null; if (commandOptions.jsonDataModel) { - clinicalAnalysisAclUpdateParams = new ClinicalAnalysisAclUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(clinicalAnalysisAclUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/acl/{members}/update")); return res; } else if (commandOptions.jsonFile != null) { clinicalAnalysisAclUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -229,6 +241,40 @@ private RestResponse updateAcl() throws Exception return openCGAClient.getClinicalAnalysisClient().updateAcl(commandOptions.members, commandOptions.action, clinicalAnalysisAclUpdateParams, queryParams); } + private RestResponse loadAnnotationSets() throws Exception { + logger.debug("Executing loadAnnotationSets in Analysis - Clinical command line"); + + AnalysisClinicalCommandOptions.LoadAnnotationSetsCommandOptions commandOptions = analysisClinicalCommandOptions.loadAnnotationSetsCommandOptions; + + ObjectMap queryParams = new ObjectMap(); + queryParams.putIfNotEmpty("study", commandOptions.study); + queryParams.putIfNotNull("parents", commandOptions.parents); + queryParams.putIfNotEmpty("annotationSetId", commandOptions.annotationSetId); + if (queryParams.get("study") == null && OpencgaMain.isShellMode()) { + queryParams.putIfNotEmpty("study", sessionManager.getSession().getCurrentStudy()); + } + + + TsvAnnotationParams tsvAnnotationParams = null; + if (commandOptions.jsonDataModel) { + RestResponse res = new RestResponse<>(); + res.setType(QueryType.VOID); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/annotationSets/load")); + return res; + } else if (commandOptions.jsonFile != null) { + tsvAnnotationParams = JacksonUtils.getDefaultObjectMapper() + .readValue(new java.io.File(commandOptions.jsonFile), TsvAnnotationParams.class); + } else { + ObjectMap beanParams = new ObjectMap(); + putNestedIfNotEmpty(beanParams, "content",commandOptions.content, true); + + tsvAnnotationParams = JacksonUtils.getDefaultObjectMapper().copy() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true) + .readValue(beanParams.toJson(), TsvAnnotationParams.class); + } + return openCGAClient.getClinicalAnalysisClient().loadAnnotationSets(commandOptions.variableSetId, commandOptions.path, tsvAnnotationParams, queryParams); + } + private RestResponse updateClinicalConfiguration() throws Exception { logger.debug("Executing updateClinicalConfiguration in Analysis - Clinical command line"); @@ -243,10 +289,9 @@ private RestResponse updateClinicalConfiguration() throws Exception { ClinicalAnalysisStudyConfiguration clinicalAnalysisStudyConfiguration = null; if (commandOptions.jsonDataModel) { - clinicalAnalysisStudyConfiguration = new ClinicalAnalysisStudyConfiguration(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(clinicalAnalysisStudyConfiguration)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/clinical/configuration/update")); return res; } else if (commandOptions.jsonFile != null) { clinicalAnalysisStudyConfiguration = JacksonUtils.getDefaultObjectMapper() @@ -280,10 +325,9 @@ private RestResponse create() throws Exception { ClinicalAnalysisCreateParams clinicalAnalysisCreateParams = null; if (commandOptions.jsonDataModel) { - clinicalAnalysisCreateParams = new ClinicalAnalysisCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(clinicalAnalysisCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/create")); return res; } else if (commandOptions.jsonFile != null) { clinicalAnalysisCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -297,13 +341,24 @@ private RestResponse create() throws Exception { putNestedIfNotEmpty(beanParams, "proband.id",commandOptions.probandId, true); putNestedIfNotEmpty(beanParams, "family.id",commandOptions.familyId, true); putNestedIfNotNull(beanParams, "panelLock",commandOptions.panelLock, true); - putNestedIfNotEmpty(beanParams, "analyst.id",commandOptions.analystId, true); putNestedIfNotEmpty(beanParams, "report.title",commandOptions.reportTitle, true); putNestedIfNotEmpty(beanParams, "report.overview",commandOptions.reportOverview, true); putNestedIfNotEmpty(beanParams, "report.logo",commandOptions.reportLogo, true); putNestedIfNotEmpty(beanParams, "report.signedBy",commandOptions.reportSignedBy, true); putNestedIfNotEmpty(beanParams, "report.signature",commandOptions.reportSignature, true); putNestedIfNotEmpty(beanParams, "report.date",commandOptions.reportDate, true); + putNestedIfNotEmpty(beanParams, "request.id",commandOptions.requestId, true); + putNestedIfNotEmpty(beanParams, "request.justification",commandOptions.requestJustification, true); + putNestedIfNotEmpty(beanParams, "request.date",commandOptions.requestDate, true); + putNestedIfNotNull(beanParams, "request.attributes",commandOptions.requestAttributes, true); + putNestedIfNotEmpty(beanParams, "responsible.id",commandOptions.responsibleId, true); + putNestedIfNotEmpty(beanParams, "responsible.name",commandOptions.responsibleName, true); + putNestedIfNotEmpty(beanParams, "responsible.email",commandOptions.responsibleEmail, true); + putNestedIfNotEmpty(beanParams, "responsible.organization",commandOptions.responsibleOrganization, true); + putNestedIfNotEmpty(beanParams, "responsible.department",commandOptions.responsibleDepartment, true); + putNestedIfNotEmpty(beanParams, "responsible.address",commandOptions.responsibleAddress, true); + putNestedIfNotEmpty(beanParams, "responsible.city",commandOptions.responsibleCity, true); + putNestedIfNotEmpty(beanParams, "responsible.postcode",commandOptions.responsiblePostcode, true); putNestedIfNotEmpty(beanParams, "interpretation.description",commandOptions.interpretationDescription, true); putNestedIfNotEmpty(beanParams, "interpretation.clinicalAnalysisId",commandOptions.interpretationClinicalAnalysisId, true); putNestedIfNotEmpty(beanParams, "interpretation.creationDate",commandOptions.interpretationCreationDate, true); @@ -311,6 +366,8 @@ private RestResponse create() throws Exception { putNestedIfNotNull(beanParams, "interpretation.locked",commandOptions.interpretationLocked, true); putNestedIfNotNull(beanParams, "interpretation.attributes",commandOptions.interpretationAttributes, true); putNestedIfNotNull(beanParams, "qualityControl.summary",commandOptions.qualityControlSummary, true); + putNestedIfNotNull(beanParams, "qualityControl.comments",commandOptions.qualityControlComments, true); + putNestedIfNotNull(beanParams, "qualityControl.files",commandOptions.qualityControlFiles, true); putNestedIfNotEmpty(beanParams, "creationDate",commandOptions.creationDate, true); putNestedIfNotEmpty(beanParams, "modificationDate",commandOptions.modificationDate, true); putNestedIfNotEmpty(beanParams, "dueDate",commandOptions.dueDate, true); @@ -356,6 +413,7 @@ private RestResponse distinct() throws Exception { queryParams.putIfNotEmpty("release", commandOptions.release); queryParams.putIfNotEmpty("status", commandOptions.status); queryParams.putIfNotEmpty("internalStatus", commandOptions.internalStatus); + queryParams.putIfNotEmpty("annotation", commandOptions.annotation); queryParams.putIfNotNull("deleted", commandOptions.deleted); if (queryParams.get("study") == null && OpencgaMain.isShellMode()) { queryParams.putIfNotEmpty("study", sessionManager.getSession().getCurrentStudy()); @@ -459,10 +517,9 @@ private RestResponse runInterpreterCancerTiering() throws Exception { CancerTieringInterpretationAnalysisParams cancerTieringInterpretationAnalysisParams = null; if (commandOptions.jsonDataModel) { - cancerTieringInterpretationAnalysisParams = new CancerTieringInterpretationAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(cancerTieringInterpretationAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/interpreter/cancerTiering/run")); return res; } else if (commandOptions.jsonFile != null) { cancerTieringInterpretationAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -498,10 +555,9 @@ private RestResponse runInterpreterExomiser() throws Exception { ExomiserInterpretationAnalysisParams exomiserInterpretationAnalysisParams = null; if (commandOptions.jsonDataModel) { - exomiserInterpretationAnalysisParams = new ExomiserInterpretationAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(exomiserInterpretationAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/interpreter/exomiser/run")); return res; } else if (commandOptions.jsonFile != null) { exomiserInterpretationAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -535,10 +591,9 @@ private RestResponse runInterpreterTeam() throws Exception { TeamInterpretationAnalysisParams teamInterpretationAnalysisParams = null; if (commandOptions.jsonDataModel) { - teamInterpretationAnalysisParams = new TeamInterpretationAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(teamInterpretationAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/interpreter/team/run")); return res; } else if (commandOptions.jsonFile != null) { teamInterpretationAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -575,10 +630,9 @@ private RestResponse runInterpreterTiering() throws Exception { TieringInterpretationAnalysisParams tieringInterpretationAnalysisParams = null; if (commandOptions.jsonDataModel) { - tieringInterpretationAnalysisParams = new TieringInterpretationAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(tieringInterpretationAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/interpreter/tiering/run")); return res; } else if (commandOptions.jsonFile != null) { tieringInterpretationAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -615,10 +669,9 @@ private RestResponse runInterpreterZetta() throws Exception { ZettaInterpretationAnalysisParams zettaInterpretationAnalysisParams = null; if (commandOptions.jsonDataModel) { - zettaInterpretationAnalysisParams = new ZettaInterpretationAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(zettaInterpretationAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/interpreter/zetta/run")); return res; } else if (commandOptions.jsonFile != null) { zettaInterpretationAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -818,10 +871,9 @@ private RestResponse runRgaIndex() throws Exception { RgaAnalysisParams rgaAnalysisParams = null; if (commandOptions.jsonDataModel) { - rgaAnalysisParams = new RgaAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(rgaAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/rga/index/run")); return res; } else if (commandOptions.jsonFile != null) { rgaAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -1003,6 +1055,7 @@ private RestResponse search() throws Exception { queryParams.putIfNotNull("limit", commandOptions.limit); queryParams.putIfNotNull("skip", commandOptions.skip); queryParams.putIfNotNull("count", commandOptions.count); + queryParams.putIfNotNull("flattenAnnotations", commandOptions.flattenAnnotations); queryParams.putIfNotEmpty("study", commandOptions.study); queryParams.putIfNotEmpty("id", commandOptions.id); queryParams.putIfNotEmpty("uuid", commandOptions.uuid); @@ -1028,6 +1081,7 @@ private RestResponse search() throws Exception { queryParams.putIfNotEmpty("release", commandOptions.release); queryParams.putIfNotEmpty("status", commandOptions.status); queryParams.putIfNotEmpty("internalStatus", commandOptions.internalStatus); + queryParams.putIfNotEmpty("annotation", commandOptions.annotation); queryParams.putIfNotNull("deleted", commandOptions.deleted); if (queryParams.get("study") == null && OpencgaMain.isShellMode()) { queryParams.putIfNotEmpty("study", sessionManager.getSession().getCurrentStudy()); @@ -1150,6 +1204,8 @@ private RestResponse update() throws Exception { queryParams.putIfNotEmpty("include", commandOptions.include); queryParams.putIfNotEmpty("exclude", commandOptions.exclude); queryParams.putIfNotEmpty("study", commandOptions.study); + queryParams.putIfNotNull("analystsAction", commandOptions.analystsAction); + queryParams.putIfNotNull("annotationSetsAction", commandOptions.annotationSetsAction); queryParams.putIfNotNull("includeResult", commandOptions.includeResult); if (queryParams.get("study") == null && OpencgaMain.isShellMode()) { queryParams.putIfNotEmpty("study", sessionManager.getSession().getCurrentStudy()); @@ -1158,10 +1214,9 @@ private RestResponse update() throws Exception { ClinicalAnalysisUpdateParams clinicalAnalysisUpdateParams = null; if (commandOptions.jsonDataModel) { - clinicalAnalysisUpdateParams = new ClinicalAnalysisUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(clinicalAnalysisUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/{clinicalAnalyses}/update")); return res; } else if (commandOptions.jsonFile != null) { clinicalAnalysisUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -1176,14 +1231,27 @@ private RestResponse update() throws Exception { putNestedIfNotEmpty(beanParams, "proband.id",commandOptions.probandId, true); putNestedIfNotEmpty(beanParams, "family.id",commandOptions.familyId, true); putNestedIfNotNull(beanParams, "locked",commandOptions.locked, true); - putNestedIfNotEmpty(beanParams, "analyst.id",commandOptions.analystId, true); putNestedIfNotEmpty(beanParams, "report.title",commandOptions.reportTitle, true); putNestedIfNotEmpty(beanParams, "report.overview",commandOptions.reportOverview, true); putNestedIfNotEmpty(beanParams, "report.logo",commandOptions.reportLogo, true); putNestedIfNotEmpty(beanParams, "report.signedBy",commandOptions.reportSignedBy, true); putNestedIfNotEmpty(beanParams, "report.signature",commandOptions.reportSignature, true); putNestedIfNotEmpty(beanParams, "report.date",commandOptions.reportDate, true); + putNestedIfNotEmpty(beanParams, "request.id",commandOptions.requestId, true); + putNestedIfNotEmpty(beanParams, "request.justification",commandOptions.requestJustification, true); + putNestedIfNotEmpty(beanParams, "request.date",commandOptions.requestDate, true); + putNestedIfNotNull(beanParams, "request.attributes",commandOptions.requestAttributes, true); + putNestedIfNotEmpty(beanParams, "responsible.id",commandOptions.responsibleId, true); + putNestedIfNotEmpty(beanParams, "responsible.name",commandOptions.responsibleName, true); + putNestedIfNotEmpty(beanParams, "responsible.email",commandOptions.responsibleEmail, true); + putNestedIfNotEmpty(beanParams, "responsible.organization",commandOptions.responsibleOrganization, true); + putNestedIfNotEmpty(beanParams, "responsible.department",commandOptions.responsibleDepartment, true); + putNestedIfNotEmpty(beanParams, "responsible.address",commandOptions.responsibleAddress, true); + putNestedIfNotEmpty(beanParams, "responsible.city",commandOptions.responsibleCity, true); + putNestedIfNotEmpty(beanParams, "responsible.postcode",commandOptions.responsiblePostcode, true); putNestedIfNotNull(beanParams, "qualityControl.summary",commandOptions.qualityControlSummary, true); + putNestedIfNotNull(beanParams, "qualityControl.comments",commandOptions.qualityControlComments, true); + putNestedIfNotNull(beanParams, "qualityControl.files",commandOptions.qualityControlFiles, true); putNestedIfNotEmpty(beanParams, "creationDate",commandOptions.creationDate, true); putNestedIfNotEmpty(beanParams, "modificationDate",commandOptions.modificationDate, true); putNestedIfNotEmpty(beanParams, "dueDate",commandOptions.dueDate, true); @@ -1198,6 +1266,32 @@ private RestResponse update() throws Exception { return openCGAClient.getClinicalAnalysisClient().update(commandOptions.clinicalAnalyses, clinicalAnalysisUpdateParams, queryParams); } + private RestResponse updateAnnotationSetsAnnotations() throws Exception { + logger.debug("Executing updateAnnotationSetsAnnotations in Analysis - Clinical command line"); + + AnalysisClinicalCommandOptions.UpdateAnnotationSetsAnnotationsCommandOptions commandOptions = analysisClinicalCommandOptions.updateAnnotationSetsAnnotationsCommandOptions; + + ObjectMap queryParams = new ObjectMap(); + queryParams.putIfNotEmpty("study", commandOptions.study); + queryParams.putIfNotNull("action", commandOptions.action); + if (queryParams.get("study") == null && OpencgaMain.isShellMode()) { + queryParams.putIfNotEmpty("study", sessionManager.getSession().getCurrentStudy()); + } + + + ObjectMap objectMap = null; + if (commandOptions.jsonDataModel) { + RestResponse res = new RestResponse<>(); + res.setType(QueryType.VOID); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/{clinicalAnalysis}/annotationSets/{annotationSet}/annotations/update")); + return res; + } else if (commandOptions.jsonFile != null) { + objectMap = JacksonUtils.getDefaultObjectMapper() + .readValue(new java.io.File(commandOptions.jsonFile), ObjectMap.class); + } + return openCGAClient.getClinicalAnalysisClient().updateAnnotationSetsAnnotations(commandOptions.clinicalAnalysis, commandOptions.annotationSet, objectMap, queryParams); + } + private RestResponse info() throws Exception { logger.debug("Executing info in Analysis - Clinical command line"); @@ -1206,6 +1300,7 @@ private RestResponse info() throws Exception { ObjectMap queryParams = new ObjectMap(); queryParams.putIfNotEmpty("include", commandOptions.include); queryParams.putIfNotEmpty("exclude", commandOptions.exclude); + queryParams.putIfNotNull("flattenAnnotations", commandOptions.flattenAnnotations); queryParams.putIfNotEmpty("study", commandOptions.study); queryParams.putIfNotNull("deleted", commandOptions.deleted); if (queryParams.get("study") == null && OpencgaMain.isShellMode()) { @@ -1233,10 +1328,9 @@ private RestResponse createInterpretation() throws Exception { InterpretationCreateParams interpretationCreateParams = null; if (commandOptions.jsonDataModel) { - interpretationCreateParams = new InterpretationCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(interpretationCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/{clinicalAnalysis}/interpretation/create")); return res; } else if (commandOptions.jsonFile != null) { interpretationCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -1323,10 +1417,9 @@ private RestResponse updateInterpretation() throws Exception { InterpretationUpdateParams interpretationUpdateParams = null; if (commandOptions.jsonDataModel) { - interpretationUpdateParams = new InterpretationUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(interpretationUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/clinical/{clinicalAnalysis}/interpretation/{interpretation}/update")); return res; } else if (commandOptions.jsonFile != null) { interpretationUpdateParams = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AnalysisVariantCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AnalysisVariantCommandExecutor.java index 2f670f539e8..33dfbc54a41 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AnalysisVariantCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/AnalysisVariantCommandExecutor.java @@ -72,6 +72,7 @@ */ public class AnalysisVariantCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "variant"; public AnalysisVariantCommandOptions analysisVariantCommandOptions; public AnalysisVariantCommandExecutor(AnalysisVariantCommandOptions analysisVariantCommandOptions) throws CatalogAuthenticationException { @@ -308,10 +309,9 @@ private RestResponse runCircos() throws Exception { CircosAnalysisParams circosAnalysisParams = null; if (commandOptions.jsonDataModel) { - circosAnalysisParams = new CircosAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(circosAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/circos/run")); return res; } else if (commandOptions.jsonFile != null) { circosAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -377,10 +377,9 @@ private RestResponse runCohortStats() throws Exception { CohortVariantStatsAnalysisParams cohortVariantStatsAnalysisParams = null; if (commandOptions.jsonDataModel) { - cohortVariantStatsAnalysisParams = new CohortVariantStatsAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(cohortVariantStatsAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/cohort/stats/run")); return res; } else if (commandOptions.jsonFile != null) { cohortVariantStatsAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -418,10 +417,9 @@ private RestResponse runExomiser() throws Exception { ExomiserWrapperParams exomiserWrapperParams = null; if (commandOptions.jsonDataModel) { - exomiserWrapperParams = new ExomiserWrapperParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(exomiserWrapperParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/exomiser/run")); return res; } else if (commandOptions.jsonFile != null) { exomiserWrapperParams = JacksonUtils.getDefaultObjectMapper() @@ -459,10 +457,9 @@ private RestResponse runExport() throws Exception { VariantExportParams variantExportParams = null; if (commandOptions.jsonDataModel) { - variantExportParams = new VariantExportParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantExportParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/export/run")); return res; } else if (commandOptions.jsonFile != null) { variantExportParams = JacksonUtils.getDefaultObjectMapper() @@ -600,10 +597,9 @@ private RestResponse runFamilyQc() throws Exception { FamilyQcAnalysisParams familyQcAnalysisParams = null; if (commandOptions.jsonDataModel) { - familyQcAnalysisParams = new FamilyQcAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(familyQcAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/family/qc/run")); return res; } else if (commandOptions.jsonFile != null) { familyQcAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -660,10 +656,9 @@ private RestResponse runGatk() throws Exception { GatkWrapperParams gatkWrapperParams = null; if (commandOptions.jsonDataModel) { - gatkWrapperParams = new GatkWrapperParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(gatkWrapperParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/gatk/run")); return res; } else if (commandOptions.jsonFile != null) { gatkWrapperParams = JacksonUtils.getDefaultObjectMapper() @@ -699,10 +694,9 @@ private RestResponse runGenomePlot() throws Exception { GenomePlotAnalysisParams genomePlotAnalysisParams = null; if (commandOptions.jsonDataModel) { - genomePlotAnalysisParams = new GenomePlotAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(genomePlotAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/genomePlot/run")); return res; } else if (commandOptions.jsonFile != null) { genomePlotAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -740,10 +734,9 @@ private RestResponse runGwas() throws Exception { GwasAnalysisParams gwasAnalysisParams = null; if (commandOptions.jsonDataModel) { - gwasAnalysisParams = new GwasAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(gwasAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/gwas/run")); return res; } else if (commandOptions.jsonFile != null) { gwasAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -788,10 +781,9 @@ private RestResponse runHrDetect() throws Exception { HRDetectAnalysisParams hRDetectAnalysisParams = null; if (commandOptions.jsonDataModel) { - hRDetectAnalysisParams = new HRDetectAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(hRDetectAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/hrDetect/run")); return res; } else if (commandOptions.jsonFile != null) { hRDetectAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -837,10 +829,9 @@ private RestResponse runIndex() throws Exception { VariantIndexParams variantIndexParams = null; if (commandOptions.jsonDataModel) { - variantIndexParams = new VariantIndexParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantIndexParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/index/run")); return res; } else if (commandOptions.jsonFile != null) { variantIndexParams = JacksonUtils.getDefaultObjectMapper() @@ -903,10 +894,9 @@ private RestResponse runIndividualQc() throws Exception { IndividualQcAnalysisParams individualQcAnalysisParams = null; if (commandOptions.jsonDataModel) { - individualQcAnalysisParams = new IndividualQcAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(individualQcAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/individual/qc/run")); return res; } else if (commandOptions.jsonFile != null) { individualQcAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -943,10 +933,9 @@ private RestResponse runInferredSex() throws Exception { InferredSexAnalysisParams inferredSexAnalysisParams = null; if (commandOptions.jsonDataModel) { - inferredSexAnalysisParams = new InferredSexAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(inferredSexAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/inferredSex/run")); return res; } else if (commandOptions.jsonFile != null) { inferredSexAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -1016,10 +1005,9 @@ private RestResponse runKnockout() throws Exception { KnockoutAnalysisParams knockoutAnalysisParams = null; if (commandOptions.jsonDataModel) { - knockoutAnalysisParams = new KnockoutAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(knockoutAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/knockout/run")); return res; } else if (commandOptions.jsonFile != null) { knockoutAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -1062,10 +1050,9 @@ private RestResponse runMendelianError() throws Exception { MendelianErrorAnalysisParams mendelianErrorAnalysisParams = null; if (commandOptions.jsonDataModel) { - mendelianErrorAnalysisParams = new MendelianErrorAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(mendelianErrorAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/mendelianError/run")); return res; } else if (commandOptions.jsonFile != null) { mendelianErrorAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -1155,10 +1142,9 @@ private RestResponse runMutationalSignature() throws Exception { MutationalSignatureAnalysisParams mutationalSignatureAnalysisParams = null; if (commandOptions.jsonDataModel) { - mutationalSignatureAnalysisParams = new MutationalSignatureAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(mutationalSignatureAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/mutationalSignature/run")); return res; } else if (commandOptions.jsonFile != null) { mutationalSignatureAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -1207,10 +1193,9 @@ private RestResponse runPlink() throws Exception { PlinkWrapperParams plinkWrapperParams = null; if (commandOptions.jsonDataModel) { - plinkWrapperParams = new PlinkWrapperParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(plinkWrapperParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/plink/run")); return res; } else if (commandOptions.jsonFile != null) { plinkWrapperParams = JacksonUtils.getDefaultObjectMapper() @@ -1335,10 +1320,9 @@ private RestResponse runRelatedness() throws Exception { RelatednessAnalysisParams relatednessAnalysisParams = null; if (commandOptions.jsonDataModel) { - relatednessAnalysisParams = new RelatednessAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(relatednessAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/relatedness/run")); return res; } else if (commandOptions.jsonFile != null) { relatednessAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -1376,10 +1360,9 @@ private RestResponse runRvtests() throws Exception { RvtestsWrapperParams rvtestsWrapperParams = null; if (commandOptions.jsonDataModel) { - rvtestsWrapperParams = new RvtestsWrapperParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(rvtestsWrapperParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/rvtests/run")); return res; } else if (commandOptions.jsonFile != null) { rvtestsWrapperParams = JacksonUtils.getDefaultObjectMapper() @@ -1450,10 +1433,9 @@ private RestResponse runSampleEligibility() throws Exception { SampleEligibilityAnalysisParams sampleEligibilityAnalysisParams = null; if (commandOptions.jsonDataModel) { - sampleEligibilityAnalysisParams = new SampleEligibilityAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(sampleEligibilityAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/sample/eligibility/run")); return res; } else if (commandOptions.jsonFile != null) { sampleEligibilityAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -1489,10 +1471,9 @@ private RestResponse runSampleQc() throws Exception { SampleQcAnalysisParams sampleQcAnalysisParams = null; if (commandOptions.jsonDataModel) { - sampleQcAnalysisParams = new SampleQcAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(sampleQcAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/sample/qc/run")); return res; } else if (commandOptions.jsonFile != null) { sampleQcAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -1590,10 +1571,9 @@ private RestResponse runSample() throws Exception { SampleVariantFilterParams sampleVariantFilterParams = null; if (commandOptions.jsonDataModel) { - sampleVariantFilterParams = new SampleVariantFilterParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(sampleVariantFilterParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/sample/run")); return res; } else if (commandOptions.jsonFile != null) { sampleVariantFilterParams = JacksonUtils.getDefaultObjectMapper() @@ -1684,10 +1664,9 @@ private RestResponse runSampleStats() throws Exception { SampleVariantStatsAnalysisParams sampleVariantStatsAnalysisParams = null; if (commandOptions.jsonDataModel) { - sampleVariantStatsAnalysisParams = new SampleVariantStatsAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(sampleVariantStatsAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/sample/stats/run")); return res; } else if (commandOptions.jsonFile != null) { sampleVariantStatsAnalysisParams = JacksonUtils.getDefaultObjectMapper() @@ -1757,10 +1736,9 @@ private RestResponse runStatsExport() throws Exception { VariantStatsExportParams variantStatsExportParams = null; if (commandOptions.jsonDataModel) { - variantStatsExportParams = new VariantStatsExportParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantStatsExportParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/stats/export/run")); return res; } else if (commandOptions.jsonFile != null) { variantStatsExportParams = JacksonUtils.getDefaultObjectMapper() @@ -1798,10 +1776,9 @@ private RestResponse runStats() throws Exception { VariantStatsAnalysisParams variantStatsAnalysisParams = null; if (commandOptions.jsonDataModel) { - variantStatsAnalysisParams = new VariantStatsAnalysisParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantStatsAnalysisParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/analysis/variant/stats/run")); return res; } else if (commandOptions.jsonFile != null) { variantStatsAnalysisParams = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/CohortsCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/CohortsCommandExecutor.java index 54d3c8c3704..f2988c96834 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/CohortsCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/CohortsCommandExecutor.java @@ -46,6 +46,7 @@ */ public class CohortsCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "cohorts"; public CohortsCommandOptions cohortsCommandOptions; public CohortsCommandExecutor(CohortsCommandOptions cohortsCommandOptions) throws CatalogAuthenticationException { @@ -122,10 +123,9 @@ private RestResponse updateAcl() throws Exception { CohortAclUpdateParams cohortAclUpdateParams = null; if (commandOptions.jsonDataModel) { - cohortAclUpdateParams = new CohortAclUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(cohortAclUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/cohorts/acl/{members}/update")); return res; } else if (commandOptions.jsonFile != null) { cohortAclUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -183,10 +183,9 @@ private RestResponse loadAnnotationSets() throws Exception { TsvAnnotationParams tsvAnnotationParams = null; if (commandOptions.jsonDataModel) { - tsvAnnotationParams = new TsvAnnotationParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(tsvAnnotationParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/cohorts/annotationSets/load")); return res; } else if (commandOptions.jsonFile != null) { tsvAnnotationParams = JacksonUtils.getDefaultObjectMapper() @@ -221,10 +220,9 @@ private RestResponse create() throws Exception { CohortCreateParams cohortCreateParams = null; if (commandOptions.jsonDataModel) { - cohortCreateParams = new CohortCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(cohortCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/cohorts/create")); return res; } else if (commandOptions.jsonFile != null) { cohortCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -307,10 +305,9 @@ private RestResponse generate() throws Exception { CohortGenerateParams cohortGenerateParams = null; if (commandOptions.jsonDataModel) { - cohortGenerateParams = new CohortGenerateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(cohortGenerateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/cohorts/generate")); return res; } else if (commandOptions.jsonFile != null) { cohortGenerateParams = JacksonUtils.getDefaultObjectMapper() @@ -434,10 +431,9 @@ private RestResponse update() throws Exception { CohortUpdateParams cohortUpdateParams = null; if (commandOptions.jsonDataModel) { - cohortUpdateParams = new CohortUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(cohortUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/cohorts/{cohorts}/update")); return res; } else if (commandOptions.jsonFile != null) { cohortUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -477,10 +473,9 @@ private RestResponse updateAnnotationSetsAnnotations() throws Exception ObjectMap objectMap = null; if (commandOptions.jsonDataModel) { - objectMap = new ObjectMap(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(objectMap)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/cohorts/{cohort}/annotationSets/{annotationSet}/annotations/update")); return res; } else if (commandOptions.jsonFile != null) { objectMap = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/DiseasePanelsCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/DiseasePanelsCommandExecutor.java index fcac8b23c88..033aff423b5 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/DiseasePanelsCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/DiseasePanelsCommandExecutor.java @@ -40,6 +40,7 @@ */ public class DiseasePanelsCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "panels"; public DiseasePanelsCommandOptions diseasePanelsCommandOptions; public DiseasePanelsCommandExecutor(DiseasePanelsCommandOptions diseasePanelsCommandOptions) throws CatalogAuthenticationException { @@ -107,10 +108,9 @@ private RestResponse updateAcl() throws Exception { PanelAclUpdateParams panelAclUpdateParams = null; if (commandOptions.jsonDataModel) { - panelAclUpdateParams = new PanelAclUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(panelAclUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/panels/acl/{members}/update")); return res; } else if (commandOptions.jsonFile != null) { panelAclUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -144,10 +144,9 @@ private RestResponse create() throws Exception { PanelCreateParams panelCreateParams = null; if (commandOptions.jsonDataModel) { - panelCreateParams = new PanelCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(panelCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/panels/create")); return res; } else if (commandOptions.jsonFile != null) { panelCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -223,10 +222,9 @@ private RestResponse importPanels() throws Exception { PanelImportParams panelImportParams = null; if (commandOptions.jsonDataModel) { - panelImportParams = new PanelImportParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(panelImportParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/panels/import")); return res; } else if (commandOptions.jsonFile != null) { panelImportParams = JacksonUtils.getDefaultObjectMapper() @@ -345,10 +343,9 @@ private RestResponse update() throws Exception { PanelUpdateParams panelUpdateParams = null; if (commandOptions.jsonDataModel) { - panelUpdateParams = new PanelUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(panelUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/panels/{panels}/update")); return res; } else if (commandOptions.jsonFile != null) { panelUpdateParams = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/FamiliesCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/FamiliesCommandExecutor.java index b7521c2c790..c069ca9c896 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/FamiliesCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/FamiliesCommandExecutor.java @@ -46,6 +46,7 @@ */ public class FamiliesCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "families"; public FamiliesCommandOptions familiesCommandOptions; public FamiliesCommandExecutor(FamiliesCommandOptions familiesCommandOptions) throws CatalogAuthenticationException { @@ -120,10 +121,9 @@ private RestResponse updateAcl() throws Exception { FamilyAclUpdateParams familyAclUpdateParams = null; if (commandOptions.jsonDataModel) { - familyAclUpdateParams = new FamilyAclUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(familyAclUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/families/acl/{members}/update")); return res; } else if (commandOptions.jsonFile != null) { familyAclUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -185,10 +185,9 @@ private RestResponse loadAnnotationSets() throws Exception { TsvAnnotationParams tsvAnnotationParams = null; if (commandOptions.jsonDataModel) { - tsvAnnotationParams = new TsvAnnotationParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(tsvAnnotationParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/families/annotationSets/load")); return res; } else if (commandOptions.jsonFile != null) { tsvAnnotationParams = JacksonUtils.getDefaultObjectMapper() @@ -222,10 +221,9 @@ private RestResponse create() throws Exception { FamilyCreateParams familyCreateParams = null; if (commandOptions.jsonDataModel) { - familyCreateParams = new FamilyCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(familyCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/families/create")); return res; } else if (commandOptions.jsonFile != null) { familyCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -386,10 +384,9 @@ private RestResponse update() throws Exception { FamilyUpdateParams familyUpdateParams = null; if (commandOptions.jsonDataModel) { - familyUpdateParams = new FamilyUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(familyUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/families/{families}/update")); return res; } else if (commandOptions.jsonFile != null) { familyUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -430,10 +427,9 @@ private RestResponse updateAnnotationSetsAnnotations() throws Exception ObjectMap objectMap = null; if (commandOptions.jsonDataModel) { - objectMap = new ObjectMap(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(objectMap)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/families/{family}/annotationSets/{annotationSet}/annotations/update")); return res; } else if (commandOptions.jsonFile != null) { objectMap = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/FilesCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/FilesCommandExecutor.java index 62796417c62..350c7491ccc 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/FilesCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/FilesCommandExecutor.java @@ -66,6 +66,7 @@ */ public class FilesCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "files"; public FilesCommandOptions filesCommandOptions; public FilesCommandExecutor(FilesCommandOptions filesCommandOptions) throws CatalogAuthenticationException { @@ -187,10 +188,9 @@ private RestResponse updateAcl() throws Exception { FileAclUpdateParams fileAclUpdateParams = null; if (commandOptions.jsonDataModel) { - fileAclUpdateParams = new FileAclUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(fileAclUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/files/acl/{members}/update")); return res; } else if (commandOptions.jsonFile != null) { fileAclUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -257,10 +257,9 @@ private RestResponse loadAnnotationSets() throws Exception { TsvAnnotationParams tsvAnnotationParams = null; if (commandOptions.jsonDataModel) { - tsvAnnotationParams = new TsvAnnotationParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(tsvAnnotationParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/files/annotationSets/load")); return res; } else if (commandOptions.jsonFile != null) { tsvAnnotationParams = JacksonUtils.getDefaultObjectMapper() @@ -298,10 +297,9 @@ private RestResponse create() throws Exception { FileCreateParams fileCreateParams = null; if (commandOptions.jsonDataModel) { - fileCreateParams = new FileCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(fileCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/files/create")); return res; } else if (commandOptions.jsonFile != null) { fileCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -394,10 +392,9 @@ private RestResponse fetch() throws Exception { FileFetch fileFetch = null; if (commandOptions.jsonDataModel) { - fileFetch = new FileFetch(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(fileFetch)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/files/fetch")); return res; } else if (commandOptions.jsonFile != null) { fileFetch = JacksonUtils.getDefaultObjectMapper() @@ -436,10 +433,9 @@ private RestResponse link() throws Exception { FileLinkParams fileLinkParams = null; if (commandOptions.jsonDataModel) { - fileLinkParams = new FileLinkParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(fileLinkParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/files/link")); return res; } else if (commandOptions.jsonFile != null) { fileLinkParams = JacksonUtils.getDefaultObjectMapper() @@ -482,10 +478,9 @@ private RestResponse runLink() throws Exception { FileLinkToolParams fileLinkToolParams = null; if (commandOptions.jsonDataModel) { - fileLinkToolParams = new FileLinkToolParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(fileLinkToolParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/files/link/run")); return res; } else if (commandOptions.jsonFile != null) { fileLinkToolParams = JacksonUtils.getDefaultObjectMapper() @@ -524,10 +519,9 @@ private RestResponse runPostlink() throws Exception { PostLinkToolParams postLinkToolParams = null; if (commandOptions.jsonDataModel) { - postLinkToolParams = new PostLinkToolParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(postLinkToolParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/files/postlink/run")); return res; } else if (commandOptions.jsonFile != null) { postLinkToolParams = JacksonUtils.getDefaultObjectMapper() @@ -690,10 +684,9 @@ private RestResponse update() throws Exception { FileUpdateParams fileUpdateParams = null; if (commandOptions.jsonDataModel) { - fileUpdateParams = new FileUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(fileUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/files/{files}/update")); return res; } else if (commandOptions.jsonFile != null) { fileUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -757,10 +750,9 @@ private RestResponse updateAnnotationSetsAnnotations() throws Exception { ObjectMap objectMap = null; if (commandOptions.jsonDataModel) { - objectMap = new ObjectMap(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(objectMap)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/files/{file}/annotationSets/{annotationSet}/annotations/update")); return res; } else if (commandOptions.jsonFile != null) { objectMap = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/IndividualsCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/IndividualsCommandExecutor.java index 1516be90a6c..504ff0043b9 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/IndividualsCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/IndividualsCommandExecutor.java @@ -52,6 +52,7 @@ */ public class IndividualsCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "individuals"; public IndividualsCommandOptions individualsCommandOptions; public IndividualsCommandExecutor(IndividualsCommandOptions individualsCommandOptions) throws CatalogAuthenticationException { @@ -129,10 +130,9 @@ private RestResponse updateAcl() throws Exception { IndividualAclUpdateParams individualAclUpdateParams = null; if (commandOptions.jsonDataModel) { - individualAclUpdateParams = new IndividualAclUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(individualAclUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/individuals/acl/{members}/update")); return res; } else if (commandOptions.jsonFile != null) { individualAclUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -200,10 +200,9 @@ private RestResponse loadAnnotationSets() throws Exception { TsvAnnotationParams tsvAnnotationParams = null; if (commandOptions.jsonDataModel) { - tsvAnnotationParams = new TsvAnnotationParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(tsvAnnotationParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/individuals/annotationSets/load")); return res; } else if (commandOptions.jsonFile != null) { tsvAnnotationParams = JacksonUtils.getDefaultObjectMapper() @@ -237,10 +236,9 @@ private RestResponse create() throws Exception { IndividualCreateParams individualCreateParams = null; if (commandOptions.jsonDataModel) { - individualCreateParams = new IndividualCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(individualCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/individuals/create")); return res; } else if (commandOptions.jsonFile != null) { individualCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -442,10 +440,9 @@ private RestResponse update() throws Exception { IndividualUpdateParams individualUpdateParams = null; if (commandOptions.jsonDataModel) { - individualUpdateParams = new IndividualUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(individualUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/individuals/{individuals}/update")); return res; } else if (commandOptions.jsonFile != null) { individualUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -512,10 +509,9 @@ private RestResponse updateAnnotationSetsAnnotations() throws Except ObjectMap objectMap = null; if (commandOptions.jsonDataModel) { - objectMap = new ObjectMap(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(objectMap)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/individuals/{individual}/annotationSets/{annotationSet}/annotations/update")); return res; } else if (commandOptions.jsonFile != null) { objectMap = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/JobsCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/JobsCommandExecutor.java index 17b78b206b7..586f631b19d 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/JobsCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/JobsCommandExecutor.java @@ -50,6 +50,7 @@ */ public class JobsCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "jobs"; public JobsCommandOptions jobsCommandOptions; public JobsCommandExecutor(JobsCommandOptions jobsCommandOptions) throws CatalogAuthenticationException { @@ -128,10 +129,9 @@ private RestResponse updateAcl() throws Exception { JobAclUpdateParams jobAclUpdateParams = null; if (commandOptions.jsonDataModel) { - jobAclUpdateParams = new JobAclUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(jobAclUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/jobs/acl/{members}/update")); return res; } else if (commandOptions.jsonFile != null) { jobAclUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -193,10 +193,9 @@ private RestResponse create() throws Exception { JobCreateParams jobCreateParams = null; if (commandOptions.jsonDataModel) { - jobCreateParams = new JobCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(jobCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/jobs/create")); return res; } else if (commandOptions.jsonFile != null) { jobCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -280,10 +279,9 @@ private RestResponse retry() throws Exception { JobRetryParams jobRetryParams = null; if (commandOptions.jsonDataModel) { - jobRetryParams = new JobRetryParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(jobRetryParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/jobs/retry")); return res; } else if (commandOptions.jsonFile != null) { jobRetryParams = JacksonUtils.getDefaultObjectMapper() @@ -416,10 +414,9 @@ private RestResponse update() throws Exception { JobUpdateParams jobUpdateParams = null; if (commandOptions.jsonDataModel) { - jobUpdateParams = new JobUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(jobUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/jobs/{jobs}/update")); return res; } else if (commandOptions.jsonFile != null) { jobUpdateParams = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/MetaCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/MetaCommandExecutor.java index e1d64ae2d4a..0d8987f61d6 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/MetaCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/MetaCommandExecutor.java @@ -32,6 +32,7 @@ */ public class MetaCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "meta"; public MetaCommandOptions metaCommandOptions; public MetaCommandExecutor(MetaCommandOptions metaCommandOptions) throws CatalogAuthenticationException { diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/OpencgaCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/OpencgaCommandExecutor.java index 8360af46f00..8f935c36ff8 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/OpencgaCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/OpencgaCommandExecutor.java @@ -17,11 +17,11 @@ package org.opencb.opencga.app.cli.main.executors; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.opencb.commons.datastore.core.ObjectMap; -import org.opencb.commons.utils.DataModelsUtils; import org.opencb.opencga.app.cli.CommandExecutor; import org.opencb.opencga.app.cli.GeneralCliOptions; import org.opencb.opencga.app.cli.main.io.*; @@ -36,6 +36,9 @@ import org.opencb.opencga.core.models.user.AuthenticationResponse; import org.opencb.opencga.core.response.QueryType; 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; @@ -221,14 +224,96 @@ public OpencgaCommandExecutor setOpenCGAClient(OpenCGAClient openCGAClient) { return this; } - public String getObjectAsJSON(Object o) throws Exception { - String jsonInString = "Data model not found."; + public String getObjectAsJSON(String objectCategory, String objectPath) throws Exception { + StringBuilder jsonInString = new StringBuilder("\n"); try { - jsonInString = DataModelsUtils.dataModelToJsonString(o.getClass()); + ObjectMap queryParams = new ObjectMap(); + queryParams.putIfNotEmpty("category", objectCategory); + RestResponse response = openCGAClient.getMetaClient().api(queryParams); + ObjectMapper jsonObjectMapper = new ObjectMapper(); + for (List list : response.getResponses().get(0).getResults()) { + List categories = jsonObjectMapper.convertValue(list, new TypeReference>() {}); + 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; + return jsonInString.toString(); + } + + private String printBody(List 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 "\"-\""; + } + } + + private boolean isNumeric(String type) { + + return "int".equals(type) || "Long".equals(type) || "Float".equals(type) || "double".equals(type); } public RestResponse saveSession(String user, AuthenticationResponse response) throws ClientException, IOException { diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/OperationsVariantStorageCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/OperationsVariantStorageCommandExecutor.java index 494067498b1..068b4a3792a 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/OperationsVariantStorageCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/OperationsVariantStorageCommandExecutor.java @@ -56,6 +56,7 @@ */ public class OperationsVariantStorageCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "operation"; public OperationsVariantStorageCommandOptions operationsVariantStorageCommandOptions; public OperationsVariantStorageCommandExecutor(OperationsVariantStorageCommandOptions operationsVariantStorageCommandOptions) throws CatalogAuthenticationException { @@ -179,10 +180,9 @@ private RestResponse configureCellbase() throws Exception { CellBaseConfiguration cellBaseConfiguration = null; if (commandOptions.jsonDataModel) { - cellBaseConfiguration = new CellBaseConfiguration(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(cellBaseConfiguration)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/cellbase/configure")); return res; } else if (commandOptions.jsonFile != null) { cellBaseConfiguration = JacksonUtils.getDefaultObjectMapper() @@ -219,10 +219,9 @@ private RestResponse aggregateVariant() throws Exception { VariantAggregateParams variantAggregateParams = null; if (commandOptions.jsonDataModel) { - variantAggregateParams = new VariantAggregateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantAggregateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/aggregate")); return res; } else if (commandOptions.jsonFile != null) { variantAggregateParams = JacksonUtils.getDefaultObjectMapper() @@ -274,10 +273,9 @@ private RestResponse indexVariantAnnotation() throws Exception { VariantAnnotationIndexParams variantAnnotationIndexParams = null; if (commandOptions.jsonDataModel) { - variantAnnotationIndexParams = new VariantAnnotationIndexParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantAnnotationIndexParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/annotation/index")); return res; } else if (commandOptions.jsonFile != null) { variantAnnotationIndexParams = JacksonUtils.getDefaultObjectMapper() @@ -316,10 +314,9 @@ private RestResponse saveVariantAnnotation() throws Exception { VariantAnnotationSaveParams variantAnnotationSaveParams = null; if (commandOptions.jsonDataModel) { - variantAnnotationSaveParams = new VariantAnnotationSaveParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantAnnotationSaveParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/annotation/save")); return res; } else if (commandOptions.jsonFile != null) { variantAnnotationSaveParams = JacksonUtils.getDefaultObjectMapper() @@ -350,10 +347,9 @@ private RestResponse configureVariant() throws Exception { VariantConfigureParams variantConfigureParams = null; if (commandOptions.jsonDataModel) { - variantConfigureParams = new VariantConfigureParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantConfigureParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/configure")); return res; } else if (commandOptions.jsonFile != null) { variantConfigureParams = JacksonUtils.getDefaultObjectMapper() @@ -387,10 +383,9 @@ private RestResponse deleteVariant() throws Exception { VariantFileDeleteParams variantFileDeleteParams = null; if (commandOptions.jsonDataModel) { - variantFileDeleteParams = new VariantFileDeleteParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantFileDeleteParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/delete")); return res; } else if (commandOptions.jsonFile != null) { variantFileDeleteParams = JacksonUtils.getDefaultObjectMapper() @@ -425,10 +420,9 @@ private RestResponse aggregateVariantFamily() throws Exception { VariantAggregateFamilyParams variantAggregateFamilyParams = null; if (commandOptions.jsonDataModel) { - variantAggregateFamilyParams = new VariantAggregateFamilyParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantAggregateFamilyParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/family/aggregate")); return res; } else if (commandOptions.jsonFile != null) { variantAggregateFamilyParams = JacksonUtils.getDefaultObjectMapper() @@ -464,10 +458,9 @@ private RestResponse indexVariantFamily() throws Exception { VariantFamilyIndexParams variantFamilyIndexParams = null; if (commandOptions.jsonDataModel) { - variantFamilyIndexParams = new VariantFamilyIndexParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantFamilyIndexParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/family/index")); return res; } else if (commandOptions.jsonFile != null) { variantFamilyIndexParams = JacksonUtils.getDefaultObjectMapper() @@ -504,10 +497,9 @@ private RestResponse indexVariant() throws Exception { VariantIndexParams variantIndexParams = null; if (commandOptions.jsonDataModel) { - variantIndexParams = new VariantIndexParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantIndexParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/index")); return res; } else if (commandOptions.jsonFile != null) { variantIndexParams = JacksonUtils.getDefaultObjectMapper() @@ -570,10 +562,9 @@ private RestResponse launcherVariantIndex() throws Exception { VariantFileIndexJobLauncherParams variantFileIndexJobLauncherParams = null; if (commandOptions.jsonDataModel) { - variantFileIndexJobLauncherParams = new VariantFileIndexJobLauncherParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantFileIndexJobLauncherParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/index/launcher")); return res; } else if (commandOptions.jsonFile != null) { variantFileIndexJobLauncherParams = JacksonUtils.getDefaultObjectMapper() @@ -638,10 +629,9 @@ private RestResponse runVariantJulie() throws Exception { JulieParams julieParams = null; if (commandOptions.jsonDataModel) { - julieParams = new JulieParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(julieParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/julie/run")); return res; } else if (commandOptions.jsonFile != null) { julieParams = JacksonUtils.getDefaultObjectMapper() @@ -673,10 +663,9 @@ private RestResponse repairVariantMetadata() throws Exception { VariantStorageMetadataRepairToolParams variantStorageMetadataRepairToolParams = null; if (commandOptions.jsonDataModel) { - variantStorageMetadataRepairToolParams = new VariantStorageMetadataRepairToolParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantStorageMetadataRepairToolParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/metadata/repair")); return res; } else if (commandOptions.jsonFile != null) { variantStorageMetadataRepairToolParams = JacksonUtils.getDefaultObjectMapper() @@ -711,10 +700,9 @@ private RestResponse synchronizeVariantMetadata() throws Exception { VariantStorageMetadataSynchronizeParams variantStorageMetadataSynchronizeParams = null; if (commandOptions.jsonDataModel) { - variantStorageMetadataSynchronizeParams = new VariantStorageMetadataSynchronizeParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantStorageMetadataSynchronizeParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/metadata/synchronize")); return res; } else if (commandOptions.jsonFile != null) { variantStorageMetadataSynchronizeParams = JacksonUtils.getDefaultObjectMapper() @@ -745,10 +733,9 @@ private RestResponse pruneVariant() throws Exception { VariantPruneParams variantPruneParams = null; if (commandOptions.jsonDataModel) { - variantPruneParams = new VariantPruneParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantPruneParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/prune")); return res; } else if (commandOptions.jsonFile != null) { variantPruneParams = JacksonUtils.getDefaultObjectMapper() @@ -784,10 +771,9 @@ private RestResponse deleteVariantSample() throws Exception { VariantSampleDeleteParams variantSampleDeleteParams = null; if (commandOptions.jsonDataModel) { - variantSampleDeleteParams = new VariantSampleDeleteParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantSampleDeleteParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/sample/delete")); return res; } else if (commandOptions.jsonFile != null) { variantSampleDeleteParams = JacksonUtils.getDefaultObjectMapper() @@ -823,10 +809,9 @@ private RestResponse indexVariantSample() throws Exception { VariantSecondarySampleIndexParams variantSecondarySampleIndexParams = null; if (commandOptions.jsonDataModel) { - variantSecondarySampleIndexParams = new VariantSecondarySampleIndexParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantSecondarySampleIndexParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/sample/index")); return res; } else if (commandOptions.jsonFile != null) { variantSecondarySampleIndexParams = JacksonUtils.getDefaultObjectMapper() @@ -861,10 +846,9 @@ private RestResponse variantSampleIndexConfigure() throws Exception { SampleIndexConfiguration sampleIndexConfiguration = null; if (commandOptions.jsonDataModel) { - sampleIndexConfiguration = new SampleIndexConfiguration(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(sampleIndexConfiguration)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/sample/index/configure")); return res; } else if (commandOptions.jsonFile != null) { sampleIndexConfiguration = JacksonUtils.getDefaultObjectMapper() @@ -912,10 +896,9 @@ private RestResponse indexVariantScore() throws Exception { VariantScoreIndexParams variantScoreIndexParams = null; if (commandOptions.jsonDataModel) { - variantScoreIndexParams = new VariantScoreIndexParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantScoreIndexParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/score/index")); return res; } else if (commandOptions.jsonFile != null) { variantScoreIndexParams = JacksonUtils.getDefaultObjectMapper() @@ -955,10 +938,9 @@ private RestResponse variantSecondaryAnnotationIndex() throws Exception { VariantSecondaryAnnotationIndexParams variantSecondaryAnnotationIndexParams = null; if (commandOptions.jsonDataModel) { - variantSecondaryAnnotationIndexParams = new VariantSecondaryAnnotationIndexParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantSecondaryAnnotationIndexParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/secondary/annotation/index")); return res; } else if (commandOptions.jsonFile != null) { variantSecondaryAnnotationIndexParams = JacksonUtils.getDefaultObjectMapper() @@ -994,10 +976,9 @@ private RestResponse variantSecondarySampleIndex() throws Exception { VariantSecondarySampleIndexParams variantSecondarySampleIndexParams = null; if (commandOptions.jsonDataModel) { - variantSecondarySampleIndexParams = new VariantSecondarySampleIndexParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantSecondarySampleIndexParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/secondary/sample/index")); return res; } else if (commandOptions.jsonFile != null) { variantSecondarySampleIndexParams = JacksonUtils.getDefaultObjectMapper() @@ -1032,10 +1013,9 @@ private RestResponse configureVariantSecondarySampleIndex() throws Exceptio SampleIndexConfiguration sampleIndexConfiguration = null; if (commandOptions.jsonDataModel) { - sampleIndexConfiguration = new SampleIndexConfiguration(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(sampleIndexConfiguration)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/secondary/sample/index/configure")); return res; } else if (commandOptions.jsonFile != null) { sampleIndexConfiguration = JacksonUtils.getDefaultObjectMapper() @@ -1063,10 +1043,9 @@ private RestResponse secondaryIndexVariant() throws Exception { VariantSecondaryAnnotationIndexParams variantSecondaryAnnotationIndexParams = null; if (commandOptions.jsonDataModel) { - variantSecondaryAnnotationIndexParams = new VariantSecondaryAnnotationIndexParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantSecondaryAnnotationIndexParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/secondaryIndex")); return res; } else if (commandOptions.jsonFile != null) { variantSecondaryAnnotationIndexParams = JacksonUtils.getDefaultObjectMapper() @@ -1121,10 +1100,9 @@ private RestResponse deleteVariantStats() throws Exception { VariantStatsDeleteParams variantStatsDeleteParams = null; if (commandOptions.jsonDataModel) { - variantStatsDeleteParams = new VariantStatsDeleteParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantStatsDeleteParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/stats/delete")); return res; } else if (commandOptions.jsonFile != null) { variantStatsDeleteParams = JacksonUtils.getDefaultObjectMapper() @@ -1159,10 +1137,9 @@ private RestResponse indexVariantStats() throws Exception { VariantStatsIndexParams variantStatsIndexParams = null; if (commandOptions.jsonDataModel) { - variantStatsIndexParams = new VariantStatsIndexParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantStatsIndexParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/stats/index")); return res; } else if (commandOptions.jsonFile != null) { variantStatsIndexParams = JacksonUtils.getDefaultObjectMapper() @@ -1201,10 +1178,9 @@ private RestResponse deleteVariantStudy() throws Exception { VariantStudyDeleteParams variantStudyDeleteParams = null; if (commandOptions.jsonDataModel) { - variantStudyDeleteParams = new VariantStudyDeleteParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variantStudyDeleteParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/operation/variant/study/delete")); return res; } else if (commandOptions.jsonFile != null) { variantStudyDeleteParams = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/ProjectsCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/ProjectsCommandExecutor.java index e1757e59f09..b7c06afd6f6 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/ProjectsCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/ProjectsCommandExecutor.java @@ -38,6 +38,7 @@ */ public class ProjectsCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "projects"; public ProjectsCommandOptions projectsCommandOptions; public ProjectsCommandExecutor(ProjectsCommandOptions projectsCommandOptions) throws CatalogAuthenticationException { @@ -98,10 +99,9 @@ private RestResponse create() throws Exception { ProjectCreateParams projectCreateParams = null; if (commandOptions.jsonDataModel) { - projectCreateParams = new ProjectCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(projectCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/projects/create")); return res; } else if (commandOptions.jsonFile != null) { projectCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -220,10 +220,9 @@ private RestResponse update() throws Exception { ProjectUpdateParams projectUpdateParams = null; if (commandOptions.jsonDataModel) { - projectUpdateParams = new ProjectUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(projectUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/projects/{project}/update")); return res; } else if (commandOptions.jsonFile != null) { projectUpdateParams = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/SamplesCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/SamplesCommandExecutor.java index e3bd0666741..328cc9eb556 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/SamplesCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/SamplesCommandExecutor.java @@ -51,6 +51,7 @@ */ public class SamplesCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "samples"; public SamplesCommandOptions samplesCommandOptions; public SamplesCommandExecutor(SamplesCommandOptions samplesCommandOptions) throws CatalogAuthenticationException { @@ -127,10 +128,9 @@ private RestResponse updateAcl() throws Exception { SampleAclUpdateParams sampleAclUpdateParams = null; if (commandOptions.jsonDataModel) { - sampleAclUpdateParams = new SampleAclUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(sampleAclUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/samples/acl/{members}/update")); return res; } else if (commandOptions.jsonFile != null) { sampleAclUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -195,10 +195,9 @@ private RestResponse loadAnnotationSets() throws Exception { TsvAnnotationParams tsvAnnotationParams = null; if (commandOptions.jsonDataModel) { - tsvAnnotationParams = new TsvAnnotationParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(tsvAnnotationParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/samples/annotationSets/load")); return res; } else if (commandOptions.jsonFile != null) { tsvAnnotationParams = JacksonUtils.getDefaultObjectMapper() @@ -231,10 +230,9 @@ private RestResponse create() throws Exception { SampleCreateParams sampleCreateParams = null; if (commandOptions.jsonDataModel) { - sampleCreateParams = new SampleCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(sampleCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/samples/create")); return res; } else if (commandOptions.jsonFile != null) { sampleCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -469,10 +467,9 @@ private RestResponse update() throws Exception { SampleUpdateParams sampleUpdateParams = null; if (commandOptions.jsonDataModel) { - sampleUpdateParams = new SampleUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(sampleUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/samples/{samples}/update")); return res; } else if (commandOptions.jsonFile != null) { sampleUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -529,10 +526,9 @@ private RestResponse updateAnnotationSetsAnnotations() throws Exception ObjectMap objectMap = null; if (commandOptions.jsonDataModel) { - objectMap = new ObjectMap(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(objectMap)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/samples/{sample}/annotationSets/{annotationSet}/annotations/update")); return res; } else if (commandOptions.jsonFile != null) { objectMap = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/StudiesCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/StudiesCommandExecutor.java index e183fcae20d..5289aedc3ef 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/StudiesCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/StudiesCommandExecutor.java @@ -67,6 +67,7 @@ */ public class StudiesCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "studies"; public StudiesCommandOptions studiesCommandOptions; public StudiesCommandExecutor(StudiesCommandOptions studiesCommandOptions) throws CatalogAuthenticationException { @@ -157,10 +158,9 @@ private RestResponse updateAcl() throws Exception { StudyAclUpdateParams studyAclUpdateParams = null; if (commandOptions.jsonDataModel) { - studyAclUpdateParams = new StudyAclUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(studyAclUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/studies/acl/{members}/update")); return res; } else if (commandOptions.jsonFile != null) { studyAclUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -192,10 +192,9 @@ private RestResponse create() throws Exception { StudyCreateParams studyCreateParams = null; if (commandOptions.jsonDataModel) { - studyCreateParams = new StudyCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(studyCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/studies/create")); return res; } else if (commandOptions.jsonFile != null) { studyCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -334,10 +333,9 @@ private RestResponse updateGroups() throws Exception { GroupCreateParams groupCreateParams = null; if (commandOptions.jsonDataModel) { - groupCreateParams = new GroupCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(groupCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/studies/{study}/groups/update")); return res; } else if (commandOptions.jsonFile != null) { groupCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -365,10 +363,9 @@ private RestResponse updateGroupsUsers() throws Exception { GroupUpdateParams groupUpdateParams = null; if (commandOptions.jsonDataModel) { - groupUpdateParams = new GroupUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(groupUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/studies/{study}/groups/{group}/users/update")); return res; } else if (commandOptions.jsonFile != null) { groupUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -402,10 +399,9 @@ private RestResponse updatePermissionRules() throws Exception { PermissionRule permissionRule = null; if (commandOptions.jsonDataModel) { - permissionRule = new PermissionRule(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(permissionRule)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/studies/{study}/permissionRules/update")); return res; } else if (commandOptions.jsonFile != null) { permissionRule = JacksonUtils.getDefaultObjectMapper() @@ -485,10 +481,9 @@ private RestResponse update() throws Exception { StudyUpdateParams studyUpdateParams = null; if (commandOptions.jsonDataModel) { - studyUpdateParams = new StudyUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(studyUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/studies/{study}/update")); return res; } else if (commandOptions.jsonFile != null) { studyUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -536,10 +531,9 @@ private RestResponse updateVariableSets() throws Exception { VariableSetCreateParams variableSetCreateParams = null; if (commandOptions.jsonDataModel) { - variableSetCreateParams = new VariableSetCreateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variableSetCreateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/studies/{study}/variableSets/update")); return res; } else if (commandOptions.jsonFile != null) { variableSetCreateParams = JacksonUtils.getDefaultObjectMapper() @@ -570,10 +564,9 @@ private RestResponse updateVariableSetsVariables() throws Exception Variable variable = null; if (commandOptions.jsonDataModel) { - variable = new Variable(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(variable)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/studies/{study}/variableSets/{variableSet}/variables/update")); return res; } else if (commandOptions.jsonFile != null) { variable = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/UsersCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/UsersCommandExecutor.java index 0c19edfe709..e25fb1e1f1c 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/UsersCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/executors/UsersCommandExecutor.java @@ -47,6 +47,7 @@ */ public class UsersCommandExecutor extends OpencgaCommandExecutor { + public String categoryName = "users"; public UsersCommandOptions usersCommandOptions; public UsersCommandExecutor(UsersCommandOptions usersCommandOptions) throws CatalogAuthenticationException { @@ -125,10 +126,9 @@ private RestResponse password() throws Exception { PasswordChangeParams passwordChangeParams = null; if (commandOptions.jsonDataModel) { - passwordChangeParams = new PasswordChangeParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(passwordChangeParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/users/password")); return res; } else if (commandOptions.jsonFile != null) { passwordChangeParams = JacksonUtils.getDefaultObjectMapper() @@ -181,10 +181,9 @@ private RestResponse updateConfigs() throws Exception { ConfigUpdateParams configUpdateParams = null; if (commandOptions.jsonDataModel) { - configUpdateParams = new ConfigUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(configUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/users/{user}/configs/update")); return res; } else if (commandOptions.jsonFile != null) { configUpdateParams = JacksonUtils.getDefaultObjectMapper() @@ -246,10 +245,9 @@ private RestResponse update() throws Exception { UserUpdateParams userUpdateParams = null; if (commandOptions.jsonDataModel) { - userUpdateParams = new UserUpdateParams(); RestResponse res = new RestResponse<>(); res.setType(QueryType.VOID); - PrintUtils.println(getObjectAsJSON(userUpdateParams)); + PrintUtils.println(getObjectAsJSON(categoryName,"/{apiVersion}/users/{user}/update")); return res; } else if (commandOptions.jsonFile != null) { userUpdateParams = JacksonUtils.getDefaultObjectMapper() diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/io/TextOutputWriter.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/io/TextOutputWriter.java index 1b8914bdbf0..a4e75a72794 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/io/TextOutputWriter.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/io/TextOutputWriter.java @@ -88,22 +88,14 @@ public void print(RestResponse queryResponse) { throw new RuntimeException(e); } - /* // if (queryResponse != null && queryResponse.getType().equals(QueryType.VOID)) { - if (queryResponse.getEvents() != null) { - for (Event event : ((RestResponse)queryResponse.getResponses().get(0)).getEvents()) { - if (StringUtils.isNotEmpty(event.getMessage())) { - if (event.getType().equals(Event.Type.ERROR)) { - PrintUtils.printError(event.getMessage()); - } else { - PrintUtils.printInfo(event.getMessage()); - } - } else { - PrintUtils.printError(event.getMessage()); - } + if (queryResponse != null && queryResponse.getType().equals(QueryType.VOID)) { + if (queryResponse.getResponses() != null && queryResponse.getResponses().size() > 0) { + manageEvents(((RestResponse) queryResponse.getResponses().get(0)).getEvents()); + } else if (queryResponse.getEvents() != null && queryResponse.getEvents().size() > 0) { + manageEvents(queryResponse.getEvents()); } + return; } - // return; - // } if (checkErrors(queryResponse) && queryResponse.allResultsSize() == 0) { return; } @@ -112,11 +104,9 @@ public void print(RestResponse queryResponse) { return; } - ps.print(printMetadata(queryResponse)); -*/ - List queryResultList = queryResponse.getResponses(); + List queryResultList = queryResponse.getResponses(); if (CollectionUtils.isNotEmpty(queryResultList) && ((OpenCGAResult) queryResultList.get(0)) != null && ((OpenCGAResult) queryResultList.get(0)).getNumMatches() > -1 && !isEdition(queryResultList) && isNotAnIdOrMessage(queryResultList)) { @@ -183,6 +173,20 @@ public void print(RestResponse queryResponse) { } } + private void manageEvents(final List events) { + for (Event event : events) { + if (StringUtils.isNotEmpty(event.getMessage())) { + if (event.getType().equals(Event.Type.ERROR)) { + PrintUtils.printError(event.getMessage()); + } else { + PrintUtils.printInfo(event.getMessage()); + } + } else { + PrintUtils.printError(event.getMessage()); + } + } + } + private boolean isNotAnIdOrMessage(List queryResultList) { return !(queryResultList.get(0).getResultType().equals("java.lang.String") && ((OpenCGAResult) queryResultList.get(0)).getNumMatches() == 1); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AnalysisClinicalCommandOptions.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AnalysisClinicalCommandOptions.java index 95636ad4c3f..7e6754c2ba7 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AnalysisClinicalCommandOptions.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AnalysisClinicalCommandOptions.java @@ -34,6 +34,7 @@ public class AnalysisClinicalCommandOptions { public CommonCommandOptions commonCommandOptions; public UpdateAclCommandOptions updateAclCommandOptions; + public LoadAnnotationSetsCommandOptions loadAnnotationSetsCommandOptions; public UpdateClinicalConfigurationCommandOptions updateClinicalConfigurationCommandOptions; public CreateCommandOptions createCommandOptions; public DistinctCommandOptions distinctCommandOptions; @@ -58,6 +59,7 @@ public class AnalysisClinicalCommandOptions { public AclCommandOptions aclCommandOptions; public DeleteCommandOptions deleteCommandOptions; public UpdateCommandOptions updateCommandOptions; + public UpdateAnnotationSetsAnnotationsCommandOptions updateAnnotationSetsAnnotationsCommandOptions; public InfoCommandOptions infoCommandOptions; public CreateInterpretationCommandOptions createInterpretationCommandOptions; public ClearInterpretationCommandOptions clearInterpretationCommandOptions; @@ -71,6 +73,7 @@ public AnalysisClinicalCommandOptions(CommonCommandOptions commonCommandOptions, this.jCommander = jCommander; this.commonCommandOptions = commonCommandOptions; this.updateAclCommandOptions = new UpdateAclCommandOptions(); + this.loadAnnotationSetsCommandOptions = new LoadAnnotationSetsCommandOptions(); this.updateClinicalConfigurationCommandOptions = new UpdateClinicalConfigurationCommandOptions(); this.createCommandOptions = new CreateCommandOptions(); this.distinctCommandOptions = new DistinctCommandOptions(); @@ -95,6 +98,7 @@ public AnalysisClinicalCommandOptions(CommonCommandOptions commonCommandOptions, this.aclCommandOptions = new AclCommandOptions(); this.deleteCommandOptions = new DeleteCommandOptions(); this.updateCommandOptions = new UpdateCommandOptions(); + this.updateAnnotationSetsAnnotationsCommandOptions = new UpdateAnnotationSetsAnnotationsCommandOptions(); this.infoCommandOptions = new InfoCommandOptions(); this.createInterpretationCommandOptions = new CreateInterpretationCommandOptions(); this.clearInterpretationCommandOptions = new ClearInterpretationCommandOptions(); @@ -136,6 +140,38 @@ public class UpdateAclCommandOptions { } + @Parameters(commandNames = {"annotation-sets-load"}, commandDescription ="Load annotation sets from a TSV file") + public class LoadAnnotationSetsCommandOptions { + + @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 [[user@]project:]study where study and project can be either the ID or UUID", required = false, arity = 1) + public String study; + + @Parameter(names = {"--variable-set-id"}, description = "Variable set ID or name", required = true, arity = 1) + public String variableSetId; + + @Parameter(names = {"--path"}, description = "Path where the TSV file is located in OpenCGA or where it should be located.", required = true, arity = 1) + public String path; + + @Parameter(names = {"--parents"}, description = "Flag indicating whether to create parent directories if they don't exist (only when TSV file was not previously associated).", required = false, help = true, arity = 0) + public boolean parents = false; + + @Parameter(names = {"--annotation-set-id"}, description = "Annotation set id. If not provided, variableSetId will be used.", required = false, arity = 1) + public String annotationSetId; + + @Parameter(names = {"--content"}, description = "The body web service content parameter", required = false, arity = 1) + public String content; + + } + @Parameters(commandNames = {"clinical-configuration-update"}, commandDescription ="Update Clinical Analysis configuration.") public class UpdateClinicalConfigurationCommandOptions { @@ -204,9 +240,6 @@ public class CreateCommandOptions { @Parameter(names = {"--panel-lock"}, description = "The body web service panelLock parameter", required = false, arity = 1) public Boolean panelLock; - @Parameter(names = {"--analyst-id"}, description = "The body web service id parameter", required = false, arity = 1) - public String analystId; - @Parameter(names = {"--report-title"}, description = "Report title.", required = false, arity = 1) public String reportTitle; @@ -225,6 +258,42 @@ public class CreateCommandOptions { @Parameter(names = {"--report-date"}, description = "Report date.", required = false, arity = 1) public String reportDate; + @Parameter(names = {"--request-id"}, description = "The body web service id parameter", required = false, arity = 1) + public String requestId; + + @Parameter(names = {"--request-justification"}, description = "The body web service justification parameter", required = false, arity = 1) + public String requestJustification; + + @Parameter(names = {"--request-date"}, description = "The body web service date parameter", required = false, arity = 1) + public String requestDate; + + @DynamicParameter(names = {"--request-attributes"}, description = "The body web service attributes parameter. Use: --request-attributes key=value", required = false) + public java.util.Map requestAttributes = new HashMap<>(); //Dynamic parameters must be initialized; + + @Parameter(names = {"--responsible-id"}, description = "The body web service id parameter", required = false, arity = 1) + public String responsibleId; + + @Parameter(names = {"--responsible-name"}, description = "The body web service name parameter", required = false, arity = 1) + public String responsibleName; + + @Parameter(names = {"--responsible-email"}, description = "The body web service email parameter", required = false, arity = 1) + public String responsibleEmail; + + @Parameter(names = {"--responsible-organization"}, description = "The body web service organization parameter", required = false, arity = 1) + public String responsibleOrganization; + + @Parameter(names = {"--responsible-department"}, description = "The body web service department parameter", required = false, arity = 1) + public String responsibleDepartment; + + @Parameter(names = {"--responsible-address"}, description = "The body web service address parameter", required = false, arity = 1) + public String responsibleAddress; + + @Parameter(names = {"--responsible-city"}, description = "The body web service city parameter", required = false, arity = 1) + public String responsibleCity; + + @Parameter(names = {"--responsible-postcode"}, description = "The body web service postcode parameter", required = false, arity = 1) + public String responsiblePostcode; + @Parameter(names = {"--interpretation-description"}, description = "The body web service description parameter", required = false, arity = 1) public String interpretationDescription; @@ -246,6 +315,12 @@ public class CreateCommandOptions { @Parameter(names = {"--quality-control-summary"}, description = "Enum param allowed values: HIGH, MEDIUM, LOW, DISCARD, NEEDS_REVIEW, UNKNOWN", required = false, arity = 1) public String qualityControlSummary; + @Parameter(names = {"--quality-control-comments"}, description = "The body web service comments parameter", required = false, arity = 1) + public String qualityControlComments; + + @Parameter(names = {"--quality-control-files"}, description = "The body web service files parameter", required = false, arity = 1) + public String qualityControlFiles; + @Parameter(names = {"--creation-date", "--cd"}, description = "The body web service creationDate parameter", required = false, arity = 1) public String creationDate; @@ -347,6 +422,9 @@ public class DistinctCommandOptions { @Parameter(names = {"--internal-status"}, description = "Filter by internal status", required = false, arity = 1) public String internalStatus; + @Parameter(names = {"--annotation"}, description = "Annotation filters. Example: age>30;gender=FEMALE. For more information, please visit http://docs.opencb.org/display/opencga/AnnotationSets+1.4.0", required = false, arity = 1) + public String annotation; + @Parameter(names = {"--deleted"}, description = "Boolean to retrieve deleted entries", required = false, help = true, arity = 0) public boolean deleted = false; @@ -1485,6 +1563,9 @@ public class SearchCommandOptions { @Parameter(names = {"--count"}, description = "Get the total number of results matching the query. Deactivated by default.", required = false, help = true, arity = 0) public boolean count = false; + @Parameter(names = {"--flatten-annotations"}, description = "Flatten the annotations?", required = false, help = true, arity = 0) + public boolean flattenAnnotations = false; + @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; @@ -1560,6 +1641,9 @@ public class SearchCommandOptions { @Parameter(names = {"--internal-status"}, description = "Filter by internal status", required = false, arity = 1) public String internalStatus; + @Parameter(names = {"--annotation"}, description = "Annotation filters. Example: age>30;gender=FEMALE. For more information, please visit http://docs.opencb.org/display/opencga/AnnotationSets+1.4.0", required = false, arity = 1) + public String annotation; + @Parameter(names = {"--deleted"}, description = "Boolean to retrieve deleted entries", required = false, help = true, arity = 0) public boolean deleted = false; @@ -1817,6 +1901,12 @@ public class UpdateCommandOptions { @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 = {"--analysts-action"}, description = "Action to be performed if the array of analysts is being updated.", required = false, arity = 1) + public String analystsAction = "ADD"; + + @Parameter(names = {"--annotation-sets-action"}, description = "Action to be performed if the array of annotationSets is being updated.", required = false, arity = 1) + public String annotationSetsAction = "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; @@ -1844,9 +1934,6 @@ public class UpdateCommandOptions { @Parameter(names = {"--locked"}, description = "The body web service locked parameter", required = false, arity = 1) public Boolean locked; - @Parameter(names = {"--analyst-id"}, description = "The body web service id parameter", required = false, arity = 1) - public String analystId; - @Parameter(names = {"--report-title"}, description = "Report title.", required = false, arity = 1) public String reportTitle; @@ -1865,9 +1952,51 @@ public class UpdateCommandOptions { @Parameter(names = {"--report-date"}, description = "Report date.", required = false, arity = 1) public String reportDate; + @Parameter(names = {"--request-id"}, description = "The body web service id parameter", required = false, arity = 1) + public String requestId; + + @Parameter(names = {"--request-justification"}, description = "The body web service justification parameter", required = false, arity = 1) + public String requestJustification; + + @Parameter(names = {"--request-date"}, description = "The body web service date parameter", required = false, arity = 1) + public String requestDate; + + @DynamicParameter(names = {"--request-attributes"}, description = "The body web service attributes parameter. Use: --request-attributes key=value", required = false) + public java.util.Map requestAttributes = new HashMap<>(); //Dynamic parameters must be initialized; + + @Parameter(names = {"--responsible-id"}, description = "The body web service id parameter", required = false, arity = 1) + public String responsibleId; + + @Parameter(names = {"--responsible-name"}, description = "The body web service name parameter", required = false, arity = 1) + public String responsibleName; + + @Parameter(names = {"--responsible-email"}, description = "The body web service email parameter", required = false, arity = 1) + public String responsibleEmail; + + @Parameter(names = {"--responsible-organization"}, description = "The body web service organization parameter", required = false, arity = 1) + public String responsibleOrganization; + + @Parameter(names = {"--responsible-department"}, description = "The body web service department parameter", required = false, arity = 1) + public String responsibleDepartment; + + @Parameter(names = {"--responsible-address"}, description = "The body web service address parameter", required = false, arity = 1) + public String responsibleAddress; + + @Parameter(names = {"--responsible-city"}, description = "The body web service city parameter", required = false, arity = 1) + public String responsibleCity; + + @Parameter(names = {"--responsible-postcode"}, description = "The body web service postcode parameter", required = false, arity = 1) + public String responsiblePostcode; + @Parameter(names = {"--quality-control-summary"}, description = "Enum param allowed values: HIGH, MEDIUM, LOW, DISCARD, NEEDS_REVIEW, UNKNOWN", required = false, arity = 1) public String qualityControlSummary; + @Parameter(names = {"--quality-control-comments"}, description = "The body web service comments parameter", required = false, arity = 1) + public String qualityControlComments; + + @Parameter(names = {"--quality-control-files"}, description = "The body web service files parameter", required = false, arity = 1) + public String qualityControlFiles; + @Parameter(names = {"--creation-date", "--cd"}, description = "The body web service creationDate parameter", required = false, arity = 1) public String creationDate; @@ -1888,6 +2017,32 @@ public class UpdateCommandOptions { } + @Parameters(commandNames = {"annotation-sets-annotations-update"}, commandDescription ="Update annotations from an annotationSet") + public class UpdateAnnotationSetsAnnotationsCommandOptions { + + @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 = {"--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 = {"--annotation-set"}, description = "AnnotationSet ID to be updated.", required = true, arity = 1) + public String annotationSet; + + @Parameter(names = {"--action"}, description = "Action to be performed: ADD to add new annotations; REPLACE to replace the value of an already existing annotation; SET to set the new list of annotations removing any possible old annotations; REMOVE to remove some annotations; RESET to set some annotations to the default value configured in the corresponding variables of the VariableSet if any.", required = false, arity = 1) + public String action = "ADD"; + + } + @Parameters(commandNames = {"info"}, commandDescription ="Clinical analysis info") public class InfoCommandOptions { @@ -1900,6 +2055,9 @@ public class InfoCommandOptions { @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 = {"--flatten-annotations"}, description = "Flatten the annotations?", required = false, help = true, arity = 0) + public boolean flattenAnnotations = false; + @Parameter(names = {"--clinical-analysis"}, description = "Comma separated list of clinical analysis IDs or names up to a maximum of 100", required = true, arity = 1) public String clinicalAnalysis; diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/FilesCommandOptions.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/FilesCommandOptions.java index 5ea18955f58..ea44a285bc9 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/FilesCommandOptions.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/FilesCommandOptions.java @@ -265,7 +265,7 @@ public class CreateCommandOptions { @Parameter(names = {"--type"}, description = "Enum param allowed values: FILE, VIRTUAL, DIRECTORY", required = false, arity = 1) public String type; - @Parameter(names = {"--format"}, description = "Enum param allowed values: VCF, BCF, GVCF, TBI, BIGWIG, SAM, BAM, BAI, CRAM, CRAI, FASTQ, FASTA, PED, TAB_SEPARATED_VALUES, COMMA_SEPARATED_VALUES, XML, PROTOCOL_BUFFER, JSON, AVRO, PARQUET, IMAGE, PLAIN, BINARY, NONE, UNKNOWN", required = false, arity = 1) + @Parameter(names = {"--format"}, description = "Enum param allowed values: VCF, BCF, GVCF, TBI, BIGWIG, SAM, BAM, BAI, CRAM, CRAI, FASTQ, FASTA, PED, TAB_SEPARATED_VALUES, COMMA_SEPARATED_VALUES, XML, PROTOCOL_BUFFER, JSON, AVRO, PARQUET, PDF, IMAGE, PLAIN, BINARY, NONE, UNKNOWN", required = false, arity = 1) public String format; @Parameter(names = {"--bioformat"}, description = "Enum param allowed values: MICROARRAY_EXPRESSION_ONECHANNEL_AGILENT, MICROARRAY_EXPRESSION_ONECHANNEL_AFFYMETRIX, MICROARRAY_EXPRESSION_ONECHANNEL_GENEPIX, MICROARRAY_EXPRESSION_TWOCHANNELS_AGILENT, MICROARRAY_EXPRESSION_TWOCHANNELS_GENEPIX, DATAMATRIX_EXPRESSION, IDLIST, IDLIST_RANKED, ANNOTATION_GENEVSANNOTATION, OTHER_NEWICK, OTHER_BLAST, OTHER_INTERACTION, OTHER_GENOTYPE, OTHER_PLINK, OTHER_VCF, OTHER_PED, VCF4, VARIANT, ALIGNMENT, COVERAGE, SEQUENCE, PEDIGREE, REFERENCE_GENOME, NONE, UNKNOWN", required = false, arity = 1) @@ -808,7 +808,7 @@ public class UpdateCommandOptions { @Parameter(names = {"--checksum"}, description = "The body web service checksum parameter", required = false, arity = 1) public String checksum; - @Parameter(names = {"--format"}, description = "Enum param allowed values: VCF, BCF, GVCF, TBI, BIGWIG, SAM, BAM, BAI, CRAM, CRAI, FASTQ, FASTA, PED, TAB_SEPARATED_VALUES, COMMA_SEPARATED_VALUES, XML, PROTOCOL_BUFFER, JSON, AVRO, PARQUET, IMAGE, PLAIN, BINARY, NONE, UNKNOWN", required = false, arity = 1) + @Parameter(names = {"--format"}, description = "Enum param allowed values: VCF, BCF, GVCF, TBI, BIGWIG, SAM, BAM, BAI, CRAM, CRAI, FASTQ, FASTA, PED, TAB_SEPARATED_VALUES, COMMA_SEPARATED_VALUES, XML, PROTOCOL_BUFFER, JSON, AVRO, PARQUET, PDF, IMAGE, PLAIN, BINARY, NONE, UNKNOWN", required = false, arity = 1) public String format; @Parameter(names = {"--bioformat"}, description = "Enum param allowed values: MICROARRAY_EXPRESSION_ONECHANNEL_AGILENT, MICROARRAY_EXPRESSION_ONECHANNEL_AFFYMETRIX, MICROARRAY_EXPRESSION_ONECHANNEL_GENEPIX, MICROARRAY_EXPRESSION_TWOCHANNELS_AGILENT, MICROARRAY_EXPRESSION_TWOCHANNELS_GENEPIX, DATAMATRIX_EXPRESSION, IDLIST, IDLIST_RANKED, ANNOTATION_GENEVSANNOTATION, OTHER_NEWICK, OTHER_BLAST, OTHER_INTERACTION, OTHER_GENOTYPE, OTHER_PLINK, OTHER_VCF, OTHER_PED, VCF4, VARIANT, ALIGNMENT, COVERAGE, SEQUENCE, PEDIGREE, REFERENCE_GENOME, NONE, UNKNOWN", required = false, arity = 1) diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_12_0/catalog/AddAnnotationSetsInClinicalAnalysisMigration.java b/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_12_0/catalog/AddAnnotationSetsInClinicalAnalysisMigration.java new file mode 100644 index 00000000000..0ab4fceb81a --- /dev/null +++ b/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_12_0/catalog/AddAnnotationSetsInClinicalAnalysisMigration.java @@ -0,0 +1,43 @@ +package org.opencb.opencga.app.migrations.v2_12_0.catalog; + + +import com.mongodb.client.MongoCollection; +import com.mongodb.client.model.Filters; +import com.mongodb.client.result.UpdateResult; +import org.bson.Document; +import org.bson.conversions.Bson; +import org.opencb.opencga.catalog.db.mongodb.AnnotationMongoDBAdaptor; +import org.opencb.opencga.catalog.db.mongodb.MongoDBAdaptorFactory; +import org.opencb.opencga.catalog.migration.Migration; +import org.opencb.opencga.catalog.migration.MigrationTool; + +import java.util.Arrays; +import java.util.Collections; + +@Migration(id = "add_annotation_sets_to_clinical_analysis" , + description = "Add private annotation fields to ClinicalAnalysis documents #TASK-5198", + version = "2.12.0", + domain = Migration.MigrationDomain.CATALOG, + language = Migration.MigrationLanguage.JAVA, + date = 20231116 +) +public class AddAnnotationSetsInClinicalAnalysisMigration extends MigrationTool { + + @Override + protected void run() throws Exception { + Bson query = Filters.exists(AnnotationMongoDBAdaptor.AnnotationSetParams.ANNOTATION_SETS.key(), false); + Document update = new Document("$set", new Document() + .append(AnnotationMongoDBAdaptor.AnnotationSetParams.ANNOTATION_SETS.key(), Collections.emptyList()) + .append(AnnotationMongoDBAdaptor.AnnotationSetParams.INTERNAL_ANNOTATION_SETS.key(), Collections.emptyList()) + .append(AnnotationMongoDBAdaptor.AnnotationSetParams.PRIVATE_VARIABLE_SET_MAP.key(), Collections.emptyMap()) + .append(AnnotationMongoDBAdaptor.AnnotationSetParams.PRIVATE_INTERNAL_VARIABLE_SET_MAP.key(), Collections.emptyMap()) + ); + // Initialise private fields in all Clinical Analysis documents + for (String collection : Arrays.asList(MongoDBAdaptorFactory.CLINICAL_ANALYSIS_COLLECTION, + MongoDBAdaptorFactory.DELETED_CLINICAL_ANALYSIS_COLLECTION)) { + MongoCollection mongoCollection = getMongoCollection(collection); + UpdateResult updateResult = mongoCollection.updateMany(query, update); + logger.info("{} clinical analysis documents updated from the {} collection", updateResult.getModifiedCount(), collection); + } + } +} diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_12_0/catalog/CompleteClinicalReportDataModelMigration.java b/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_12_0/catalog/CompleteClinicalReportDataModelMigration.java new file mode 100644 index 00000000000..f7e6123b223 --- /dev/null +++ b/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_12_0/catalog/CompleteClinicalReportDataModelMigration.java @@ -0,0 +1,62 @@ +package org.opencb.opencga.app.migrations.v2_12_0.catalog; + +import com.mongodb.client.model.Filters; +import com.mongodb.client.model.Projections; +import com.mongodb.client.model.UpdateOneModel; +import org.bson.Document; +import org.opencb.opencga.catalog.db.mongodb.MongoDBAdaptor; +import org.opencb.opencga.catalog.db.mongodb.MongoDBAdaptorFactory; +import org.opencb.opencga.catalog.migration.Migration; +import org.opencb.opencga.catalog.migration.MigrationTool; + +import java.util.Arrays; +import java.util.Collections; + +import static com.mongodb.client.model.Filters.eq; + +@Migration(id = "complete_clinical_report_data_model" , + description = "Complete Clinical Report data model #TASK-5198", + version = "2.12.0", + domain = Migration.MigrationDomain.CATALOG, + language = Migration.MigrationLanguage.JAVA, + date = 20231128 +) +public class CompleteClinicalReportDataModelMigration extends MigrationTool { + + @Override + protected void run() throws Exception { + migrateCollection( + Arrays.asList(MongoDBAdaptorFactory.CLINICAL_ANALYSIS_COLLECTION, MongoDBAdaptorFactory.DELETED_CLINICAL_ANALYSIS_COLLECTION), + Filters.exists("analyst"), + Projections.include(Arrays.asList("analyst", "report")), + (document, bulk) -> { + Document analyst = document.get("analyst", Document.class); + analyst.remove("assignedBy"); + analyst.remove("date"); + + Document report = document.get("report", Document.class); + if (report != null) { + report.put("comments", Collections.emptyList()); + report.put("supportingEvidences", Collections.emptyList()); + report.put("files", Collections.emptyList()); + } + + MongoDBAdaptor.UpdateDocument updateDocument = new MongoDBAdaptor.UpdateDocument(); + updateDocument.getSet().put("report", report); + updateDocument.getSet().put("request", new Document()); + updateDocument.getSet().put("responsible", new Document() + .append("id", analyst.get("id")) + .append("name", analyst.get("name")) + .append("email", analyst.get("email")) + ); + updateDocument.getSet().put("analysts", Collections.singletonList(analyst)); + updateDocument.getUnset().add("analyst"); + + bulk.add(new UpdateOneModel<>( + eq("_id", document.get("_id")), + updateDocument.toFinalUpdateDocument() + ) + ); + }); + } +} diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/api/ClinicalAnalysisDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/api/ClinicalAnalysisDBAdaptor.java index f40e073d760..a4b3d8f19b4 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/api/ClinicalAnalysisDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/api/ClinicalAnalysisDBAdaptor.java @@ -26,8 +26,10 @@ import org.opencb.opencga.catalog.exceptions.CatalogDBException; import org.opencb.opencga.catalog.exceptions.CatalogException; import org.opencb.opencga.catalog.exceptions.CatalogParameterException; +import org.opencb.opencga.catalog.utils.Constants; import org.opencb.opencga.core.api.ParamConstants; import org.opencb.opencga.core.models.clinical.ClinicalAnalysis; +import org.opencb.opencga.core.models.study.VariableSet; import org.opencb.opencga.core.response.OpenCGAResult; import java.util.List; @@ -38,7 +40,7 @@ /** * Created by pfurio on 05/06/17. */ -public interface ClinicalAnalysisDBAdaptor extends CoreDBAdaptor { +public interface ClinicalAnalysisDBAdaptor extends AnnotationSetDBAdaptor { enum QueryParams implements QueryParam { ID("id", TEXT, ""), @@ -67,10 +69,14 @@ enum QueryParams implements QueryParam { CONSENT("consent", OBJECT, ""), PRIORITY("priority", OBJECT, ""), PRIORITY_ID("priority.id", TEXT, ""), - ANALYST("analyst", TEXT_ARRAY, ""), - ANALYST_ID("analyst.id", TEXT, ""), - ANALYST_ASSIGNED_BY("analyst.assignedBy", TEXT, ""), + ANALYSTS("analysts", TEXT_ARRAY, ""), + ANALYSTS_ID("analysts.id", TEXT, ""), + ANALYSTS_ASSIGNED_BY("analysts.assignedBy", TEXT, ""), REPORT("report", OBJECT, ""), + REPORT_SUPPORTING_EVIDENCES("report.supportingEvidences", TEXT_ARRAY, ""), + REPORT_FILES("report.files", TEXT_ARRAY, ""), + REQUEST("request", OBJECT, ""), + RESPONSIBLE("responsible", OBJECT, ""), FLAGS("flags", OBJECT, ""), FLAGS_ID("flags.id", TEXT, ""), RELEASE("release", INTEGER, ""), @@ -109,7 +115,11 @@ enum QueryParams implements QueryParam { DELETED(ParamConstants.DELETED_PARAM, BOOLEAN, ""), STUDY_UID("studyUid", INTEGER_ARRAY, ""), - STUDY("study", INTEGER_ARRAY, ""); // Alias to studyId in the database. Only for the webservices. + STUDY("study", INTEGER_ARRAY, ""), // Alias to studyId in the database. Only for the webservices. + + ANNOTATION_SETS("annotationSets", TEXT_ARRAY, ""), + ANNOTATION_SET_NAME("annotationSetName", TEXT_ARRAY, ""), + ANNOTATION(Constants.ANNOTATION, TEXT_ARRAY, ""); private static Map map; @@ -154,6 +164,54 @@ public static QueryParams getParam(String key) { } } + enum ReportQueryParams implements QueryParam { + COMMENTS("comments", OBJECT, ""), + SUPPORTING_EVIDENCES("supportingEvidences", TEXT_ARRAY, ""), + FILES("files", TEXT_ARRAY, ""); + + private static Map map; + + static { + map = new LinkedMap(); + for (ReportQueryParams params : ReportQueryParams.values()) { + map.put(params.key(), params); + } + } + + private final String key; + private Type type; + private String description; + + ReportQueryParams(String key, Type type, String description) { + this.key = key; + this.type = type; + this.description = description; + } + + @Override + public String key() { + return key; + } + + @Override + public Type type() { + return type; + } + + @Override + public String description() { + return description; + } + + public static Map getMap() { + return map; + } + + public static ReportQueryParams getParam(String key) { + return map.get(key); + } + } + default boolean exists(long clinicalAnalysisId) throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { return count(new Query(QueryParams.UID.key(), clinicalAnalysisId)).getNumMatches() > 0; } @@ -170,14 +228,16 @@ default void checkId(long clinicalAnalysisId) throws CatalogDBException, Catalog OpenCGAResult nativeInsert(Map clinicalAnalysis, String userId) throws CatalogDBException; - OpenCGAResult insert(long studyId, ClinicalAnalysis clinicalAnalysis, List clinicalAuditList, QueryOptions options) + OpenCGAResult insert(long studyId, ClinicalAnalysis clinicalAnalysis, List variableSetList, + List clinicalAuditList, QueryOptions options) throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException; - OpenCGAResult update(long id, ObjectMap parameters, List clinicalAuditList, QueryOptions queryOptions) + OpenCGAResult update(long id, ObjectMap parameters, List variableSetList, + List clinicalAuditList, QueryOptions queryOptions) throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException; - OpenCGAResult update(Query query, ObjectMap parameters, List clinicalAuditList, - QueryOptions queryOptions) + OpenCGAResult update(Query query, ObjectMap parameters, List variableSetList, + List clinicalAuditList, QueryOptions queryOptions) throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException; OpenCGAResult get(long clinicalAnalysisUid, QueryOptions options) diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/AnnotationMongoDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/AnnotationMongoDBAdaptor.java index 15c7555e75e..e8cfa1d0ad1 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/AnnotationMongoDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/AnnotationMongoDBAdaptor.java @@ -262,7 +262,7 @@ public boolean containsAnnotationQuery(Query query) { return query.containsKey(Constants.ANNOTATION); } - OpenCGAResult updateAnnotationSets(ClientSession clientSession, long entryId, ObjectMap parameters, + OpenCGAResult updateAnnotationSets(ClientSession clientSession, long entryUid, ObjectMap parameters, List variableSetList, QueryOptions options, boolean isVersioned) throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { Map actionMap = options.getMap(Constants.ACTIONS, new HashMap<>()); @@ -281,7 +281,7 @@ OpenCGAResult updateAnnotationSets(ClientSession clientSess // Create or remove a new annotation set if (action == ParamUtils.BasicUpdateAction.ADD || action == ParamUtils.BasicUpdateAction.SET) { // 1. Check the annotation set ids are not in use - validateNewAnnotations(clientSession, entryId, annotationSetList, variableSetList, isVersioned); + validateNewAnnotations(clientSession, entryUid, annotationSetList, variableSetList, isVersioned); // 2. Obtain the list of documents that need to be inserted List annotationDocumentList = getNewAnnotationList(annotationSetList, variableSetList); @@ -290,26 +290,26 @@ OpenCGAResult updateAnnotationSets(ClientSession clientSess if (action == ParamUtils.BasicUpdateAction.SET) { if (CollectionUtils.isEmpty(internalAnnotationDocumentList)) { // 2.1 Remove all user existing annotations - removeAllAnnotationSets(clientSession, entryId, isVersioned); + removeAllAnnotationSets(clientSession, entryUid, isVersioned); } else { // 2.1 Remove all internal existing annotations - removeAllAnnotationSets(clientSession, entryId, isVersioned, true); + removeAllAnnotationSets(clientSession, entryUid, isVersioned, true); } } if (CollectionUtils.isEmpty(internalAnnotationDocumentList)) { // 3. Insert the list of documents - addNewAnnotations(clientSession, entryId, annotationDocumentList, isVersioned); + addNewAnnotations(clientSession, entryUid, annotationDocumentList, isVersioned); // 4. Set variable set map uid - id - addPrivateVariableMap(clientSession, entryId, getPrivateVariableMapToSet(annotationSetList, variableSetList), + addPrivateVariableMap(clientSession, entryUid, getPrivateVariableMapToSet(annotationSetList, variableSetList), isVersioned); } else { // 3. Insert the list of documents - addNewAnnotations(clientSession, entryId, internalAnnotationDocumentList, isVersioned, true); + addNewAnnotations(clientSession, entryUid, internalAnnotationDocumentList, isVersioned, true); // 4. Set variable set map uid - id - addPrivateVariableMap(clientSession, entryId, getPrivateVariableMapToSet(annotationSetList, variableSetList), + addPrivateVariableMap(clientSession, entryUid, getPrivateVariableMapToSet(annotationSetList, variableSetList), isVersioned, true); } @@ -317,7 +317,7 @@ OpenCGAResult updateAnnotationSets(ClientSession clientSess // Action = REMOVE // 0. Obtain the annotationSet to be removed to know the variableSet being annotated - OpenCGAResult queryResult = nativeGet(new Query(PRIVATE_UID, entryId), new QueryOptions(QueryOptions.INCLUDE, + OpenCGAResult queryResult = nativeGet(new Query(PRIVATE_UID, entryUid), new QueryOptions(QueryOptions.INCLUDE, Arrays.asList(ANNOTATION_SETS))); if (queryResult.getNumResults() != 1) { @@ -373,7 +373,7 @@ OpenCGAResult updateAnnotationSets(ClientSession clientSess } // 1. Remove annotationSet - removeAnnotationSetByAnnotationSetId(clientSession, entryId, annotationSet.getId(), isVersioned); + removeAnnotationSetByAnnotationSetId(clientSession, entryUid, annotationSet.getId(), isVersioned); String variableSetId = annotationSetIdVariableSetUidMap.get(annotationSet.getId()); // Remove the annotation set from the variableSetAnnotationsets @@ -384,7 +384,7 @@ OpenCGAResult updateAnnotationSets(ClientSession clientSess // 2. Unset variable set map uid - id Map variableSetMapToRemove = new HashMap<>(); variableSetMapToRemove.put(variableSetId, null); - removePrivateVariableMap(clientSession, entryId, variableSetMapToRemove, isVersioned); + removePrivateVariableMap(clientSession, entryUid, variableSetMapToRemove, isVersioned); } } else if (StringUtils.isNotEmpty(annotationSet.getVariableSetId())) { VariableSet variableSet = variableSetMap.get(annotationSet.getVariableSetId()); @@ -402,19 +402,18 @@ OpenCGAResult updateAnnotationSets(ClientSession clientSess if (!variableSet.isInternal()) { // Remove all annotationSets - removeAnnotationSetByVariableSetId(clientSession, entryId, variableSet.getUid(), isVersioned); - removePrivateVariableMap(clientSession, entryId, variableSetMapToRemove, isVersioned); + removeAnnotationSetByVariableSetId(clientSession, entryUid, variableSet.getUid(), isVersioned); + removePrivateVariableMap(clientSession, entryUid, variableSetMapToRemove, isVersioned); } else { // Remove all annotationSets - removeAnnotationSetByVariableSetId(clientSession, entryId, variableSet.getUid(), isVersioned, true); - removePrivateVariableMap(clientSession, entryId, variableSetMapToRemove, isVersioned, true); + removeAnnotationSetByVariableSetId(clientSession, entryUid, variableSet.getUid(), isVersioned, true); + removePrivateVariableMap(clientSession, entryUid, variableSetMapToRemove, isVersioned, true); } } } else { throw new CatalogDBException("Could not delete AnnotationSet. AnnotationSet 'id' or 'variableSetId' not defined."); } } - } } else if (actionMap.containsKey(ANNOTATIONS)) { // Update annotation @@ -424,10 +423,10 @@ OpenCGAResult updateAnnotationSets(ClientSession clientSess List annotationDocumentList = getNewAnnotationList(Collections.singletonList(annotationSet), variableSetList); // 2. Remove all the existing annotations of the annotation set - removeAnnotationSetByAnnotationSetId(clientSession, entryId, annotationSet.getId(), isVersioned); + removeAnnotationSetByAnnotationSetId(clientSession, entryUid, annotationSet.getId(), isVersioned); // 3. Add new list of annotations - addNewAnnotations(clientSession, entryId, annotationDocumentList, isVersioned); + addNewAnnotations(clientSession, entryUid, annotationDocumentList, isVersioned); } return endWrite(startTime, 1, 1, new ArrayList<>()); diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/AuthorizationMongoDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/AuthorizationMongoDBAdaptor.java index fff9a1ed3b3..26d65edff3f 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/AuthorizationMongoDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/AuthorizationMongoDBAdaptor.java @@ -128,7 +128,7 @@ private void initCollectionConnections() { this.dbCollectionMap.put(Enums.Resource.JOB, Collections.singletonList(dbAdaptorFactory.getCatalogJobDBAdaptor().getJobCollection())); this.dbCollectionMap.put(Enums.Resource.CLINICAL_ANALYSIS, - Collections.singletonList(dbAdaptorFactory.getClinicalAnalysisDBAdaptor().getClinicalCollection())); + Collections.singletonList(dbAdaptorFactory.getClinicalAnalysisDBAdaptor().getCollection())); // Versioned models will always have first the main collection and second the archive collection this.dbCollectionMap.put(Enums.Resource.INDIVIDUAL, Arrays.asList(dbAdaptorFactory.getCatalogIndividualDBAdaptor().getCollection(), diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/ClinicalAnalysisMongoDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/ClinicalAnalysisMongoDBAdaptor.java index 9ef226dabde..996a7eaac48 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/ClinicalAnalysisMongoDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/ClinicalAnalysisMongoDBAdaptor.java @@ -25,6 +25,7 @@ import org.apache.commons.lang3.time.StopWatch; import org.bson.Document; import org.bson.conversions.Bson; +import org.opencb.biodata.models.clinical.ClinicalAnalyst; import org.opencb.biodata.models.clinical.ClinicalAudit; import org.opencb.biodata.models.clinical.ClinicalComment; import org.opencb.commons.datastore.core.*; @@ -48,6 +49,7 @@ import org.opencb.opencga.core.common.TimeUtils; import org.opencb.opencga.core.config.Configuration; import org.opencb.opencga.core.models.clinical.*; +import org.opencb.opencga.core.models.common.AnnotationSet; import org.opencb.opencga.core.models.common.Enums; import org.opencb.opencga.core.models.common.FlagAnnotation; import org.opencb.opencga.core.models.common.InternalStatus; @@ -56,22 +58,27 @@ import org.opencb.opencga.core.models.individual.Individual; import org.opencb.opencga.core.models.panel.Panel; import org.opencb.opencga.core.models.sample.Sample; +import org.opencb.opencga.core.models.study.StudyPermissions; +import org.opencb.opencga.core.models.study.VariableSet; import org.opencb.opencga.core.response.OpenCGAResult; import org.slf4j.LoggerFactory; +import javax.annotation.Nullable; import java.io.IOException; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; +import java.util.function.UnaryOperator; import static org.opencb.opencga.catalog.db.api.ClinicalAnalysisDBAdaptor.QueryParams.*; +import static org.opencb.opencga.catalog.db.mongodb.AuthorizationMongoDBUtils.filterAnnotationSets; import static org.opencb.opencga.catalog.db.mongodb.AuthorizationMongoDBUtils.getQueryForAuthorisedEntries; import static org.opencb.opencga.catalog.db.mongodb.MongoDBUtils.*; /** * Created by pfurio on 05/06/17. */ -public class ClinicalAnalysisMongoDBAdaptor extends MongoDBAdaptor implements ClinicalAnalysisDBAdaptor { +public class ClinicalAnalysisMongoDBAdaptor extends AnnotationMongoDBAdaptor implements ClinicalAnalysisDBAdaptor { private static final String PRIVATE_DUE_DATE = "_dueDate"; private final MongoDBCollection clinicalCollection; @@ -87,6 +94,11 @@ public ClinicalAnalysisMongoDBAdaptor(MongoDBCollection clinicalCollection, Mong this.clinicalConverter = new ClinicalAnalysisConverter(); } + @Override + protected MongoDBCollection getCollection() { + return clinicalCollection; + } + static void fixCommentsForRemoval(ObjectMap parameters) { if (parameters.get(COMMENTS.key()) == null) { return; @@ -144,8 +156,41 @@ static void fixFilesForRemoval(ObjectMap parameters) { parameters.put(FILES.key(), fileParamList); } - public MongoDBCollection getClinicalCollection() { - return clinicalCollection; + static void fixAnalystsForRemoval(ObjectMap parameters) { + if (parameters.get(ANALYSTS.key()) == null) { + return; + } + + List analystParamList = new LinkedList<>(); + for (Object analyst : parameters.getAsList(ANALYSTS.key())) { + if (analyst instanceof ClinicalAnalyst) { + analystParamList.add(new Document("id", ((ClinicalAnalyst) analyst).getId())); + } + } + parameters.put(ANALYSTS.key(), analystParamList); + } + + @Override + public OpenCGAResult getAnnotationSet(long id, @Nullable String annotationSetName) + throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { + QueryOptions queryOptions = new QueryOptions(); + List includeList = new ArrayList<>(); + + if (StringUtils.isNotEmpty(annotationSetName)) { + includeList.add(Constants.ANNOTATION_SET_NAME + "." + annotationSetName); + } else { + includeList.add(QueryParams.ANNOTATION_SETS.key()); + } + queryOptions.put(QueryOptions.INCLUDE, includeList); + + OpenCGAResult clinicalDataResult = get(id, queryOptions); + if (CollectionUtils.isEmpty(clinicalDataResult.first().getAnnotationSets())) { + return new OpenCGAResult<>(clinicalDataResult.getTime(), clinicalDataResult.getEvents(), 0, Collections.emptyList(), 0); + } else { + List annotationSets = clinicalDataResult.first().getAnnotationSets(); + int size = annotationSets.size(); + return new OpenCGAResult<>(clinicalDataResult.getTime(), clinicalDataResult.getEvents(), size, annotationSets, size); + } } @Override @@ -190,7 +235,8 @@ public OpenCGAResult update(Query query, ObjectMap parameters, } @Override - public OpenCGAResult update(long uid, ObjectMap parameters, List clinicalAuditList, QueryOptions queryOptions) + public OpenCGAResult update(long uid, ObjectMap parameters, List variableSetList, List clinicalAuditList, + QueryOptions queryOptions) throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { Query query = new Query(QueryParams.UID.key(), uid); QueryOptions options = new QueryOptions() @@ -203,7 +249,8 @@ public OpenCGAResult update(long uid, ObjectMap parameters, List String clinicalAnalysisId = result.first().getId(); try { - return runTransaction(clientSession -> update(clientSession, result.first(), parameters, clinicalAuditList, queryOptions)); + return runTransaction(clientSession -> privateUpdate(clientSession, result.first(), parameters, variableSetList, + clinicalAuditList, queryOptions)); } catch (CatalogDBException e) { logger.error("Could not update clinical analysis {}: {}", clinicalAnalysisId, e.getMessage(), e); throw new CatalogDBException("Could not update clinical analysis " + clinicalAnalysisId + ": " + e.getMessage(), e.getCause()); @@ -211,26 +258,40 @@ public OpenCGAResult update(long uid, ObjectMap parameters, List } @Override - public OpenCGAResult update(Query query, ObjectMap parameters, List clinicalAuditList, QueryOptions queryOptions) - throws CatalogDBException { - return null; + public OpenCGAResult update(Query query, ObjectMap parameters, List variableSetList, List clinicalAuditList, + QueryOptions queryOptions) throws CatalogDBException { + throw new NotImplementedException("Not possible updating Clinical Analyses based on a query"); } - OpenCGAResult update(ClientSession clientSession, ClinicalAnalysis clinical, ObjectMap parameters, - List clinicalAuditList, QueryOptions queryOptions) + @Override + public OpenCGAResult update(long uid, ObjectMap parameters, List variableSetList, QueryOptions queryOptions) + throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { + throw new NotImplementedException("Use other update method passing the ClinicalAuditList"); + } + + @Override + public OpenCGAResult update(Query query, ObjectMap parameters, List variableSetList, QueryOptions queryOptions) + throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { + throw new NotImplementedException("Use other update method passing the ClinicalAuditList"); + } + + OpenCGAResult privateUpdate(ClientSession clientSession, ClinicalAnalysis clinical, ObjectMap parameters, + List variableSetList, List clinicalAuditList, QueryOptions queryOptions) throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { long tmpStartTime = startQuery(); String clinicalAnalysisId = clinical.getId(); long clinicalAnalysisUid = clinical.getUid(); + DataResult result = updateAnnotationSets(clientSession, clinicalAnalysisUid, parameters, variableSetList, queryOptions, false); + + // Perform the update Query query = new Query(QueryParams.UID.key(), clinicalAnalysisUid); UpdateDocument updateDocument = parseAndValidateUpdateParams(parameters, clinicalAuditList, query, queryOptions); Document updateOperation = updateDocument.toFinalUpdateDocument(); - List events = new ArrayList<>(); if (!updateOperation.isEmpty() || !updateDocument.getNestedUpdateList().isEmpty()) { - DataResult update; + DataResult update; if (!updateOperation.isEmpty()) { Bson bsonQuery = Filters.eq(PRIVATE_UID, clinicalAnalysisUid); @@ -270,7 +331,7 @@ OpenCGAResult update(ClientSession clientSession, ClinicalAnalysis clinical, Obj } } - } else { + } else if (result.getNumUpdated() == 0) { throw new CatalogDBException("Nothing to update"); } @@ -336,8 +397,8 @@ UpdateDocument parseAndValidateUpdateParams(ObjectMap parameters, List actionMap = queryOptions.getMap(Constants.ACTIONS, new HashMap<>()); @@ -374,8 +436,26 @@ UpdateDocument parseAndValidateUpdateParams(ObjectMap parameters, List iterator(Query query, QueryOptions options) public DBIterator iterator(ClientSession clientSession, Query query, QueryOptions options) throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { MongoDBIterator mongoCursor = getMongoCursor(clientSession, query, options, null); - return new ClinicalAnalysisCatalogMongoDBIterator<>(mongoCursor, clientSession, clinicalConverter, dbAdaptorFactory, options); + return new ClinicalAnalysisCatalogMongoDBIterator<>(mongoCursor, clientSession, clinicalConverter, null, dbAdaptorFactory, options); } @Override @@ -694,7 +774,7 @@ private DBIterator nativeIterator(ClientSession clientSession, Query q queryOptions.put(NATIVE_QUERY, true); MongoDBIterator mongoCursor = getMongoCursor(clientSession, query, queryOptions); - return new ClinicalAnalysisCatalogMongoDBIterator(mongoCursor, clientSession, null, dbAdaptorFactory, queryOptions); + return new ClinicalAnalysisCatalogMongoDBIterator(mongoCursor, clientSession, null, null, dbAdaptorFactory, queryOptions); } @Override @@ -702,7 +782,12 @@ public DBIterator iterator(long studyUid, Query query, QueryOp throws CatalogDBException, CatalogAuthorizationException, CatalogParameterException { query.put(PRIVATE_STUDY_UID, studyUid); MongoDBIterator mongoCursor = getMongoCursor(query, options, user); - return new ClinicalAnalysisCatalogMongoDBIterator(mongoCursor, null, clinicalConverter, dbAdaptorFactory, studyUid, user, options); + Document studyDocument = getStudyDocument(null, studyUid); + UnaryOperator iteratorFilter = (d) -> filterAnnotationSets(studyDocument, d, user, + StudyPermissions.Permissions.VIEW_CLINICAL_ANNOTATIONS.name(), + ClinicalAnalysisPermissions.VIEW_ANNOTATIONS.name()); + return new ClinicalAnalysisCatalogMongoDBIterator(mongoCursor, null, clinicalConverter, iteratorFilter, dbAdaptorFactory, studyUid, + user, options); } @Override @@ -710,10 +795,14 @@ public DBIterator nativeIterator(long studyUid, Query query, QueryOptions option throws CatalogDBException, CatalogAuthorizationException, CatalogParameterException { QueryOptions queryOptions = options != null ? new QueryOptions(options) : new QueryOptions(); queryOptions.put(NATIVE_QUERY, true); - query.put(PRIVATE_STUDY_UID, studyUid); MongoDBIterator mongoCursor = getMongoCursor(query, queryOptions, user); - return new ClinicalAnalysisCatalogMongoDBIterator(mongoCursor, null, null, dbAdaptorFactory, studyUid, user, options); + Document studyDocument = getStudyDocument(null, studyUid); + UnaryOperator iteratorFilter = (d) -> filterAnnotationSets(studyDocument, d, user, + StudyPermissions.Permissions.VIEW_CLINICAL_ANNOTATIONS.name(), + ClinicalAnalysisPermissions.VIEW_ANNOTATIONS.name()); + return new ClinicalAnalysisCatalogMongoDBIterator(mongoCursor, null, null, iteratorFilter, dbAdaptorFactory, studyUid, user, + options); } private MongoDBIterator getMongoCursor(ClientSession clientSession, Query query, QueryOptions options) @@ -823,14 +912,15 @@ public OpenCGAResult nativeInsert(Map clinicalAnalysis, String u } @Override - public OpenCGAResult insert(long studyId, ClinicalAnalysis clinicalAnalysis, List clinicalAuditList, - QueryOptions options) throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { + public OpenCGAResult insert(long studyId, ClinicalAnalysis clinicalAnalysis, List variableSetList, + List clinicalAuditList, QueryOptions options) + throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { try { return runTransaction(clientSession -> { long tmpStartTime = startQuery(); logger.debug("Starting ClinicalAnalysis insert transaction for ClinicalAnalysis id '{}'", clinicalAnalysis.getId()); dbAdaptorFactory.getCatalogStudyDBAdaptor().checkId(studyId); - insert(clientSession, studyId, clinicalAnalysis, clinicalAuditList); + insert(clientSession, studyId, clinicalAnalysis, variableSetList, clinicalAuditList); return endWrite(tmpStartTime, 1, 1, 0, 0, null); }); } catch (Exception e) { @@ -839,7 +929,8 @@ public OpenCGAResult insert(long studyId, ClinicalAnalysis clinicalAnalysis, Lis } } - ClinicalAnalysis insert(ClientSession clientSession, long studyId, ClinicalAnalysis clinicalAnalysis, List clinicalAudit) + ClinicalAnalysis insert(ClientSession clientSession, long studyId, ClinicalAnalysis clinicalAnalysis, List variableSetList, + List clinicalAudit) throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { if (clinicalAnalysis.getInterpretation() != null) { InterpretationMongoDBAdaptor interpretationDBAdaptor = dbAdaptorFactory.getInterpretationDBAdaptor(); @@ -865,7 +956,7 @@ ClinicalAnalysis insert(ClientSession clientSession, long studyId, ClinicalAnaly clinicalAnalysis.setUuid(UuidUtils.generateOpenCgaUuid(UuidUtils.Entity.CLINICAL)); } - Document clinicalDocument = clinicalConverter.convertToStorageType(clinicalAnalysis); + Document clinicalDocument = clinicalConverter.convertToStorageType(clinicalAnalysis, variableSetList); if (StringUtils.isNotEmpty(clinicalAnalysis.getCreationDate())) { clinicalDocument.put(PRIVATE_CREATION_DATE, TimeUtils.toDate(clinicalAnalysis.getCreationDate())); } else { @@ -1001,8 +1092,8 @@ void updateClinicalAnalysisFamilyReferences(ClientSession clientSession, Family } ObjectMap params = new ObjectMap(QueryParams.FAMILY.key(), familyCopy); - OpenCGAResult result = dbAdaptorFactory.getClinicalAnalysisDBAdaptor().update(clientSession, clinicalAnalysis, params, - null, QueryOptions.empty()); + OpenCGAResult result = dbAdaptorFactory.getClinicalAnalysisDBAdaptor().privateUpdate(clientSession, clinicalAnalysis, + params, Collections.emptyList(), null, QueryOptions.empty()); if (result.getNumUpdated() != 1) { throw new CatalogDBException("ClinicalAnalysis '" + clinicalAnalysis.getId() + "' could not be updated to the latest " + "family version of '" + family.getId() + "'"); @@ -1059,7 +1150,7 @@ void updateClinicalAnalysisPanelReferences(ClientSession clientSession, Panel pa actionMap.put(PANELS.key(), ParamUtils.BasicUpdateAction.SET); QueryOptions updateOptions = new QueryOptions(Constants.ACTIONS, actionMap); ObjectMap params = new ObjectMap(PANELS.key(), panelList); - update(clientSession, clinicalAnalysis, params, null, updateOptions); + privateUpdate(clientSession, clinicalAnalysis, params, Collections.emptyList(), null, updateOptions); // Update references from Interpretations dbAdaptorFactory.getInterpretationDBAdaptor().updateInterpretationPanelReferences(clientSession, clinicalAnalysis, panel); @@ -1082,6 +1173,7 @@ protected Bson parseQuery(Query query, Document extraQuery) private Bson parseQuery(Query query, Document extraQuery, String user) throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException { List andBsonList = new ArrayList<>(); + Document annotationDocument = null; Query queryCopy = new Query(query); queryCopy.remove(QueryParams.DELETED.key()); @@ -1094,9 +1186,13 @@ private Bson parseQuery(Query query, Document extraQuery, String user) andBsonList.addAll(AuthorizationMongoDBUtils.parseAclQuery(studyDocument, queryCopy, Enums.Resource.CLINICAL_ANALYSIS, user, configuration)); } else { - // Get the document query needed to check the permissions as well - andBsonList.add(getQueryForAuthorisedEntries(studyDocument, user, - ClinicalAnalysisPermissions.VIEW.name(), Enums.Resource.CLINICAL_ANALYSIS, configuration)); + if (containsAnnotationQuery(query)) { + andBsonList.add(getQueryForAuthorisedEntries(studyDocument, user, + ClinicalAnalysisPermissions.VIEW_ANNOTATIONS.name(), Enums.Resource.CLINICAL_ANALYSIS, configuration)); + } else { + andBsonList.add(getQueryForAuthorisedEntries(studyDocument, user, ClinicalAnalysisPermissions.VIEW.name(), + Enums.Resource.CLINICAL_ANALYSIS, configuration)); + } } queryCopy.remove(ParamConstants.ACL_PARAM); @@ -1107,6 +1203,9 @@ private Bson parseQuery(Query query, Document extraQuery, String user) QueryParams queryParam = QueryParams.getParam(entry.getKey()) != null ? QueryParams.getParam(entry.getKey()) : QueryParams.getParam(key); if (queryParam == null) { + if (Constants.PRIVATE_ANNOTATION_PARAM_TYPES.equals(entry.getKey())) { + continue; + } throw new CatalogDBException("Unexpected parameter " + entry.getKey() + ". The parameter does not exist or cannot be " + "queried for."); } @@ -1154,6 +1253,12 @@ private Bson parseQuery(Query query, Document extraQuery, String user) queryCopy.getString(queryParam.key()))); addAutoOrQuery(INTERNAL_STATUS_ID.key(), queryParam.key(), queryCopy, INTERNAL_STATUS_ID.type(), andBsonList); break; + case ANNOTATION: + if (annotationDocument == null) { + annotationDocument = createAnnotationQuery(queryCopy.getString(QueryParams.ANNOTATION.key()), + queryCopy.get(Constants.PRIVATE_ANNOTATION_PARAM_TYPES, ObjectMap.class)); + } + break; // Other parameter that can be queried. case ID: case UUID: @@ -1167,7 +1272,7 @@ private Bson parseQuery(Query query, Document extraQuery, String user) case FAMILY_MEMBERS_UID: case FAMILY_MEMBERS_SAMPLES_UID: case PANELS_UID: - case ANALYST_ID: + case ANALYSTS_ID: case PRIORITY_ID: case FLAGS_ID: case QUALITY_CONTROL_SUMMARY: @@ -1179,11 +1284,14 @@ private Bson parseQuery(Query query, Document extraQuery, String user) throw new CatalogDBException("Cannot query by parameter " + queryParam.key()); } } catch (Exception e) { - logger.error("Error with " + entry.getKey() + " " + entry.getValue()); + logger.error("Error with {}: {}", entry.getKey(), entry.getValue()); throw new CatalogDBException(e); } } + if (annotationDocument != null && !annotationDocument.isEmpty()) { + andBsonList.add(annotationDocument); + } if (extraQuery != null && !extraQuery.isEmpty()) { andBsonList.add(extraQuery); } diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/IndividualMongoDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/IndividualMongoDBAdaptor.java index 6437a0293b2..d9c6857200a 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/IndividualMongoDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/IndividualMongoDBAdaptor.java @@ -625,8 +625,8 @@ private void updateClinicalAnalysisIndividualReferences(ClientSession clientSess ObjectMap params = new ObjectMap(ClinicalAnalysisDBAdaptor.QueryParams.PROBAND.key(), individualCopy); - OpenCGAResult result = dbAdaptorFactory.getClinicalAnalysisDBAdaptor().update(clientSession, clinicalAnalysis, params, null, - QueryOptions.empty()); + OpenCGAResult result = dbAdaptorFactory.getClinicalAnalysisDBAdaptor().privateUpdate(clientSession, clinicalAnalysis, + params, Collections.emptyList(), null, QueryOptions.empty()); if (result.getNumUpdated() != 1) { throw new CatalogDBException("ClinicalAnalysis '" + clinicalAnalysis.getId() + "' could not be updated to the latest " + "individual version of '" + individual.getId() + "'"); diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/InterpretationMongoDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/InterpretationMongoDBAdaptor.java index cf2b0a64eaa..97b1d50546b 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/InterpretationMongoDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/InterpretationMongoDBAdaptor.java @@ -200,7 +200,7 @@ private void updateClinicalAnalysisReferences(ClientSession clientSession, Inter } // Update interpretation(s) in ClinicalAnalysis - clinicalDBAdaptor.update(clientSession, ca, params, clinicalAuditList, options); + clinicalDBAdaptor.privateUpdate(clientSession, ca, params, Collections.emptyList(), clinicalAuditList, options); break; case SECONDARY: // Add to secondaryInterpretations array in ClinicalAnalysis @@ -215,7 +215,7 @@ private void updateClinicalAnalysisReferences(ClientSession clientSession, Inter params.put(ClinicalAnalysisDBAdaptor.QueryParams.INTERPRETATION.key(), null); } - clinicalDBAdaptor.update(clientSession, ca, params, clinicalAuditList, options); + clinicalDBAdaptor.privateUpdate(clientSession, ca, params, Collections.emptyList(), clinicalAuditList, options); break; default: throw new IllegalStateException("Unknown action " + action); @@ -785,7 +785,8 @@ private void updateClinicalAnalysisInterpretationReference(ClientSession clientS params = new ObjectMap(ClinicalAnalysisDBAdaptor.QueryParams.SECONDARY_INTERPRETATIONS.key(), interpretationList); } - OpenCGAResult update = clinicalDBAdaptor.update(clientSession, ca, params, clinicalAuditList, options); + OpenCGAResult update = clinicalDBAdaptor.privateUpdate(clientSession, ca, params, Collections.emptyList(), clinicalAuditList, + options); if (update.getNumUpdated() != 1) { throw new CatalogDBException("Could not update interpretation reference in Clinical Analysis to new version"); } @@ -877,7 +878,8 @@ OpenCGAResult delete(ClientSession clientSession, Interpretation interpretation, actions.put(ClinicalAnalysisDBAdaptor.QueryParams.SECONDARY_INTERPRETATIONS.key(), ParamUtils.BasicUpdateAction.REMOVE); clinicalOptions.put(Constants.ACTIONS, actions); } - clinicalDBAdaptor.update(clientSession, clinicalAnalysis, clinicalParams, clinicalAuditList, clinicalOptions); + clinicalDBAdaptor.privateUpdate(clientSession, clinicalAnalysis, clinicalParams, Collections.emptyList(), clinicalAuditList, + clinicalOptions); Query query = new Query() .append(QueryParams.UID.key(), interpretation.getUid()) diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/StudyMongoDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/StudyMongoDBAdaptor.java index d2e01a601be..d1648813ee8 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/StudyMongoDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/StudyMongoDBAdaptor.java @@ -1263,6 +1263,10 @@ private void deleteAllAnnotationSetsByVariableSet(ClientSession session, long st dbAdaptorFactory.getCatalogFileDBAdaptor() .removeAllAnnotationSetsByVariableSetId(session, studyUid, variableSet, false); break; + case CLINICAL_ANALYSIS: + dbAdaptorFactory.getClinicalAnalysisDBAdaptor() + .removeAllAnnotationSetsByVariableSetId(session, studyUid, variableSet, false); + break; default: throw new CatalogDBException("Unexpected entity '" + entity + "'"); } @@ -1296,6 +1300,9 @@ private void checkVariableSetInUse(VariableSet variableSet) case FILE: result = dbAdaptorFactory.getCatalogFileDBAdaptor().get(query, options); break; + case CLINICAL_ANALYSIS: + result = dbAdaptorFactory.getClinicalAnalysisDBAdaptor().get(query, options); + break; default: throw new CatalogDBException("Unexpected entity '" + entity + "'"); } diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/converters/ClinicalAnalysisConverter.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/converters/ClinicalAnalysisConverter.java index 1244c9a7b7e..45fff9dd2f3 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/converters/ClinicalAnalysisConverter.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/converters/ClinicalAnalysisConverter.java @@ -16,31 +16,30 @@ package org.opencb.opencga.catalog.db.mongodb.converters; +import org.apache.commons.collections4.CollectionUtils; import org.bson.Document; import org.opencb.opencga.catalog.db.api.*; import org.opencb.opencga.core.models.clinical.ClinicalAnalysis; import org.opencb.opencga.core.models.file.File; import org.opencb.opencga.core.models.panel.Panel; import org.opencb.opencga.core.models.sample.Sample; +import org.opencb.opencga.core.models.study.VariableSet; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** * Created by pfurio on 05/06/17. */ -public class ClinicalAnalysisConverter extends OpenCgaMongoConverter { +public class ClinicalAnalysisConverter extends AnnotableConverter { public ClinicalAnalysisConverter() { super(ClinicalAnalysis.class); } @Override - public Document convertToStorageType(ClinicalAnalysis clinicalAnalysis) { - Document document = super.convertToStorageType(clinicalAnalysis); + public Document convertToStorageType(ClinicalAnalysis clinicalAnalysis, List variableSetList) { + Document document = super.convertToStorageType(clinicalAnalysis, variableSetList); document.put(ClinicalAnalysisDBAdaptor.QueryParams.UID.key(), clinicalAnalysis.getUid()); document.put(ClinicalAnalysisDBAdaptor.QueryParams.STUDY_UID.key(), clinicalAnalysis.getStudyUid()); @@ -56,6 +55,24 @@ public void validateDocumentToUpdate(Document document) { validateProbandToUpdate(document); validatePanelsToUpdate(document); validateFilesToUpdate(document); + validateReportToUpdate(document); + } + + public void validateReportToUpdate(Document document) { + Document report = document.get(ClinicalAnalysisDBAdaptor.QueryParams.REPORT.key(), Document.class); + if (report != null) { + List files = report.getList(ClinicalAnalysisDBAdaptor.ReportQueryParams.SUPPORTING_EVIDENCES.key(), Document.class); + if (CollectionUtils.isNotEmpty(files)) { + List filteredFiles = getReducedFileDocuments(files); + report.put(ClinicalAnalysisDBAdaptor.ReportQueryParams.SUPPORTING_EVIDENCES.key(), filteredFiles); + } + + files = report.getList(ClinicalAnalysisDBAdaptor.ReportQueryParams.FILES.key(), Document.class); + if (CollectionUtils.isNotEmpty(files)) { + List filteredFiles = getReducedFileDocuments(files); + report.put(ClinicalAnalysisDBAdaptor.ReportQueryParams.FILES.key(), filteredFiles); + } + } } public void validateInterpretationToUpdate(Document document) { @@ -141,6 +158,11 @@ public void validatePanelsToUpdate(Document document) { public void validateFilesToUpdate(Document document) { List files = (List) document.get(ClinicalAnalysisDBAdaptor.QueryParams.FILES.key()); + List reducedFiles = getReducedFileDocuments(files); + document.put(ClinicalAnalysisDBAdaptor.QueryParams.FILES.key(), reducedFiles); + } + + private static List getReducedFileDocuments(List files) { if (files != null) { // We make sure we don't store duplicates Map fileMap = new HashMap<>(); @@ -154,12 +176,13 @@ public void validateFilesToUpdate(Document document) { } } - document.put(ClinicalAnalysisDBAdaptor.QueryParams.FILES.key(), - fileMap.entrySet().stream() - .map(entry -> new Document() - .append(FileDBAdaptor.QueryParams.PATH.key(), entry.getValue().getPath()) - .append(FileDBAdaptor.QueryParams.UID.key(), entry.getValue().getUid())) - .collect(Collectors.toList())); + return fileMap.values().stream() + .map(file -> new Document() + .append(FileDBAdaptor.QueryParams.PATH.key(), file.getPath()) + .append(FileDBAdaptor.QueryParams.UID.key(), file.getUid())) + .collect(Collectors.toList()); + } else { + return Collections.emptyList(); } } diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/iterators/ClinicalAnalysisCatalogMongoDBIterator.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/iterators/ClinicalAnalysisCatalogMongoDBIterator.java index 05607ed5a68..fa4ead98ef1 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/iterators/ClinicalAnalysisCatalogMongoDBIterator.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/iterators/ClinicalAnalysisCatalogMongoDBIterator.java @@ -21,24 +21,26 @@ import org.bson.Document; import org.opencb.commons.datastore.core.Query; import org.opencb.commons.datastore.core.QueryOptions; -import org.opencb.commons.datastore.mongodb.GenericDocumentComplexConverter; import org.opencb.commons.datastore.mongodb.MongoDBIterator; import org.opencb.opencga.catalog.db.api.*; import org.opencb.opencga.catalog.db.mongodb.*; +import org.opencb.opencga.catalog.db.mongodb.converters.AnnotableConverter; import org.opencb.opencga.catalog.exceptions.CatalogAuthorizationException; import org.opencb.opencga.catalog.exceptions.CatalogDBException; import org.opencb.opencga.catalog.exceptions.CatalogParameterException; import org.opencb.opencga.core.common.JacksonUtils; +import org.opencb.opencga.core.models.common.Annotable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.*; +import java.util.function.UnaryOperator; import static org.opencb.opencga.catalog.db.api.ClinicalAnalysisDBAdaptor.QueryParams.*; import static org.opencb.opencga.catalog.db.mongodb.MongoDBAdaptor.NATIVE_QUERY; -public class ClinicalAnalysisCatalogMongoDBIterator extends CatalogMongoDBIterator { +public class ClinicalAnalysisCatalogMongoDBIterator extends AnnotableCatalogMongoDBIterator { private long studyUid; private String user; @@ -54,8 +56,6 @@ public class ClinicalAnalysisCatalogMongoDBIterator extends CatalogMongoDBIte private QueryOptions interpretationQueryOptions; private QueryOptions panelQueryOptions; - private QueryOptions options; - private Queue clinicalAnalysisListBuffer; private Logger logger; @@ -68,21 +68,20 @@ public class ClinicalAnalysisCatalogMongoDBIterator extends CatalogMongoDBIte private static final String UID_VERSION_SEP = "___"; public ClinicalAnalysisCatalogMongoDBIterator(MongoDBIterator mongoCursor, ClientSession clientSession, - GenericDocumentComplexConverter converter, MongoDBAdaptorFactory dbAdaptorFactory, - QueryOptions options) { - this(mongoCursor, clientSession, converter, dbAdaptorFactory, 0, null, options); + AnnotableConverter converter, UnaryOperator filter, + MongoDBAdaptorFactory dbAdaptorFactory, QueryOptions options) { + this(mongoCursor, clientSession, converter, filter, dbAdaptorFactory, 0, null, options); } public ClinicalAnalysisCatalogMongoDBIterator(MongoDBIterator mongoCursor, ClientSession clientSession, - GenericDocumentComplexConverter converter, MongoDBAdaptorFactory dbAdaptorFactory, - long studyUid, String user, QueryOptions options) { - super(mongoCursor, clientSession, converter, null); + AnnotableConverter converter, UnaryOperator filter, + MongoDBAdaptorFactory dbAdaptorFactory, long studyUid, String user, + QueryOptions options) { + super(mongoCursor, clientSession, converter, filter, options); this.user = user; this.studyUid = studyUid; - this.options = options; - this.fileDBAdaptor = dbAdaptorFactory.getCatalogFileDBAdaptor(); this.familyDBAdaptor = dbAdaptorFactory.getCatalogFamilyDBAdaptor(); this.individualDBAdaptor = dbAdaptorFactory.getCatalogIndividualDBAdaptor(); @@ -110,7 +109,7 @@ public E next() { addAclInformation(next, options); if (converter != null) { - return (E) converter.convertToDataModelType(next); + return (E) converter.convertToDataModelType(next, options); } else { return (E) next; } diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/ClinicalAnalysisManager.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/ClinicalAnalysisManager.java index da22c3da07b..13be28039cc 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/ClinicalAnalysisManager.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/ClinicalAnalysisManager.java @@ -19,7 +19,10 @@ import com.fasterxml.jackson.core.JsonProcessingException; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.opencb.biodata.models.clinical.*; +import org.opencb.biodata.models.clinical.ClinicalAnalyst; +import org.opencb.biodata.models.clinical.ClinicalAudit; +import org.opencb.biodata.models.clinical.ClinicalComment; +import org.opencb.biodata.models.clinical.Disorder; import org.opencb.biodata.models.common.Status; import org.opencb.commons.datastore.core.Event; import org.opencb.commons.datastore.core.ObjectMap; @@ -34,16 +37,16 @@ import org.opencb.opencga.catalog.exceptions.CatalogException; import org.opencb.opencga.catalog.exceptions.CatalogParameterException; import org.opencb.opencga.catalog.models.InternalGetDataResult; -import org.opencb.opencga.catalog.utils.Constants; -import org.opencb.opencga.catalog.utils.ParamUtils; -import org.opencb.opencga.catalog.utils.UuidUtils; +import org.opencb.opencga.catalog.utils.*; import org.opencb.opencga.core.api.ParamConstants; +import org.opencb.opencga.core.common.JacksonUtils; import org.opencb.opencga.core.common.TimeUtils; import org.opencb.opencga.core.config.Configuration; import org.opencb.opencga.core.models.AclEntryList; import org.opencb.opencga.core.models.AclParams; import org.opencb.opencga.core.models.audit.AuditRecord; import org.opencb.opencga.core.models.clinical.*; +import org.opencb.opencga.core.models.common.AnnotationSet; import org.opencb.opencga.core.models.common.Enums; import org.opencb.opencga.core.models.common.FlagAnnotation; import org.opencb.opencga.core.models.common.FlagValue; @@ -56,6 +59,7 @@ import org.opencb.opencga.core.models.sample.Sample; import org.opencb.opencga.core.models.study.Study; import org.opencb.opencga.core.models.study.StudyPermissions; +import org.opencb.opencga.core.models.study.VariableSet; import org.opencb.opencga.core.models.study.configuration.ClinicalConsent; import org.opencb.opencga.core.models.study.configuration.*; import org.opencb.opencga.core.models.user.User; @@ -64,6 +68,7 @@ import org.slf4j.LoggerFactory; import javax.annotation.Nullable; +import java.io.IOException; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -75,7 +80,7 @@ /** * Created by pfurio on 05/06/17. */ -public class ClinicalAnalysisManager extends ResourceManager { +public class ClinicalAnalysisManager extends AnnotationSetManager { public static final QueryOptions INCLUDE_CLINICAL_IDS = new QueryOptions(QueryOptions.INCLUDE, Arrays.asList( ClinicalAnalysisDBAdaptor.QueryParams.ID.key(), ClinicalAnalysisDBAdaptor.QueryParams.UID.key(), @@ -204,9 +209,10 @@ public DBIterator iterator(String studyStr, Query query, Query options = ParamUtils.defaultObject(options, QueryOptions::new); String userId = catalogManager.getUserManager().getUserId(sessionId); - Study study = catalogManager.getStudyManager().resolveId(studyStr, userId); + Study study = catalogManager.getStudyManager().resolveId(studyStr, userId, StudyManager.INCLUDE_VARIABLE_SET); fixQueryObject(study, query, userId, sessionId); + AnnotationUtils.fixQueryOptionAnnotation(options); query.append(ClinicalAnalysisDBAdaptor.QueryParams.STUDY_UID.key(), study.getUid()); return clinicalDBAdaptor.iterator(study.getUid(), query, options, userId); @@ -222,7 +228,7 @@ public OpenCGAResult create(String studyStr, ClinicalAnalysis Boolean skipCreateDefaultInterpretation, QueryOptions options, String token) throws CatalogException { String userId = catalogManager.getUserManager().getUserId(token); - Study study = catalogManager.getStudyManager().resolveId(studyStr, userId, StudyManager.INCLUDE_CONFIGURATION); + Study study = catalogManager.getStudyManager().resolveId(studyStr, userId, StudyManager.INCLUDE_VARIABLE_SET_AND_CONFIGURATION); ObjectMap auditParams = new ObjectMap() .append("study", studyStr) @@ -258,6 +264,26 @@ public OpenCGAResult create(String studyStr, ClinicalAnalysis clinicalAnalysis.setQualityControl(ParamUtils.defaultObject(clinicalAnalysis.getQualityControl(), ClinicalAnalysisQualityControl::new)); clinicalAnalysis.setPanels(ParamUtils.defaultObject(clinicalAnalysis.getPanels(), Collections.emptyList())); + clinicalAnalysis.setAnnotationSets(ParamUtils.defaultObject(clinicalAnalysis.getAnnotationSets(), Collections.emptyList())); + clinicalAnalysis.setResponsible(ParamUtils.defaultObject(clinicalAnalysis.getResponsible(), ClinicalResponsible::new)); + clinicalAnalysis.setRequest(ParamUtils.defaultObject(clinicalAnalysis.getRequest(), ClinicalRequest::new)); + + // ---------- Check and init report fields + validateAndInitReport(study, clinicalAnalysis.getReport(), userId); + + // ---------- Check and init responsible fields + ClinicalResponsible responsible = clinicalAnalysis.getResponsible(); + if (StringUtils.isEmpty(responsible.getId())) { + responsible.setId(userId); + } + fillResponsible(responsible); + + // ---------- Check and init request fields + ClinicalRequest request = clinicalAnalysis.getRequest(); + if (StringUtils.isNotEmpty(request.getId())) { + request.setDate(ParamUtils.checkDateOrGetCurrentDate(request.getDate(), "request.date")); + fillResponsible(request.getResponsible()); + } if (clinicalAnalysis.getQualityControl().getComments() != null) { for (ClinicalComment comment : clinicalAnalysis.getQualityControl().getComments()) { @@ -291,20 +317,29 @@ public OpenCGAResult create(String studyStr, ClinicalAnalysis } // Analyst + List userList; QueryOptions userInclude = new QueryOptions(QueryOptions.INCLUDE, Arrays.asList(UserDBAdaptor.QueryParams.ID.key(), UserDBAdaptor.QueryParams.NAME.key(), UserDBAdaptor.QueryParams.EMAIL.key())); - User user; - if (clinicalAnalysis.getAnalyst() == null || StringUtils.isEmpty(clinicalAnalysis.getAnalyst().getId())) { - user = userDBAdaptor.get(userId, userInclude).first(); + if (clinicalAnalysis.getAnalysts() == null) { + userList = userDBAdaptor.get(userId, userInclude).getResults(); } else { - // Validate user - OpenCGAResult result = userDBAdaptor.get(clinicalAnalysis.getAnalyst().getId(), userInclude); - if (result.getNumResults() == 0) { - throw new CatalogException("User '" + clinicalAnalysis.getAnalyst().getId() + "' not found"); + // Validate users + Set userIds = new HashSet<>(); + for (ClinicalAnalyst analyst : clinicalAnalysis.getAnalysts()) { + userIds.add(analyst.getId()); + } + Query query = new Query(UserDBAdaptor.QueryParams.ID.key(), userIds); + OpenCGAResult result = userDBAdaptor.get(query, userInclude); + if (result.getNumResults() < userIds.size()) { + throw new CatalogException("Some clinical analysts could not be found."); } - user = result.first(); + userList = result.getResults(); } - clinicalAnalysis.setAnalyst(new ClinicalAnalyst(user.getId(), user.getName(), user.getEmail(), userId, TimeUtils.getTime())); + List clinicalAnalystList = new ArrayList<>(userList.size()); + for (User user : userList) { + clinicalAnalystList.add(new ClinicalAnalyst(user.getId(), user.getName(), user.getEmail(), userId, Collections.emptyMap())); + } + clinicalAnalysis.setAnalysts(clinicalAnalystList); if (TimeUtils.toDate(clinicalAnalysis.getDueDate()) == null) { throw new CatalogException("Unrecognised due date. Accepted format is: yyyyMMddHHmmss"); @@ -501,10 +536,17 @@ public OpenCGAResult create(String studyStr, ClinicalAnalysis } } } + List files = obtainFiles(study, clinicalAnalysis, userId); if (clinicalAnalysis.getFiles() != null && !clinicalAnalysis.getFiles().isEmpty()) { - validateFiles(study, clinicalAnalysis, userId); + Set fileIds = clinicalAnalysis.getFiles().stream().map(File::getId).collect(Collectors.toSet()); + String notFoundFiles = files.stream().map(File::getId).filter(f -> !fileIds.contains(f)).collect(Collectors.joining(", ")); + if (StringUtils.isNotEmpty(notFoundFiles)) { + throw new CatalogException("Files '" + notFoundFiles + "' not found or do not belong to any participant."); + } + List filteredFiles = files.stream().filter(f -> fileIds.contains(f.getId())).collect(Collectors.toList()); + clinicalAnalysis.setFiles(filteredFiles); } else { - obtainFiles(study, clinicalAnalysis, userId); + clinicalAnalysis.setFiles(files); } clinicalAnalysis.setCreationDate(ParamUtils.checkDateOrGetCurrentDate(clinicalAnalysis.getCreationDate(), @@ -561,7 +603,8 @@ public OpenCGAResult create(String studyStr, ClinicalAnalysis clinicalAuditList.add(new ClinicalAudit(userId, ClinicalAudit.Action.CREATE_CLINICAL_ANALYSIS, "Create ClinicalAnalysis '" + clinicalAnalysis.getId() + "'", TimeUtils.getTime())); - OpenCGAResult insert = clinicalDBAdaptor.insert(study.getUid(), clinicalAnalysis, clinicalAuditList, options); + OpenCGAResult insert = clinicalDBAdaptor.insert(study.getUid(), clinicalAnalysis, study.getVariableSets(), + clinicalAuditList, options); insert.addEvents(events); auditManager.auditCreate(userId, Enums.Resource.CLINICAL_ANALYSIS, clinicalAnalysis.getId(), clinicalAnalysis.getUuid(), @@ -582,6 +625,43 @@ public OpenCGAResult create(String studyStr, ClinicalAnalysis } } + private void validateAndInitReport(Study study, ClinicalReport report, String userId) throws CatalogException { + if (report == null) { + return; + } + if (StringUtils.isNotEmpty(report.getTitle()) || StringUtils.isNotEmpty(report.getOverview())) { + report.setDate(ParamUtils.checkDateOrGetCurrentDate(report.getDate(), "report.date")); + } + if (report.getComments() != null) { + for (ClinicalComment comment : report.getComments()) { + comment.setDate(TimeUtils.getTime()); + comment.setAuthor(userId); + } + } + if (CollectionUtils.isNotEmpty(report.getFiles())) { + List files = obtainFiles(study, userId, report.getFiles()); + report.setFiles(files); + } + if (CollectionUtils.isNotEmpty(report.getSupportingEvidences())) { + List files = obtainFiles(study, userId, report.getSupportingEvidences()); + report.setSupportingEvidences(files); + } + } + + private void fillResponsible(ClinicalResponsible responsible) throws CatalogException { + if (responsible == null) { + return; + } + QueryOptions userInclude = new QueryOptions(QueryOptions.INCLUDE, Arrays.asList(UserDBAdaptor.QueryParams.ID.key(), + UserDBAdaptor.QueryParams.NAME.key(), UserDBAdaptor.QueryParams.EMAIL.key())); + OpenCGAResult result = userDBAdaptor.get(responsible.getId(), userInclude); + if (result.getNumResults() == 0) { + throw new CatalogException("Responsible user '" + responsible.getId() + "' not found."); + } + responsible.setName(ParamUtils.defaultString(responsible.getName(), result.first().getName())); + responsible.setEmail(ParamUtils.defaultString(responsible.getEmail(), result.first().getEmail())); + } + private void validateStatusParameter(ClinicalAnalysis clinicalAnalysis, ClinicalAnalysisStudyConfiguration clinicalConfiguration) throws CatalogException { // Status @@ -747,7 +827,7 @@ private void validateDisorder(ClinicalAnalysis clinicalAnalysis) throws CatalogE } } - private void obtainFiles(Study study, ClinicalAnalysis clinicalAnalysis, String userId) throws CatalogException { + private List obtainFiles(Study study, ClinicalAnalysis clinicalAnalysis, String userId) throws CatalogException { Set sampleSet = new HashSet<>(); if (clinicalAnalysis.getFamily() != null && clinicalAnalysis.getFamily().getMembers() != null) { for (Individual member : clinicalAnalysis.getFamily().getMembers()) { @@ -772,8 +852,18 @@ private void obtainFiles(Study study, ClinicalAnalysis clinicalAnalysis, String .append(FileDBAdaptor.QueryParams.SAMPLE_IDS.key(), new ArrayList<>(sampleSet)) .append(FileDBAdaptor.QueryParams.BIOFORMAT.key(), Arrays.asList(File.Bioformat.ALIGNMENT, File.Bioformat.VARIANT)); OpenCGAResult fileResults = fileDBAdaptor.get(study.getUid(), query, FileManager.INCLUDE_FILE_URI_PATH, userId); - clinicalAnalysis.setFiles(fileResults.getResults()); + return fileResults.getResults(); } + return Collections.emptyList(); + } + + private List obtainFiles(Study study, String userId, List files) throws CatalogException { + Query query = new Query(FileDBAdaptor.QueryParams.ID.key(), files.stream().map(File::getId).collect(Collectors.toSet())); + List results = fileDBAdaptor.get(study.getUid(), query, FileManager.INCLUDE_FILE_URI_PATH, userId).getResults(); + if (results.size() < files.size()) { + throw new CatalogException("Some of the files were not found"); + } + return results; } private void validateFiles(Study study, ClinicalAnalysis clinicalAnalysis, String userId) throws CatalogException { @@ -844,6 +934,103 @@ private void validateFiles(Study study, ClinicalAnalysis clinicalAnalysis, Strin // } } +// private void obtainFiles(Study study, ClinicalAnalysis clinicalAnalysis, String userId) throws CatalogException { +// Set sampleSet = new HashSet<>(); +// if (clinicalAnalysis.getFamily() != null && clinicalAnalysis.getFamily().getMembers() != null) { +// for (Individual member : clinicalAnalysis.getFamily().getMembers()) { +// if (member.getSamples() != null) { +// for (Sample sample : member.getSamples()) { +// sampleSet.add(sample.getId()); +// } +// } +// } +// } else if (clinicalAnalysis.getProband() != null && clinicalAnalysis.getProband().getSamples() != null) { +// for (Sample sample : clinicalAnalysis.getProband().getSamples()) { +// sampleSet.add(sample.getId()); +// } +// } +// +// if (clinicalAnalysis.getFiles() != null && !clinicalAnalysis.getFiles().isEmpty()) { +// throw new CatalogException("Cannot obtain map of files if this is already provided"); +// } +// +// if (!sampleSet.isEmpty()) { +// Query query = new Query() +// .append(FileDBAdaptor.QueryParams.SAMPLE_IDS.key(), new ArrayList<>(sampleSet)) +// .append(FileDBAdaptor.QueryParams.BIOFORMAT.key(), Arrays.asList(File.Bioformat.ALIGNMENT, File.Bioformat.VARIANT)); +// OpenCGAResult fileResults = fileDBAdaptor.get(study.getUid(), query, FileManager.INCLUDE_FILE_URI_PATH, userId); +// clinicalAnalysis.setFiles(fileResults.getResults()); +// } +// } + +// private void validateFiles(Study study, ClinicalAnalysis clinicalAnalysis, String userId) throws CatalogException { +// Map sampleMap = new HashMap<>(); +// if (clinicalAnalysis.getFamily() != null && clinicalAnalysis.getFamily().getMembers() != null) { +// for (Individual member : clinicalAnalysis.getFamily().getMembers()) { +// if (member.getSamples() != null) { +// for (Sample sample : member.getSamples()) { +// sampleMap.put(sample.getId(), sample.getUid()); +// } +// } +// } +// } else if (clinicalAnalysis.getProband() != null && clinicalAnalysis.getProband().getSamples() != null) { +// for (Sample sample : clinicalAnalysis.getProband().getSamples()) { +// sampleMap.put(sample.getId(), sample.getUid()); +// } +// } +// +// if (clinicalAnalysis.getFiles() == null || clinicalAnalysis.getFiles().isEmpty()) { +// throw new CatalogException("Found empty map of files"); +// } +// +// // Look for all the samples associated to the files +// Query query = new Query(FileDBAdaptor.QueryParams.ID.key(), +// clinicalAnalysis.getFiles().stream().map(File::getId).collect(Collectors.toList())); +// QueryOptions fileOptions = keepFieldInQueryOptions(FileManager.INCLUDE_FILE_URI_PATH, FileDBAdaptor.QueryParams.SAMPLE_IDS.key()); +// OpenCGAResult fileResults = fileDBAdaptor.get(study.getUid(), query, fileOptions, userId); +// +// if (fileResults.getNumResults() != clinicalAnalysis.getFiles().size()) { +// Set fileIds = clinicalAnalysis.getFiles().stream().map(File::getId).collect(Collectors.toSet()); +// String notFoundFiles = fileResults.getResults().stream().map(File::getId).filter(f -> !fileIds.contains(f)) +// .collect(Collectors.joining(", ")); +// throw new CatalogException("Files '" + notFoundFiles + "' not found"); +// } +// +// // Complete file information +// clinicalAnalysis.setFiles(fileResults.getResults()); +// +// // Validate the file ids passed are related to the samples +// for (File file : clinicalAnalysis.getFiles()) { +// if (CollectionUtils.isNotEmpty(file.getSampleIds())) { +// boolean found = false; +// for (String sampleId : file.getSampleIds()) { +// if (sampleMap.containsKey(sampleId)) { +// found = true; +// break; +// } +// } +// if (!found) { +// throw new CatalogException("Clinical analysis file (" + file.getId() + ") contains sample ids not related to any " +// + "member/proband"); +// } +// } +// } +// +//// for (File caFile : clinicalAnalysis.getFiles()) { +//// List fileIds = caFile.getFiles().stream().map(File::getId).collect(Collectors.toList()); +//// InternalGetDataResult fileResult = catalogManager.getFileManager().internalGet(study.getUid(), fileIds, new Query(), +//// new QueryOptions(), userId, false); +//// // Validate sample id belongs to files +//// for (File file : fileResult.getResults()) { +//// if (!file.getSamples().stream().map(Sample::getUid).collect(Collectors.toSet()) +//// .contains(sampleMap.get(caFile.getSampleId()))) { +//// throw new CatalogException("Associated file '" + file.getPath() + "' seems not to be related to sample '" +//// + caFile.getSampleId() + "'."); +//// } +//// } +//// } +// } + private Family getFullValidatedFamily(Family family, Study study, String sessionId) throws CatalogException { if (family == null) { return null; @@ -966,7 +1153,7 @@ public OpenCGAResult update(String studyStr, Query query, Clin public OpenCGAResult update(String studyStr, Query query, ClinicalAnalysisUpdateParams updateParams, boolean ignoreException, QueryOptions options, String token) throws CatalogException { String userId = userManager.getUserId(token); - Study study = studyManager.resolveId(studyStr, userId, StudyManager.INCLUDE_CONFIGURATION); + Study study = studyManager.resolveId(studyStr, userId, StudyManager.INCLUDE_VARIABLE_SET_AND_CONFIGURATION); String operationId = UuidUtils.generateOpenCgaUuid(UuidUtils.Entity.AUDIT); @@ -988,6 +1175,7 @@ public OpenCGAResult update(String studyStr, Query query, Clin DBIterator iterator; try { fixQueryObject(study, query, userId, token); + AnnotationUtils.fixQueryOptionAnnotation(options); query.append(ClinicalAnalysisDBAdaptor.QueryParams.STUDY_UID.key(), study.getUid()); iterator = clinicalDBAdaptor.iterator(study.getUid(), query, new QueryOptions(), userId); } catch (CatalogException e) { @@ -1026,7 +1214,7 @@ public OpenCGAResult update(String studyStr, Query query, Clin public OpenCGAResult update(String studyStr, String clinicalId, ClinicalAnalysisUpdateParams updateParams, QueryOptions options, String token) throws CatalogException { String userId = userManager.getUserId(token); - Study study = studyManager.resolveId(studyStr, userId, StudyManager.INCLUDE_CONFIGURATION); + Study study = studyManager.resolveId(studyStr, userId, StudyManager.INCLUDE_VARIABLE_SET_AND_CONFIGURATION); String operationId = UuidUtils.generateOpenCgaUuid(UuidUtils.Entity.AUDIT); @@ -1097,7 +1285,7 @@ public OpenCGAResult update(String studyStr, List clin public OpenCGAResult update(String studyStr, List clinicalIds, ClinicalAnalysisUpdateParams updateParams, boolean ignoreException, QueryOptions options, String token) throws CatalogException { String userId = userManager.getUserId(token); - Study study = studyManager.resolveId(studyStr, userId, StudyManager.INCLUDE_CONFIGURATION); + Study study = studyManager.resolveId(studyStr, userId, StudyManager.INCLUDE_VARIABLE_SET_AND_CONFIGURATION); String operationId = UuidUtils.generateOpenCgaUuid(UuidUtils.Entity.AUDIT); @@ -1157,6 +1345,39 @@ public OpenCGAResult update(String studyStr, List clin private OpenCGAResult update(Study study, ClinicalAnalysis clinicalAnalysis, ClinicalAnalysisUpdateParams updateParams, String userId, QueryOptions options) throws CatalogException { + ClinicalAnalysisUpdateParams updateParamsClone; + try { + updateParamsClone = JacksonUtils.copy(updateParams, ClinicalAnalysisUpdateParams.class); + } catch (IOException e) { + throw new CatalogException("Could not clone ClinicalAnalysisUpdateParams object"); + } + if (updateParamsClone == null) { + throw new CatalogException("Empty update parameters. Nothing to update."); + } + + validateAndInitReport(study, updateParamsClone.getReport(), userId); + + // ---------- Check and init responsible fields + ClinicalResponsible responsible = updateParamsClone.getResponsible(); + if (responsible != null && StringUtils.isNotEmpty(responsible.getId())) { + fillResponsible(responsible); + } + + // ---------- Check and init request fields + ClinicalRequest request = updateParamsClone.getRequest(); + if (request != null && StringUtils.isNotEmpty(request.getId())) { + request.setDate(ParamUtils.checkDateOrGetCurrentDate(request.getDate(), "request.date")); + fillResponsible(request.getResponsible()); + } + + ObjectMap parameters; + try { + parameters = updateParamsClone.getUpdateMap(); + } catch (JsonProcessingException e) { + throw new CatalogException("Could not parse ClinicalUpdateParams object: " + e.getMessage(), e); + } + ParamUtils.checkUpdateParametersMap(parameters); + options = ParamUtils.defaultObject(options, QueryOptions::new); if (study.getInternal() == null || study.getInternal().getConfiguration() == null || study.getInternal().getConfiguration().getClinical() == null) { @@ -1164,10 +1385,30 @@ private OpenCGAResult update(Study study, ClinicalAnalysis cli } ClinicalAnalysisStudyConfiguration clinicalConfiguration = study.getInternal().getConfiguration().getClinical(); - authorizationManager.checkClinicalAnalysisPermission(study.getUid(), clinicalAnalysis.getUid(), userId, - ClinicalAnalysisPermissions.WRITE); - List events = new LinkedList<>(); + // Check permissions... + // Only check write annotation permissions if the user wants to update the annotation sets + if (updateParamsClone.getAnnotationSets() != null) { + authorizationManager.checkClinicalAnalysisPermission(study.getUid(), clinicalAnalysis.getUid(), userId, + ClinicalAnalysisPermissions.WRITE_ANNOTATIONS); + } + // Only check update permissions if the user wants to update anything apart from the annotation sets + if ((parameters.size() == 1 && !parameters.containsKey(SampleDBAdaptor.QueryParams.ANNOTATION_SETS.key())) + || parameters.size() > 1) { + authorizationManager.checkClinicalAnalysisPermission(study.getUid(), clinicalAnalysis.getUid(), userId, + ClinicalAnalysisPermissions.WRITE); + } + + if (parameters.containsKey(ClinicalAnalysisDBAdaptor.QueryParams.ANNOTATION_SETS.key())) { + Map actionMap = options.getMap(Constants.ACTIONS, new HashMap<>()); + if (!actionMap.containsKey(AnnotationSetManager.ANNOTATION_SETS) + && !actionMap.containsKey(AnnotationSetManager.ANNOTATIONS)) { + logger.warn("Assuming the user wants to add the list of annotation sets provided"); + actionMap.put(AnnotationSetManager.ANNOTATION_SETS, ParamUtils.BasicUpdateAction.ADD); + options.put(Constants.ACTIONS, actionMap); + } + } + List events = new LinkedList<>(); if (StringUtils.isNotEmpty(clinicalAnalysis.getCreationDate())) { ParamUtils.checkDateFormat(clinicalAnalysis.getCreationDate(), ClinicalAnalysisDBAdaptor.QueryParams.CREATION_DATE.key()); } @@ -1176,29 +1417,17 @@ private OpenCGAResult update(Study study, ClinicalAnalysis cli ClinicalAnalysisDBAdaptor.QueryParams.MODIFICATION_DATE.key()); } - ObjectMap parameters; - if (updateParams != null) { - try { - parameters = updateParams.getUpdateMap(); - } catch (JsonProcessingException e) { - throw new CatalogException("Could not parse ClinicalUpdateParams object: " + e.getMessage(), e); - } - } else { - throw new CatalogException("Empty update parameters. Nothing to update."); - } - ParamUtils.checkUpdateParametersMap(parameters); - Map actionMap = options.getMap(Constants.ACTIONS); - if (updateParams.getId() != null) { - ParamUtils.checkIdentifier(updateParams.getId(), ClinicalAnalysisDBAdaptor.QueryParams.ID.key()); + if (updateParamsClone.getId() != null) { + ParamUtils.checkIdentifier(updateParamsClone.getId(), ClinicalAnalysisDBAdaptor.QueryParams.ID.key()); } - if (StringUtils.isNotEmpty(updateParams.getDueDate()) && TimeUtils.toDate(updateParams.getDueDate()) == null) { + if (StringUtils.isNotEmpty(updateParamsClone.getDueDate()) && TimeUtils.toDate(updateParamsClone.getDueDate()) == null) { throw new CatalogException("Unrecognised due date. Accepted format is: yyyyMMddHHmmss"); } - if (updateParams.getComments() != null && !updateParams.getComments().isEmpty()) { - List comments = new ArrayList<>(updateParams.getComments().size()); + if (updateParamsClone.getComments() != null && !updateParamsClone.getComments().isEmpty()) { + List comments = new ArrayList<>(updateParamsClone.getComments().size()); ParamUtils.AddRemoveReplaceAction action = ParamUtils.AddRemoveReplaceAction.from(actionMap, ClinicalAnalysisDBAdaptor.QueryParams.COMMENTS.key(), ParamUtils.AddRemoveReplaceAction.ADD); @@ -1207,7 +1436,7 @@ private OpenCGAResult update(Study study, ClinicalAnalysis cli case ADD: // Ensure each comment has a different milisecond Calendar calendar = Calendar.getInstance(); - for (ClinicalCommentParam comment : updateParams.getComments()) { + for (ClinicalCommentParam comment : updateParamsClone.getComments()) { comments.add(new ClinicalComment(userId, comment.getMessage(), comment.getTags(), TimeUtils.getTimeMillis(calendar.getTime()))); calendar.add(Calendar.MILLISECOND, 1); @@ -1215,7 +1444,7 @@ private OpenCGAResult update(Study study, ClinicalAnalysis cli break; case REMOVE: case REPLACE: - for (ClinicalCommentParam comment : updateParams.getComments()) { + for (ClinicalCommentParam comment : updateParamsClone.getComments()) { if (StringUtils.isEmpty(comment.getDate())) { throw new CatalogException("Missing mandatory 'date' field. This field is mandatory when action is '" + action + "'."); @@ -1230,26 +1459,48 @@ private OpenCGAResult update(Study study, ClinicalAnalysis cli parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.COMMENTS.key(), comments); } - if (parameters.get(InterpretationDBAdaptor.QueryParams.ANALYST.key()) != null) { - if (StringUtils.isNotEmpty(updateParams.getAnalyst().getId())) { - QueryOptions userOptions = new QueryOptions(QueryOptions.INCLUDE, Arrays.asList(UserDBAdaptor.QueryParams.ID.key(), - UserDBAdaptor.QueryParams.NAME.key(), UserDBAdaptor.QueryParams.EMAIL.key())); - // Check user exists - OpenCGAResult userResult = userDBAdaptor.get(updateParams.getAnalyst().getId(), userOptions); - if (userResult.getNumResults() == 0) { - throw new CatalogException("User '" + updateParams.getAnalyst().getId() + "' not found"); - } + if (parameters.get(ClinicalAnalysisDBAdaptor.QueryParams.ANALYSTS.key()) != null) { + ParamUtils.BasicUpdateAction action = ParamUtils.BasicUpdateAction.from(actionMap, + ClinicalAnalysisDBAdaptor.QueryParams.ANALYSTS.key(), ParamUtils.BasicUpdateAction.ADD); + List analystList = updateParamsClone.getAnalysts(); + switch (action) { + case ADD: + case SET: + QueryOptions userOptions = new QueryOptions(QueryOptions.INCLUDE, Arrays.asList(UserDBAdaptor.QueryParams.ID.key(), + UserDBAdaptor.QueryParams.NAME.key(), UserDBAdaptor.QueryParams.EMAIL.key())); - parameters.put(InterpretationDBAdaptor.QueryParams.ANALYST.key(), new ClinicalAnalyst(userResult.first().getId(), - userResult.first().getName(), userResult.first().getEmail(), userId, TimeUtils.getTime())); - } else { - // Remove assignee - parameters.put(InterpretationDBAdaptor.QueryParams.ANALYST.key(), new ClinicalAnalyst("", "", "", userId, - TimeUtils.getTime())); + Set analystIdList = new HashSet<>(); + for (ClinicalAnalystParam clinicalAnalystParam : analystList) { + analystIdList.add(clinicalAnalystParam.getId()); + } + + List clinicalAnalystList = new ArrayList<>(analystIdList.size()); + // Check analysts exist + if (!analystIdList.isEmpty()) { + Query query = new Query(UserDBAdaptor.QueryParams.ID.key(), analystIdList); + OpenCGAResult userResult = userDBAdaptor.get(query, userOptions); + if (userResult.getNumResults() < analystIdList.size()) { + throw new CatalogException("Some analysts were not found."); + } + for (User user : userResult.getResults()) { + clinicalAnalystList.add(new ClinicalAnalyst(user.getId(), user.getName(), user.getEmail(), userId, + Collections.emptyMap())); + } + } + parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.ANALYSTS.key(), clinicalAnalystList); + break; + case REMOVE: + // Directly add those analysts. No need to check + List analysts = analystList.stream().map(ClinicalAnalystParam::toClinicalAnalyst) + .collect(Collectors.toList()); + parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.ANALYSTS.key(), analysts); + break; + default: + throw new IllegalStateException("Unknown analysts action " + action); } } if (parameters.get(ClinicalAnalysisDBAdaptor.QueryParams.QUALITY_CONTROL.key()) != null) { - ClinicalAnalysisQualityControl qualityControl = updateParams.getQualityControl().toClinicalQualityControl(); + ClinicalAnalysisQualityControl qualityControl = updateParamsClone.getQualityControl().toClinicalQualityControl(); if (qualityControl.getComments() != null) { for (ClinicalComment comment : qualityControl.getComments()) { comment.setDate(TimeUtils.getTime()); @@ -1259,27 +1510,36 @@ private OpenCGAResult update(Study study, ClinicalAnalysis cli parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.QUALITY_CONTROL.key(), qualityControl); } - if (updateParams.getFiles() != null && !updateParams.getFiles().isEmpty()) { - clinicalAnalysis.setFiles(updateParams.getFiles().stream().map(FileReferenceParam::toFile).collect(Collectors.toList())); + if (updateParamsClone.getReport() != null && CollectionUtils.isNotEmpty(updateParamsClone.getReport().getFiles())) { + parameters.putNested(ClinicalAnalysisDBAdaptor.QueryParams.REPORT_FILES.key(), updateParamsClone.getReport().getFiles(), false); + } + if (updateParamsClone.getReport() != null && CollectionUtils.isNotEmpty(updateParamsClone.getReport().getSupportingEvidences())) { + parameters.putNested(ClinicalAnalysisDBAdaptor.QueryParams.REPORT_SUPPORTING_EVIDENCES.key(), + updateParamsClone.getReport().getSupportingEvidences(), false); + } + if (updateParamsClone.getFiles() != null && !updateParamsClone.getFiles().isEmpty()) { + clinicalAnalysis.setFiles(updateParamsClone.getFiles().stream().map(FileReferenceParam::toFile).collect(Collectors.toList())); // Validate files validateFiles(study, clinicalAnalysis, userId); + parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.FILES.key(), clinicalAnalysis.getFiles()); } - if (CollectionUtils.isNotEmpty(updateParams.getPanels()) && updateParams.getPanelLock() != null && updateParams.getPanelLock()) { + if (CollectionUtils.isNotEmpty(updateParamsClone.getPanels()) && updateParamsClone.getPanelLock() != null + && updateParamsClone.getPanelLock()) { throw new CatalogException("Updating the list of panels and setting 'panelLock' to true at the same time is not allowed."); } - if (CollectionUtils.isNotEmpty(updateParams.getPanels())) { - if (clinicalAnalysis.isPanelLock() && (updateParams.getPanelLock() == null || updateParams.getPanelLock())) { + if (CollectionUtils.isNotEmpty(updateParamsClone.getPanels())) { + if (clinicalAnalysis.isPanelLock() && (updateParamsClone.getPanelLock() == null || updateParamsClone.getPanelLock())) { throw new CatalogException("Cannot update panels from ClinicalAnalysis '" + clinicalAnalysis.getId() + "'. " + "'panelLocked' field from ClinicalAnalysis is set to true."); } // Validate and get panels - List panelIds = updateParams.getPanels().stream().map(PanelReferenceParam::getId).collect(Collectors.toList()); + List panelIds = updateParamsClone.getPanels().stream().map(PanelReferenceParam::getId).collect(Collectors.toList()); Query query = new Query(PanelDBAdaptor.QueryParams.ID.key(), panelIds); - OpenCGAResult panelResult = + OpenCGAResult panelResult = panelDBAdaptor.get(study.getUid(), query, PanelManager.INCLUDE_PANEL_IDS, userId); if (panelResult.getNumResults() < panelIds.size()) { throw new CatalogException("Some panels were not found or user doesn't have permissions to see them."); @@ -1288,7 +1548,7 @@ private OpenCGAResult update(Study study, ClinicalAnalysis cli parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.PANELS.key(), panelResult.getResults()); } - if (updateParams.getPanelLock() != null && updateParams.getPanelLock() && !clinicalAnalysis.isPanelLock()) { + if (updateParamsClone.getPanelLock() != null && updateParamsClone.getPanelLock() && !clinicalAnalysis.isPanelLock()) { // if user wants to set panelLock to true // We need to check if the CA has interpretations. If so, the interpretations should contain at least one of the case panels // in order to set panelLock to true. Otherwise, that action is not allowed. @@ -1323,17 +1583,13 @@ private OpenCGAResult update(Study study, ClinicalAnalysis cli } } - if (updateParams.getFiles() != null && !updateParams.getFiles().isEmpty()) { - parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.FILES.key(), clinicalAnalysis.getFiles()); - } - - if (CollectionUtils.isNotEmpty(updateParams.getPanels())) { + if (CollectionUtils.isNotEmpty(updateParamsClone.getPanels())) { // Get panels Query query = new Query(PanelDBAdaptor.QueryParams.ID.key(), - updateParams.getPanels().stream().map(PanelReferenceParam::getId).collect(Collectors.toList())); - OpenCGAResult panelResult = + updateParamsClone.getPanels().stream().map(PanelReferenceParam::getId).collect(Collectors.toList())); + OpenCGAResult panelResult = panelDBAdaptor.get(study.getUid(), query, PanelManager.INCLUDE_PANEL_IDS, userId); - if (panelResult.getNumResults() < updateParams.getPanels().size()) { + if (panelResult.getNumResults() < updateParamsClone.getPanels().size()) { throw new CatalogException("Some panels were not found or user doesn't have permissions to see them"); } @@ -1342,7 +1598,7 @@ private OpenCGAResult update(Study study, ClinicalAnalysis cli if (parameters.containsKey(ClinicalAnalysisDBAdaptor.QueryParams.DISORDER.key())) { // Assign the disorder to be updated to the clinicalAnalysis obtained from the DB so it can be checked in context - clinicalAnalysis.setDisorder(updateParams.getDisorder().toDisorder()); + clinicalAnalysis.setDisorder(updateParamsClone.getDisorder().toDisorder()); validateDisorder(clinicalAnalysis); // Fill parameter to be updated with complete disorder information parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.DISORDER.key(), clinicalAnalysis.getDisorder()); @@ -1358,7 +1614,7 @@ private OpenCGAResult update(Study study, ClinicalAnalysis cli // Validate user-defined parameters if (parameters.containsKey(ClinicalAnalysisDBAdaptor.QueryParams.PRIORITY.key())) { - clinicalAnalysis.setPriority(updateParams.getPriority().toClinicalPriorityAnnotation()); + clinicalAnalysis.setPriority(updateParamsClone.getPriority().toClinicalPriorityAnnotation()); validateCustomPriorityParameters(clinicalAnalysis, clinicalConfiguration); parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.PRIORITY.key(), clinicalAnalysis.getPriority()); } @@ -1368,7 +1624,8 @@ private OpenCGAResult update(Study study, ClinicalAnalysis cli currentFlags = clinicalAnalysis.getFlags().stream().map(FlagAnnotation::getId).collect(Collectors.toSet()); } - clinicalAnalysis.setFlags(updateParams.getFlags().stream().map(FlagValueParam::toFlagAnnotation).collect(Collectors.toList())); + clinicalAnalysis.setFlags(updateParamsClone.getFlags().stream().map(FlagValueParam::toFlagAnnotation) + .collect(Collectors.toList())); validateCustomFlagParameters(clinicalAnalysis, clinicalConfiguration); ParamUtils.BasicUpdateAction action = ParamUtils.BasicUpdateAction.from(actionMap, @@ -1389,22 +1646,22 @@ private OpenCGAResult update(Study study, ClinicalAnalysis cli parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.FLAGS.key(), clinicalAnalysis.getFlags()); } if (parameters.containsKey(ClinicalAnalysisDBAdaptor.QueryParams.CONSENT.key())) { - clinicalAnalysis.setConsent(updateParams.getConsent().toClinicalConsentAnnotation()); + clinicalAnalysis.setConsent(updateParamsClone.getConsent().toClinicalConsentAnnotation()); validateCustomConsentParameters(clinicalAnalysis, clinicalConfiguration); parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.CONSENT.key(), clinicalAnalysis.getConsent()); } if (parameters.containsKey(ClinicalAnalysisDBAdaptor.QueryParams.STATUS.key())) { - clinicalAnalysis.setStatus(updateParams.getStatus().toStatus()); + clinicalAnalysis.setStatus(updateParamsClone.getStatus().toStatus()); validateStatusParameter(clinicalAnalysis, clinicalConfiguration); parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.STATUS.key(), clinicalAnalysis.getStatus()); - if (StringUtils.isNotEmpty(updateParams.getStatus().getId())) { + if (StringUtils.isNotEmpty(updateParamsClone.getStatus().getId())) { List clinicalStatusValues = clinicalConfiguration.getStatus().get(clinicalAnalysis.getType()); for (ClinicalStatusValue clinicalStatusValue : clinicalStatusValues) { - if (updateParams.getStatus().getId().equals(clinicalStatusValue.getId())) { + if (updateParamsClone.getStatus().getId().equals(clinicalStatusValue.getId())) { if (clinicalStatusValue.getType() == ClinicalStatusValue.ClinicalStatusType.CLOSED) { String msg = "User '" + userId + "' changed case '" + clinicalAnalysis.getId() + "' to status '" - + updateParams.getStatus().getId() + "', which is of type CLOSED. Automatically locking " + + updateParamsClone.getStatus().getId() + "', which is of type CLOSED. Automatically locking " + "ClinicalAnalysis"; logger.info(msg); parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.LOCKED.key(), true); @@ -1415,9 +1672,11 @@ private OpenCGAResult update(Study study, ClinicalAnalysis cli } } + checkUpdateAnnotations(study, clinicalAnalysis, parameters, options, VariableSet.AnnotableDataModels.CLINICAL_ANALYSIS, + clinicalDBAdaptor, userId); ClinicalAudit clinicalAudit = new ClinicalAudit(userId, ClinicalAudit.Action.UPDATE_CLINICAL_ANALYSIS, "Update ClinicalAnalysis '" + clinicalAnalysis.getId() + "'", TimeUtils.getTime()); - OpenCGAResult update = clinicalDBAdaptor.update(clinicalAnalysis.getUid(), parameters, + OpenCGAResult update = clinicalDBAdaptor.update(clinicalAnalysis.getUid(), parameters, study.getVariableSets(), Collections.singletonList(clinicalAudit), options); update.addEvents(events); if (options.getBoolean(ParamConstants.INCLUDE_RESULT_PARAM)) { @@ -1494,9 +1753,11 @@ public OpenCGAResult search(String studyId, Query query, Query options = ParamUtils.defaultObject(options, QueryOptions::new); String userId = catalogManager.getUserManager().getUserId(token); - Study study = catalogManager.getStudyManager().resolveId(studyId, userId); + Study study = catalogManager.getStudyManager().resolveId(studyId, userId, StudyManager.INCLUDE_VARIABLE_SET); fixQueryObject(study, query, userId, token); + AnnotationUtils.fixQueryOptionAnnotation(options); + query.append(ClinicalAnalysisDBAdaptor.QueryParams.STUDY_UID.key(), study.getUid()); return clinicalDBAdaptor.get(study.getUid(), query, options, userId); @@ -1507,7 +1768,7 @@ public OpenCGAResult distinct(String studyId, List fields, Query quer query = ParamUtils.defaultObject(query, Query::new); String userId = userManager.getUserId(token); - Study study = catalogManager.getStudyManager().resolveId(studyId, userId); + Study study = catalogManager.getStudyManager().resolveId(studyId, userId, StudyManager.INCLUDE_VARIABLE_SET); ObjectMap auditParams = new ObjectMap() .append("studyId", studyId) @@ -1532,8 +1793,11 @@ public OpenCGAResult distinct(String studyId, List fields, Query quer } protected void fixQueryObject(Study study, Query query, String user, String token) throws CatalogException { + // Fix query if it contains any annotation + AnnotationUtils.fixQueryAnnotationSearch(study, query); + changeQueryId(query, ParamConstants.CLINICAL_DISORDER_PARAM, ClinicalAnalysisDBAdaptor.QueryParams.DISORDER.key()); - changeQueryId(query, ParamConstants.CLINICAL_ANALYST_ID_PARAM, ClinicalAnalysisDBAdaptor.QueryParams.ANALYST_ID.key()); + changeQueryId(query, ParamConstants.CLINICAL_ANALYST_ID_PARAM, ClinicalAnalysisDBAdaptor.QueryParams.ANALYSTS_ID.key()); changeQueryId(query, ParamConstants.CLINICAL_PRIORITY_PARAM, ClinicalAnalysisDBAdaptor.QueryParams.PRIORITY_ID.key()); changeQueryId(query, ParamConstants.CLINICAL_FLAGS_PARAM, ClinicalAnalysisDBAdaptor.QueryParams.FLAGS_ID.key()); changeQueryId(query, ParamConstants.CLINICAL_QUALITY_CONTROL_SUMMARY_PARAM, @@ -1689,7 +1953,7 @@ protected void fixQueryObject(Study study, Query query, String user, String toke public OpenCGAResult count(String studyId, Query query, String token) throws CatalogException { String userId = catalogManager.getUserManager().getUserId(token); - Study study = catalogManager.getStudyManager().resolveId(studyId, userId); + Study study = catalogManager.getStudyManager().resolveId(studyId, userId, StudyManager.INCLUDE_VARIABLE_SET); ObjectMap auditParams = new ObjectMap() .append("studyId", studyId) @@ -1837,7 +2101,7 @@ public OpenCGAResult delete(String studyStr, Query query, QueryOptions options, OpenCGAResult result = OpenCGAResult.empty(); String userId = catalogManager.getUserManager().getUserId(token); - Study study = catalogManager.getStudyManager().resolveId(studyStr, userId); + Study study = catalogManager.getStudyManager().resolveId(studyStr, userId, StudyManager.INCLUDE_VARIABLE_SET); String operationUuid = UuidUtils.generateOpenCgaUuid(UuidUtils.Entity.AUDIT); @@ -1855,6 +2119,7 @@ public OpenCGAResult delete(String studyStr, Query query, QueryOptions options, DBIterator iterator; try { fixQueryObject(study, finalQuery, userId, token); + AnnotationUtils.fixQueryOptionAnnotation(options); finalQuery.append(ClinicalAnalysisDBAdaptor.QueryParams.STUDY_UID.key(), study.getUid()); iterator = clinicalDBAdaptor.iterator(study.getUid(), finalQuery, INCLUDE_CLINICAL_INTERPRETATION_IDS, userId); @@ -1922,9 +2187,10 @@ public OpenCGAResult groupBy(@Nullable String studyStr, Query query, List updateAnnotations(String studyStr, String clinicalStr, String annotationSetId, + Map annotations, ParamUtils.CompleteUpdateAction action, + QueryOptions options, String token) throws CatalogException { + if (annotations == null || annotations.isEmpty()) { + throw new CatalogException("Missing array of annotations."); + } + ClinicalAnalysisUpdateParams clinicalUpdateParams = new ClinicalAnalysisUpdateParams() + .setAnnotationSets(Collections.singletonList(new AnnotationSet(annotationSetId, null, annotations))); + options = ParamUtils.defaultObject(options, QueryOptions::new); + options.put(Constants.ACTIONS, new ObjectMap(AnnotationSetManager.ANNOTATIONS, action)); + + return update(studyStr, clinicalStr, clinicalUpdateParams, options, token); + } + // ************************** ACLs ******************************** // public OpenCGAResult> getAcls( String studyStr, List clinicalList, String member, boolean ignoreException, String token) throws CatalogException { diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/FileManager.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/FileManager.java index d3e4c12503a..d7cbd3cc475 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/FileManager.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/FileManager.java @@ -3712,16 +3712,23 @@ OpenCGAResult registerFile(Study study, String filePath, URI fileUri, Stri File.Type type = filePath.endsWith("/") ? File.Type.DIRECTORY : File.Type.FILE; - File subfile = new File(Paths.get(filePath).getFileName().toString(), type, File.Format.UNKNOWN, - File.Bioformat.NONE, fileUri, filePath, "", TimeUtils.getTime(), TimeUtils.getTime(), - "", isExternal(study, filePath, fileUri), size, new Software(), new FileExperiment(), Collections.emptyList(), - Collections.emptyList(), jobId, studyManager.getCurrentRelease(study), Collections.emptyList(), Collections.emptyList(), - new FileQualityControl(), Collections.emptyMap(), new Status(), FileInternal.init(), Collections.emptyMap()); + File.Format format = org.opencb.opencga.catalog.managers.FileUtils.detectFormat(fileUri); + File.Bioformat bioformat = org.opencb.opencga.catalog.managers.FileUtils.detectBioformat(fileUri); + File subfile = new File(Paths.get(filePath).getFileName().toString(), type, format, bioformat, fileUri, filePath, "", + TimeUtils.getTime(), TimeUtils.getTime(), "", isExternal(study, filePath, fileUri), size, new Software(), + new FileExperiment(), Collections.emptyList(), Collections.emptyList(), jobId, studyManager.getCurrentRelease(study), + Collections.emptyList(), Collections.emptyList(), new FileQualityControl(), Collections.emptyMap(), new Status(), + FileInternal.init(), Collections.emptyMap()); subfile.setUuid(UuidUtils.generateOpenCgaUuid(UuidUtils.Entity.FILE)); checkHooks(subfile, study.getFqn(), HookConfiguration.Stage.CREATE); // Improve metadata information and extract samples if any - new FileMetadataReader(catalogManager).addMetadataInformation(study.getFqn(), subfile); + try { + new FileMetadataReader(catalogManager).addMetadataInformation(study.getFqn(), subfile); + } catch (CatalogException e) { + subfile.getInternal().setStatus(new FileStatus(FileStatus.ERROR, "Could not extract metadata information: " + e.getMessage())); + logger.warn("Could not extract metadata information from file {}: {}", fileUri, e.getMessage(), e); + } List existingSamples = new LinkedList<>(); List nonExistingSamples = new LinkedList<>(); validateNewSamples(study, subfile, existingSamples, nonExistingSamples, token); diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/FileUtils.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/FileUtils.java index 46423ef9a2f..02f5cae855b 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/FileUtils.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/FileUtils.java @@ -261,6 +261,7 @@ public static File.Bioformat detectBioformat(URI uri, File.Format format, File.C case BINARY: case UNKNOWN: case XML: + case PDF: return File.Bioformat.NONE; default: break; @@ -398,6 +399,8 @@ public static File.Format detectFormat(URI uri) { case "jpeg": case "tif": return File.Format.IMAGE; + case "pdf": + return File.Format.PDF; default: break; } diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/InterpretationManager.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/InterpretationManager.java index 4294998ca19..0ab582184d0 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/InterpretationManager.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/InterpretationManager.java @@ -388,7 +388,7 @@ void validateNewInterpretation(Study study, Interpretation interpretation, Clini } user = result.first(); } - interpretation.setAnalyst(new ClinicalAnalyst(user.getId(), user.getName(), user.getEmail(), userId, TimeUtils.getTime())); + interpretation.setAnalyst(new ClinicalAnalyst(user.getId(), user.getName(), user.getEmail(), userId, Collections.emptyMap())); } public OpenCGAResult clear(String studyStr, String clinicalAnalysisId, List interpretationList, String token) @@ -984,11 +984,11 @@ private OpenCGAResult update(Study study, Interpretation interpretation, Interpr throw new CatalogException("User '" + updateParams.getAnalyst().getId() + "' not found"); } parameters.put(InterpretationDBAdaptor.QueryParams.ANALYST.key(), new ClinicalAnalyst(userResult.first().getId(), - userResult.first().getName(), userResult.first().getEmail(), userId, TimeUtils.getTime())); + userResult.first().getName(), userResult.first().getEmail(), userId, Collections.emptyMap())); } else { // Remove assignee parameters.put(InterpretationDBAdaptor.QueryParams.ANALYST.key(), new ClinicalAnalyst("", "", "", userId, - TimeUtils.getTime())); + Collections.emptyMap())); } } diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/StudyManager.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/StudyManager.java index e9e48ab01f4..184bbe18b67 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/StudyManager.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/StudyManager.java @@ -110,9 +110,12 @@ public class StudyManager extends AbstractManager { public static final QueryOptions INCLUDE_STUDY_IDS = new QueryOptions(QueryOptions.INCLUDE, Arrays.asList( StudyDBAdaptor.QueryParams.UID.key(), StudyDBAdaptor.QueryParams.ID.key(), StudyDBAdaptor.QueryParams.UUID.key(), StudyDBAdaptor.QueryParams.FQN.key())); - static final QueryOptions INCLUDE_VARIABLE_SET = new QueryOptions(QueryOptions.INCLUDE, StudyDBAdaptor.QueryParams.VARIABLE_SET.key()); - static final QueryOptions INCLUDE_CONFIGURATION = - new QueryOptions(QueryOptions.INCLUDE, StudyDBAdaptor.QueryParams.INTERNAL_CONFIGURATION.key()); + static final QueryOptions INCLUDE_VARIABLE_SET = keepFieldInQueryOptions(INCLUDE_STUDY_IDS, + StudyDBAdaptor.QueryParams.VARIABLE_SET.key()); + static final QueryOptions INCLUDE_CONFIGURATION = keepFieldInQueryOptions(INCLUDE_STUDY_IDS, + StudyDBAdaptor.QueryParams.INTERNAL_CONFIGURATION.key()); + static final QueryOptions INCLUDE_VARIABLE_SET_AND_CONFIGURATION = keepFieldsInQueryOptions(INCLUDE_STUDY_IDS, + Arrays.asList(StudyDBAdaptor.QueryParams.INTERNAL_CONFIGURATION.key(), StudyDBAdaptor.QueryParams.VARIABLE_SET.key())); protected Logger logger; diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/FileMetadataReader.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/FileMetadataReader.java index 12cdbf83801..8a51691706f 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/FileMetadataReader.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/FileMetadataReader.java @@ -181,7 +181,7 @@ private FileUpdateParams extractMetadataInformation(String studyId, File file) t VariantFileMetadata fileMetadata; try { fileMetadata = readVariantFileMetadata(file, file.getUri()); - } catch (IOException e) { + } catch (Exception e) { throw new CatalogIOException("Unable to read VariantSource", e); } if (fileMetadata != null) { diff --git a/opencga-catalog/src/test/java/org/opencb/opencga/catalog/managers/AbstractManagerTest.java b/opencga-catalog/src/test/java/org/opencb/opencga/catalog/managers/AbstractManagerTest.java index d29de6b553a..fbce0a4576f 100644 --- a/opencga-catalog/src/test/java/org/opencb/opencga/catalog/managers/AbstractManagerTest.java +++ b/opencga-catalog/src/test/java/org/opencb/opencga/catalog/managers/AbstractManagerTest.java @@ -49,7 +49,7 @@ import java.util.List; @Category(MediumTests.class) -public class AbstractManagerTest extends GenericTest { +public class AbstractManagerTest extends GenericTest { @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/opencga-catalog/src/test/java/org/opencb/opencga/catalog/managers/ClinicalAnalysisManagerTest.java b/opencga-catalog/src/test/java/org/opencb/opencga/catalog/managers/ClinicalAnalysisManagerTest.java index d703b598e44..e07d53338b9 100644 --- a/opencga-catalog/src/test/java/org/opencb/opencga/catalog/managers/ClinicalAnalysisManagerTest.java +++ b/opencga-catalog/src/test/java/org/opencb/opencga/catalog/managers/ClinicalAnalysisManagerTest.java @@ -24,10 +24,7 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.ExpectedException; -import org.opencb.biodata.models.clinical.ClinicalAudit; -import org.opencb.biodata.models.clinical.ClinicalComment; -import org.opencb.biodata.models.clinical.ClinicalDiscussion; -import org.opencb.biodata.models.clinical.Disorder; +import org.opencb.biodata.models.clinical.*; import org.opencb.biodata.models.clinical.interpretation.ClinicalVariant; import org.opencb.biodata.models.clinical.interpretation.ClinicalVariantEvidence; import org.opencb.biodata.models.clinical.interpretation.InterpretationMethod; @@ -52,16 +49,14 @@ import org.opencb.opencga.core.models.AclEntryList; import org.opencb.opencga.core.models.AclParams; import org.opencb.opencga.core.models.clinical.*; +import org.opencb.opencga.core.models.common.AnnotationSet; import org.opencb.opencga.core.models.common.FlagAnnotation; import org.opencb.opencga.core.models.common.FlagValue; import org.opencb.opencga.core.models.common.StatusParam; import org.opencb.opencga.core.models.family.Family; import org.opencb.opencga.core.models.family.FamilyPermissions; import org.opencb.opencga.core.models.family.FamilyUpdateParams; -import org.opencb.opencga.core.models.file.File; -import org.opencb.opencga.core.models.file.FileLinkParams; -import org.opencb.opencga.core.models.file.FileReferenceParam; -import org.opencb.opencga.core.models.file.FileUpdateParams; +import org.opencb.opencga.core.models.file.*; import org.opencb.opencga.core.models.individual.Individual; import org.opencb.opencga.core.models.individual.IndividualPermissions; import org.opencb.opencga.core.models.panel.Panel; @@ -70,9 +65,12 @@ import org.opencb.opencga.core.models.sample.SamplePermissions; import org.opencb.opencga.core.models.sample.SampleUpdateParams; import org.opencb.opencga.core.models.study.Study; +import org.opencb.opencga.core.models.study.Variable; +import org.opencb.opencga.core.models.study.VariableSet; import org.opencb.opencga.core.models.study.configuration.ClinicalConsent; import org.opencb.opencga.core.models.study.configuration.*; import org.opencb.opencga.core.models.user.Account; +import org.opencb.opencga.core.models.user.User; import org.opencb.opencga.core.response.OpenCGAResult; import org.opencb.opencga.core.testclassification.duration.MediumTests; @@ -289,6 +287,196 @@ public void createMultipleCasesSameFamily() throws CatalogException { } } + @Test + public void updateClinicalAnalystsTest() throws CatalogException { + ClinicalAnalysis case1 = createDummyEnvironment(true, true).first(); + + catalogManager.getUserManager().create(new User().setId("u1").setName("u1").setAccount(new Account()), TestParamConstants.PASSWORD, opencgaToken); + catalogManager.getUserManager().create(new User().setId("u2").setName("u2").setAccount(new Account()), TestParamConstants.PASSWORD, opencgaToken); + + // Add analysts + OpenCGAResult result = catalogManager.getClinicalAnalysisManager().update(STUDY, case1.getId(), + new ClinicalAnalysisUpdateParams().setAnalysts( + Arrays.asList(new ClinicalAnalystParam("u1"), new ClinicalAnalystParam("u2"))), INCLUDE_RESULT, sessionIdUser); + assertEquals(3, result.first().getAnalysts().size()); + assertTrue(result.first().getAnalysts().stream().map(ClinicalAnalyst::getId).collect(Collectors.toSet()).containsAll(Arrays.asList("u1", "u2"))); + + // Check analyst params + for (ClinicalAnalyst analyst : result.first().getAnalysts()) { + assertNotNull(analyst.getId()); + assertNotNull(analyst.getName()); + assertNotNull(analyst.getRole()); + assertNotNull(analyst.getAttributes()); + } + + // Remove analysts + Map actionMap = new HashMap<>(); + actionMap.put(ClinicalAnalysisDBAdaptor.QueryParams.ANALYSTS.key(), ParamUtils.BasicUpdateAction.REMOVE); + QueryOptions options = new QueryOptions() + .append(Constants.ACTIONS, actionMap) + .append(ParamConstants.INCLUDE_RESULT_PARAM, true); + result = catalogManager.getClinicalAnalysisManager().update(STUDY, case1.getId(), + new ClinicalAnalysisUpdateParams().setAnalysts( + Arrays.asList(new ClinicalAnalystParam("u1"), new ClinicalAnalystParam("u2"))), options, sessionIdUser); + assertEquals(1, result.first().getAnalysts().size()); + assertTrue(result.first().getAnalysts().stream().map(ClinicalAnalyst::getId).noneMatch(x -> Arrays.asList("u1", "u2").contains(x))); + + // Set analysts + actionMap.put(ClinicalAnalysisDBAdaptor.QueryParams.ANALYSTS.key(), ParamUtils.BasicUpdateAction.SET); + options = new QueryOptions() + .append(Constants.ACTIONS, actionMap) + .append(ParamConstants.INCLUDE_RESULT_PARAM, true); + result = catalogManager.getClinicalAnalysisManager().update(STUDY, case1.getId(), + new ClinicalAnalysisUpdateParams().setAnalysts( + Arrays.asList(new ClinicalAnalystParam("u1"), new ClinicalAnalystParam("u2"))), options, sessionIdUser); + assertEquals(2, result.first().getAnalysts().size()); + assertTrue(result.first().getAnalysts().stream().map(ClinicalAnalyst::getId).allMatch(x -> Arrays.asList("u1", "u2").contains(x))); + + thrown.expect(CatalogException.class); + thrown.expectMessage("not found"); + catalogManager.getClinicalAnalysisManager().update(STUDY, case1.getId(), + new ClinicalAnalysisUpdateParams().setAnalysts( + Arrays.asList(new ClinicalAnalystParam("unknown"), new ClinicalAnalystParam("u2"))), options, sessionIdUser); + } + + @Test + public void updateClinicalAnalysisRequest() throws CatalogException { + ClinicalAnalysis case1 = createDummyEnvironment(true, true).first(); + assertTrue(StringUtils.isEmpty(case1.getRequest().getId())); + + catalogManager.getUserManager().create(new User().setId("u1").setName("u1").setEmail("mail@mail.com").setAccount(new Account()), + TestParamConstants.PASSWORD, opencgaToken); + + ClinicalRequest request = new ClinicalRequest("requestId", "bla", null, new ClinicalResponsible().setId("u1"), new HashMap<>()); + + // Change request + OpenCGAResult result = catalogManager.getClinicalAnalysisManager().update(STUDY, case1.getId(), + new ClinicalAnalysisUpdateParams().setRequest(request), INCLUDE_RESULT, sessionIdUser); + assertNotNull(result.first().getRequest()); + assertTrue(StringUtils.isNotEmpty(result.first().getRequest().getDate())); + assertEquals("requestId", result.first().getRequest().getId()); + assertEquals("u1", result.first().getRequest().getResponsible().getId()); + assertEquals("u1", result.first().getRequest().getResponsible().getName()); + assertEquals("mail@mail.com", result.first().getRequest().getResponsible().getEmail()); + + // Remove request responsible + request.setResponsible(null); + result = catalogManager.getClinicalAnalysisManager().update(STUDY, case1.getId(), + new ClinicalAnalysisUpdateParams().setRequest(request), INCLUDE_RESULT, sessionIdUser); + assertNotNull(result.first().getRequest()); + assertTrue(StringUtils.isNotEmpty(result.first().getRequest().getDate())); + assertEquals("requestId", result.first().getRequest().getId()); + assertNull(result.first().getRequest().getResponsible()); + + // Add non existing request responsible user id + request.setResponsible(new ClinicalResponsible().setId("unknown")); + thrown.expect(CatalogException.class); + thrown.expectMessage("not found"); + catalogManager.getClinicalAnalysisManager().update(STUDY, case1.getId(), + new ClinicalAnalysisUpdateParams().setRequest(request), INCLUDE_RESULT, sessionIdUser); + } + + @Test + public void updateClinicalAnalysisResponsible() throws CatalogException { + ClinicalAnalysis case1 = createDummyEnvironment(true, true).first(); + assertEquals("user", case1.getResponsible().getId()); + + catalogManager.getUserManager().create(new User().setId("u1").setName("u1").setEmail("mail@mail.com").setAccount(new Account()), + TestParamConstants.PASSWORD, opencgaToken); + + ClinicalResponsible responsible = new ClinicalResponsible().setId("u1"); + + // Change responsible + OpenCGAResult result = catalogManager.getClinicalAnalysisManager().update(STUDY, case1.getId(), + new ClinicalAnalysisUpdateParams().setResponsible(responsible), INCLUDE_RESULT, sessionIdUser); + assertNotNull(result.first().getResponsible()); + assertEquals("u1", result.first().getResponsible().getId()); + assertEquals("u1", result.first().getResponsible().getName()); + assertEquals("mail@mail.com", result.first().getResponsible().getEmail()); + + // Change to non existing request responsible user id + responsible.setId("unknown"); + thrown.expect(CatalogException.class); + thrown.expectMessage("not found"); + catalogManager.getClinicalAnalysisManager().update(STUDY, case1.getId(), + new ClinicalAnalysisUpdateParams().setResponsible(responsible), INCLUDE_RESULT, sessionIdUser); + } + + @Test + public void updateClinicalAnalysisReport() throws CatalogException { + ClinicalAnalysis case1 = createDummyEnvironment(true, true).first(); + assertNull(case1.getReport()); + + ClinicalReport report = new ClinicalReport() + .setTitle("my report") + .setComments(Arrays.asList(new ClinicalComment("author", "msg", null, null), new ClinicalComment("author2", "msg", null, null))); + + // Change report + OpenCGAResult result = catalogManager.getClinicalAnalysisManager().update(STUDY, case1.getId(), + new ClinicalAnalysisUpdateParams().setReport(report), INCLUDE_RESULT, sessionIdUser); + assertNotNull(result.first().getReport()); + assertEquals(report.getTitle(), result.first().getReport().getTitle()); + assertEquals(2, result.first().getReport().getComments().size()); + for (ClinicalComment comment : result.first().getReport().getComments()) { + assertEquals("user", comment.getAuthor()); + assertTrue(StringUtils.isNotEmpty(comment.getDate())); + } + + // Add files + catalogManager.getFileManager().create(STUDY, + new FileCreateParams() + .setContent(RandomStringUtils.randomAlphanumeric(1000)) + .setPath("/data/file1.txt") + .setType(File.Type.FILE), + true, sessionIdUser); + catalogManager.getFileManager().create(STUDY, + new FileCreateParams() + .setContent(RandomStringUtils.randomAlphanumeric(1000)) + .setPath("/data/file2.txt") + .setType(File.Type.FILE), + true, sessionIdUser); + + List fileList = Arrays.asList(new File().setId("data:file1.txt"), new File().setId("data:file2.txt")); + report.setSupportingEvidences(fileList); + result = catalogManager.getClinicalAnalysisManager().update(STUDY, case1.getId(), + new ClinicalAnalysisUpdateParams().setReport(report), INCLUDE_RESULT, sessionIdUser); + assertNotNull(result.first().getReport()); + assertEquals(report.getTitle(), result.first().getReport().getTitle()); + assertEquals(2, result.first().getReport().getComments().size()); + for (ClinicalComment comment : result.first().getReport().getComments()) { + assertEquals("user", comment.getAuthor()); + assertTrue(StringUtils.isNotEmpty(comment.getDate())); + } + assertEquals(2, result.first().getReport().getSupportingEvidences().size()); + assertEquals("data/file1.txt", result.first().getReport().getSupportingEvidences().get(0).getPath()); + assertEquals("data/file2.txt", result.first().getReport().getSupportingEvidences().get(1).getPath()); + assertNull(result.first().getReport().getFiles()); + + report.setFiles(fileList); + result = catalogManager.getClinicalAnalysisManager().update(STUDY, case1.getId(), + new ClinicalAnalysisUpdateParams().setReport(report), INCLUDE_RESULT, sessionIdUser); + assertNotNull(result.first().getReport()); + assertEquals(report.getTitle(), result.first().getReport().getTitle()); + assertEquals(2, result.first().getReport().getComments().size()); + for (ClinicalComment comment : result.first().getReport().getComments()) { + assertEquals("user", comment.getAuthor()); + assertTrue(StringUtils.isNotEmpty(comment.getDate())); + } + assertEquals(2, result.first().getReport().getSupportingEvidences().size()); + assertEquals("data/file1.txt", result.first().getReport().getSupportingEvidences().get(0).getPath()); + assertEquals("data/file2.txt", result.first().getReport().getSupportingEvidences().get(1).getPath()); + assertEquals(2, result.first().getReport().getFiles().size()); + assertEquals("data/file1.txt", result.first().getReport().getFiles().get(0).getPath()); + assertEquals("data/file2.txt", result.first().getReport().getFiles().get(1).getPath()); + + // Provide non existing file + report.setFiles(Collections.singletonList(new File().setId("nonexisting.txt"))); + thrown.expect(CatalogException.class); + thrown.expectMessage("not found"); + catalogManager.getClinicalAnalysisManager().update(STUDY, case1.getId(), + new ClinicalAnalysisUpdateParams().setReport(report), INCLUDE_RESULT, sessionIdUser); + } + @Test public void createAndUpdateClinicalAnalysisWithQualityControl() throws CatalogException, InterruptedException { Individual individual = new Individual().setId("child1").setSamples(Arrays.asList(new Sample().setId("sample2"))); @@ -3494,4 +3682,127 @@ public void fetchCasesWithSameProbandAndDifferentSample() throws CatalogExceptio assertEquals(1, result.getResults().get(1).getProband().getSamples().size()); assertEquals(proband.getSamples().get(1).getId(), result.getResults().get(1).getProband().getSamples().get(0).getId()); } + + // Annotation sets + @Test + public void searchByInternalAnnotationSetTest() throws CatalogException { + Set variables = new HashSet<>(); + variables.add(new Variable().setId("a").setType(Variable.VariableType.STRING)); + variables.add(new Variable().setId("b").setType(Variable.VariableType.MAP_INTEGER).setAllowedKeys(Arrays.asList("b1", "b2"))); + VariableSet variableSet = new VariableSet("myInternalVset", "", false, false, true, "", variables, null, 1, null); + catalogManager.getStudyManager().createVariableSet(STUDY, variableSet, sessionIdUser); + + Map annotations = new HashMap<>(); + annotations.put("a", "hello"); + annotations.put("b", new ObjectMap("b1", 2).append("b2", 3)); + AnnotationSet annotationSet = new AnnotationSet("annSet", variableSet.getId(), annotations); + + annotations = new HashMap<>(); + annotations.put("a", "bye"); + annotations.put("b", new ObjectMap("b1", Integer.MAX_VALUE + 1L).append("b2", 5)); + AnnotationSet annotationSet2 = new AnnotationSet("annSet2", variableSet.getId(), annotations); + + DataResult clinicalAnalysisDataResult = createDummyEnvironment(true, true); + ClinicalAnalysis clinicalAnalysis = catalogManager.getClinicalAnalysisManager().update(STUDY, clinicalAnalysisDataResult.first().getId(), + new ClinicalAnalysisUpdateParams().setAnnotationSets(Arrays.asList(annotationSet, annotationSet2)), INCLUDE_RESULT, sessionIdUser).first(); + assertEquals(0, clinicalAnalysis.getAnnotationSets().size()); + + // Create a different case with different annotations + annotations = new HashMap<>(); + annotations.put("a", "hi"); + annotations.put("b", new ObjectMap("b1", 12).append("b2", 13)); + annotationSet = new AnnotationSet("annSet", variableSet.getId(), annotations); + + annotations = new HashMap<>(); + annotations.put("a", "goodbye"); + annotations.put("b", new ObjectMap("b1", 14).append("b2", 15)); + annotationSet2 = new AnnotationSet("annSet2", variableSet.getId(), annotations); + + DataResult clinicalAnalysisDataResult2 = createDummyEnvironment(false, true); + ClinicalAnalysis clinicalAnalysis2 = catalogManager.getClinicalAnalysisManager().update(STUDY, clinicalAnalysisDataResult2.first().getId(), + new ClinicalAnalysisUpdateParams().setAnnotationSets(Arrays.asList(annotationSet, annotationSet2)), INCLUDE_RESULT, sessionIdUser).first(); + assertEquals(0, clinicalAnalysis2.getAnnotationSets().size()); + + // Query by one of the annotations + Query query = new Query(Constants.ANNOTATION, "myInternalVset:a=hello"); + assertEquals(1, catalogManager.getClinicalAnalysisManager().count(STUDY, query, sessionIdUser).getNumMatches()); + assertEquals(clinicalAnalysis.getId(), catalogManager.getClinicalAnalysisManager().search(STUDY, query, ClinicalAnalysisManager.INCLUDE_CLINICAL_IDS, sessionIdUser).first() + .getId()); + + query = new Query(Constants.ANNOTATION, "myInternalVset:b.b1=" + (Integer.MAX_VALUE + 1L)); + assertEquals(1, catalogManager.getClinicalAnalysisManager().count(STUDY, query, sessionIdUser).getNumMatches()); + assertEquals(clinicalAnalysis.getId(), catalogManager.getClinicalAnalysisManager().search(STUDY, query, ClinicalAnalysisManager.INCLUDE_CLINICAL_IDS, sessionIdUser).first() + .getId()); + + query = new Query(Constants.ANNOTATION, "b.b1=14"); + assertEquals(1, catalogManager.getClinicalAnalysisManager().count(STUDY, query, sessionIdUser).getNumMatches()); + assertEquals(clinicalAnalysis2.getId(), catalogManager.getClinicalAnalysisManager().search(STUDY, query, ClinicalAnalysisManager.INCLUDE_CLINICAL_IDS, sessionIdUser).first() + .getId()); + + query = new Query(Constants.ANNOTATION, "a=goodbye"); + assertEquals(1, catalogManager.getClinicalAnalysisManager().count(STUDY, query, sessionIdUser).getNumMatches()); + assertEquals(clinicalAnalysis2.getId(), catalogManager.getClinicalAnalysisManager().search(STUDY, query, ClinicalAnalysisManager.INCLUDE_CLINICAL_IDS, sessionIdUser).first() + .getId()); + + // Update sample annotation to be exactly the same as sample2 + ObjectMap action = new ObjectMap(ClinicalAnalysisDBAdaptor.QueryParams.ANNOTATION_SETS.key(), ParamUtils.BasicUpdateAction.SET); + QueryOptions options = new QueryOptions(Constants.ACTIONS, action); + catalogManager.getClinicalAnalysisManager().update(STUDY, clinicalAnalysis.getId(), + new ClinicalAnalysisUpdateParams().setAnnotationSets(Arrays.asList(annotationSet, annotationSet2)), options, sessionIdUser); + + query = new Query(Constants.ANNOTATION, "myInternalVset:a=hello"); + assertEquals(0, catalogManager.getClinicalAnalysisManager().count(STUDY, query, sessionIdUser).getNumMatches()); + + query = new Query(Constants.ANNOTATION, "myInternalVset:b.b1=4"); + assertEquals(0, catalogManager.getClinicalAnalysisManager().count(STUDY, query, sessionIdUser).getNumMatches()); + + query = new Query(Constants.ANNOTATION, "b.b1=14"); + assertEquals(2, catalogManager.getClinicalAnalysisManager().count(STUDY, query, sessionIdUser).getNumMatches()); + assertTrue(Arrays.asList(clinicalAnalysis.getId(), clinicalAnalysis2.getId()) + .containsAll(catalogManager.getClinicalAnalysisManager().search(STUDY, query, ClinicalAnalysisManager.INCLUDE_CLINICAL_IDS, sessionIdUser) + .getResults().stream().map(ClinicalAnalysis::getId).collect(Collectors.toList()))); + + query = new Query(Constants.ANNOTATION, "a=goodbye"); + assertEquals(2, catalogManager.getClinicalAnalysisManager().count(STUDY, query, sessionIdUser).getNumMatches()); + assertTrue(Arrays.asList(clinicalAnalysis.getId(), clinicalAnalysis2.getId()) + .containsAll(catalogManager.getClinicalAnalysisManager().search(STUDY, query, ClinicalAnalysisManager.INCLUDE_CLINICAL_IDS, sessionIdUser) + .getResults().stream().map(ClinicalAnalysis::getId).collect(Collectors.toList()))); + } + + @Test + public void testSearchAnnotation() throws CatalogException { + List variables = new ArrayList<>(); + variables.add(new Variable("var_name", "", "", Variable.VariableType.STRING, "", true, false, Collections.emptyList(), null, 0, "", + "", null, Collections.emptyMap())); + variables.add(new Variable("AGE", "", "", Variable.VariableType.INTEGER, "", false, false, Collections.emptyList(), null, 0, "", "", + null, Collections.emptyMap())); + variables.add(new Variable("HEIGHT", "", "", Variable.VariableType.DOUBLE, "", false, false, Collections.emptyList(), null, 0, "", + "", null, Collections.emptyMap())); + variables.add(new Variable("OTHER", "", "", Variable.VariableType.OBJECT, null, false, false, null, null, 1, "", "", null, + Collections.emptyMap())); + VariableSet vs1 = catalogManager.getStudyManager().createVariableSet(STUDY, "vs1", "vs1", false, false, "", null, variables, + Collections.singletonList(VariableSet.AnnotableDataModels.CLINICAL_ANALYSIS), sessionIdUser).first(); + + ObjectMap annotations = new ObjectMap() + .append("var_name", "Joe") + .append("AGE", 25) + .append("HEIGHT", 180); + AnnotationSet annotationSet = new AnnotationSet("annotation1", vs1.getId(), annotations); + + DataResult clinicalAnalysisDataResult = createDummyEnvironment(true, true); + createDummyEnvironment(false, true); + catalogManager.getClinicalAnalysisManager().update(STUDY, clinicalAnalysisDataResult.first().getId(), + new ClinicalAnalysisUpdateParams().setAnnotationSets(Collections.singletonList(annotationSet)), QueryOptions.empty(), + sessionIdUser); + + Query query = new Query(Constants.ANNOTATION, "var_name=Joe;" + vs1.getId() + ":AGE=25"); + DataResult annotDataResult = catalogManager.getClinicalAnalysisManager().search(STUDY, query, + QueryOptions.empty(), sessionIdUser); + assertEquals(1, annotDataResult.getNumResults()); + + query.put(Constants.ANNOTATION, "var_name=Joe;" + vs1.getId() + ":AGE=23"); + annotDataResult = catalogManager.getClinicalAnalysisManager().search(STUDY, query, QueryOptions.empty(), sessionIdUser); + assertEquals(0, annotDataResult.getNumResults()); + } + } diff --git a/opencga-client/src/main/R/R/Admin-methods.R b/opencga-client/src/main/R/R/Admin-methods.R index cfbbbcd3db8..9c652ae5c3d 100644 --- a/opencga-client/src/main/R/R/Admin-methods.R +++ b/opencga-client/src/main/R/R/Admin-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. diff --git a/opencga-client/src/main/R/R/Alignment-methods.R b/opencga-client/src/main/R/R/Alignment-methods.R index 200f77a9007..e2ce9564b03 100644 --- a/opencga-client/src/main/R/R/Alignment-methods.R +++ b/opencga-client/src/main/R/R/Alignment-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. diff --git a/opencga-client/src/main/R/R/AllGenerics.R b/opencga-client/src/main/R/R/AllGenerics.R index eaab25f1d98..9733247bec5 100644 --- a/opencga-client/src/main/R/R/AllGenerics.R +++ b/opencga-client/src/main/R/R/AllGenerics.R @@ -1,6 +1,6 @@ # ############################################################################## ## UserClient -setGeneric("userClient", function(OpencgaR, user, filterId, users, endpointName, params=NULL, ...) +setGeneric("userClient", function(OpencgaR, user, users, filterId, endpointName, params=NULL, ...) standardGeneric("userClient")) # ############################################################################## @@ -10,42 +10,42 @@ setGeneric("projectClient", function(OpencgaR, project, projects, endpointName, # ############################################################################## ## StudyClient -setGeneric("studyClient", function(OpencgaR, templateId, study, group, variableSet, members, studies, endpointName, params=NULL, ...) +setGeneric("studyClient", function(OpencgaR, study, templateId, variableSet, members, studies, group, endpointName, params=NULL, ...) standardGeneric("studyClient")) # ############################################################################## ## FileClient -setGeneric("fileClient", function(OpencgaR, folder, file, files, members, annotationSet, endpointName, params=NULL, ...) +setGeneric("fileClient", function(OpencgaR, file, folder, annotationSet, members, files, endpointName, params=NULL, ...) standardGeneric("fileClient")) # ############################################################################## ## JobClient -setGeneric("jobClient", function(OpencgaR, jobs, job, members, endpointName, params=NULL, ...) +setGeneric("jobClient", function(OpencgaR, members, job, jobs, endpointName, params=NULL, ...) standardGeneric("jobClient")) # ############################################################################## ## SampleClient -setGeneric("sampleClient", function(OpencgaR, annotationSet, sample, samples, members, endpointName, params=NULL, ...) +setGeneric("sampleClient", function(OpencgaR, members, samples, sample, annotationSet, endpointName, params=NULL, ...) standardGeneric("sampleClient")) # ############################################################################## ## IndividualClient -setGeneric("individualClient", function(OpencgaR, annotationSet, individual, individuals, members, endpointName, params=NULL, ...) +setGeneric("individualClient", function(OpencgaR, members, individual, individuals, annotationSet, endpointName, params=NULL, ...) standardGeneric("individualClient")) # ############################################################################## ## FamilyClient -setGeneric("familyClient", function(OpencgaR, families, annotationSet, family, members, endpointName, params=NULL, ...) +setGeneric("familyClient", function(OpencgaR, family, members, annotationSet, families, endpointName, params=NULL, ...) standardGeneric("familyClient")) # ############################################################################## ## CohortClient -setGeneric("cohortClient", function(OpencgaR, annotationSet, cohort, cohorts, members, endpointName, params=NULL, ...) +setGeneric("cohortClient", function(OpencgaR, cohort, members, cohorts, annotationSet, endpointName, params=NULL, ...) standardGeneric("cohortClient")) # ############################################################################## ## PanelClient -setGeneric("panelClient", function(OpencgaR, panels, members, endpointName, params=NULL, ...) +setGeneric("panelClient", function(OpencgaR, members, panels, endpointName, params=NULL, ...) standardGeneric("panelClient")) # ############################################################################## @@ -60,7 +60,7 @@ setGeneric("variantClient", function(OpencgaR, endpointName, params=NULL, ...) # ############################################################################## ## ClinicalClient -setGeneric("clinicalClient", function(OpencgaR, interpretations, clinicalAnalyses, clinicalAnalysis, members, interpretation, endpointName, params=NULL, ...) +setGeneric("clinicalClient", function(OpencgaR, annotationSet, clinicalAnalysis, interpretation, clinicalAnalyses, interpretations, members, endpointName, params=NULL, ...) standardGeneric("clinicalClient")) # ############################################################################## diff --git a/opencga-client/src/main/R/R/Clinical-methods.R b/opencga-client/src/main/R/R/Clinical-methods.R index 6c61ecb790b..f9b0f7228a3 100644 --- a/opencga-client/src/main/R/R/Clinical-methods.R +++ b/opencga-client/src/main/R/R/Clinical-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. @@ -21,9 +21,10 @@ #' | endpointName | Endpoint WS | parameters accepted | #' | -- | :-- | --: | #' | updateAcl | /{apiVersion}/analysis/clinical/acl/{members}/update | study, members[*], action[*], propagate, body[*] | +#' | loadAnnotationSets | /{apiVersion}/analysis/clinical/annotationSets/load | study, variableSetId[*], path[*], parents, annotationSetId, body | #' | updateClinicalConfiguration | /{apiVersion}/analysis/clinical/clinical/configuration/update | study, body | #' | create | /{apiVersion}/analysis/clinical/create | include, exclude, study, skipCreateDefaultInterpretation, includeResult, body[*] | -#' | distinct | /{apiVersion}/analysis/clinical/distinct | study, id, uuid, type, disorder, files, sample, individual, proband, probandSamples, family, familyMembers, familyMemberSamples, panels, locked, analystId, priority, flags, creationDate, modificationDate, dueDate, qualityControlSummary, release, status, internalStatus, deleted, field[*] | +#' | distinct | /{apiVersion}/analysis/clinical/distinct | study, id, uuid, type, disorder, files, sample, individual, proband, probandSamples, family, familyMembers, familyMemberSamples, panels, locked, analystId, priority, flags, creationDate, modificationDate, dueDate, qualityControlSummary, release, status, internalStatus, annotation, deleted, field[*] | #' | distinctInterpretation | /{apiVersion}/analysis/clinical/interpretation/distinct | study, id, uuid, clinicalAnalysisId, analystId, methodName, panels, primaryFindings, secondaryFindings, creationDate, modificationDate, status, internalStatus, release, field[*] | #' | searchInterpretation | /{apiVersion}/analysis/clinical/interpretation/search | include, exclude, limit, skip, sort, study, id, uuid, clinicalAnalysisId, analystId, methodName, panels, primaryFindings, secondaryFindings, creationDate, modificationDate, status, internalStatus, release | #' | infoInterpretation | /{apiVersion}/analysis/clinical/interpretation/{interpretations}/info | include, exclude, interpretations[*], study, version, deleted | @@ -40,12 +41,13 @@ #' | summaryRgaIndividual | /{apiVersion}/analysis/clinical/rga/individual/summary | limit, skip, count, sampleId, individualId, sex, phenotypes, disorders, numParents, geneId, geneName, chromosome, start, end, transcriptId, variants, dbSnps, knockoutType, filter, type, clinicalSignificance, populationFrequency, consequenceType, study | #' | queryRgaVariant | /{apiVersion}/analysis/clinical/rga/variant/query | include, exclude, limit, skip, count, includeIndividual, skipIndividual, limitIndividual, sampleId, individualId, sex, phenotypes, disorders, numParents, geneId, geneName, chromosome, start, end, transcriptId, variants, dbSnps, knockoutType, filter, type, clinicalSignificance, populationFrequency, consequenceType, study | #' | summaryRgaVariant | /{apiVersion}/analysis/clinical/rga/variant/summary | limit, skip, count, sampleId, individualId, sex, phenotypes, disorders, numParents, geneId, geneName, chromosome, start, end, transcriptId, variants, dbSnps, knockoutType, filter, type, clinicalSignificance, populationFrequency, consequenceType, study | -#' | search | /{apiVersion}/analysis/clinical/search | include, exclude, limit, skip, count, study, id, uuid, type, disorder, files, sample, individual, proband, probandSamples, family, familyMembers, familyMemberSamples, panels, locked, analystId, priority, flags, creationDate, modificationDate, dueDate, qualityControlSummary, release, status, internalStatus, deleted | +#' | search | /{apiVersion}/analysis/clinical/search | include, exclude, limit, skip, count, flattenAnnotations, study, id, uuid, type, disorder, files, sample, individual, proband, probandSamples, family, familyMembers, familyMemberSamples, panels, locked, analystId, priority, flags, creationDate, modificationDate, dueDate, qualityControlSummary, release, status, internalStatus, annotation, deleted | #' | queryVariant | /{apiVersion}/analysis/clinical/variant/query | include, exclude, limit, skip, count, approximateCount, approximateCountSamplingSize, savedFilter, includeInterpretation, id, region, type, study, file, filter, qual, fileData, sample, sampleData, sampleAnnotation, cohort, cohortStatsRef, cohortStatsAlt, cohortStatsMaf, cohortStatsMgf, cohortStatsPass, missingAlleles, missingGenotypes, score, family, familyDisorder, familySegregation, familyMembers, familyProband, gene, ct, xref, biotype, proteinSubstitution, conservation, populationFrequencyAlt, populationFrequencyRef, populationFrequencyMaf, transcriptFlag, geneTraitId, go, expression, proteinKeyword, drug, functionalScore, clinical, clinicalSignificance, clinicalConfirmedStatus, customAnnotation, panel, panelModeOfInheritance, panelConfidence, panelRoleInCancer, panelFeatureType, panelIntersection, trait | #' | acl | /{apiVersion}/analysis/clinical/{clinicalAnalyses}/acl | clinicalAnalyses[*], study, member, silent | #' | delete | /{apiVersion}/analysis/clinical/{clinicalAnalyses}/delete | study, force, clinicalAnalyses[*] | -#' | update | /{apiVersion}/analysis/clinical/{clinicalAnalyses}/update | include, exclude, clinicalAnalyses[*], study, commentsAction, flagsAction, filesAction, panelsAction, includeResult, body[*] | -#' | info | /{apiVersion}/analysis/clinical/{clinicalAnalysis}/info | include, exclude, clinicalAnalysis[*], study, deleted | +#' | update | /{apiVersion}/analysis/clinical/{clinicalAnalyses}/update | include, exclude, clinicalAnalyses[*], study, commentsAction, flagsAction, analystsAction, filesAction, panelsAction, annotationSetsAction, includeResult, body[*] | +#' | updateAnnotationSetsAnnotations | /{apiVersion}/analysis/clinical/{clinicalAnalysis}/annotationSets/{annotationSet}/annotations/update | clinicalAnalysis[*], study, annotationSet[*], action, body | +#' | info | /{apiVersion}/analysis/clinical/{clinicalAnalysis}/info | include, exclude, flattenAnnotations, clinicalAnalysis[*], study, deleted | #' | createInterpretation | /{apiVersion}/analysis/clinical/{clinicalAnalysis}/interpretation/create | include, exclude, clinicalAnalysis[*], study, setAs, includeResult, body[*] | #' | clearInterpretation | /{apiVersion}/analysis/clinical/{clinicalAnalysis}/interpretation/{interpretations}/clear | study, interpretations[*], clinicalAnalysis[*] | #' | deleteInterpretation | /{apiVersion}/analysis/clinical/{clinicalAnalysis}/interpretation/{interpretations}/delete | study, clinicalAnalysis[*], interpretations[*], setAsPrimary | @@ -58,7 +60,7 @@ #' [*]: Required parameter #' @export -setMethod("clinicalClient", "OpencgaR", function(OpencgaR, interpretations, clinicalAnalyses, clinicalAnalysis, members, interpretation, endpointName, params=NULL, ...) { +setMethod("clinicalClient", "OpencgaR", function(OpencgaR, annotationSet, clinicalAnalysis, interpretation, clinicalAnalyses, interpretations, members, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/analysis/clinical/acl/{members}/update: @@ -72,6 +74,18 @@ setMethod("clinicalClient", "OpencgaR", function(OpencgaR, interpretations, clin subcategoryId=members, action="update", params=params, httpMethod="POST", as.queryParam=c("action"), ...), + #' @section Endpoint /{apiVersion}/analysis/clinical/annotationSets/load: + #' Load annotation sets from a TSV file. + #' @param study Study [[user@]project:]study where study and project can be either the ID or UUID. + #' @param variableSetId Variable set ID or name. + #' @param path Path where the TSV file is located in OpenCGA or where it should be located. + #' @param parents Flag indicating whether to create parent directories if they don't exist (only when TSV file was not previously associated). + #' @param annotationSetId Annotation set id. If not provided, variableSetId will be used. + #' @param data JSON containing the 'content' of the TSV file if this has not yet been registered into OpenCGA. + loadAnnotationSets=fetchOpenCGA(object=OpencgaR, category="analysis", categoryId=NULL, + subcategory="clinical/annotationSets", subcategoryId=NULL, action="load", params=params, + httpMethod="POST", as.queryParam=c("variableSetId","path"), ...), + #' @section Endpoint /{apiVersion}/analysis/clinical/clinical/configuration/update: #' Update Clinical Analysis configuration. #' @param study Study [[user@]project:]study where study and project can be either the ID or UUID. @@ -118,6 +132,7 @@ setMethod("clinicalClient", "OpencgaR", function(OpencgaR, interpretations, clin #' @param release Release when it was created. #' @param status Filter by status. #' @param internalStatus Filter by internal status. + #' @param annotation Annotation filters. Example: age>30;gender=FEMALE. For more information, please visit http://docs.opencb.org/display/opencga/AnnotationSets+1.4.0. #' @param deleted Boolean to retrieve deleted entries. #' @param field Comma separated list of fields for which to obtain the distinct values. distinct=fetchOpenCGA(object=OpencgaR, category="analysis", categoryId=NULL, subcategory="clinical", @@ -483,6 +498,7 @@ setMethod("clinicalClient", "OpencgaR", function(OpencgaR, interpretations, clin #' @param limit Number of results to be returned. #' @param skip Number of results to skip. #' @param count Get the total number of results matching the query. Deactivated by default. + #' @param flattenAnnotations Flatten the annotations?. #' @param study Study [[user@]project:]study where study and project can be either the ID or UUID. #' @param id Comma separated list of Clinical Analysis IDs up to a maximum of 100. Also admits basic regular expressions using the operator '~', i.e. '~{perl-regex}' e.g. '~value' for case sensitive, '~/value/i' for case insensitive search. #' @param uuid Comma separated list of Clinical Analysis UUIDs up to a maximum of 100. @@ -508,6 +524,7 @@ setMethod("clinicalClient", "OpencgaR", function(OpencgaR, interpretations, clin #' @param release Release when it was created. #' @param status Filter by status. #' @param internalStatus Filter by internal status. + #' @param annotation Annotation filters. Example: age>30;gender=FEMALE. For more information, please visit http://docs.opencb.org/display/opencga/AnnotationSets+1.4.0. #' @param deleted Boolean to retrieve deleted entries. search=fetchOpenCGA(object=OpencgaR, category="analysis", categoryId=NULL, subcategory="clinical", subcategoryId=NULL, action="search", params=params, httpMethod="GET", as.queryParam=NULL, ...), @@ -605,18 +622,32 @@ setMethod("clinicalClient", "OpencgaR", function(OpencgaR, interpretations, clin #' @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 flagsAction Action to be performed if the array of flags is being updated. Allowed values: ['ADD SET REMOVE'] + #' @param analystsAction Action to be performed if the array of analysts 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 panelsAction Action to be performed if the array of panels is being updated. Allowed values: ['ADD SET REMOVE'] + #' @param annotationSetsAction Action to be performed if the array of annotationSets 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 analysis information. update=fetchOpenCGA(object=OpencgaR, category="analysis", categoryId=NULL, subcategory="clinical", subcategoryId=clinicalAnalyses, action="update", params=params, httpMethod="POST", as.queryParam=NULL, ...), + #' @section Endpoint /{apiVersion}/analysis/clinical/{clinicalAnalysis}/annotationSets/{annotationSet}/annotations/update: + #' Update annotations from an annotationSet. + #' @param clinicalAnalysis Clinical analysis ID. + #' @param study Study [[user@]project:]study where study and project can be either the ID or UUID. + #' @param annotationSet AnnotationSet ID to be updated. + #' @param action Action to be performed: ADD to add new annotations; REPLACE to replace the value of an already existing annotation; SET to set the new list of annotations removing any possible old annotations; REMOVE to remove some annotations; RESET to set some annotations to the default value configured in the corresponding variables of the VariableSet if any. Allowed values: ['ADD SET REMOVE RESET REPLACE'] + #' @param data Json containing the map of annotations when the action is ADD, SET or REPLACE, a json with only the key 'remove' containing the comma separated variables to be removed as a value when the action is REMOVE or a json with only the key 'reset' containing the comma separated variables that will be set to the default value when the action is RESET. + updateAnnotationSetsAnnotations=fetchOpenCGA(object=OpencgaR, category="analysis/clinical", + categoryId=clinicalAnalysis, subcategory="annotationSets", subcategoryId=annotationSet, + action="annotations/update", params=params, httpMethod="POST", as.queryParam=NULL, ...), + #' @section Endpoint /{apiVersion}/analysis/clinical/{clinicalAnalysis}/info: #' Clinical analysis info. #' @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 flattenAnnotations Flatten the annotations?. #' @param clinicalAnalysis Comma separated list of clinical analysis IDs or names up to a maximum of 100. #' @param study Study [[user@]project:]study where study and project can be either the ID or UUID. #' @param deleted Boolean to retrieve deleted entries. diff --git a/opencga-client/src/main/R/R/Cohort-methods.R b/opencga-client/src/main/R/R/Cohort-methods.R index 0b812191131..06fd04b9449 100644 --- a/opencga-client/src/main/R/R/Cohort-methods.R +++ b/opencga-client/src/main/R/R/Cohort-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. @@ -39,7 +39,7 @@ #' [*]: Required parameter #' @export -setMethod("cohortClient", "OpencgaR", function(OpencgaR, annotationSet, cohort, cohorts, members, endpointName, params=NULL, ...) { +setMethod("cohortClient", "OpencgaR", function(OpencgaR, cohort, members, cohorts, annotationSet, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/cohorts/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/Family-methods.R b/opencga-client/src/main/R/R/Family-methods.R index c7b6c7e2eda..0f6722a73f8 100644 --- a/opencga-client/src/main/R/R/Family-methods.R +++ b/opencga-client/src/main/R/R/Family-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. @@ -38,7 +38,7 @@ #' [*]: Required parameter #' @export -setMethod("familyClient", "OpencgaR", function(OpencgaR, families, annotationSet, family, members, endpointName, params=NULL, ...) { +setMethod("familyClient", "OpencgaR", function(OpencgaR, family, members, annotationSet, families, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/families/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/File-methods.R b/opencga-client/src/main/R/R/File-methods.R index 6652797ec91..12510a7e63d 100644 --- a/opencga-client/src/main/R/R/File-methods.R +++ b/opencga-client/src/main/R/R/File-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. @@ -54,7 +54,7 @@ #' [*]: Required parameter #' @export -setMethod("fileClient", "OpencgaR", function(OpencgaR, folder, file, files, members, annotationSet, endpointName, params=NULL, ...) { +setMethod("fileClient", "OpencgaR", function(OpencgaR, file, folder, annotationSet, members, files, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/files/acl/{members}/update: @@ -239,7 +239,7 @@ setMethod("fileClient", "OpencgaR", function(OpencgaR, folder, file, files, memb #' Resource to upload a file by chunks. #' @param file File to upload. #' @param fileName File name to overwrite the input fileName. - #' @param fileFormat File format. Allowed values: ['VCF BCF GVCF TBI BIGWIG SAM BAM BAI CRAM CRAI FASTQ FASTA PED TAB_SEPARATED_VALUES COMMA_SEPARATED_VALUES XML PROTOCOL_BUFFER JSON AVRO PARQUET IMAGE PLAIN BINARY NONE UNKNOWN'] + #' @param fileFormat File format. Allowed values: ['VCF BCF GVCF TBI BIGWIG SAM BAM BAI CRAM CRAI FASTQ FASTA PED TAB_SEPARATED_VALUES COMMA_SEPARATED_VALUES XML PROTOCOL_BUFFER JSON AVRO PARQUET PDF IMAGE PLAIN BINARY NONE UNKNOWN'] #' @param bioformat File bioformat. Allowed values: ['MICROARRAY_EXPRESSION_ONECHANNEL_AGILENT MICROARRAY_EXPRESSION_ONECHANNEL_AFFYMETRIX MICROARRAY_EXPRESSION_ONECHANNEL_GENEPIX MICROARRAY_EXPRESSION_TWOCHANNELS_AGILENT MICROARRAY_EXPRESSION_TWOCHANNELS_GENEPIX DATAMATRIX_EXPRESSION IDLIST IDLIST_RANKED ANNOTATION_GENEVSANNOTATION OTHER_NEWICK OTHER_BLAST OTHER_INTERACTION OTHER_GENOTYPE OTHER_PLINK OTHER_VCF OTHER_PED VCF4 VARIANT ALIGNMENT COVERAGE SEQUENCE PEDIGREE REFERENCE_GENOME NONE UNKNOWN'] #' @param checksum Expected MD5 file checksum. #' @param study Study [[user@]project:]study where study and project can be either the ID or UUID. diff --git a/opencga-client/src/main/R/R/GA4GH-methods.R b/opencga-client/src/main/R/R/GA4GH-methods.R index 0437d411e14..1dcd27d98bd 100644 --- a/opencga-client/src/main/R/R/GA4GH-methods.R +++ b/opencga-client/src/main/R/R/GA4GH-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. diff --git a/opencga-client/src/main/R/R/Individual-methods.R b/opencga-client/src/main/R/R/Individual-methods.R index bc213458afd..e468976ab4d 100644 --- a/opencga-client/src/main/R/R/Individual-methods.R +++ b/opencga-client/src/main/R/R/Individual-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. @@ -39,7 +39,7 @@ #' [*]: Required parameter #' @export -setMethod("individualClient", "OpencgaR", function(OpencgaR, annotationSet, individual, individuals, members, endpointName, params=NULL, ...) { +setMethod("individualClient", "OpencgaR", function(OpencgaR, members, individual, individuals, annotationSet, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/individuals/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/Job-methods.R b/opencga-client/src/main/R/R/Job-methods.R index 33f938d2c36..a96b8b58b19 100644 --- a/opencga-client/src/main/R/R/Job-methods.R +++ b/opencga-client/src/main/R/R/Job-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. @@ -40,7 +40,7 @@ #' [*]: Required parameter #' @export -setMethod("jobClient", "OpencgaR", function(OpencgaR, jobs, job, members, endpointName, params=NULL, ...) { +setMethod("jobClient", "OpencgaR", function(OpencgaR, members, job, jobs, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/jobs/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/Meta-methods.R b/opencga-client/src/main/R/R/Meta-methods.R index fe4f981c155..32eeb09f335 100644 --- a/opencga-client/src/main/R/R/Meta-methods.R +++ b/opencga-client/src/main/R/R/Meta-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. diff --git a/opencga-client/src/main/R/R/Operation-methods.R b/opencga-client/src/main/R/R/Operation-methods.R index 39c31443bfd..65c0e083e8e 100644 --- a/opencga-client/src/main/R/R/Operation-methods.R +++ b/opencga-client/src/main/R/R/Operation-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. diff --git a/opencga-client/src/main/R/R/Panel-methods.R b/opencga-client/src/main/R/R/Panel-methods.R index 82bda6cae83..7c79027c43f 100644 --- a/opencga-client/src/main/R/R/Panel-methods.R +++ b/opencga-client/src/main/R/R/Panel-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. @@ -36,7 +36,7 @@ #' [*]: Required parameter #' @export -setMethod("panelClient", "OpencgaR", function(OpencgaR, panels, members, endpointName, params=NULL, ...) { +setMethod("panelClient", "OpencgaR", function(OpencgaR, members, panels, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/panels/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/Project-methods.R b/opencga-client/src/main/R/R/Project-methods.R index a4432945c30..e05921a527c 100644 --- a/opencga-client/src/main/R/R/Project-methods.R +++ b/opencga-client/src/main/R/R/Project-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. diff --git a/opencga-client/src/main/R/R/Sample-methods.R b/opencga-client/src/main/R/R/Sample-methods.R index be3ac2fedd7..e2a51186dd7 100644 --- a/opencga-client/src/main/R/R/Sample-methods.R +++ b/opencga-client/src/main/R/R/Sample-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. @@ -39,7 +39,7 @@ #' [*]: Required parameter #' @export -setMethod("sampleClient", "OpencgaR", function(OpencgaR, annotationSet, sample, samples, members, endpointName, params=NULL, ...) { +setMethod("sampleClient", "OpencgaR", function(OpencgaR, members, samples, sample, annotationSet, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/samples/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/Study-methods.R b/opencga-client/src/main/R/R/Study-methods.R index ba11f8cbc68..2d98e078207 100644 --- a/opencga-client/src/main/R/R/Study-methods.R +++ b/opencga-client/src/main/R/R/Study-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. @@ -46,7 +46,7 @@ #' [*]: Required parameter #' @export -setMethod("studyClient", "OpencgaR", function(OpencgaR, templateId, study, group, variableSet, members, studies, endpointName, params=NULL, ...) { +setMethod("studyClient", "OpencgaR", function(OpencgaR, study, templateId, variableSet, members, studies, group, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/studies/acl/{members}/update: diff --git a/opencga-client/src/main/R/R/User-methods.R b/opencga-client/src/main/R/R/User-methods.R index 9f5592c1af6..5206f98e8fb 100644 --- a/opencga-client/src/main/R/R/User-methods.R +++ b/opencga-client/src/main/R/R/User-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. @@ -38,7 +38,7 @@ #' [*]: Required parameter #' @export -setMethod("userClient", "OpencgaR", function(OpencgaR, user, filterId, users, endpointName, params=NULL, ...) { +setMethod("userClient", "OpencgaR", function(OpencgaR, user, users, filterId, endpointName, params=NULL, ...) { switch(endpointName, #' @section Endpoint /{apiVersion}/users/login: diff --git a/opencga-client/src/main/R/R/Variant-methods.R b/opencga-client/src/main/R/R/Variant-methods.R index 18de5c9e748..24d77ff2bcd 100644 --- a/opencga-client/src/main/R/R/Variant-methods.R +++ b/opencga-client/src/main/R/R/Variant-methods.R @@ -2,7 +2,7 @@ # WARNING: AUTOGENERATED CODE # # This code was generated by a tool. -# Autogenerated on: 2023-11-16 +# Autogenerated on: 2023-12-04 # # 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. diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AdminClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AdminClient.java index d392477c488..681080ed7ec 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AdminClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AdminClient.java @@ -36,7 +36,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -45,7 +45,7 @@ /** * This class contains methods for the Admin webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: admin */ public class AdminClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AlignmentClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AlignmentClient.java index 5ad010515e5..509c48c0eab 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AlignmentClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/AlignmentClient.java @@ -40,7 +40,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -49,7 +49,7 @@ /** * This class contains methods for the Alignment webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: analysis/alignment */ public class AlignmentClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ClinicalAnalysisClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ClinicalAnalysisClient.java index a5226f55c1d..37f2254435c 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ClinicalAnalysisClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ClinicalAnalysisClient.java @@ -42,7 +42,9 @@ import org.opencb.opencga.core.models.clinical.TeamInterpretationAnalysisParams; import org.opencb.opencga.core.models.clinical.TieringInterpretationAnalysisParams; import org.opencb.opencga.core.models.clinical.ZettaInterpretationAnalysisParams; +import org.opencb.opencga.core.models.common.TsvAnnotationParams; import org.opencb.opencga.core.models.job.Job; +import org.opencb.opencga.core.models.sample.Sample; import org.opencb.opencga.core.models.study.configuration.ClinicalAnalysisStudyConfiguration; import org.opencb.opencga.core.response.RestResponse; @@ -51,7 +53,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -60,7 +62,7 @@ /** * This class contains methods for the ClinicalAnalysis webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: analysis/clinical */ public class ClinicalAnalysisClient extends AbstractParentClient { @@ -88,6 +90,28 @@ public RestResponse updateAcl(String members, Stri return execute("analysis", null, "clinical/acl", members, "update", params, POST, ClinicalAnalysisAclEntryList.class); } + /** + * Load annotation sets from a TSV file. + * @param variableSetId Variable set ID or name. + * @param path Path where the TSV file is located in OpenCGA or where it should be located. + * @param data JSON containing the 'content' of the TSV file if this has not yet been registered into OpenCGA. + * @param params Map containing any of the following optional parameters. + * study: Study [[user@]project:]study where study and project can be either the ID or UUID. + * parents: Flag indicating whether to create parent directories if they don't exist (only when TSV file was not previously + * associated). + * annotationSetId: Annotation set id. If not provided, variableSetId will be used. + * @return a RestResponse object. + * @throws ClientException ClientException if there is any server error. + */ + public RestResponse loadAnnotationSets(String variableSetId, String path, TsvAnnotationParams data, ObjectMap params) + throws ClientException { + params = params != null ? params : new ObjectMap(); + params.putIfNotNull("variableSetId", variableSetId); + params.putIfNotNull("path", path); + params.put("body", data); + return execute("analysis", null, "clinical/annotationSets", null, "load", params, POST, Job.class); + } + /** * Update Clinical Analysis configuration. * @param data Configuration params to update. @@ -153,6 +177,8 @@ public RestResponse create(ClinicalAnalysisCreateParams data, * release: Release when it was created. * status: Filter by status. * internalStatus: Filter by internal status. + * annotation: Annotation filters. Example: age>30;gender=FEMALE. For more information, please visit + * http://docs.opencb.org/display/opencga/AnnotationSets+1.4.0. * deleted: Boolean to retrieve deleted entries. * @return a RestResponse object. * @throws ClientException ClientException if there is any server error. @@ -619,6 +645,7 @@ public RestResponse summaryRgaVariant(ObjectMap params * limit: Number of results to be returned. * skip: Number of results to skip. * count: Get the total number of results matching the query. Deactivated by default. + * flattenAnnotations: Flatten the annotations?. * study: Study [[user@]project:]study where study and project can be either the ID or UUID. * id: Comma separated list of Clinical Analysis IDs up to a maximum of 100. Also admits basic regular expressions using the * operator '~', i.e. '~{perl-regex}' e.g. '~value' for case sensitive, '~/value/i' for case insensitive search. @@ -646,6 +673,8 @@ public RestResponse summaryRgaVariant(ObjectMap params * release: Release when it was created. * status: Filter by status. * internalStatus: Filter by internal status. + * annotation: Annotation filters. Example: age>30;gender=FEMALE. For more information, please visit + * http://docs.opencb.org/display/opencga/AnnotationSets+1.4.0. * deleted: Boolean to retrieve deleted entries. * @return a RestResponse object. * @throws ClientException ClientException if there is any server error. @@ -796,8 +825,10 @@ public RestResponse delete(String clinicalAnalyses, ObjectMap * study: Study [[user@]project:]study where study and project can be either the ID or UUID. * commentsAction: Action to be performed if the array of comments is being updated. * flagsAction: Action to be performed if the array of flags is being updated. + * analystsAction: Action to be performed if the array of analysts is being updated. * filesAction: Action to be performed if the array of files is being updated. * panelsAction: Action to be performed if the array of panels is being updated. + * annotationSetsAction: Action to be performed if the array of annotationSets is being updated. * includeResult: Flag indicating to include the created or updated document result in the response. * @return a RestResponse object. * @throws ClientException ClientException if there is any server error. @@ -809,12 +840,36 @@ public RestResponse update(String clinicalAnalyses, ClinicalAn return execute("analysis", null, "clinical", clinicalAnalyses, "update", params, POST, ClinicalAnalysis.class); } + /** + * Update annotations from an annotationSet. + * @param clinicalAnalysis Clinical analysis ID. + * @param annotationSet AnnotationSet ID to be updated. + * @param data Json containing the map of annotations when the action is ADD, SET or REPLACE, a json with only the key 'remove' + * containing the comma separated variables to be removed as a value when the action is REMOVE or a json with only the key 'reset' + * containing the comma separated variables that will be set to the default value when the action is RESET. + * @param params Map containing any of the following optional parameters. + * study: Study [[user@]project:]study where study and project can be either the ID or UUID. + * action: Action to be performed: ADD to add new annotations; REPLACE to replace the value of an already existing annotation; + * SET to set the new list of annotations removing any possible old annotations; REMOVE to remove some annotations; RESET to + * set some annotations to the default value configured in the corresponding variables of the VariableSet if any. + * @return a RestResponse object. + * @throws ClientException ClientException if there is any server error. + */ + public RestResponse updateAnnotationSetsAnnotations(String clinicalAnalysis, String annotationSet, ObjectMap data, ObjectMap + params) throws ClientException { + params = params != null ? params : new ObjectMap(); + params.put("body", data); + return execute("analysis/clinical", clinicalAnalysis, "annotationSets", annotationSet, "annotations/update", params, POST, + Sample.class); + } + /** * Clinical analysis info. * @param clinicalAnalysis Comma separated list of clinical analysis IDs or names up to a maximum of 100. * @param params Map containing any of the following optional parameters. * include: Fields included in the response, whole JSON path must be provided. * exclude: Fields excluded in the response, whole JSON path must be provided. + * flattenAnnotations: Flatten the annotations?. * study: Study [[user@]project:]study where study and project can be either the ID or UUID. * deleted: Boolean to retrieve deleted entries. * @return a RestResponse object. diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/CohortClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/CohortClient.java index b40625287e5..f80327b9869 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/CohortClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/CohortClient.java @@ -37,7 +37,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -46,7 +46,7 @@ /** * This class contains methods for the Cohort webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: cohorts */ public class CohortClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/DiseasePanelClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/DiseasePanelClient.java index 0ffb75406df..5bcd565ae52 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/DiseasePanelClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/DiseasePanelClient.java @@ -35,7 +35,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -44,7 +44,7 @@ /** * This class contains methods for the DiseasePanel webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: panels */ public class DiseasePanelClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FamilyClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FamilyClient.java index ad14313183f..06e6060df9d 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FamilyClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FamilyClient.java @@ -36,7 +36,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -45,7 +45,7 @@ /** * This class contains methods for the Family webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: families */ public class FamilyClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FileClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FileClient.java index 4d3824911c4..333f34943f1 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FileClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/FileClient.java @@ -43,7 +43,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -52,7 +52,7 @@ /** * This class contains methods for the File webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: files */ public class FileClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/GA4GHClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/GA4GHClient.java index 595a6a3f89e..7d9817077cf 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/GA4GHClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/GA4GHClient.java @@ -27,7 +27,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -36,7 +36,7 @@ /** * This class contains methods for the GA4GH webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: ga4gh */ public class GA4GHClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/IndividualClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/IndividualClient.java index 98fae165c5c..09d5162ee36 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/IndividualClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/IndividualClient.java @@ -36,7 +36,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -45,7 +45,7 @@ /** * This class contains methods for the Individual webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: individuals */ public class IndividualClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/JobClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/JobClient.java index e674ba7cd1a..1df79d4bf5d 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/JobClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/JobClient.java @@ -37,7 +37,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -46,7 +46,7 @@ /** * This class contains methods for the Job webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: jobs */ public class JobClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/MetaClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/MetaClient.java index 2ea513755f2..d2f8c2fdb65 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/MetaClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/MetaClient.java @@ -28,7 +28,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -37,7 +37,7 @@ /** * This class contains methods for the Meta webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: meta */ public class MetaClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ProjectClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ProjectClient.java index fe3b879c5e8..e3bc0c86d9a 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ProjectClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/ProjectClient.java @@ -32,7 +32,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -41,7 +41,7 @@ /** * This class contains methods for the Project webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: projects */ public class ProjectClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/SampleClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/SampleClient.java index 1287afa3604..9fdd01ee98c 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/SampleClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/SampleClient.java @@ -36,7 +36,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -45,7 +45,7 @@ /** * This class contains methods for the Sample webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: samples */ public class SampleClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/StudyClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/StudyClient.java index 423c9269ca8..b5aeb27cf3a 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/StudyClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/StudyClient.java @@ -45,7 +45,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -54,7 +54,7 @@ /** * This class contains methods for the Study webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: studies */ public class StudyClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/UserClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/UserClient.java index ac72d10e0e3..50682de902d 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/UserClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/UserClient.java @@ -36,7 +36,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -45,7 +45,7 @@ /** * This class contains methods for the User webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: users */ public class UserClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantClient.java index 414be131cf2..ca3d4687bab 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantClient.java @@ -62,7 +62,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -71,7 +71,7 @@ /** * This class contains methods for the Variant webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: analysis/variant */ public class VariantClient extends AbstractParentClient { diff --git a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantOperationClient.java b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantOperationClient.java index 0ac839dda24..f80b9ff3f9d 100644 --- a/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantOperationClient.java +++ b/opencga-client/src/main/java/org/opencb/opencga/client/rest/clients/VariantOperationClient.java @@ -50,7 +50,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. -* Autogenerated on: 2023-11-16 +* Autogenerated on: 2023-12-04 * * 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. @@ -59,7 +59,7 @@ /** * This class contains methods for the VariantOperation webservices. - * Client version: 2.12.0-SNAPSHOT + * Client version: 2.12.1-SNAPSHOT * PATH: operation */ public class VariantOperationClient extends AbstractParentClient { diff --git a/opencga-client/src/main/javascript/Admin.js b/opencga-client/src/main/javascript/Admin.js index 0ee2bc44d87..dfb9c735b66 100644 --- a/opencga-client/src/main/javascript/Admin.js +++ b/opencga-client/src/main/javascript/Admin.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/Alignment.js b/opencga-client/src/main/javascript/Alignment.js index 261eebcacdd..8138c31a19b 100644 --- a/opencga-client/src/main/javascript/Alignment.js +++ b/opencga-client/src/main/javascript/Alignment.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/ClinicalAnalysis.js b/opencga-client/src/main/javascript/ClinicalAnalysis.js index 6a7b5ec95c0..db1ab0457c7 100644 --- a/opencga-client/src/main/javascript/ClinicalAnalysis.js +++ b/opencga-client/src/main/javascript/ClinicalAnalysis.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. @@ -46,6 +46,21 @@ export default class ClinicalAnalysis extends OpenCGAParentClass { return this._post("analysis", null, "clinical/acl", members, "update", data, {action, ...params}); } + /** Load annotation sets from a TSV file + * @param {Object} [data] - JSON containing the 'content' of the TSV file if this has not yet been registered into OpenCGA. + * @param {String} variableSetId - Variable set ID or name. + * @param {String} path - Path where the TSV file is located in OpenCGA or where it should be located. + * @param {Object} [params] - The Object containing the following optional parameters: + * @param {String} [params.study] - Study [[user@]project:]study where study and project can be either the ID or UUID. + * @param {Boolean} [params.parents] - Flag indicating whether to create parent directories if they don't exist (only when TSV file was + * not previously associated). + * @param {String} [params.annotationSetId] - Annotation set id. If not provided, variableSetId will be used. + * @returns {Promise} Promise object in the form of RestResponse instance. + */ + loadAnnotationSets(variableSetId, path, data, params) { + return this._post("analysis", null, "clinical/annotationSets", null, "load", data, {variableSetId, path, ...params}); + } + /** Update Clinical Analysis configuration. * @param {Object} [data] - Configuration params to update. * @param {Object} [params] - The Object containing the following optional parameters: @@ -103,6 +118,8 @@ export default class ClinicalAnalysis extends OpenCGAParentClass { * @param {String} [params.release] - Release when it was created. * @param {String} [params.status] - Filter by status. * @param {String} [params.internalStatus] - Filter by internal status. + * @param {String} [params.annotation] - Annotation filters. Example: age>30;gender=FEMALE. For more information, please visit + * http://docs.opencb.org/display/opencga/AnnotationSets+1.4.0. * @param {Boolean} [params.deleted] - Boolean to retrieve deleted entries. * @returns {Promise} Promise object in the form of RestResponse instance. */ @@ -518,6 +535,7 @@ export default class ClinicalAnalysis extends OpenCGAParentClass { * @param {Number} [params.skip] - Number of results to skip. * @param {Boolean} [params.count = "false"] - Get the total number of results matching the query. Deactivated by default. The default * value is false. + * @param {Boolean} [params.flattenAnnotations = "false"] - Flatten the annotations?. The default value is false. * @param {String} [params.study] - Study [[user@]project:]study where study and project can be either the ID or UUID. * @param {String} [params.id] - Comma separated list of Clinical Analysis IDs up to a maximum of 100. Also admits basic regular * expressions using the operator '~', i.e. '~{perl-regex}' e.g. '~value' for case sensitive, '~/value/i' for case insensitive search. @@ -546,6 +564,8 @@ export default class ClinicalAnalysis extends OpenCGAParentClass { * @param {String} [params.release] - Release when it was created. * @param {String} [params.status] - Filter by status. * @param {String} [params.internalStatus] - Filter by internal status. + * @param {String} [params.annotation] - Annotation filters. Example: age>30;gender=FEMALE. For more information, please visit + * http://docs.opencb.org/display/opencga/AnnotationSets+1.4.0. * @param {Boolean} [params.deleted] - Boolean to retrieve deleted entries. * @returns {Promise} Promise object in the form of RestResponse instance. */ @@ -698,10 +718,14 @@ export default class ClinicalAnalysis extends OpenCGAParentClass { * default value is ADD. * @param {"ADD SET REMOVE"} [params.flagsAction = "ADD"] - Action to be performed if the array of flags is being updated. The default * value is ADD. + * @param {"ADD SET REMOVE"} [params.analystsAction = "ADD"] - Action to be performed if the array of analysts is being updated. The + * default value is ADD. * @param {"ADD SET REMOVE"} [params.filesAction = "ADD"] - Action to be performed if the array of files is being updated. The default * value is ADD. * @param {"ADD SET REMOVE"} [params.panelsAction = "ADD"] - Action to be performed if the array of panels is being updated. The default * value is ADD. + * @param {"ADD SET REMOVE"} [params.annotationSetsAction = "ADD"] - Action to be performed if the array of annotationSets is being + * updated. The default value is ADD. * @param {Boolean} [params.includeResult = "false"] - Flag indicating to include the created or updated document result in the response. * The default value is false. * @returns {Promise} Promise object in the form of RestResponse instance. @@ -710,11 +734,30 @@ export default class ClinicalAnalysis extends OpenCGAParentClass { return this._post("analysis", null, "clinical", clinicalAnalyses, "update", data, params); } + /** Update annotations from an annotationSet + * @param {String} clinicalAnalysis - Clinical analysis ID. + * @param {String} annotationSet - AnnotationSet ID to be updated. + * @param {Object} [data] - Json containing the map of annotations when the action is ADD, SET or REPLACE, a json with only the key + * 'remove' containing the comma separated variables to be removed as a value when the action is REMOVE or a json with only the key + * 'reset' containing the comma separated variables that will be set to the default value when the action is RESET. + * @param {Object} [params] - The Object containing the following optional parameters: + * @param {String} [params.study] - Study [[user@]project:]study where study and project can be either the ID or UUID. + * @param {"ADD SET REMOVE RESET REPLACE"} [params.action = "ADD"] - Action to be performed: ADD to add new annotations; REPLACE to + * replace the value of an already existing annotation; SET to set the new list of annotations removing any possible old annotations; + * REMOVE to remove some annotations; RESET to set some annotations to the default value configured in the corresponding variables of the + * VariableSet if any. The default value is ADD. + * @returns {Promise} Promise object in the form of RestResponse instance. + */ + updateAnnotationSetsAnnotations(clinicalAnalysis, annotationSet, data, params) { + return this._post("analysis/clinical", clinicalAnalysis, "annotationSets", annotationSet, "annotations/update", data, params); + } + /** Clinical analysis info * @param {String} clinicalAnalysis - Comma separated list of clinical analysis IDs or names up to a maximum of 100. * @param {Object} [params] - The Object containing the following optional parameters: * @param {String} [params.include] - Fields included in the response, whole JSON path must be provided. * @param {String} [params.exclude] - Fields excluded in the response, whole JSON path must be provided. + * @param {Boolean} [params.flattenAnnotations = "false"] - Flatten the annotations?. The default value is false. * @param {String} [params.study] - Study [[user@]project:]study where study and project can be either the ID or UUID. * @param {Boolean} [params.deleted = "false"] - Boolean to retrieve deleted entries. The default value is false. * @returns {Promise} Promise object in the form of RestResponse instance. diff --git a/opencga-client/src/main/javascript/Cohort.js b/opencga-client/src/main/javascript/Cohort.js index 37265bb8555..f6054f1fea0 100644 --- a/opencga-client/src/main/javascript/Cohort.js +++ b/opencga-client/src/main/javascript/Cohort.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/DiseasePanel.js b/opencga-client/src/main/javascript/DiseasePanel.js index 4e342dba712..e5c7e775de3 100644 --- a/opencga-client/src/main/javascript/DiseasePanel.js +++ b/opencga-client/src/main/javascript/DiseasePanel.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/Family.js b/opencga-client/src/main/javascript/Family.js index 484cfe6d8b6..2e3364c4ada 100644 --- a/opencga-client/src/main/javascript/Family.js +++ b/opencga-client/src/main/javascript/Family.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/File.js b/opencga-client/src/main/javascript/File.js index c18abd55692..ff13373e01f 100644 --- a/opencga-client/src/main/javascript/File.js +++ b/opencga-client/src/main/javascript/File.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. @@ -269,7 +269,7 @@ export default class File extends OpenCGAParentClass { * @param {InputStream} [params.file] - File to upload. * @param {String} [params.fileName] - File name to overwrite the input fileName. * @param {"VCF BCF GVCF TBI BIGWIG SAM BAM BAI CRAM CRAI FASTQ FASTA PED TAB_SEPARATED_VALUES COMMA_SEPARATED_VALUES XML PROTOCOL_BUFFER - * JSON AVRO PARQUET IMAGE PLAIN BINARY NONE UNKNOWN"} [params.fileFormat] - File format. + * JSON AVRO PARQUET PDF IMAGE PLAIN BINARY NONE UNKNOWN"} [params.fileFormat] - File format. * @param {"MICROARRAY_EXPRESSION_ONECHANNEL_AGILENT MICROARRAY_EXPRESSION_ONECHANNEL_AFFYMETRIX MICROARRAY_EXPRESSION_ONECHANNEL_GENEPIX * MICROARRAY_EXPRESSION_TWOCHANNELS_AGILENT MICROARRAY_EXPRESSION_TWOCHANNELS_GENEPIX DATAMATRIX_EXPRESSION IDLIST IDLIST_RANKED * ANNOTATION_GENEVSANNOTATION OTHER_NEWICK OTHER_BLAST OTHER_INTERACTION OTHER_GENOTYPE OTHER_PLINK OTHER_VCF OTHER_PED VCF4 VARIANT diff --git a/opencga-client/src/main/javascript/GA4GH.js b/opencga-client/src/main/javascript/GA4GH.js index 1fb3b7f2da1..5c7f7365cfa 100644 --- a/opencga-client/src/main/javascript/GA4GH.js +++ b/opencga-client/src/main/javascript/GA4GH.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/Individual.js b/opencga-client/src/main/javascript/Individual.js index 392cc5a464e..2c1653e67f3 100644 --- a/opencga-client/src/main/javascript/Individual.js +++ b/opencga-client/src/main/javascript/Individual.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/Job.js b/opencga-client/src/main/javascript/Job.js index 4989a14e761..a2366a16bcc 100644 --- a/opencga-client/src/main/javascript/Job.js +++ b/opencga-client/src/main/javascript/Job.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/Meta.js b/opencga-client/src/main/javascript/Meta.js index d0d8f020b98..38ed0aa7176 100644 --- a/opencga-client/src/main/javascript/Meta.js +++ b/opencga-client/src/main/javascript/Meta.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/Project.js b/opencga-client/src/main/javascript/Project.js index 715a57c806f..3f51dc791ef 100644 --- a/opencga-client/src/main/javascript/Project.js +++ b/opencga-client/src/main/javascript/Project.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/Sample.js b/opencga-client/src/main/javascript/Sample.js index cf3d6eabe25..c750ede33b0 100644 --- a/opencga-client/src/main/javascript/Sample.js +++ b/opencga-client/src/main/javascript/Sample.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/Study.js b/opencga-client/src/main/javascript/Study.js index 336b83d176b..0c55aec2919 100644 --- a/opencga-client/src/main/javascript/Study.js +++ b/opencga-client/src/main/javascript/Study.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/User.js b/opencga-client/src/main/javascript/User.js index 9208760894f..33169158f2c 100644 --- a/opencga-client/src/main/javascript/User.js +++ b/opencga-client/src/main/javascript/User.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/Variant.js b/opencga-client/src/main/javascript/Variant.js index f24450c43ad..8a0b9427784 100644 --- a/opencga-client/src/main/javascript/Variant.js +++ b/opencga-client/src/main/javascript/Variant.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/javascript/VariantOperation.js b/opencga-client/src/main/javascript/VariantOperation.js index 5927ac01461..97d25ad91c3 100644 --- a/opencga-client/src/main/javascript/VariantOperation.js +++ b/opencga-client/src/main/javascript/VariantOperation.js @@ -12,7 +12,7 @@ * WARNING: AUTOGENERATED CODE * * This code was generated by a tool. - * Autogenerated on: 2023-11-16 + * Autogenerated on: 2023-12-04 * * 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. diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/admin_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/admin_client.py index 80b25019af6..0263c3621ac 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/admin_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/admin_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class Admin(_ParentRestClient): """ This class contains methods for the 'Admin' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/admin """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/alignment_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/alignment_client.py index 9faddbfc22a..22b054ef71a 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/alignment_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/alignment_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class Alignment(_ParentRestClient): """ This class contains methods for the 'Analysis - Alignment' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/analysis/alignment """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/clinical_analysis_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/clinical_analysis_client.py index 25ccbef39fe..5afe1cdadfb 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/clinical_analysis_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/clinical_analysis_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class ClinicalAnalysis(_ParentRestClient): """ This class contains methods for the 'Analysis - Clinical' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/analysis/clinical """ @@ -41,6 +41,29 @@ def update_acl(self, members, action, data=None, **options): options['action'] = action return self._post(category='analysis', resource='update', subcategory='clinical/acl', second_query_id=members, data=data, **options) + def load_annotation_sets(self, variable_set_id, path, data=None, **options): + """ + Load annotation sets from a TSV file. + PATH: /{apiVersion}/analysis/clinical/annotationSets/load + + :param str path: Path where the TSV file is located in OpenCGA or + where it should be located. (REQUIRED) + :param str variable_set_id: Variable set ID or name. (REQUIRED) + :param str study: Study [[user@]project:]study where study and project + can be either the ID or UUID. + :param bool parents: Flag indicating whether to create parent + directories if they don't exist (only when TSV file was not + previously associated). + :param str annotation_set_id: Annotation set id. If not provided, + variableSetId will be used. + :param dict data: JSON containing the 'content' of the TSV file if + this has not yet been registered into OpenCGA. + """ + + options['variableSetId'] = variable_set_id + options['path'] = path + return self._post(category='analysis', resource='load', subcategory='clinical/annotationSets', data=data, **options) + def update_clinical_configuration(self, data=None, **options): """ Update Clinical Analysis configuration. @@ -122,6 +145,9 @@ def distinct(self, field, **options): :param str release: Release when it was created. :param str status: Filter by status. :param str internal_status: Filter by internal status. + :param str annotation: Annotation filters. Example: + age>30;gender=FEMALE. For more information, please visit + http://docs.opencb.org/display/opencga/AnnotationSets+1.4.0. :param bool deleted: Boolean to retrieve deleted entries. """ @@ -618,6 +644,7 @@ def search(self, **options): :param int skip: Number of results to skip. :param bool count: Get the total number of results matching the query. Deactivated by default. + :param bool flatten_annotations: Flatten the annotations?. :param str study: Study [[user@]project:]study where study and project can be either the ID or UUID. :param str id: Comma separated list of Clinical Analysis IDs up to a @@ -657,6 +684,9 @@ def search(self, **options): :param str release: Release when it was created. :param str status: Filter by status. :param str internal_status: Filter by internal status. + :param str annotation: Annotation filters. Example: + age>30;gender=FEMALE. For more information, please visit + http://docs.opencb.org/display/opencga/AnnotationSets+1.4.0. :param bool deleted: Boolean to retrieve deleted entries. """ @@ -880,16 +910,47 @@ def update(self, clinical_analyses, data=None, **options): comments is being updated. Allowed values: ['ADD REMOVE REPLACE'] :param str flags_action: Action to be performed if the array of flags is being updated. Allowed values: ['ADD SET REMOVE'] + :param str analysts_action: Action to be performed if the array of + analysts is being updated. Allowed values: ['ADD SET REMOVE'] :param str files_action: Action to be performed if the array of files is being updated. Allowed values: ['ADD SET REMOVE'] :param str panels_action: Action to be performed if the array of panels is being updated. Allowed values: ['ADD SET REMOVE'] + :param str annotation_sets_action: Action to be performed if the array + of annotationSets is being updated. Allowed values: ['ADD SET + REMOVE'] :param bool include_result: Flag indicating to include the created or updated document result in the response. """ return self._post(category='analysis', resource='update', subcategory='clinical', second_query_id=clinical_analyses, data=data, **options) + def update_annotation_sets_annotations(self, clinical_analysis, annotation_set, data=None, **options): + """ + Update annotations from an annotationSet. + PATH: /{apiVersion}/analysis/clinical/{clinicalAnalysis}/annotationSets/{annotationSet}/annotations/update + + :param str annotation_set: AnnotationSet ID to be updated. (REQUIRED) + :param str clinical_analysis: Clinical analysis ID. (REQUIRED) + :param str study: Study [[user@]project:]study where study and project + can be either the ID or UUID. + :param str action: Action to be performed: ADD to add new annotations; + REPLACE to replace the value of an already existing annotation; SET + to set the new list of annotations removing any possible old + annotations; REMOVE to remove some annotations; RESET to set some + annotations to the default value configured in the corresponding + variables of the VariableSet if any. Allowed values: ['ADD SET + REMOVE RESET REPLACE'] + :param dict data: Json containing the map of annotations when the + action is ADD, SET or REPLACE, a json with only the key 'remove' + containing the comma separated variables to be removed as a value + when the action is REMOVE or a json with only the key 'reset' + containing the comma separated variables that will be set to the + default value when the action is RESET. + """ + + return self._post(category='analysis/clinical', resource='annotations/update', query_id=clinical_analysis, subcategory='annotationSets', second_query_id=annotation_set, data=data, **options) + def info(self, clinical_analysis, **options): """ Clinical analysis info. @@ -901,6 +962,7 @@ def info(self, clinical_analysis, **options): must be provided. :param str exclude: Fields excluded in the response, whole JSON path must be provided. + :param bool flatten_annotations: Flatten the annotations?. :param str study: Study [[user@]project:]study where study and project can be either the ID or UUID. :param bool deleted: Boolean to retrieve deleted entries. diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/cohort_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/cohort_client.py index fdd3410e17b..a73811bbf33 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/cohort_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/cohort_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class Cohort(_ParentRestClient): """ This class contains methods for the 'Cohorts' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/cohorts """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/disease_panel_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/disease_panel_client.py index 46a9dfd2481..8b42c8b7503 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/disease_panel_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/disease_panel_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class DiseasePanel(_ParentRestClient): """ This class contains methods for the 'Disease Panels' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/panels """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/family_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/family_client.py index 19cbba58e1e..fcbc7dfe740 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/family_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/family_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class Family(_ParentRestClient): """ This class contains methods for the 'Families' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/families """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/file_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/file_client.py index dfa6959715b..4c383bbae80 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/file_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/file_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class File(_ParentRestClient): """ This class contains methods for the 'Files' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/files """ @@ -349,7 +349,7 @@ def upload(self, **options): :param str file_format: File format. Allowed values: ['VCF BCF GVCF TBI BIGWIG SAM BAM BAI CRAM CRAI FASTQ FASTA PED TAB_SEPARATED_VALUES COMMA_SEPARATED_VALUES XML PROTOCOL_BUFFER - JSON AVRO PARQUET IMAGE PLAIN BINARY NONE UNKNOWN'] + JSON AVRO PARQUET PDF IMAGE PLAIN BINARY NONE UNKNOWN'] :param str bioformat: File bioformat. Allowed values: ['MICROARRAY_EXPRESSION_ONECHANNEL_AGILENT MICROARRAY_EXPRESSION_ONECHANNEL_AFFYMETRIX diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/ga4gh_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/ga4gh_client.py index 1a3a275de72..a485004088b 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/ga4gh_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/ga4gh_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class GA4GH(_ParentRestClient): """ This class contains methods for the 'GA4GH' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/ga4gh """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/individual_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/individual_client.py index 22c451748f4..5f97c56a7c3 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/individual_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/individual_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class Individual(_ParentRestClient): """ This class contains methods for the 'Individuals' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/individuals """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/job_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/job_client.py index 78d73855169..71800a23450 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/job_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/job_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class Job(_ParentRestClient): """ This class contains methods for the 'Jobs' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/jobs """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/meta_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/meta_client.py index c6eda7d8b3d..200e88dca55 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/meta_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/meta_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class Meta(_ParentRestClient): """ This class contains methods for the 'Meta' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/meta """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/project_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/project_client.py index ee0afaa1100..d63e289fbac 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/project_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/project_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class Project(_ParentRestClient): """ This class contains methods for the 'Projects' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/projects """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/sample_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/sample_client.py index 8399c7240b3..9f4bc866901 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/sample_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/sample_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class Sample(_ParentRestClient): """ This class contains methods for the 'Samples' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/samples """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/study_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/study_client.py index 0441473a757..30e8e39ed46 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/study_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/study_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class Study(_ParentRestClient): """ This class contains methods for the 'Studies' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/studies """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/user_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/user_client.py index de12e5d0bfa..a0575cad799 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/user_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/user_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class User(_ParentRestClient): """ This class contains methods for the 'Users' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/users """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/variant_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/variant_client.py index 98f5cc61a2e..31aed511f4d 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/variant_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/variant_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class Variant(_ParentRestClient): """ This class contains methods for the 'Analysis - Variant' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/analysis/variant """ diff --git a/opencga-client/src/main/python/pyopencga/rest_clients/variant_operation_client.py b/opencga-client/src/main/python/pyopencga/rest_clients/variant_operation_client.py index ed0c0da54f2..63b1afc96ec 100644 --- a/opencga-client/src/main/python/pyopencga/rest_clients/variant_operation_client.py +++ b/opencga-client/src/main/python/pyopencga/rest_clients/variant_operation_client.py @@ -2,7 +2,7 @@ WARNING: AUTOGENERATED CODE This code was generated by a tool. - Autogenerated on: 2023-11-16 + Autogenerated on: 2023-12-04 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. @@ -14,7 +14,7 @@ class VariantOperation(_ParentRestClient): """ This class contains methods for the 'Operations - Variant Storage' webservices - Client version: 2.12.0-SNAPSHOT + Client version: 2.12.1-SNAPSHOT PATH: /{apiVersion}/operation """ diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/api/FieldConstants.java b/opencga-core/src/main/java/org/opencb/opencga/core/api/FieldConstants.java index 4cccaaae80b..36fce194f36 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/api/FieldConstants.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/api/FieldConstants.java @@ -187,8 +187,10 @@ public class FieldConstants { public static final String CLINICAL_ANALYSIS_INTERPRETATION = "Interpretation of the clinical analysis."; public static final String CLINICAL_ANALYSIS_SECONDARY_INTERPRETATION = "List of Interpretations containing the second and consecutive."; public static final String CLINICAL_ANALYSIS_CONSENT = "Object contains consent annotations of clinical analysis."; - public static final String CLINICAL_ANALYSIS_ANALYST = "The analyst of the clinical analysis."; + public static final String CLINICAL_ANALYSIS_ANALYST = "The analysts of the clinical analysis."; public static final String CLINICAL_ANALYSIS_REPORT = "Report of the clinical analysis."; + public static final String CLINICAL_ANALYSIS_REQUEST = "Request of the clinical analysis."; + public static final String CLINICAL_ANALYSIS_RESPONSIBLE = "Responsible of the clinical analysis."; public static final String CLINICAL_ANALYSIS_PRIORITY = "Priority of the clinical analysis."; public static final String CLINICAL_ANALYSIS_FLAGS = "List of flags for the clinical analysis."; public static final String CLINICAL_ANALYSIS_DUE_DATE_DESCRIPTION = "Due date of the clinical analysis."; @@ -212,6 +214,9 @@ public class FieldConstants { public static final String CLINICAL_REPORT_SIGNED_BY = "Indicates who has signed the report."; public static final String CLINICAL_REPORT_SIGNATURE = "Report signature."; public static final String CLINICAL_REPORT_DATE = "Report date."; + public static final String CLINICAL_REPORT_COMMENTS = "Report comments."; + public static final String CLINICAL_REPORT_SUPPORTING_EVIDENCES = "Report supporting evidences."; + public static final String CLINICAL_REPORT_FILES = "Report files."; //ClinicalPriorityAnnotation public static final String CLINICAL_PRIORITY_ANNOTATION_RANK_DESCRIPTION = "ClinicalPriorityAnnotation rank."; diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysis.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysis.java index 1ba86bb4d1d..1c9ffd04027 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysis.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysis.java @@ -24,7 +24,8 @@ import org.opencb.commons.annotations.DataClass; import org.opencb.commons.annotations.DataField; import org.opencb.opencga.core.api.FieldConstants; -import org.opencb.opencga.core.models.PrivateStudyUid; +import org.opencb.opencga.core.models.common.Annotable; +import org.opencb.opencga.core.models.common.AnnotationSet; import org.opencb.opencga.core.models.common.FlagAnnotation; import org.opencb.opencga.core.models.family.Family; import org.opencb.opencga.core.models.file.File; @@ -41,7 +42,7 @@ */ @DataClass(id = "ClinicalAnalysis", since = "1.0", description = "ClinicalAnalysis data model hosts information about any analysis.") -public class ClinicalAnalysis extends PrivateStudyUid { +public class ClinicalAnalysis extends Annotable { /** * ClinicalAnalysis ID is a mandatory parameter when creating a new ClinicalAnalysis, this ID cannot be changed at the moment. @@ -116,14 +117,22 @@ public class ClinicalAnalysis extends PrivateStudyUid { description = FieldConstants.CLINICAL_ANALYSIS_CONSENT) private ClinicalConsentAnnotation consent; - @DataField(id = "analyst", indexed = true, + @DataField(id = "analysts", indexed = true, description = FieldConstants.CLINICAL_ANALYSIS_ANALYST) - private ClinicalAnalyst analyst; + private List analysts; @DataField(id = "report", indexed = true, description = FieldConstants.CLINICAL_ANALYSIS_REPORT) private ClinicalReport report; + @DataField(id = "request", since = "2.12.0", + description = FieldConstants.CLINICAL_ANALYSIS_REPORT) + private ClinicalRequest request; + + @DataField(id = "responsible", since = "2.12.0", + description = FieldConstants.CLINICAL_ANALYSIS_RESPONSIBLE) + private ClinicalResponsible responsible; + @DataField(id = "priority", indexed = true, description = FieldConstants.CLINICAL_ANALYSIS_PRIORITY) private ClinicalPriorityAnnotation priority; @@ -208,10 +217,11 @@ public ClinicalAnalysis() { public ClinicalAnalysis(String id, String description, Type type, Disorder disorder, List files, Individual proband, Family family, List panels, boolean panelLock, boolean locked, Interpretation interpretation, - List secondaryInterpretations, ClinicalConsentAnnotation consent, ClinicalAnalyst analyst, - ClinicalReport report, ClinicalPriorityAnnotation priority, List flags, String creationDate, - String modificationDate, String dueDate, int release, List comments, - ClinicalAnalysisQualityControl qualityControl, List audit, ClinicalAnalysisInternal internal, + List secondaryInterpretations, ClinicalConsentAnnotation consent, + List analysts, ClinicalReport report, ClinicalRequest request, ClinicalResponsible responsible, + ClinicalPriorityAnnotation priority, List flags, String creationDate, String modificationDate, + String dueDate, int release, List comments, ClinicalAnalysisQualityControl qualityControl, + List audit, ClinicalAnalysisInternal internal, List annotationSets, Map attributes, Status status) { this.id = id; this.description = description; @@ -226,8 +236,10 @@ public ClinicalAnalysis(String id, String description, Type type, Disorder disor this.interpretation = interpretation; this.secondaryInterpretations = secondaryInterpretations; this.consent = consent; - this.analyst = analyst; + this.analysts = analysts; this.report = report; + this.request = request; + this.responsible = responsible; this.priority = priority; this.flags = flags; this.creationDate = creationDate; @@ -238,6 +250,7 @@ public ClinicalAnalysis(String id, String description, Type type, Disorder disor this.comments = comments; this.audit = audit; this.internal = internal; + this.annotationSets = annotationSets; this.attributes = attributes; this.status = status; } @@ -259,8 +272,10 @@ public String toString() { sb.append(", interpretation=").append(interpretation); sb.append(", secondaryInterpretations=").append(secondaryInterpretations); sb.append(", consent=").append(consent); - sb.append(", analyst=").append(analyst); + sb.append(", analysts=").append(analysts); sb.append(", report=").append(report); + sb.append(", request=").append(request); + sb.append(", responsible=").append(responsible); sb.append(", priority=").append(priority); sb.append(", flags=").append(flags); sb.append(", creationDate='").append(creationDate).append('\''); @@ -406,12 +421,12 @@ public ClinicalAnalysis setConsent(ClinicalConsentAnnotation consent) { return this; } - public ClinicalAnalyst getAnalyst() { - return analyst; + public List getAnalysts() { + return analysts; } - public ClinicalAnalysis setAnalyst(ClinicalAnalyst analyst) { - this.analyst = analyst; + public ClinicalAnalysis setAnalysts(List analysts) { + this.analysts = analysts; return this; } @@ -424,6 +439,24 @@ public ClinicalAnalysis setReport(ClinicalReport report) { return this; } + public ClinicalRequest getRequest() { + return request; + } + + public ClinicalAnalysis setRequest(ClinicalRequest request) { + this.request = request; + return this; + } + + public ClinicalResponsible getResponsible() { + return responsible; + } + + public ClinicalAnalysis setResponsible(ClinicalResponsible responsible) { + this.responsible = responsible; + return this; + } + public ClinicalPriorityAnnotation getPriority() { return priority; } @@ -514,6 +547,12 @@ public ClinicalAnalysis setInternal(ClinicalAnalysisInternal internal) { return this; } + @Override + public ClinicalAnalysis setAnnotationSets(List annotationSets) { + super.setAnnotationSets(annotationSets); + return this; + } + public Map getAttributes() { return attributes; } diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisCreateParams.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisCreateParams.java index cd0d5243f7b..ee4ab6d703b 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisCreateParams.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisCreateParams.java @@ -17,7 +17,7 @@ package org.opencb.opencga.core.models.clinical; import org.opencb.biodata.models.clinical.ClinicalAnalyst; -import org.opencb.opencga.core.common.TimeUtils; +import org.opencb.opencga.core.models.common.AnnotationSet; import org.opencb.opencga.core.models.common.StatusParam; import org.opencb.opencga.core.models.family.Family; import org.opencb.opencga.core.models.file.File; @@ -47,8 +47,10 @@ public class ClinicalAnalysisCreateParams { private List panels; private Boolean panelLock; - private ClinicalAnalystParam analyst; + private List analysts; private ClinicalReport report; + private ClinicalRequest request; + private ClinicalResponsible responsible; private InterpretationCreateParams interpretation; private ClinicalAnalysisQualityControlUpdateParam qualityControl; @@ -61,6 +63,7 @@ public class ClinicalAnalysisCreateParams { private PriorityParam priority; private List flags; + private List annotationSets; private Map attributes; private StatusParam status; @@ -69,12 +72,13 @@ public ClinicalAnalysisCreateParams() { public ClinicalAnalysisCreateParams(String id, String description, ClinicalAnalysis.Type type, DisorderReferenceParam disorder, List files, ProbandParam proband, FamilyParam family, - List panels, Boolean panelLock, ClinicalAnalystParam analyst, - ClinicalReport report, InterpretationCreateParams interpretation, - ClinicalConsentAnnotationParam consent, String creationDate, String modificationDate, - String dueDate, List comments, + List panels, Boolean panelLock, List analysts, + ClinicalReport report, ClinicalRequest request, ClinicalResponsible responsible, + InterpretationCreateParams interpretation, ClinicalConsentAnnotationParam consent, + String creationDate, String modificationDate, String dueDate, List comments, ClinicalAnalysisQualityControlUpdateParam qualityControl, PriorityParam priority, - List flags, Map attributes, StatusParam status) { + List flags, List annotationSets, Map attributes, + StatusParam status) { this.id = id; this.description = description; this.type = type; @@ -85,7 +89,9 @@ public ClinicalAnalysisCreateParams(String id, String description, ClinicalAnaly this.panels = panels; this.panelLock = panelLock; this.report = report; - this.analyst = analyst; + this.request = request; + this.responsible = responsible; + this.analysts = analysts; this.interpretation = interpretation; this.consent = consent; this.creationDate = creationDate; @@ -95,6 +101,7 @@ public ClinicalAnalysisCreateParams(String id, String description, ClinicalAnaly this.qualityControl = qualityControl; this.priority = priority; this.flags = flags; + this.annotationSets = annotationSets; this.attributes = attributes; this.status = status; } @@ -111,8 +118,10 @@ public static ClinicalAnalysisCreateParams of(ClinicalAnalysis clinicalAnalysis) ? clinicalAnalysis.getPanels().stream().map(p -> new PanelReferenceParam(p.getId())).collect(Collectors.toList()) : null, clinicalAnalysis.isPanelLock(), - clinicalAnalysis.getAnalyst() != null ? ClinicalAnalystParam.of(clinicalAnalysis.getAnalyst()) : null, - clinicalAnalysis.getReport(), + clinicalAnalysis.getAnalysts() != null + ? clinicalAnalysis.getAnalysts().stream().map(ClinicalAnalystParam::of).collect(Collectors.toList()) + : null, + clinicalAnalysis.getReport(), clinicalAnalysis.getRequest(), clinicalAnalysis.getResponsible(), clinicalAnalysis.getInterpretation() != null ? InterpretationCreateParams.of(clinicalAnalysis.getInterpretation()) : null, @@ -128,6 +137,7 @@ public static ClinicalAnalysisCreateParams of(ClinicalAnalysis clinicalAnalysis) clinicalAnalysis.getFlags() != null ? clinicalAnalysis.getFlags().stream().map(FlagValueParam::of).collect(Collectors.toList()) : null, + clinicalAnalysis.getAnnotationSets(), clinicalAnalysis.getAttributes(), StatusParam.of(clinicalAnalysis.getStatus())); } @@ -143,8 +153,10 @@ public String toString() { sb.append(", family=").append(family); sb.append(", panels=").append(panels); sb.append(", panelLock=").append(panelLock); - sb.append(", analyst=").append(analyst); + sb.append(", analysts=").append(analysts); sb.append(", report=").append(report); + sb.append(", request=").append(request); + sb.append(", responsible=").append(responsible); sb.append(", interpretation=").append(interpretation); sb.append(", qualityControl=").append(qualityControl); sb.append(", consent=").append(consent); @@ -154,6 +166,7 @@ public String toString() { sb.append(", comments=").append(comments); sb.append(", priority=").append(priority); sb.append(", flags=").append(flags); + sb.append(", annotationSets=").append(annotationSets); sb.append(", attributes=").append(attributes); sb.append(", status=").append(status); sb.append('}'); @@ -192,7 +205,13 @@ public ClinicalAnalysis toClinicalAnalysis() { Interpretation primaryInterpretation = interpretation != null ? interpretation.toClinicalInterpretation() : null; - String assignee = analyst != null ? analyst.getId() : ""; + List clinicalAnalystList = null; + if (analysts != null) { + clinicalAnalystList = new ArrayList<>(analysts.size()); + for (ClinicalAnalystParam analyst : analysts) { + clinicalAnalystList.add(new ClinicalAnalyst(analyst.getId(), analyst.getId(), "", "", Collections.emptyMap())); + } + } List caFiles = new LinkedList<>(); if (files != null) { @@ -211,12 +230,12 @@ public ClinicalAnalysis toClinicalAnalysis() { return new ClinicalAnalysis(id, description, type, disorder != null ? disorder.toDisorder() : null, caFiles, individual, f, diseasePanelList, panelLock != null ? panelLock : false, false, primaryInterpretation, new LinkedList<>(), consent != null ? consent.toClinicalConsentAnnotation() : null, - new ClinicalAnalyst(assignee, assignee, "", "", TimeUtils.getTime()), report, - priority != null ? priority.toClinicalPriorityAnnotation() : null, + clinicalAnalystList, report, request, responsible, priority != null ? priority.toClinicalPriorityAnnotation() : null, flags != null ? flags.stream().map(FlagValueParam::toFlagAnnotation).collect(Collectors.toList()) : null, creationDate, modificationDate, dueDate, 1, - comments != null ? comments.stream().map(ClinicalCommentParam::toClinicalComment).collect(Collectors.toList()) : null, qualityControl != null ? qualityControl.toClinicalQualityControl() : null, new LinkedList<>(), null, - attributes, status != null ? status.toStatus() : null); + comments != null ? comments.stream().map(ClinicalCommentParam::toClinicalComment).collect(Collectors.toList()) : null, + qualityControl != null ? qualityControl.toClinicalQualityControl() : null, new LinkedList<>(), null, + annotationSets, attributes, status != null ? status.toStatus() : null); } public String getId() { @@ -300,12 +319,12 @@ public ClinicalAnalysisCreateParams setPanelLock(Boolean panelLock) { return this; } - public ClinicalAnalystParam getAnalyst() { - return analyst; + public List getAnalysts() { + return analysts; } - public ClinicalAnalysisCreateParams setAnalyst(ClinicalAnalystParam analyst) { - this.analyst = analyst; + public ClinicalAnalysisCreateParams setAnalysts(List analysts) { + this.analysts = analysts; return this; } @@ -318,6 +337,24 @@ public ClinicalAnalysisCreateParams setReport(ClinicalReport report) { return this; } + public ClinicalRequest getRequest() { + return request; + } + + public ClinicalAnalysisCreateParams setRequest(ClinicalRequest request) { + this.request = request; + return this; + } + + public ClinicalResponsible getResponsible() { + return responsible; + } + + public ClinicalAnalysisCreateParams setResponsible(ClinicalResponsible responsible) { + this.responsible = responsible; + return this; + } + public InterpretationCreateParams getInterpretation() { return interpretation; } @@ -399,6 +436,15 @@ public ClinicalAnalysisCreateParams setFlags(List flags) { return this; } + public List getAnnotationSets() { + return annotationSets; + } + + public ClinicalAnalysisCreateParams setAnnotationSets(List annotationSets) { + this.annotationSets = annotationSets; + return this; + } + public Map getAttributes() { return attributes; } diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisPermissions.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisPermissions.java index af45797dbf2..e0cdfadd0c0 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisPermissions.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisPermissions.java @@ -6,7 +6,10 @@ public enum ClinicalAnalysisPermissions { NONE(Collections.emptyList()), VIEW(Collections.emptyList()), WRITE(Collections.singletonList(VIEW)), - DELETE(Arrays.asList(VIEW, WRITE)); + DELETE(Arrays.asList(VIEW, WRITE)), + VIEW_ANNOTATIONS(Collections.singletonList(VIEW)), + WRITE_ANNOTATIONS(Arrays.asList(VIEW_ANNOTATIONS, VIEW)), + DELETE_ANNOTATIONS(Arrays.asList(VIEW_ANNOTATIONS, WRITE_ANNOTATIONS, VIEW)); private final List implicitPermissions; diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisQualityControlUpdateParam.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisQualityControlUpdateParam.java index d2634228641..98e957bc234 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisQualityControlUpdateParam.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisQualityControlUpdateParam.java @@ -49,6 +49,7 @@ public String toString() { final StringBuilder sb = new StringBuilder("ClinicalAnalysisQualityControlUpdateParam{"); sb.append("summary=").append(summary); sb.append(", comments=").append(comments); + sb.append(", files=").append(files); sb.append('}'); return sb.toString(); } @@ -61,4 +62,22 @@ public ClinicalAnalysisQualityControlUpdateParam setSummary(ClinicalAnalysisQual this.summary = summary; return this; } + + public List getComments() { + return comments; + } + + public ClinicalAnalysisQualityControlUpdateParam setComments(List comments) { + this.comments = comments; + return this; + } + + public List getFiles() { + return files; + } + + public ClinicalAnalysisQualityControlUpdateParam setFiles(List files) { + this.files = files; + return this; + } } diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisUpdateParams.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisUpdateParams.java index a30f469e7a6..b32711af25b 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisUpdateParams.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalysisUpdateParams.java @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.core.JsonProcessingException; import org.opencb.commons.datastore.core.ObjectMap; +import org.opencb.opencga.core.models.common.AnnotationSet; import org.opencb.opencga.core.models.common.StatusParam; import org.opencb.opencga.core.models.file.FileReferenceParam; import org.opencb.opencga.core.models.panel.Panel; @@ -47,9 +48,10 @@ public class ClinicalAnalysisUpdateParams { private FamilyParam family; private Boolean locked; - private ClinicalAnalystParam analyst; + private List analysts; private ClinicalReport report; - + private ClinicalRequest request; + private ClinicalResponsible responsible; private ClinicalAnalysisQualityControlUpdateParam qualityControl; @@ -62,6 +64,7 @@ public class ClinicalAnalysisUpdateParams { private PriorityParam priority; // id private List flags; // id + private List annotationSets; private Map attributes; private StatusParam status; @@ -70,11 +73,13 @@ public ClinicalAnalysisUpdateParams() { public ClinicalAnalysisUpdateParams(String id, String description, ClinicalAnalysis.Type type, DisorderReferenceParam disorder, List files, ProbandParam proband, FamilyParam family, - List panels, Boolean panelLock, Boolean locked, ClinicalAnalystParam analyst, - ClinicalReport report, ClinicalAnalysisQualityControlUpdateParam qualityControl, + List panels, Boolean panelLock, Boolean locked, + List analysts, ClinicalReport report, ClinicalRequest request, + ClinicalResponsible responsible, ClinicalAnalysisQualityControlUpdateParam qualityControl, ClinicalConsentAnnotationParam consent, String creationDate, String modificationDate, String dueDate, List comments, PriorityParam priority, - List flags, Map attributes, StatusParam status) { + List flags, List annotationSets, Map attributes, + StatusParam status) { this.id = id; this.description = description; this.type = type; @@ -85,8 +90,10 @@ public ClinicalAnalysisUpdateParams(String id, String description, ClinicalAnaly this.panels = panels; this.panelLock = panelLock; this.locked = locked; - this.analyst = analyst; + this.analysts = analysts; this.report = report; + this.request = request; + this.responsible = responsible; this.qualityControl = qualityControl; this.consent = consent; this.creationDate = creationDate; @@ -95,6 +102,7 @@ public ClinicalAnalysisUpdateParams(String id, String description, ClinicalAnaly this.comments = comments; this.priority = priority; this.flags = flags; + this.annotationSets = annotationSets; this.attributes = attributes; this.status = status; } @@ -115,12 +123,16 @@ public ClinicalAnalysis toClinicalAnalysis() { locked != null && locked, null, null, consent != null ? consent.toClinicalConsentAnnotation() : null, - analyst != null ? analyst.toClinicalAnalyst() : null, report, + analysts != null + ? analysts.stream().map(ClinicalAnalystParam::toClinicalAnalyst).collect(Collectors.toList()) + : null, + report, request, responsible, priority != null ? priority.toClinicalPriorityAnnotation() : null, flags != null ? flags.stream().map(FlagValueParam::toFlagAnnotation).collect(Collectors.toList()) : null, creationDate, modificationDate, dueDate, 1, comments != null ? comments.stream().map(ClinicalCommentParam::toClinicalComment).collect(Collectors.toList()) : null, - qualityControl != null ? qualityControl.toClinicalQualityControl() : null, null, null, attributes, status != null ? status.toStatus() : null); + qualityControl != null ? qualityControl.toClinicalQualityControl() : null, null, null, annotationSets, attributes, + status != null ? status.toStatus() : null); } @Override @@ -136,8 +148,10 @@ public String toString() { sb.append(", proband=").append(proband); sb.append(", family=").append(family); sb.append(", locked=").append(locked); - sb.append(", analyst=").append(analyst); + sb.append(", analysts=").append(analysts); sb.append(", report=").append(report); + sb.append(", request=").append(request); + sb.append(", responsible=").append(responsible); sb.append(", qualityControl=").append(qualityControl); sb.append(", consent=").append(consent); sb.append(", creationDate='").append(creationDate).append('\''); @@ -146,6 +160,7 @@ public String toString() { sb.append(", comments=").append(comments); sb.append(", priority=").append(priority); sb.append(", flags=").append(flags); + sb.append(", annotationSets=").append(annotationSets); sb.append(", attributes=").append(attributes); sb.append(", status=").append(status); sb.append('}'); @@ -242,12 +257,12 @@ public ClinicalAnalysisUpdateParams setLocked(Boolean locked) { return this; } - public ClinicalAnalystParam getAnalyst() { - return analyst; + public List getAnalysts() { + return analysts; } - public ClinicalAnalysisUpdateParams setAnalyst(ClinicalAnalystParam analyst) { - this.analyst = analyst; + public ClinicalAnalysisUpdateParams setAnalysts(List analysts) { + this.analysts = analysts; return this; } @@ -323,6 +338,15 @@ public ClinicalAnalysisUpdateParams setFlags(List flags) { return this; } + public List getAnnotationSets() { + return annotationSets; + } + + public ClinicalAnalysisUpdateParams setAnnotationSets(List annotationSets) { + this.annotationSets = annotationSets; + return this; + } + public Map getAttributes() { return attributes; } @@ -350,4 +374,21 @@ public ClinicalAnalysisUpdateParams setReport(ClinicalReport report) { return this; } + public ClinicalRequest getRequest() { + return request; + } + + public ClinicalAnalysisUpdateParams setRequest(ClinicalRequest request) { + this.request = request; + return this; + } + + public ClinicalResponsible getResponsible() { + return responsible; + } + + public ClinicalAnalysisUpdateParams setResponsible(ClinicalResponsible responsible) { + this.responsible = responsible; + return this; + } } diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalystParam.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalystParam.java index 91861b29d0b..ad3a3cd13f7 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalystParam.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalAnalystParam.java @@ -1,7 +1,8 @@ package org.opencb.opencga.core.models.clinical; import org.opencb.biodata.models.clinical.ClinicalAnalyst; -import org.opencb.opencga.core.common.TimeUtils; + +import java.util.Collections; public class ClinicalAnalystParam { @@ -23,7 +24,7 @@ public static ClinicalAnalystParam of(ClinicalAnalyst clinicalAnalyst) { } public ClinicalAnalyst toClinicalAnalyst() { - return new ClinicalAnalyst(id != null ? id : "", "", "", "", TimeUtils.getTime()); + return new ClinicalAnalyst(id != null ? id : "", "", "", "", Collections.emptyMap()); } @Override diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalReport.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalReport.java index 8303fdc7a1b..fca6fd5c418 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalReport.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalReport.java @@ -1,8 +1,12 @@ package org.opencb.opencga.core.models.clinical; +import org.opencb.biodata.models.clinical.ClinicalComment; import org.opencb.biodata.models.clinical.ClinicalDiscussion; import org.opencb.commons.annotations.DataField; import org.opencb.opencga.core.api.FieldConstants; +import org.opencb.opencga.core.models.file.File; + +import java.util.List; public class ClinicalReport { @@ -34,11 +38,20 @@ public class ClinicalReport { description = FieldConstants.CLINICAL_REPORT_DATE) private String date; + @DataField(id = "comments", description = FieldConstants.CLINICAL_REPORT_COMMENTS, since = "2.12.0") + private List comments; + + @DataField(id = "supportingEvidences", description = FieldConstants.CLINICAL_REPORT_SUPPORTING_EVIDENCES, since = "2.12.0") + private List supportingEvidences; + + @DataField(id = "files", description = FieldConstants.CLINICAL_REPORT_FILES, since = "2.12.0") + private List files; + public ClinicalReport() { } - public ClinicalReport(String title, String overview, ClinicalDiscussion discussion, String logo, String signedBy, - String signature, String date) { + public ClinicalReport(String title, String overview, ClinicalDiscussion discussion, String logo, String signedBy, String signature, + String date, List comments, List supportingEvidences, List files) { this.title = title; this.overview = overview; this.discussion = discussion; @@ -46,6 +59,9 @@ public ClinicalReport(String title, String overview, ClinicalDiscussion discussi this.signedBy = signedBy; this.signature = signature; this.date = date; + this.comments = comments; + this.supportingEvidences = supportingEvidences; + this.files = files; } @Override @@ -53,11 +69,14 @@ public String toString() { final StringBuilder sb = new StringBuilder("ClinicalReport{"); sb.append("title='").append(title).append('\''); sb.append(", overview='").append(overview).append('\''); - sb.append(", discussion='").append(discussion).append('\''); + sb.append(", discussion=").append(discussion); sb.append(", logo='").append(logo).append('\''); sb.append(", signedBy='").append(signedBy).append('\''); sb.append(", signature='").append(signature).append('\''); sb.append(", date='").append(date).append('\''); + sb.append(", comments=").append(comments); + sb.append(", supportingEvidences=").append(supportingEvidences); + sb.append(", files=").append(files); sb.append('}'); return sb.toString(); } @@ -124,4 +143,31 @@ public ClinicalReport setDate(String date) { this.date = date; return this; } + + public List getComments() { + return comments; + } + + public ClinicalReport setComments(List comments) { + this.comments = comments; + return this; + } + + public List getSupportingEvidences() { + return supportingEvidences; + } + + public ClinicalReport setSupportingEvidences(List supportingEvidences) { + this.supportingEvidences = supportingEvidences; + return this; + } + + public List getFiles() { + return files; + } + + public ClinicalReport setFiles(List files) { + this.files = files; + return this; + } } diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalRequest.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalRequest.java new file mode 100644 index 00000000000..38998b4bb0d --- /dev/null +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalRequest.java @@ -0,0 +1,80 @@ +package org.opencb.opencga.core.models.clinical; + +import java.util.Map; + +public class ClinicalRequest { + + private String id; + private String justification; + private String date; + private ClinicalResponsible responsible; + private Map attributes; + + public ClinicalRequest() { + } + + public ClinicalRequest(String id, String justification, String date, ClinicalResponsible responsible, Map attributes) { + this.id = id; + this.justification = justification; + this.date = date; + this.responsible = responsible; + this.attributes = attributes; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("ClinicalRequest{"); + sb.append("id='").append(id).append('\''); + sb.append(", justification='").append(justification).append('\''); + sb.append(", date='").append(date).append('\''); + sb.append(", responsible=").append(responsible); + sb.append(", attributes=").append(attributes); + sb.append('}'); + return sb.toString(); + } + + public String getId() { + return id; + } + + public ClinicalRequest setId(String id) { + this.id = id; + return this; + } + + public String getJustification() { + return justification; + } + + public ClinicalRequest setJustification(String justification) { + this.justification = justification; + return this; + } + + public String getDate() { + return date; + } + + public ClinicalRequest setDate(String date) { + this.date = date; + return this; + } + + public ClinicalResponsible getResponsible() { + return responsible; + } + + public ClinicalRequest setResponsible(ClinicalResponsible responsible) { + this.responsible = responsible; + return this; + } + + public Map getAttributes() { + return attributes; + } + + public ClinicalRequest setAttributes(Map attributes) { + this.attributes = attributes; + return this; + } +} diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalResponsible.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalResponsible.java new file mode 100644 index 00000000000..3e8967b552a --- /dev/null +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/clinical/ClinicalResponsible.java @@ -0,0 +1,115 @@ +package org.opencb.opencga.core.models.clinical; + +public class ClinicalResponsible { + + private String id; + private String name; + private String email; + private String organization; + private String department; + private String address; + private String city; + private String postcode; + + public ClinicalResponsible() { + } + + public ClinicalResponsible(String id, String name, String email, String organization, String department, String address, String city, + String postcode) { + this.id = id; + this.name = name; + this.email = email; + this.organization = organization; + this.department = department; + this.address = address; + this.city = city; + this.postcode = postcode; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("ClinicalResponsible{"); + sb.append("id='").append(id).append('\''); + sb.append(", name='").append(name).append('\''); + sb.append(", email='").append(email).append('\''); + sb.append(", organization='").append(organization).append('\''); + sb.append(", department='").append(department).append('\''); + sb.append(", address='").append(address).append('\''); + sb.append(", city='").append(city).append('\''); + sb.append(", postcode='").append(postcode).append('\''); + sb.append('}'); + return sb.toString(); + } + + public String getId() { + return id; + } + + public ClinicalResponsible setId(String id) { + this.id = id; + return this; + } + + public String getName() { + return name; + } + + public ClinicalResponsible setName(String name) { + this.name = name; + return this; + } + + public String getEmail() { + return email; + } + + public ClinicalResponsible setEmail(String email) { + this.email = email; + return this; + } + + public String getOrganization() { + return organization; + } + + public ClinicalResponsible setOrganization(String organization) { + this.organization = organization; + return this; + } + + public String getDepartment() { + return department; + } + + public ClinicalResponsible setDepartment(String department) { + this.department = department; + return this; + } + + public String getAddress() { + return address; + } + + public ClinicalResponsible setAddress(String address) { + this.address = address; + return this; + } + + public String getCity() { + return city; + } + + public ClinicalResponsible setCity(String city) { + this.city = city; + return this; + } + + public String getPostcode() { + return postcode; + } + + public ClinicalResponsible setPostcode(String postcode) { + this.postcode = postcode; + return this; + } +} diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/file/File.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/file/File.java index 28a2a05980f..581cc6d6dd1 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/file/File.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/file/File.java @@ -562,6 +562,7 @@ public enum Format { TAB_SEPARATED_VALUES, COMMA_SEPARATED_VALUES, XML, PROTOCOL_BUFFER, JSON, AVRO, PARQUET, //Serialization formats + PDF, IMAGE, PLAIN, BINARY, diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/file/FileStatus.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/file/FileStatus.java index 04ee6363d47..e35f463b9c6 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/file/FileStatus.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/file/FileStatus.java @@ -33,9 +33,10 @@ public class FileStatus extends InternalStatus { public static final String DELETING = "DELETING"; // This status is set exactly before deleting the file from disk. public static final String REMOVED = "REMOVED"; public static final String MISSING_SAMPLES = "MISSING_SAMPLES"; + public static final String ERROR = "ERROR"; public static final List STATUS_LIST = Arrays.asList(READY, DELETED, TRASHED, STAGE, MISSING, PENDING_DELETE, DELETING, - REMOVED, MISSING_SAMPLES); + REMOVED, MISSING_SAMPLES, ERROR); public FileStatus(String status, String message) { if (isValid(status)) { @@ -59,7 +60,7 @@ public static boolean isValid(String status) { } if (status != null && (status.equals(STAGE) || status.equals(MISSING) || status.equals(TRASHED) || status.equals(PENDING_DELETE) || status.equals(DELETING) || status.equals(REMOVED) - || status.equals(MISSING_SAMPLES))) { + || status.equals(MISSING_SAMPLES) || status.equals(ERROR))) { return true; } return false; diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/study/StudyPermissions.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/study/StudyPermissions.java index 3eefb1a5c63..059af8182ab 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/study/StudyPermissions.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/study/StudyPermissions.java @@ -103,7 +103,13 @@ public enum Permissions { WRITE_CLINICAL_ANALYSIS(Collections.singletonList(VIEW_CLINICAL_ANALYSIS), ClinicalAnalysisPermissions.WRITE.name(), CLINICAL_ANALYSIS), DELETE_CLINICAL_ANALYSIS(Arrays.asList(VIEW_CLINICAL_ANALYSIS, WRITE_CLINICAL_ANALYSIS), - ClinicalAnalysisPermissions.DELETE.name(), CLINICAL_ANALYSIS); + ClinicalAnalysisPermissions.DELETE.name(), CLINICAL_ANALYSIS), + VIEW_CLINICAL_ANNOTATIONS(Collections.singletonList(VIEW_CLINICAL_ANALYSIS), ClinicalAnalysisPermissions.VIEW_ANNOTATIONS.name(), + CLINICAL_ANALYSIS), + WRITE_CLINICAL_ANNOTATIONS(Arrays.asList(VIEW_CLINICAL_ANALYSIS, VIEW_CLINICAL_ANNOTATIONS), + ClinicalAnalysisPermissions.WRITE_ANNOTATIONS.name(), CLINICAL_ANALYSIS), + DELETE_CLINICAL_ANNOTATIONS(Arrays.asList(VIEW_CLINICAL_ANALYSIS, VIEW_CLINICAL_ANNOTATIONS, WRITE_CLINICAL_ANNOTATIONS), + ClinicalAnalysisPermissions.DELETE_ANNOTATIONS.name(), CLINICAL_ANALYSIS); private final static Map map; diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/study/VariableSet.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/study/VariableSet.java index 7ffdb8a460c..c2ac1f3ba43 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/study/VariableSet.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/study/VariableSet.java @@ -45,7 +45,8 @@ public enum AnnotableDataModels { COHORT, INDIVIDUAL, FAMILY, - FILE + FILE, + CLINICAL_ANALYSIS } public VariableSet() { diff --git a/opencga-master/src/main/java/org/opencb/opencga/master/monitor/daemons/ExecutionDaemon.java b/opencga-master/src/main/java/org/opencb/opencga/master/monitor/daemons/ExecutionDaemon.java index e7920c53303..5ab2fee0840 100644 --- a/opencga-master/src/main/java/org/opencb/opencga/master/monitor/daemons/ExecutionDaemon.java +++ b/opencga-master/src/main/java/org/opencb/opencga/master/monitor/daemons/ExecutionDaemon.java @@ -26,6 +26,7 @@ import org.opencb.commons.datastore.core.ObjectMap; import org.opencb.commons.datastore.core.Query; import org.opencb.commons.datastore.core.QueryOptions; +import org.opencb.opencga.analysis.clinical.ClinicalTsvAnnotationLoader; import org.opencb.opencga.analysis.clinical.exomiser.ExomiserInterpretationAnalysis; import org.opencb.opencga.analysis.clinical.rga.AuxiliarRgaAnalysis; import org.opencb.opencga.analysis.clinical.rga.RgaAnalysis; @@ -242,6 +243,7 @@ public class ExecutionDaemon extends MonitorParentDaemon { put(RgaAnalysis.ID, "clinical " + RgaAnalysis.ID + "-run"); put(AuxiliarRgaAnalysis.ID, "clinical " + AuxiliarRgaAnalysis.ID + "-run"); + put(ClinicalTsvAnnotationLoader.ID, "clinical tsv-load"); put(JulieTool.ID, "variant julie-run"); @@ -986,7 +988,7 @@ private int processFinishedJob(Job job, Enums.ExecutionStatus status) { registeredFiles = fileManager.syncUntrackedFiles(job.getStudy().getId(), job.getOutDir().getPath(), uriPredicate, job.getId(), token).getResults(); } catch (CatalogException e) { - logger.error("Could not registered files in Catalog: {}", e.getMessage(), e); + logger.error("Could not register files in Catalog: {}", e.getMessage(), e); return 0; } diff --git a/opencga-master/src/test/java/org/opencb/opencga/master/monitor/daemons/ExecutionDaemonTest.java b/opencga-master/src/test/java/org/opencb/opencga/master/monitor/daemons/ExecutionDaemonTest.java index e04aee848ae..2251f2b5b09 100644 --- a/opencga-master/src/test/java/org/opencb/opencga/master/monitor/daemons/ExecutionDaemonTest.java +++ b/opencga-master/src/test/java/org/opencb/opencga/master/monitor/daemons/ExecutionDaemonTest.java @@ -37,7 +37,9 @@ import org.opencb.opencga.core.exceptions.ToolException; import org.opencb.opencga.core.models.AclParams; import org.opencb.opencga.core.models.common.Enums; +import org.opencb.opencga.core.models.file.File; import org.opencb.opencga.core.models.file.FileContent; +import org.opencb.opencga.core.models.file.FileStatus; import org.opencb.opencga.core.models.job.Job; import org.opencb.opencga.core.models.job.JobInternal; import org.opencb.opencga.core.models.job.JobInternalWebhook; @@ -52,6 +54,7 @@ import org.opencb.opencga.master.monitor.models.PrivateJobUpdateParams; import java.io.ByteArrayInputStream; +import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.net.URL; @@ -538,6 +541,34 @@ public void testRunJobFailMissingExecutionResult() throws Exception { assertEquals("Job could not finish successfully. Missing execution result", getJob(jobId).getInternal().getStatus().getDescription()); } + @Test + public void registerMalformedVcfFromExecutedJobTest() throws CatalogException { + HashMap params = new HashMap<>(); + params.put(ExecutionDaemon.OUTDIR_PARAM, "outputDir/"); + Job job = catalogManager.getJobManager().submit(studyFqn, "variant-index", Enums.Priority.MEDIUM, params, token).first(); + String jobId = job.getId(); + + daemon.checkJobs(); + job = catalogManager.getJobManager().get(studyFqn, jobId, QueryOptions.empty(), token).first(); + executor.jobStatus.put(jobId, Enums.ExecutionStatus.READY); + try { + // Create an empty VCF file (this will fail because OpenCGA will not be able to parse it) + Path vcffile = Paths.get(job.getOutDir().getUri()).resolve("myemptyvcf.vcf"); + Files.createFile(vcffile); + } catch (IOException e) { + throw new RuntimeException(e); + } + + daemon.checkJobs(); + + // Check the file has been properly registered + job = catalogManager.getJobManager().get(studyFqn, jobId, QueryOptions.empty(), token).first(); + assertEquals(1, job.getOutput().size()); + assertEquals("myemptyvcf.vcf", job.getOutput().get(0).getName()); + assertEquals(File.Format.VCF, job.getOutput().get(0).getFormat()); + assertEquals(FileStatus.ERROR, job.getOutput().get(0).getInternal().getStatus().getId()); + } + private void checkStatus(Job job, String status) { assertEquals(status, job.getInternal().getStatus().getId()); assertEquals(status, job.getInternal().getStatus().getName()); diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/generator/writers/ParentClientRestApiWriter.java b/opencga-server/src/main/java/org/opencb/opencga/server/generator/writers/ParentClientRestApiWriter.java index 86f1bcda615..99bcf162548 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/generator/writers/ParentClientRestApiWriter.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/generator/writers/ParentClientRestApiWriter.java @@ -84,11 +84,15 @@ protected static String reverseCommandName(String commandName) { return commandName.toLowerCase(); } + public String getCategoryRestName(RestCategory restCategory, CategoryConfig categoryConfig) { + return restCategory.getPath().substring(restCategory.getPath().lastIndexOf("/") + 1); + } + public String getCategoryCommandName(RestCategory restCategory, CategoryConfig categoryConfig) { if (!StringUtils.isEmpty(categoryConfig.getCommandName())) { return categoryConfig.getCommandName(); } - return restCategory.getPath().substring(restCategory.getPath().lastIndexOf("/") + 1); + return getCategoryRestName(restCategory, categoryConfig); } protected void writeToFile(File file, StringBuffer sb) throws IOException { diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/generator/writers/cli/ExecutorsCliRestApiWriter.java b/opencga-server/src/main/java/org/opencb/opencga/server/generator/writers/cli/ExecutorsCliRestApiWriter.java index d0c830abd3d..8befc2876c5 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/generator/writers/cli/ExecutorsCliRestApiWriter.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/generator/writers/cli/ExecutorsCliRestApiWriter.java @@ -178,6 +178,7 @@ protected String getClassHeader(String key) { CategoryConfig config = availableCategoryConfigs.get(key); sb.append("public class " + getAsClassName(restCategory.getName()) + "CommandExecutor extends " + getExtendedClass() + " {\n\n"); + sb.append(" public String categoryName = \"" + getCategoryRestName(restCategory, config) + "\";\n"); sb.append(" public " + getCommandOptionsClassName(restCategory) + " " + getCommandOptionsVarName(restCategory) + ";\n\n"); sb.append(" public " + getAsClassName(restCategory.getName()) + "CommandExecutor(" + getAsClassName(restCategory.getName()) + "CommandOptions " + getAsVariableName(getAsCamelCase(restCategory.getName())) @@ -366,10 +367,9 @@ private String getBodyParams(RestCategory restCategory, RestEndpoint restEndpoin sb.append("\n " + bodyClassName + " " + variableName + " = null;"); sb.append("\n if (commandOptions.jsonDataModel) {"); - sb.append("\n " + variableName + " = new " + bodyClassName + "();"); sb.append("\n RestResponse<" + getValidResponseNames(restEndpoint.getResponse()) + "> res = new RestResponse<>();"); sb.append("\n res.setType(QueryType.VOID);"); - sb.append("\n PrintUtils.println(getObjectAsJSON(" + variableName + "));"); + sb.append("\n PrintUtils.println(getObjectAsJSON(categoryName,\""+restEndpoint.getPath()+"\"));"); sb.append("\n return res;"); sb.append("\n } else if (commandOptions.jsonFile != null) {"); sb.append("\n " + getAsVariableName(bodyClassName) + " = JacksonUtils.getDefaultObjectMapper()"); diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/rest/analysis/ClinicalWebService.java b/opencga-server/src/main/java/org/opencb/opencga/server/rest/analysis/ClinicalWebService.java index 7906588ad23..fdaa1e84449 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/rest/analysis/ClinicalWebService.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/rest/analysis/ClinicalWebService.java @@ -21,6 +21,7 @@ import org.opencb.biodata.models.clinical.interpretation.ClinicalVariant; import org.opencb.commons.datastore.core.*; import org.opencb.opencga.analysis.clinical.ClinicalInterpretationManager; +import org.opencb.opencga.analysis.clinical.ClinicalTsvAnnotationLoader; import org.opencb.opencga.analysis.clinical.exomiser.ExomiserInterpretationAnalysis; import org.opencb.opencga.analysis.clinical.rga.AuxiliarRgaAnalysis; import org.opencb.opencga.analysis.clinical.rga.RgaAnalysis; @@ -43,7 +44,9 @@ import org.opencb.opencga.core.models.AclParams; import org.opencb.opencga.core.models.analysis.knockout.*; import org.opencb.opencga.core.models.clinical.*; +import org.opencb.opencga.core.models.common.TsvAnnotationParams; import org.opencb.opencga.core.models.job.Job; +import org.opencb.opencga.core.models.sample.Sample; import org.opencb.opencga.core.models.study.configuration.ClinicalAnalysisStudyConfiguration; import org.opencb.opencga.core.tools.annotations.*; @@ -208,13 +211,20 @@ public Response update( @QueryParam("commentsAction") ParamUtils.AddRemoveReplaceAction commentsAction, @ApiParam(value = "Action to be performed if the array of flags is being updated.", allowableValues = "ADD,SET,REMOVE", defaultValue = "ADD") @QueryParam("flagsAction") ParamUtils.BasicUpdateAction flagsAction, + @ApiParam(value = "Action to be performed if the array of analysts is being updated.", allowableValues = "ADD,SET,REMOVE", defaultValue = "ADD") + @QueryParam("analystsAction") ParamUtils.BasicUpdateAction analystsAction, @ApiParam(value = "Action to be performed if the array of files is being updated.", allowableValues = "ADD,SET,REMOVE", defaultValue = "ADD") @QueryParam("filesAction") ParamUtils.BasicUpdateAction filesAction, @ApiParam(value = "Action to be performed if the array of panels is being updated.", allowableValues = "ADD,SET,REMOVE", defaultValue = "ADD") @QueryParam("panelsAction") ParamUtils.BasicUpdateAction panelsAction, + @ApiParam(value = "Action to be performed if the array of annotationSets is being updated.", allowableValues = "ADD,SET,REMOVE", defaultValue = "ADD") + @QueryParam("annotationSetsAction") ParamUtils.BasicUpdateAction annotationSetsAction, @ApiParam(value = ParamConstants.INCLUDE_RESULT_DESCRIPTION, defaultValue = "false") @QueryParam(ParamConstants.INCLUDE_RESULT_PARAM) boolean includeResult, @ApiParam(name = "body", value = "JSON containing clinical analysis information", required = true) ClinicalAnalysisUpdateParams params) { try { + if (annotationSetsAction == null) { + annotationSetsAction = ParamUtils.BasicUpdateAction.ADD; + } if (commentsAction == null) { commentsAction = ParamUtils.AddRemoveReplaceAction.ADD; } @@ -227,12 +237,17 @@ public Response update( if (panelsAction == null) { panelsAction = ParamUtils.BasicUpdateAction.ADD; } + if (analystsAction == null) { + analystsAction = ParamUtils.BasicUpdateAction.ADD; + } Map actionMap = new HashMap<>(); + actionMap.put(ClinicalAnalysisDBAdaptor.QueryParams.ANNOTATION_SETS.key(), annotationSetsAction); actionMap.put(ClinicalAnalysisDBAdaptor.QueryParams.COMMENTS.key(), commentsAction); actionMap.put(ClinicalAnalysisDBAdaptor.QueryParams.FLAGS.key(), flagsAction); actionMap.put(ClinicalAnalysisDBAdaptor.QueryParams.FILES.key(), filesAction); actionMap.put(ClinicalAnalysisDBAdaptor.QueryParams.PANELS.key(), panelsAction); + actionMap.put(ClinicalAnalysisDBAdaptor.QueryParams.ANALYSTS.key(), analystsAction); queryOptions.put(Constants.ACTIONS, actionMap); return createOkResponse(clinicalManager.update(studyStr, getIdList(clinicalAnalysisStr), params, true, queryOptions, token)); @@ -241,6 +256,55 @@ public Response update( } } + @POST + @Path("/annotationSets/load") + @Consumes(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Load annotation sets from a TSV file", response = Job.class) + public Response loadTsvAnnotations( + @ApiParam(value = ParamConstants.STUDY_DESCRIPTION) @QueryParam(ParamConstants.STUDY_PARAM) String studyStr, + @ApiParam(value = ParamConstants.VARIABLE_SET_DESCRIPTION, required = true) @QueryParam("variableSetId") String variableSetId, + @ApiParam(value = "Path where the TSV file is located in OpenCGA or where it should be located.", required = true) + @QueryParam("path") String path, + @ApiParam(value = "Flag indicating whether to create parent directories if they don't exist (only when TSV file was not " + + "previously associated).") + @DefaultValue("false") @QueryParam("parents") boolean parents, + @ApiParam(value = "Annotation set id. If not provided, variableSetId will be used.") @QueryParam("annotationSetId") String annotationSetId, + @ApiParam(value = ParamConstants.TSV_ANNOTATION_DESCRIPTION) TsvAnnotationParams params) { + try { + ObjectMap additionalParams = new ObjectMap() + .append("parents", parents) + .append("annotationSetId", annotationSetId); + + return createOkResponse(catalogManager.getClinicalAnalysisManager().loadTsvAnnotations(studyStr, variableSetId, path, params, + additionalParams, ClinicalTsvAnnotationLoader.ID, token)); + } catch (Exception e) { + return createErrorResponse(e); + } + } + + @POST + @Path("/{clinicalAnalysis}/annotationSets/{annotationSet}/annotations/update") + @Consumes(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Update annotations from an annotationSet", response = Sample.class) + public Response updateAnnotations( + @ApiParam(value = "Clinical analysis ID") @PathParam("clinicalAnalysis") String clinicalId, + @ApiParam(value = ParamConstants.STUDY_DESCRIPTION) @QueryParam(ParamConstants.STUDY_PARAM) String studyStr, + @ApiParam(value = ParamConstants.ANNOTATION_SET_ID) @PathParam("annotationSet") String annotationSetId, + @ApiParam(value = ParamConstants.ANNOTATION_SET_UPDATE_ACTION_DESCRIPTION, allowableValues = "ADD,SET,REMOVE,RESET,REPLACE", + defaultValue = "ADD") + @QueryParam("action") ParamUtils.CompleteUpdateAction action, + @ApiParam(value = ParamConstants.ANNOTATION_SET_UPDATE_PARAMS_DESCRIPTION) Map updateParams) { + try { + if (action == null) { + action = ParamUtils.CompleteUpdateAction.ADD; + } + return createOkResponse(catalogManager.getClinicalAnalysisManager().updateAnnotations(studyStr, clinicalId, annotationSetId, + updateParams, action, queryOptions, token)); + } catch (Exception e) { + return createErrorResponse(e); + } + } + @DELETE @Path("/{clinicalAnalyses}/delete") @ApiOperation(value = "Delete clinical analyses", response = ClinicalAnalysis.class) @@ -263,7 +327,9 @@ public Response delete( @ApiImplicitParam(name = QueryOptions.INCLUDE, value = ParamConstants.INCLUDE_DESCRIPTION, example = "name,attributes", dataType = "string", paramType = "query"), @ApiImplicitParam(name = QueryOptions.EXCLUDE, value = ParamConstants.EXCLUDE_DESCRIPTION, - example = "id,status", dataType = "string", paramType = "query") + example = "id,status", dataType = "string", paramType = "query"), + @ApiImplicitParam(name = ParamConstants.FLATTEN_ANNOTATIONS, value = "Flatten the annotations?", defaultValue = "false", + dataType = "boolean", paramType = "query") }) public Response info( @ApiParam(value = ParamConstants.CLINICAL_ANALYSES_DESCRIPTION) @PathParam(value = "clinicalAnalysis") String clinicalAnalysisStr, @@ -289,7 +355,9 @@ public Response info( @ApiImplicitParam(name = QueryOptions.EXCLUDE, value = ParamConstants.EXCLUDE_DESCRIPTION, example = "id,status", dataType = "string", paramType = "query"), @ApiImplicitParam(name = QueryOptions.LIMIT, value = ParamConstants.LIMIT_DESCRIPTION, dataType = "integer", paramType = "query"), @ApiImplicitParam(name = QueryOptions.SKIP, value = ParamConstants.SKIP_DESCRIPTION, dataType = "integer", paramType = "query"), - @ApiImplicitParam(name = QueryOptions.COUNT, value = ParamConstants.COUNT_DESCRIPTION, defaultValue = "false", dataType = "boolean", paramType = "query") + @ApiImplicitParam(name = QueryOptions.COUNT, value = ParamConstants.COUNT_DESCRIPTION, defaultValue = "false", dataType = "boolean", paramType = "query"), + @ApiImplicitParam(name = ParamConstants.FLATTEN_ANNOTATIONS, value = "Flatten the annotations?", defaultValue = "false", + dataType = "boolean", paramType = "query") }) public Response search( @ApiParam(value = ParamConstants.STUDY_DESCRIPTION) @QueryParam(ParamConstants.STUDY_PARAM) String studyStr, @@ -317,6 +385,7 @@ public Response search( @ApiParam(value = ParamConstants.CLINICAL_RELEASE_DESCRIPTION) @QueryParam(ParamConstants.CLINICAL_RELEASE_PARAM) String release, @ApiParam(value = ParamConstants.CLINICAL_STATUS_DESCRIPTION) @QueryParam(ParamConstants.CLINICAL_STATUS_PARAM) String status, @ApiParam(value = ParamConstants.CLINICAL_INTERNAL_STATUS_DESCRIPTION) @QueryParam(ParamConstants.CLINICAL_INTERNAL_STATUS_PARAM) String internalStatus, + @ApiParam(value = ParamConstants.ANNOTATION_DESCRIPTION) @QueryParam(Constants.ANNOTATION) String annotation, @ApiParam(value = ParamConstants.DELETED_DESCRIPTION) @QueryParam(ParamConstants.DELETED_PARAM) boolean deleted) { try { query.remove(ParamConstants.STUDY_PARAM); @@ -356,6 +425,7 @@ public Response distinct( @ApiParam(value = ParamConstants.CLINICAL_RELEASE_DESCRIPTION) @QueryParam(ParamConstants.CLINICAL_RELEASE_PARAM) String release, @ApiParam(value = ParamConstants.CLINICAL_STATUS_DESCRIPTION) @QueryParam(ParamConstants.CLINICAL_STATUS_PARAM) String status, @ApiParam(value = ParamConstants.CLINICAL_INTERNAL_STATUS_DESCRIPTION) @QueryParam(ParamConstants.CLINICAL_INTERNAL_STATUS_PARAM) String internalStatus, + @ApiParam(value = ParamConstants.ANNOTATION_DESCRIPTION) @QueryParam(Constants.ANNOTATION) String annotation, @ApiParam(value = ParamConstants.DELETED_DESCRIPTION) @QueryParam(ParamConstants.DELETED_PARAM) boolean deleted, @ApiParam(value = ParamConstants.DISTINCT_FIELD_DESCRIPTION, required = true) @QueryParam(ParamConstants.DISTINCT_FIELD_PARAM) String field) { try { diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/rest/analysis/VariantWebService.java b/opencga-server/src/main/java/org/opencb/opencga/server/rest/analysis/VariantWebService.java index 6ac26bbb92e..761426a0b9a 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/rest/analysis/VariantWebService.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/rest/analysis/VariantWebService.java @@ -30,6 +30,7 @@ import org.opencb.commons.annotations.DataField; import org.opencb.commons.datastore.core.*; import org.opencb.opencga.analysis.AnalysisUtils; +import org.opencb.opencga.analysis.ResourceUtils; import org.opencb.opencga.analysis.family.qc.FamilyQcAnalysis; import org.opencb.opencga.analysis.individual.qc.IndividualQcAnalysis; import org.opencb.opencga.analysis.individual.qc.IndividualQcUtils; @@ -1330,6 +1331,7 @@ public Response circos( if (!outDir.exists()) { return createErrorResponse(new Exception("Error creating temporal directory for Circos analysis")); } + Runtime.getRuntime().exec("chmod 777 " + outDir.getAbsolutePath()); // Create and set up Circos executor CircosLocalAnalysisExecutor executor = new CircosLocalAnalysisExecutor(study, params, variantManager); @@ -1361,13 +1363,13 @@ public Response circos( } else { return createErrorResponse(new Exception("Error plotting Circos graph")); } - } catch (ToolException | IOException e) { + } catch (ToolException | IOException | CatalogException e) { return createErrorResponse(e); } finally { if (outDir != null) { // Delete temporal directory try { - if (outDir.exists() && !params.getTitle().startsWith("no.delete.")) { + if (outDir.exists()) { FileUtils.deleteDirectory(outDir); } } catch (IOException e) { diff --git a/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/annotation/annotators/VariantAnnotatorTest.java b/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/annotation/annotators/VariantAnnotatorTest.java index 02b84fc38a9..ecc48098006 100644 --- a/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/annotation/annotators/VariantAnnotatorTest.java +++ b/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/annotation/annotators/VariantAnnotatorTest.java @@ -1,20 +1,19 @@ package org.opencb.opencga.storage.core.variant.annotation.annotators; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.ExpectedException; import org.opencb.biodata.models.variant.Variant; -import org.opencb.biodata.models.variant.avro.EvidenceEntry; import org.opencb.biodata.models.variant.avro.VariantAnnotation; import org.opencb.cellbase.core.result.CellBaseDataResult; import org.opencb.commons.datastore.core.ObjectMap; +import org.opencb.opencga.core.config.storage.StorageConfiguration; import org.opencb.opencga.core.testclassification.duration.ShortTests; import org.opencb.opencga.storage.core.StorageEngine; -import org.opencb.opencga.core.config.storage.StorageConfiguration; import org.opencb.opencga.storage.core.metadata.models.ProjectMetadata; import org.opencb.opencga.storage.core.variant.VariantStorageOptions; import org.opencb.opencga.storage.core.variant.annotation.VariantAnnotatorException; @@ -111,6 +110,7 @@ public void testErrorVariant() throws VariantAnnotatorException { testAnnotator.annotate(Arrays.asList(new Variant("10:999:A:C"), new Variant("10:1000:A:C"), new Variant("10:1001:A:C"))); } + @Ignore @Test public void useCellBaseApiKeys() throws VariantAnnotatorException { storageConfiguration.getCellbase().setUrl("https://uk.ws.zettagenomics.com/cellbase/"); diff --git a/pom.xml b/pom.xml index b3ac04f3d10..063b5446550 100644 --- a/pom.xml +++ b/pom.xml @@ -49,6 +49,7 @@ 2.12.1-SNAPSHOT 4.12.1-SNAPSHOT 2.12.1-SNAPSHOT + 0.2.0 2.11.4