-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSnakefile
More file actions
68 lines (59 loc) · 2.01 KB
/
Copy pathSnakefile
File metadata and controls
68 lines (59 loc) · 2.01 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
shell.executable("zsh")
""" Snakemake pipeline for single-cell RNA-seq 3' end counting """
configfile: "config.yaml"
DATA = config["DATA"]
RESULTS = config["RESULTS"]
STAR_INDEX = config["STAR_INDEX"]
POLYA_SITES = config["POLYA_SITES"]
STAR = config["STAR"]
DEFAULTS = config["DEFAULTS"]
SAMPLES = config["SAMPLES"]
READS = ["R1", "R2", "paired"]
import yaml
with open('chemistry.yaml') as fp:
CHEMISTRY = yaml.safe_load(fp)
def _get_config(sample, item):
try:
return SAMPLES[sample][item]
except KeyError:
pass
try:
return CHEMISTRY[SAMPLES[sample]["chemistry"]][SAMPLES[sample]["platform"]][item]
except KeyError:
pass
try:
return CHEMISTRY[SAMPLES[sample]["chemistry"]][DEFAULTS["platform"]][item]
except KeyError:
pass
try:
return CHEMISTRY[SAMPLES[sample]["chemistry"]][item]
except KeyError:
pass
try:
return CHEMISTRY[DEFAULTS["chemistry"]][SAMPLES[sample]["platform"]][item]
except KeyError:
pass
try:
return CHEMISTRY[DEFAULTS["chemistry"]][DEFAULTS["platform"]][item]
except KeyError:
pass
try:
return CHEMISTRY[DEFAULTS["chemistry"]][item]
except KeyError:
return DEFAULTS[item]
# assemble outputs for rule all
SAMPLE_OUTS = []
for x in SAMPLES:
SAMPLE_OUTS.extend(expand("{results}/counts/{sample}_{alignments}_counts.tsv.gz", results = RESULTS, sample = x, alignments = _get_config(x, "alignments")))
SAMPLE_OUTS.extend(expand("{results}/{sample}/{sample}_{alignments}_Aligned.sortedByCoord.out.bam", results = RESULTS, sample = x, alignments = _get_config(x, "alignments")))
SAMPLE_OUTS.extend(expand("{results}/bed/{sample}_{alignments}.bed.gz", results = RESULTS, sample = x, alignments = _get_config(x, "alignments")))
# optionally add multiqc
all_outputs = SAMPLE_OUTS #+ expand("{results}/report/multiqc_report.html", results = RESULTS)
print(all_outputs)
rule all:
input:
all_outputs = all_outputs
include: "rules/check_versions.snake"
include: "rules/cutadapt_star.snake"
include: "rules/count.snake"
include: "rules/qc.snake"