-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSnakefile
More file actions
85 lines (73 loc) · 2.71 KB
/
Copy pathSnakefile
File metadata and controls
85 lines (73 loc) · 2.71 KB
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
# Emulate a user configuring the module.
configfile: workflow.source_path("./test_config.yaml")
rule download_netherlands_shapes:
message:
"Download and unzip the Netherlands shapes."
output:
"resources/inputs/shapes/NLD.parquet",
log:
"logs/download_netherlands_shapes.log",
conda:
"../../workflow/envs/shell.yaml"
shell:
"""
curl -sSLo {output:q} "https://zenodo.org/records/16684683/files/NLD.parquet"
"""
rule download_netherlands_protected_areas:
message:
"Download a dummy drop-in dataset for Netherlands protected areas (not based on WDPA)."
output:
"resources/inputs/wdpa.gdb.zip",
log:
"logs/download_netherlands_protected_areas.log",
conda:
"../../workflow/envs/shell.yaml"
shell:
"""
curl -sSLo {output:q} "https://zenodo.org/records/16684513/files/wdpa-nl-dropin.gdb.zip"
"""
rule unzip_netherlands_protected_areas:
message:
"Download protected areas data."
input:
script=workflow.source_path("../../workflow/scripts/unzip_like.py"),
zipfile=rules.download_netherlands_protected_areas.output,
output:
directory("resources/inputs/wdpa.gdb"),
log:
"logs/unzip_netherlands_protected_areas.log",
conda:
"../../workflow/envs/shell.yaml"
shell:
"""
python {input.script:q} {input.zipfile:q} -t "resources/inputs/" 2> {log:q}
"""
# Import the module and configure it.
# `snakefile:` specifies the module. It can use file paths and special github(...) / gitlab(...) markers
# `config`: specifies the module configuration.
# `pathvars:` helps you re-wire where the module places files.
module module_area_potentials:
snakefile:
"../../workflow/Snakefile"
config:
config["module_area_potentials"]
pathvars:
# Redirect specific user resources (inputs)
shapes="resources/inputs/shapes/{shape}.parquet",
wdpa="resources/inputs/wdpa.gdb",
# Redirect specific module results (outputs)
area_potential="results/outputs/{shape}/area_potential_{tech}.tif",
# Redirect module intermediate files
logs="resources/module/logs",
resources="resources/module/resources",
results="resources/module/results",
# rename all module rules with a prefix, to avoid naming conflicts.
use rule * from module_area_potentials as module_area_potentials_*
# Request something from the module
rule all:
message:
"Run the module for the Netherlands shapes."
default_target: True
input:
# The report file requires all area potential output files
"resources/module/results/NLD/area_potential_report.html",