diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/family/qc/FamilyVariantQcAnalysis.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/family/qc/FamilyVariantQcAnalysis.java index 7fc8d02857..6e7be29d68 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/family/qc/FamilyVariantQcAnalysis.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/family/qc/FamilyVariantQcAnalysis.java @@ -27,6 +27,7 @@ import org.opencb.commons.datastore.core.Query; import org.opencb.commons.datastore.core.QueryOptions; import org.opencb.opencga.analysis.variant.qc.VariantQcAnalysis; +import org.opencb.opencga.analysis.variant.relatedness.RelatednessAnalysis; import org.opencb.opencga.catalog.db.api.IndividualDBAdaptor; import org.opencb.opencga.catalog.exceptions.CatalogException; import org.opencb.opencga.catalog.managers.CatalogManager; @@ -40,6 +41,7 @@ import org.opencb.opencga.core.models.individual.Individual; import org.opencb.opencga.core.models.sample.Sample; import org.opencb.opencga.core.models.variant.FamilyQcAnalysisParams; +import org.opencb.opencga.core.models.variant.FamilyQcRelatednessAnalysisParams; import org.opencb.opencga.core.response.OpenCGAResult; import org.opencb.opencga.core.tools.annotations.Tool; import org.opencb.opencga.core.tools.annotations.ToolParams; @@ -68,6 +70,14 @@ public class FamilyVariantQcAnalysis extends VariantQcAnalysis { public static final String DESCRIPTION = "Run quality control (QC) for a given family. It computes the relatedness scores among the" + " family members"; + public static final String RELATEDNESS_POP_FREQ_FILENAME = "autosomes_1000G_QC_prune_in.frq"; + public static final String RELATEDNESS_POP_EXCLUDE_VAR_FILENAME = "autosomes_1000G_QC.prune.out"; + public static final String RELATEDNESS_THRESHOLDS_FILENAME = "relatedness_thresholds.tsv"; + + private static final String RELATEDNESS_POP_FREQ_FILE_MSG = "Population frequency file"; + private static final String RELATEDNESS_POP_EXCLUDE_VAR_FILE_MSG = "Population exclude variant file"; + private static final String RELATEDNESS_THRESHOLDS_FILE_MSG = "Thresholds file"; + @ToolParams protected final FamilyQcAnalysisParams analysisParams = new FamilyQcAnalysisParams(); @@ -75,6 +85,39 @@ public class FamilyVariantQcAnalysis extends VariantQcAnalysis { protected void check() throws Exception { super.check(); checkParameters(analysisParams, getStudy(), catalogManager, token); + + // Get paths from external files + FamilyQcRelatednessAnalysisParams relatednessParams = analysisParams.getRelatednessParams(); + + // Get relatedness population frequency + if (relatednessParams != null && StringUtils.isNotEmpty(relatednessParams.getPopulationFrequencyFile())) { + Path path = checkFileParameter(relatednessParams.getPopulationFrequencyFile(), RELATEDNESS_POP_FREQ_FILE_MSG, getStudy(), + catalogManager, getToken()); + analysisParams.getRelatednessParams().setPopulationFrequencyFile(path.toAbsolutePath().toString()); + } else { + Path path = getExternalFilePath(RelatednessAnalysis.ID, RELATEDNESS_POP_FREQ_FILENAME); + analysisParams.getRelatednessParams().setPopulationFrequencyFile(path.toAbsolutePath().toString()); + } + + // Get relatedness population exclude variant + if (relatednessParams != null && StringUtils.isNotEmpty(relatednessParams.getPopulationExcludeVariantsFile())) { + Path path = checkFileParameter(relatednessParams.getPopulationExcludeVariantsFile(), RELATEDNESS_POP_EXCLUDE_VAR_FILE_MSG, + getStudy(), catalogManager, getToken()); + analysisParams.getRelatednessParams().setPopulationExcludeVariantsFile(path.toAbsolutePath().toString()); + } else { + Path path = getExternalFilePath(RelatednessAnalysis.ID, RELATEDNESS_POP_EXCLUDE_VAR_FILENAME); + analysisParams.getRelatednessParams().setPopulationExcludeVariantsFile(path.toAbsolutePath().toString()); + } + + // Get relatedness thresholds + if (relatednessParams != null && StringUtils.isNotEmpty(relatednessParams.getPopulationFrequencyFile())) { + Path path = checkFileParameter(relatednessParams.getThresholdsFile(), RELATEDNESS_THRESHOLDS_FILE_MSG, getStudy(), + catalogManager, getToken()); + analysisParams.getRelatednessParams().setThresholdsFile(path.toAbsolutePath().toString()); + } else { + Path path = getExternalFilePath(RelatednessAnalysis.ID, RELATEDNESS_THRESHOLDS_FILENAME); + analysisParams.getRelatednessParams().setThresholdsFile(path.toAbsolutePath().toString()); + } } @Override @@ -229,6 +272,22 @@ public static void checkParameters(FamilyQcAnalysisParams params, String studyId throw new ToolException("Found the following error for family IDs: " + StringUtils.join(errors.entrySet().stream().map( e -> "Family ID " + e.getKey() + ": " + e.getValue()).collect(Collectors.toList()), ",")); } + + // Check external files: pop. freq. file, pop. exclude var. file and threadshold file + if (params.getRelatednessParams() != null) { + FamilyQcRelatednessAnalysisParams relatednessParams = params.getRelatednessParams(); + if (StringUtils.isNotEmpty(relatednessParams.getPopulationFrequencyFile())) { + checkFileParameter(relatednessParams.getPopulationFrequencyFile(), RELATEDNESS_POP_FREQ_FILE_MSG, studyId, catalogManager, + token); + } + if (StringUtils.isNotEmpty(relatednessParams.getPopulationExcludeVariantsFile())) { + checkFileParameter(relatednessParams.getPopulationExcludeVariantsFile(), RELATEDNESS_POP_EXCLUDE_VAR_FILE_MSG, studyId, + catalogManager, token); + } + if (StringUtils.isNotEmpty(relatednessParams.getThresholdsFile())) { + checkFileParameter(relatednessParams.getThresholdsFile(), RELATEDNESS_THRESHOLDS_FILE_MSG, studyId, catalogManager, token); + } + } } private static List getSampleIds(Family family, String studyId, CatalogManager catalogManager, String token) diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/family/qc/FamilyVariantQcLocalAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/family/qc/FamilyVariantQcLocalAnalysisExecutor.java index 9ac67b38dc..ab0a8d092d 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/family/qc/FamilyVariantQcLocalAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/family/qc/FamilyVariantQcLocalAnalysisExecutor.java @@ -89,7 +89,7 @@ public void run() throws ToolExecutorException { // Execute Pythong script in docker String dockerImage = "opencb/opencga-ext-tools:" + GitRepositoryState.getInstance().getBuildVersion(); - //DockerUtils.run(dockerImage, inputBindings, outputBinding, params, null); + DockerUtils.run(dockerImage, inputBindings, outputBinding, params, null); } catch (IOException e) { throw new ToolExecutorException(e); } diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/qc/VariantQcAnalysis.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/qc/VariantQcAnalysis.java index 1b2ce2e77b..9cbd0b3561 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/qc/VariantQcAnalysis.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/qc/VariantQcAnalysis.java @@ -18,16 +18,25 @@ import org.apache.commons.lang3.StringUtils; import org.opencb.commons.datastore.core.QueryOptions; +import org.opencb.opencga.analysis.ResourceUtils; import org.opencb.opencga.analysis.tools.OpenCgaToolScopeStudy; import org.opencb.opencga.catalog.exceptions.CatalogException; import org.opencb.opencga.catalog.managers.CatalogManager; import org.opencb.opencga.catalog.utils.CatalogFqn; import org.opencb.opencga.core.exceptions.ToolException; +import org.opencb.opencga.core.exceptions.ToolExecutorException; import org.opencb.opencga.core.models.JwtPayload; +import org.opencb.opencga.core.models.file.File; import org.opencb.opencga.core.models.study.Study; import org.opencb.opencga.core.models.study.StudyPermissions; import org.opencb.opencga.core.tools.ToolParams; +import java.io.IOException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + import static org.opencb.opencga.core.models.study.StudyPermissions.Permissions.WRITE_SAMPLES; public class VariantQcAnalysis extends OpenCgaToolScopeStudy { @@ -78,4 +87,65 @@ protected static void checkPermissions(StudyPermissions.Permissions permissions, throw new ToolException(e); } } + + protected static Path checkFileParameter(String fileId, String msg, String studyId, CatalogManager catalogManager, String token) + throws ToolException { + if (StringUtils.isEmpty(fileId)) { + throw new ToolException(msg + " ID is empty"); + } + File file; + try { + file = catalogManager.getFileManager().get(studyId, fileId, QueryOptions.empty(), token).first(); + } catch (CatalogException e) { + throw new ToolExecutorException(msg + " ID '" + fileId + "' not found in OpenCGA catalog", e); + } + Path path = Paths.get(file.getUri()); + if (!Files.exists(path)) { + throw new ToolExecutorException(msg + " '" + path + "' does not exist (file ID: " + fileId + ")"); + } + return path; + } + + protected Path getExternalFilePath(String analysisId, String resourceName) throws ToolException { + URL url = null; + try { + url = new URL(ResourceUtils.URL + "analysis/" + analysisId + "/" + resourceName); + ResourceUtils.downloadThirdParty(url, getOutDir()); + } catch (IOException e) { + throw new ToolException("Something wrong happened downloading the resource '" + resourceName + "' from '" + url + "'", e); + } + + if (!Files.exists(getOutDir().resolve(resourceName))) { + throw new ToolException("After downloading the resource '" + resourceName + "', it does not exist at " + getOutDir()); + } + return getOutDir().resolve(resourceName); + } + + protected Path downloadExternalFileAtResources(String analysisId, String resourceName) throws ToolException { + // Check if the resource has been downloaded previously + Path resourcePath = getOpencgaHome().resolve("analysis/resources/" + analysisId); + if (!Files.exists(resourcePath)) { + // Create the resource path if it does not exist yet + try { + Files.createDirectories(resourcePath); + } catch (IOException e) { + throw new ToolException("It could not create the resource path '" + resourcePath + "'", e); + } + } + if (!Files.exists(resourcePath.resolve(resourceName))) { + // Otherwise, download it from the resource repository + URL url = null; + try { + url = new URL(ResourceUtils.URL + "analysis/" + analysisId + "/" + resourceName); + ResourceUtils.downloadThirdParty(url, resourcePath); + } catch (IOException e) { + throw new ToolException("Something wrong happened downloading the resource '" + resourceName + "' from '" + url + "'", e); + } + + if (!Files.exists(resourcePath.resolve(resourceName))) { + throw new ToolException("After downloading the resource '" + resourceName + "', it does not exist at " + resourcePath); + } + } + return resourcePath.resolve(resourceName); + } } diff --git a/opencga-app/app/analysis/qc/family_qc/family_qc.py b/opencga-app/app/analysis/qc/family_qc/family_qc.py index 88d3413816..88698ba8aa 100644 --- a/opencga-app/app/analysis/qc/family_qc/family_qc.py +++ b/opencga-app/app/analysis/qc/family_qc/family_qc.py @@ -4,8 +4,6 @@ import logging import gzip import json -import subprocess -#import pandas from utils import create_output_dir, execute_bash_command @@ -184,12 +182,12 @@ def relatedness_results_data_model(method): # Return relatedness json data model with method info filled in. return relatedness_json - def relatedness_plink(self,filtered_vcf_fpath,pop_freq_fpath,pop_exclude_var_fpath,outdir_fpath,method="PLINK/IBD"): + def relatedness_plink(self,filtered_vcf_fpath,pop_freq_fpath,pop_exclude_var_fpath,outdir_fpath,plink_path,method="PLINK/IBD"): LOGGER.info('Method: {}'.format(method)) plink_outdir_fpath = create_output_dir(path_elements=[str(outdir_fpath),'plink_IBD']) sex_info_fpath, parent_offspring_fpath = self.generate_files_for_plink_fam_file(outdir_fpath=plink_outdir_fpath) - - plink_path = "path/to/plink" + # Preparing PLINK commands + plink_path = str(plink_path) files_prefix = self.id_ + "_plink_relatedness_results" plink_output_folder_files_prefix = os.path.join(plink_outdir_fpath,files_prefix) cmd_plink_files = ' '.join([plink_path, @@ -248,8 +246,18 @@ def relatedness_validation(reported_result,inferred_result): def relatedness_inference(self,relatedness_thresholds_fpath,method,plink_genome_fpath): # Reading relatedness thresholds file (.tsv) LOGGER.debug('Getting relatedness thresholds from file: "{}"'.format(relatedness_thresholds_fpath)) - relatedness_thresholds_fhand = pandas.read_csv(str(relatedness_thresholds_fpath),header=0,sep='\t').set_index('relationship') - relationship_groups_thresholds_dict = relatedness_thresholds_fhand.to_dict("index") + relatedness_thresholds_fhand = open(str(relatedness_thresholds_fpath)) + relationship_groups_thresholds_dict = {} + for index,line in enumerate(relatedness_thresholds_fhand): + relatedness_thresholds_row_values = line.strip().split() + if index == 0: + relatedness_thresholds_file_header = relatedness_thresholds_row_values + continue + for column,value in enumerate(relatedness_thresholds_row_values): + if relatedness_thresholds_file_header[column] == 'relationship': + relationship_groups_thresholds_dict[value] == {} + else: + relationship_groups_thresholds_dict[relatedness_thresholds_file_header[column]] == value # Reading plink genome file (.genome) LOGGER.debug('Getting PLINK results from file: "{}"'.format(plink_genome_fpath)) @@ -260,7 +268,6 @@ def relatedness_inference(self,relatedness_thresholds_fpath,method,plink_genome_ for index,line in enumerate(input_genome_file_fhand): genome_file_row_values = line.strip().split() if index == 0: - genome_file_header = genome_file_row_values continue # Getting values from PLINK .genome file block score = relatedness_results["scores"][0] 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 00dd7d0175..2f7f34589c 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 @@ -34,6 +34,7 @@ import org.opencb.opencga.core.models.variant.CircosAnalysisParams; import org.opencb.opencga.core.models.variant.CohortVariantStatsAnalysisParams; import org.opencb.opencga.core.models.variant.FamilyQcAnalysisParams; +import org.opencb.opencga.core.models.variant.FamilyQcRelatednessAnalysisParams; import org.opencb.opencga.core.models.variant.GatkWrapperParams; import org.opencb.opencga.core.models.variant.GenomePlotAnalysisParams; import org.opencb.opencga.core.models.variant.GwasAnalysisParams; @@ -623,6 +624,9 @@ private RestResponse runFamilyQc() throws Exception { putNestedIfNotEmpty(beanParams, "family",commandOptions.family, true); putNestedIfNotEmpty(beanParams, "relatednessMethod",commandOptions.relatednessMethod, true); putNestedIfNotEmpty(beanParams, "relatednessMaf",commandOptions.relatednessMaf, true); + putNestedIfNotEmpty(beanParams, "relatednessParams.populationFrequencyFile",commandOptions.relatednessParamsPopulationFrequencyFile, true); + putNestedIfNotEmpty(beanParams, "relatednessParams.populationExcludeVariantsFile",commandOptions.relatednessParamsPopulationExcludeVariantsFile, true); + putNestedIfNotEmpty(beanParams, "relatednessParams.thresholdsFile",commandOptions.relatednessParamsThresholdsFile, true); putNestedIfNotNull(beanParams, "skipIndex",commandOptions.skipIndex, true); putNestedIfNotNull(beanParams, "overwrite",commandOptions.overwrite, true); putNestedIfNotEmpty(beanParams, "outdir",commandOptions.outdir, true); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AnalysisVariantCommandOptions.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AnalysisVariantCommandOptions.java index 3f469b3702..235b48755d 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AnalysisVariantCommandOptions.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/AnalysisVariantCommandOptions.java @@ -821,6 +821,15 @@ public class RunFamilyQcCommandOptions { @Parameter(names = {"--relatedness-maf"}, description = "Minor allele frequence (MAF) is used to filter variants before computing relatedness, e.g.: 1000G:CEU>0.35 or cohort:ALL>0.05", required = false, arity = 1) public String relatednessMaf; + @Parameter(names = {"--relatedness-params-population-frequency-file"}, description = "Population frequencies file ID for relatedness analysis", required = false, arity = 1) + public String relatednessParamsPopulationFrequencyFile; + + @Parameter(names = {"--relatedness-params-population-exclude-variants-file"}, description = "Population exclude variants file ID for relatedness analysis", required = false, arity = 1) + public String relatednessParamsPopulationExcludeVariantsFile; + + @Parameter(names = {"--relatedness-params-thresholds-file"}, description = "Threshold file ID for relatedness analysis", required = false, arity = 1) + public String relatednessParamsThresholdsFile; + @Parameter(names = {"--skip-index"}, description = "Do not save the computed quality control in catalog", required = false, arity = 1) public Boolean skipIndex; diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/FamiliesCommandOptions.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/FamiliesCommandOptions.java index 92fb59cbfb..810c4ad5cd 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/FamiliesCommandOptions.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/FamiliesCommandOptions.java @@ -450,7 +450,7 @@ public class UpdateCommandOptions { @Parameter(names = {"--expected-size"}, description = "The body web service expectedSize parameter", required = false, arity = 1) public Integer expectedSize; - @Parameter(names = {"--quality-control-files"}, description = "File IDs related to the quality control.", required = false, arity = 1) + @Parameter(names = {"--quality-control-files"}, description = "File IDs related to the quality control", required = false, arity = 1) public String qualityControlFiles; @Parameter(names = {"--quality-control-status-id"}, description = "The body web service id parameter", required = false, arity = 1) diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/IndividualsCommandOptions.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/IndividualsCommandOptions.java index 139e2d4ab6..8fdefbd9e9 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/IndividualsCommandOptions.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/options/IndividualsCommandOptions.java @@ -659,7 +659,7 @@ public class UpdateCommandOptions { @Parameter(names = {"--status-description"}, description = "The body web service description parameter", required = false, arity = 1) public String statusDescription; - @Parameter(names = {"--quality-control-files"}, description = "File IDs related to the quality control.", required = false, arity = 1) + @Parameter(names = {"--quality-control-files"}, description = "File IDs related to the quality control", required = false, arity = 1) public String qualityControlFiles; @DynamicParameter(names = {"--attributes"}, description = "The body web service attributes parameter. Use: --attributes key=value", required = false) 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 1b021a931f..76f95ef9ef 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 @@ -4,7 +4,6 @@ import org.opencb.opencga.core.models.variant.MutationalSignatureAnalysisParams; import org.opencb.opencga.core.models.variant.SampleQcAnalysisParams; import org.opencb.opencga.core.tools.variant.IndividualQcAnalysisExecutor; -import org.opencb.opencga.core.tools.variant.InferredSexAnalysisExecutor; public class FieldConstants { @@ -34,9 +33,6 @@ public class FieldConstants { + " changed at the moment."; public static final String GENERIC_STATUS_DESCRIPTION = "Object status."; public static final String GENERIC_STATS = "Stats of the object."; - //QualityControl - public static final String QUALITY_CONTROL_FILES_DESCRIPTION = "File IDs related to the quality control."; - public static final String QUALITY_CONTROL_COMMENTS_DESCRIPTION = "Comments related to the quality control."; // Organization public static final String ORGANIZATION_ID_DESCRIPTION = "Organization unique identifier."; @@ -185,6 +181,8 @@ public class FieldConstants { // Quality control public static final String QC_SKIP_INDEX_DESCRIPTION = "Do not save the computed quality control in catalog"; public static final String QC_OVERWRITE_DESCRIPTION = "Overwrite quality control in catalog"; + public static final String QC_FILES_DESCRIPTION = "File IDs related to the quality control"; + public static final String QC_COMMENTS_DESCRIPTION = "Comments related to the quality control"; // Family quality control public static final String FAMILY_QC_FAMILY_ID_LIST_DESCRIPTION = "List of family IDs"; @@ -193,7 +191,12 @@ public class FieldConstants { @Deprecated public static final String FAMILY_QC_RELATEDNESS_MAF_DESCRIPTION = "Minor allele frequence (MAF) is used to filter variants before" + " computing relatedness, e.g.: " + ParamConstants.POP_FREQ_1000G + ":CEU>0.35 or cohort:ALL>0.05"; - public static final String FAMILY_QUALITY_CONTROL_RELATEDNESS_DESCRIPTION = "Reports of family relationship."; + public static final String FAMILY_QC_RELATEDNESS_DESCRIPTION = "Parameters for relatedness analysis"; + public static final String FAMILY_QC_RELATEDNESS_POP_FREQ_FILE_DESCRIPTION = "Population frequencies file ID for relatedness analysis"; + public static final String FAMILY_QC_RELATEDNESS_POP_EXCLUDE_VAR_FILE_DESCRIPTION = "Population exclude variants file ID for" + + " relatedness analysis"; + public static final String FAMILY_QC_RELATEDNESS_THRESHOLD_FILE_DESCRIPTION = "Threshold file ID for relatedness analysis"; + public static final String FAMILY_QUALITY_CONTROL_RELATEDNESS_REPORT_DESCRIPTION = "Relatedness report for family QC"; // Individual quality control public static final String INFERRED_SEX_ID = "inferred-sex"; diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/family/FamilyQualityControl.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/family/FamilyQualityControl.java index e1ba6cd183..677351aa4f 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/family/FamilyQualityControl.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/family/FamilyQualityControl.java @@ -12,15 +12,15 @@ public class FamilyQualityControl implements Serializable { @DataField(id = "relatedness", - description = FieldConstants.FAMILY_QUALITY_CONTROL_RELATEDNESS_DESCRIPTION) + description = FieldConstants.FAMILY_QUALITY_CONTROL_RELATEDNESS_REPORT_DESCRIPTION) private List relatedness; @DataField(id = "files", - description = FieldConstants.QUALITY_CONTROL_FILES_DESCRIPTION) + description = FieldConstants.QC_FILES_DESCRIPTION) private List files; @DataField(id = "comments", - description = FieldConstants.QUALITY_CONTROL_COMMENTS_DESCRIPTION) + description = FieldConstants.QC_COMMENTS_DESCRIPTION) private List comments; public FamilyQualityControl() { diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/individual/IndividualQualityControl.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/individual/IndividualQualityControl.java index 2e1cc7d9a3..be2896cdbf 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/individual/IndividualQualityControl.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/individual/IndividualQualityControl.java @@ -50,13 +50,13 @@ public class IndividualQualityControl { * File IDs related to the quality control */ @DataField(id = "files", indexed = true, - description = FieldConstants.QUALITY_CONTROL_FILES_DESCRIPTION) + description = FieldConstants.QC_FILES_DESCRIPTION) private List files; /** * Comments related to the quality control */ @DataField(id = "author", indexed = true, - description = FieldConstants.QUALITY_CONTROL_COMMENTS_DESCRIPTION) + description = FieldConstants.QC_COMMENTS_DESCRIPTION) private List comments; public IndividualQualityControl() { diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/variant/FamilyQcAnalysisParams.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/variant/FamilyQcAnalysisParams.java index e31fd6d1c8..20427787d0 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/variant/FamilyQcAnalysisParams.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/variant/FamilyQcAnalysisParams.java @@ -39,6 +39,9 @@ public class FamilyQcAnalysisParams extends ToolParams { @DataField(id = "relatednessMaf", description = FieldConstants.FAMILY_QC_RELATEDNESS_MAF_DESCRIPTION, deprecated = true) private String relatednessMaf; + @DataField(id = "relatednessParams", description = FieldConstants.FAMILY_QC_RELATEDNESS_DESCRIPTION) + private FamilyQcRelatednessAnalysisParams relatednessParams; + @DataField(id = "skipIndex", description = FieldConstants.QC_SKIP_INDEX_DESCRIPTION) private Boolean skipIndex; @@ -59,19 +62,13 @@ public FamilyQcAnalysisParams(String family, String relatednessMethod, String re this.outdir = outdir; } - public FamilyQcAnalysisParams(List families, String family, String relatednessMethod, String relatednessMaf, Boolean skipIndex, - Boolean overwrite, String outdir) { + public FamilyQcAnalysisParams(List families, String family, String relatednessMethod, String relatednessMaf, + FamilyQcRelatednessAnalysisParams relatednessParams, Boolean skipIndex, Boolean overwrite, String outdir) { this.families = families; this.family = family; this.relatednessMethod = relatednessMethod; this.relatednessMaf = relatednessMaf; - this.skipIndex = skipIndex; - this.overwrite = overwrite; - this.outdir = outdir; - } - - public FamilyQcAnalysisParams(List families, Boolean skipIndex, Boolean overwrite, String outdir) { - this.families = families; + this.relatednessParams = relatednessParams; this.skipIndex = skipIndex; this.overwrite = overwrite; this.outdir = outdir; @@ -80,10 +77,11 @@ public FamilyQcAnalysisParams(List families, Boolean skipIndex, Boolean @Override public String toString() { final StringBuilder sb = new StringBuilder("FamilyQcAnalysisParams{"); - sb.append("families='").append(families).append('\''); + sb.append("families=").append(families); sb.append(", family='").append(family).append('\''); sb.append(", relatednessMethod='").append(relatednessMethod).append('\''); sb.append(", relatednessMaf='").append(relatednessMaf).append('\''); + sb.append(", relatednessParams=").append(relatednessParams); sb.append(", skipIndex=").append(skipIndex); sb.append(", overwrite=").append(overwrite); sb.append(", outdir='").append(outdir).append('\''); @@ -100,39 +98,42 @@ public FamilyQcAnalysisParams setFamilies(List families) { return this; } - @Deprecated public String getFamily() { return family; } - @Deprecated public FamilyQcAnalysisParams setFamily(String family) { this.family = family; return this; } - @Deprecated public String getRelatednessMethod() { return relatednessMethod; } - @Deprecated public FamilyQcAnalysisParams setRelatednessMethod(String relatednessMethod) { this.relatednessMethod = relatednessMethod; return this; } - @Deprecated public String getRelatednessMaf() { return relatednessMaf; } - @Deprecated public FamilyQcAnalysisParams setRelatednessMaf(String relatednessMaf) { this.relatednessMaf = relatednessMaf; return this; } + public FamilyQcRelatednessAnalysisParams getRelatednessParams() { + return relatednessParams; + } + + public FamilyQcAnalysisParams setRelatednessParams(FamilyQcRelatednessAnalysisParams relatednessParams) { + this.relatednessParams = relatednessParams; + return this; + } + public Boolean getSkipIndex() { return skipIndex; } diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/variant/FamilyQcRelatednessAnalysisParams.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/variant/FamilyQcRelatednessAnalysisParams.java new file mode 100644 index 0000000000..be5c2c9324 --- /dev/null +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/variant/FamilyQcRelatednessAnalysisParams.java @@ -0,0 +1,78 @@ +/* + * 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.core.models.variant; + +import org.opencb.commons.annotations.DataField; +import org.opencb.opencga.core.api.FieldConstants; + +public class FamilyQcRelatednessAnalysisParams { + + @DataField(id = "populationFrequencyFile", description = FieldConstants.FAMILY_QC_RELATEDNESS_POP_FREQ_FILE_DESCRIPTION) + private String populationFrequencyFile; + + @DataField(id = "populationExcludeVariantsFile", description = FieldConstants.FAMILY_QC_RELATEDNESS_POP_EXCLUDE_VAR_FILE_DESCRIPTION) + private String populationExcludeVariantsFile; + + @DataField(id = "thresholdsFile", description = FieldConstants.FAMILY_QC_RELATEDNESS_THRESHOLD_FILE_DESCRIPTION) + private String thresholdsFile; + + public FamilyQcRelatednessAnalysisParams() { + } + + public FamilyQcRelatednessAnalysisParams(String populationFrequencyFile, String populationExcludeVariantsFile, String thresholdsFile) { + this.populationFrequencyFile = populationFrequencyFile; + this.populationExcludeVariantsFile = populationExcludeVariantsFile; + this.thresholdsFile = thresholdsFile; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("FamilyQcRelatednessAnalysisParams{"); + sb.append("populationFrequencyFile='").append(populationFrequencyFile).append('\''); + sb.append(", populationExcludeVariantsFile='").append(populationExcludeVariantsFile).append('\''); + sb.append(", thresholdsFile='").append(thresholdsFile).append('\''); + sb.append('}'); + return sb.toString(); + } + + public String getPopulationFrequencyFile() { + return populationFrequencyFile; + } + + public FamilyQcRelatednessAnalysisParams setPopulationFrequencyFile(String populationFrequencyFile) { + this.populationFrequencyFile = populationFrequencyFile; + return this; + } + + public String getPopulationExcludeVariantsFile() { + return populationExcludeVariantsFile; + } + + public FamilyQcRelatednessAnalysisParams setPopulationExcludeVariantsFile(String populationExcludeVariantsFile) { + this.populationExcludeVariantsFile = populationExcludeVariantsFile; + return this; + } + + public String getThresholdsFile() { + return thresholdsFile; + } + + public FamilyQcRelatednessAnalysisParams setThresholdsFile(String thresholdsFile) { + this.thresholdsFile = thresholdsFile; + return this; + } +} diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/variant/RelatednessAnalysisParams.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/variant/RelatednessAnalysisParams.java index 7bb1f0ca0e..8d224b11ce 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/variant/RelatednessAnalysisParams.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/variant/RelatednessAnalysisParams.java @@ -20,6 +20,7 @@ import java.util.List; +@Deprecated public class RelatednessAnalysisParams extends ToolParams { public static final String DESCRIPTION = "Relatedness analysis params"; private List individuals;