From b3ff0214033da644bad3d59d45587f18a5991949 Mon Sep 17 00:00:00 2001 From: Alexander Blume Date: Tue, 23 Jul 2024 13:37:52 +0200 Subject: [PATCH 1/3] create warning function --- scripts/func_defs.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/func_defs.py b/scripts/func_defs.py index 7ea7895..4f1f271 100755 --- a/scripts/func_defs.py +++ b/scripts/func_defs.py @@ -86,6 +86,12 @@ def bail(msg): print(msg, file=sys.stderr) exit(1) + +# print a warning +def warn(msg): + """Print the warning message to stderr.""" + print(f"WARNING: {msg}", file=sys.stderr) + def TrueOrFalse(value): value = repr(value) if value: From a0fbae2aef739a11432faee7ac13cf722a8bfdbf Mon Sep 17 00:00:00 2001 From: Alexander Blume Date: Tue, 23 Jul 2024 13:42:17 +0200 Subject: [PATCH 2/3] allow annotation section in settings for backwards compatibility - issue warning instead of error - propagete old annotation paths to locations dict if paths are given, this still requires that annotation files exist and for old annotation specification does not allow relative paths --- scripts/validate_config.py | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/scripts/validate_config.py b/scripts/validate_config.py index 58ff969..e9e815c 100644 --- a/scripts/validate_config.py +++ b/scripts/validate_config.py @@ -20,7 +20,7 @@ import os import csv from glob import glob -from func_defs import bail +from func_defs import bail, warn # ============================================================================== # @@ -101,12 +101,35 @@ def parse_samples(lines): outputdict[row[2]] = sampleid_dict return { 'SAMPLES': outputdict } +def update_config_layout(config): + # check for new annotation layout + if not 'differential-methylation' in config['general']: + return config + + differential_methylation = config['general']['differential-methylation'] + if not 'annotation' in differential_methylation: + return config + + warn("The specification of annotation files has changed in version 0.1.9 \n"+ + "For now updating configuration file with the new default settings layout.\n"+ + "In the future, please retrieve the new default settings layout with 'pigx-bsseq --init settings'.") + ## move cpgisland and refgene files to location dict + if 'cpgIsland-bedfile' in differential_methylation['annotation']: + config['locations']['cpgIsland-bedfile'] = differential_methylation['annotation']['cpgIsland-bedfile'] + if 'refGenes-bedfile' in differential_methylation['annotation']: + config['locations']['refGenes-bedfile'] = differential_methylation['annotation']['refGenes-bedfile'] + ## remove annotation section + differential_methylation.pop('annotation') + + config['general']['differential-methylation'] = differential_methylation + + return config + + # -------------------------------------- # validation of Config # -------------------------------------- - - # check for common input/configuration errors: def validate_config(config): # Check that all locations exist @@ -149,14 +172,6 @@ def validate_config(config): bail("ERROR: The specification of treatment groups and differential analysis has changed.\n"+ "Please retrieve the new default settings layout with 'pigx-bsseq --init settings'.\n") - - # check for new annotation layout - if 'annotation' in config['general']['differential-methylation']: - bail("ERROR: The specification of annotation files has changed.\n"+ - "Please retrieve the new default settings layout with 'pigx-bsseq --init settings'.\n") - - - # Check for a any Assembly string if not config['general']['assembly']: bail("ERROR: Please set a genome assembly string in the settings file at general::assembly.") From cf7e5818b0286f967a3a153e2073c68070937ee2 Mon Sep 17 00:00:00 2001 From: Alexander Blume Date: Tue, 23 Jul 2024 13:43:22 +0200 Subject: [PATCH 3/3] update config layout --- snakefile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/snakefile.py b/snakefile.py index 257d41c..3cd1045 100644 --- a/snakefile.py +++ b/snakefile.py @@ -25,6 +25,7 @@ include : os.path.join(config['locations']['pkglibexecdir'], 'scripts/update_pigx_work.py') include : os.path.join(config['locations']['pkglibexecdir'], 'scripts/validate_config.py') +config = update_config_layout(config) validate_config(config) update_pigx_work(config)