From 08f6f5231b449372d1548fa64c6c43d88e1e5b13 Mon Sep 17 00:00:00 2001
From: Blaise Li <blaise.li__git@nsup.org>
Date: Fri, 5 Mar 2021 18:36:43 +0100
Subject: [PATCH] Accept methods outputs and genome config file.
---
Data_submission/build_file_dicts.py | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/Data_submission/build_file_dicts.py b/Data_submission/build_file_dicts.py
index 6e99e67..9ba1093 100755
--- a/Data_submission/build_file_dicts.py
+++ b/Data_submission/build_file_dicts.py
@@ -229,10 +229,14 @@ def main():
assert not common_vars, f"Variable overwriting hazard!\n{common_vars}"
vars_from_analyses |= set(analysis_config.keys())
# This may be needed for analysis types with configurable genome
- genome = analysis_config.get(
+ genome_dict = analysis_config.get(
"genome_dict",
# default genome name will be "C_elegans"
- {"name": "C_elegans"})["name"]
+ {"name": "C_elegans"})
+ if isinstance(genome_dict, (str, bytes)):
+ with open(analysis_config["genome_dict"]) as gendict_fh:
+ genome_dict = yload(gendict_fh)
+ genome = genome_dict["name"]
# Load the snakefile to get information
# about the rule making bigwig files
# Based on snakemake/__init__.py and snakemake/workflow.py
@@ -253,7 +257,16 @@ def main():
#after_loading_vars = list(recdir())
# Use pattern matching so that it fails if we have not exactly
# one bigwig file in the output of the rule
- [bw_pattern] = sf._rules[bw_rulename].output
+ try:
+ [bw_pattern] = sf._rules[bw_rulename].output
+ except ValueError:
+ try:
+ # Sometimes, a rule may also output a "methods" file
+ [bw_pattern, methods_pattern] = sf._rules[bw_rulename].output
+ assert methods_pattern.endswith("_methods.txt")
+ except ValueError:
+ print(analysis_snakefile, bw_rulename, file=sys.stderr)
+ raise
#for varname in set(after_loading_vars) - set(before_loading_vars):
# # https://stackoverflow.com/a/26545111/1878788
# del globals()[varname]
--
GitLab