-
Notifications
You must be signed in to change notification settings - Fork 0
/
Snakefile
111 lines (90 loc) · 3.81 KB
/
Snakefile
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
"""
Main Snakemake file for making Snakemake to chain the intermediate snakefiles.
Output driven: last output of the last intermediate Snakemake file to be run. Snakemake will figure out how to chain for making the pipeline to work.
"""
# =================================================================================================
from snakemake.utils import min_version
# Make Sure Minimun Snakemake version
min_version("5.3.0")
# =========================================================================================================
# Setup Config and Report
# =========================================================================================================
# Load config file
configfile: "config/config.yml"
conda: "workflow/envs/smkenv.yml"
# validate(config, schema="../schemas/config.schema.yaml")
# Description of the workflow can be found in the final report
#report: "report/workflow.rst"
# =========================================================================================================
# Load Rules
# =========================================================================================================
include: "workflow/rules/install_genotypooler.smk"
include: "workflow/rules/prepare_stu_data_55K.smk"
include: "workflow/rules/prepare_pnl_data.smk"
include: "workflow/rules/eda.smk"
include: "workflow/rules/pool_chromosomes.smk"
include: "workflow/rules/genetic_maps.smk"
include: "workflow/rules/imputation_prophaser.smk"
include: "workflow/rules/run_prophaser.smk"
# =========================================================================================================
# The `onstart` Checker
# =========================================================================================================
'''
onstart:
try:
print("Checking if all required files are provided...")
important_files = [ config["samples"],
config["phenotypes"] ]
for filename in important_files:
if not os.path.exists(filename):
raise FileNotFoundError(filename)
except FileNotFoundError as e:
print("This file is not available or accessible: %s" % e)
sys.exit(1)
else:
print("\tAll required files are present!")
'''
# =========================================================================================================
# Target Outputs
# =========================================================================================================
rule all:
input:
"results/rulegraph.png",
"results/jobgraph.png"
if config['imputation'] == 'none':
rule generate_workflow_graphs:
"""
Generate a rulegraph for the entire workflow.
"""
input:
expand("results/data/{nchrom}/{nchrom}_interpolated_wheat_map", nchrom=list(config["chromosomes"]["prefix"].values())) # output from genetic_maps.smk
output:
rulegraph = "results/rulegraph.png",
jobgraph = "results/jobgraph.png"
shell:
"""
snakemake --rulegraph | dot -Tpng > {output.rulegraph}
snakemake --dag | dot -Tpng > {output.jobgraph}
"""
elif config['imputation'] == 'prophaser':
rule generate_workflow_graphs:
"""
Generate a rulegraph for the entire workflow.
"""
input:
"results/data/1/prophaser"
output:
rulegraph = "results/rulegraph.png",
jobgraph = "results/jobgraph.png"
shell:
"""
snakemake --rulegraph | dot -Tpng > {output.rulegraph}
snakemake --dag | dot -Tpng > {output.jobgraph}
"""
# =========================================================================================================
# Success and Failure Messages
# =========================================================================================================
onsuccess:
print("Success! The Snakemake workflow is completed.")
onerror:
print("Error! The Snakemake workflow aborted.")