-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnakefile
127 lines (97 loc) · 3.71 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import re
import os
import yaml
from typing import List
from pathlib import Path
import pandas as pd
from snakemake.utils import min_version, validate
min_version("5.23.0")
report: "report/workflow.rst"
# ======================================================
# Config files
# ======================================================
#configfile: "config.yaml"
validate(config, "schemas/config.schema.yaml")
smpls = pd.read_csv(config["samples"], dtype=str).set_index(["run", "sample"], drop=False)
smpls.index = smpls.index.set_levels([i.astype(str) for i in smpls.index.levels])
validate(smpls, schema="schemas/samples.schema.yaml")
wildcard_constraints:
sample = '[A-Za-z0-9]+',
run = '[A-Za-z0-9]+'
# ======================================================
# directories
# ======================================================
ROOTDIR = srcdir(".")
DBPATH = os.path.expandvars(config['db_path'])
if not os.path.isabs(DBPATH):
DBPATH = os.path.join(ROOTDIR, DBPATH)
if not os.path.exists(DBPATH):
os.makedirs(DBPATH)
SRCDIR = srcdir("scripts")
ENVDIR = srcdir("envs")
OUTPUTDIR = os.path.abspath(os.path.expandvars(config['output_dir']))
workdir:
OUTPUTDIR
# ======================================================
# Rules
# ======================================================
optrules = []
optrules.extend(["plots/precision.pdf"] if len(config["methods"]) > 2 else [])
rule all:
input:
expand("data/{samples.run}/porechopped/{samples.sample}.trimmed.fastq.gz",
samples=smpls.itertuples()
),
expand("plots/{samples.run}/chopper/{samples.sample}.filtered.pdf",
samples=smpls.itertuples(), method=config["methods"]
),
expand("stats/{samples.run}/chopper/{samples.sample}.filtered.txt",
samples=smpls.itertuples(), method=config["methods"]
),
expand("classifications/{samples.run}/{method}/{samples.sample}.{method}.taxmat",
samples=smpls.itertuples(), method=config["methods"]
),
expand("plots/{absrel}-Genus-by-{grouper}.pdf",
absrel = ["aabund","rabund"], grouper=config["common"]["group-by"]
),
expand("plots/runtime-by-{grouper}.pdf", grouper=config["common"]["group-by"]
),
optrules
rule filter:
input:
expand("plots/{samples.run}/chopper/{samples.sample}.filtered.pdf",
samples=smpls.itertuples(), method=config["methods"]
),
expand("stats/{samples.run}/chopper/{samples.sample}.filtered.txt",
samples=smpls.itertuples(), method=config["methods"]
)
# ======================================================
# Functions and Classes
# ======================================================
onsuccess:
print("NanoClass finished!")
print("To generate a report run: snakemake --report report/NanoClass.zip")
onerror:
print("Note the path to the log file for debugging.")
print("Documentation is available at: https://ejongepier.github.io/NanoClass/")
print("Issues can be raised at: https://github.com/ejongepier/NanoClass/issues")
# ======================================================
# Global variables
# ======================================================
#======================================================
# Include
#======================================================
include: "rules/preprocess.smk"
include: "rules/common.smk"
include: "rules/blastn.smk"
include: "rules/centrifuge.smk"
include: "rules/dcmegablast.smk"
include: "rules/idtaxa.smk"
include: "rules/kraken.smk"
include: "rules/mapseq.smk"
include: "rules/megablast.smk"
include: "rules/minimap.smk"
include: "rules/mothur.smk"
include: "rules/qiime.smk"
include: "rules/rdp.smk"
include: "rules/spingo.smk"