Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make backwards compatible #197

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions scripts/func_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
37 changes: 26 additions & 11 deletions scripts/validate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import os
import csv
from glob import glob
from func_defs import bail
from func_defs import bail, warn

# ==============================================================================
#
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.")
Expand Down
1 change: 1 addition & 0 deletions snakefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading