-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.smk
64 lines (49 loc) · 2.59 KB
/
common.smk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""Small, shared functions used to generate inputs and parameters.
"""
def _get_beast_analysis(wildcards):
beast_analysis = _get_beast_analysis_by_build_name(wildcards.build_name)
return beast_analysis
def _get_beast_analysis_by_build_name(build_name):
return [analysis + ".xml" for analysis in config["builds"][build_name].get("beast_analysis")]
def _get_beast_trajectory_analysis(wildcards):
beast_analysis = _get_beast_trajectory_analysis_by_build_name(wildcards.build_name)
return beast_analysis
def _get_beast_trajectory_analysis_by_build_name(build_name):
return [analysis + ".trajectoryMapper.xml" for analysis in config["builds"][build_name].get("beast_analysis")]
def _get_subsampling_scheme_by_build_name(build_name):
return config["builds"][build_name].get("subsampling_scheme", build_name)
def _get_metadata_by_build_name(build_name):
"""Returns a path associated with the metadata for the given build name.
The path can include wildcards that must be provided by the caller through
the Snakemake `expand` function or through string formatting with `.format`.
"""
return rules.load.output.metadata
#if build_name == "global" or "region" not in config["builds"][build_name]:
# return rules.load.output.metadata
#else:
# return rules.adjust_metadata_regions.output.metadata
def _get_metadata_by_wildcards(wildcards):
"""Returns a metadata path based on the given wildcards object.
This function is designed to be used as an input function.
"""
return _get_metadata_by_build_name(wildcards.build_name)
def _get_sampling_trait_for_wildcards(wildcards):
if wildcards.build_name in config["exposure"]:
return config["exposure"][wildcards.build_name]["trait"]
else:
return config["exposure"]["default"]["trait"]
def _get_exposure_trait_for_wildcards(wildcards):
if wildcards.build_name in config["exposure"]:
return config["exposure"][wildcards.build_name]["exposure"]
else:
return config["exposure"]["default"]["exposure"]
def _get_trait_columns_by_wildcards(wildcards):
if wildcards.build_name in config["traits"]:
return config["traits"][wildcards.build_name]["columns"]
else:
return config["traits"]["default"]["columns"]
def _get_sampling_bias_correction_for_wildcards(wildcards):
if wildcards.build_name in config["traits"] and 'sampling_bias_correction' in config["traits"][wildcards.build_name]:
return config["traits"][wildcards.build_name]["sampling_bias_correction"]
else:
return config["traits"]["default"]["sampling_bias_correction"]