From 1fae29602bd09a886cb74184c837f26fedf2bf89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20T=C3=A1rraga=20Gim=C3=A9nez?= Date: Wed, 11 Sep 2024 03:13:10 +0200 Subject: [PATCH] app: rename qc/data to qc/resources, #TASK-6772, #TASK-6766 --- .../variant/qc/VariantQcAnalysis.java | 29 ++++++++++++++----- .../karyotypic_sex_thresholds.json | 0 .../relatedness_thresholds.tsv | 0 3 files changed, 21 insertions(+), 8 deletions(-) rename opencga-app/app/analysis/qc/{data => resources}/karyotypic_sex_thresholds.json (100%) rename opencga-app/app/analysis/qc/{data => resources}/relatedness_thresholds.tsv (100%) 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 1303304afb9..c5884e3cc51 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 @@ -63,7 +63,8 @@ public class VariantQcAnalysis extends OpenCgaToolScopeStudy { // QC folders public static final String QC_FOLDER = "qc/"; - public static final String QC_DATA_FOLDER = QC_FOLDER + "data/"; + public static final String RESOURCES_FOLDER = "resources/"; + public static final String QC_RESOURCES_FOLDER = QC_FOLDER + RESOURCES_FOLDER; // Data type public static final String FAMILY_QC_TYPE = "family"; @@ -292,17 +293,28 @@ protected static List getNoSomaticSampleIds(Individual individual) { } protected Path getExternalFilePath(String analysisId, String resourceName) throws ToolException { + Path resourcesPath = getOutDir().resolve(RESOURCES_FOLDER); + if (!Files.exists(resourcesPath)) { + try { + Files.createDirectories(resourcesPath); + if (!Files.exists(resourcesPath)) { + throw new ToolException("Something wrong happened when creating the resources folder at " + resourcesPath); + } + } catch (IOException e) { + throw new ToolException("Error creating the resources folder at " + resourcesPath, e); + } + } switch (resourceName) { case RELATEDNESS_THRESHOLDS_FILENAME: case INFERRED_SEX_THRESHOLDS_FILENAME: - return copyExternalFile(getOpencgaHome().resolve(ANALYSIS_FOLDER).resolve(QC_DATA_FOLDER).resolve(resourceName)); + return copyExternalFile(getOpencgaHome().resolve(ANALYSIS_FOLDER).resolve(QC_RESOURCES_FOLDER).resolve(resourceName)); default: return downloadExternalFile(analysisId, resourceName); } } protected Path copyExternalFile(Path source) throws ToolException { - Path dest = getOutDir().resolve(source.getFileName()); + Path dest = getOutDir().resolve(RESOURCES_FOLDER).resolve(source.getFileName()); try { Files.copy(source, dest); } catch (IOException e) { @@ -317,17 +329,18 @@ protected Path copyExternalFile(Path source) throws ToolException { protected Path downloadExternalFile(String analysisId, String resourceName) throws ToolException { URL url = null; + Path resourcesPath = getOutDir().resolve(RESOURCES_FOLDER); try { url = new URL(ResourceUtils.URL + ANALYSIS_FOLDER + analysisId + "/" + resourceName); - ResourceUtils.downloadThirdParty(url, getOutDir()); + ResourceUtils.downloadThirdParty(url, resourcesPath); } catch (IOException e) { - throw new ToolException("Something wrong happened downloading the resource '" + resourceName + "' from '" + url + "'", e); + throw new ToolException("Something wrong happened when 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()); + if (!Files.exists(resourcesPath.resolve(resourceName))) { + throw new ToolException("After downloading the resource '" + resourceName + "', it does not exist at " + resourcesPath); } - return getOutDir().resolve(resourceName); + return resourcesPath.resolve(resourceName); } protected Path downloadExternalFileAtResources(String analysisId, String resourceName) throws ToolException { diff --git a/opencga-app/app/analysis/qc/data/karyotypic_sex_thresholds.json b/opencga-app/app/analysis/qc/resources/karyotypic_sex_thresholds.json similarity index 100% rename from opencga-app/app/analysis/qc/data/karyotypic_sex_thresholds.json rename to opencga-app/app/analysis/qc/resources/karyotypic_sex_thresholds.json diff --git a/opencga-app/app/analysis/qc/data/relatedness_thresholds.tsv b/opencga-app/app/analysis/qc/resources/relatedness_thresholds.tsv similarity index 100% rename from opencga-app/app/analysis/qc/data/relatedness_thresholds.tsv rename to opencga-app/app/analysis/qc/resources/relatedness_thresholds.tsv