@@ -19,35 +19,28 @@ import pandas as pd
19
19
from sequana.utils.datatables_js import DataTable
20
20
from sequana.utils.tree import HTMLDirectory
21
21
22
- from sequana_pipetools import PipelineManagerGeneric
22
+ from sequana_pipetools import PipelineManager
23
23
from sequana_pipetools import snaketools as sm
24
24
25
25
# This must be defined before the include
26
26
configfile: "config.yaml"
27
27
28
- # A convenient manager
29
- def func(filename):
30
- return filename.split("/")[-1].split('.', 1)[0]
28
+ manager = PipelineManager("fastqc", config)
31
29
32
- manager = PipelineManagerGeneric("fastqc", config, sample_func=func)
33
-
34
- # the manager can figure out whether data is paired or not but with input
35
- # sam/bam it is not for sure, so we need some additional simple code here:
36
- # we can try to figure out whether input data is paired.
37
- PAIRED = False
38
-
39
- # do we have illumina paired data with tag _R1_
30
+ # This is just for information. Not used in the pipeline but only for HTML rpeort
31
+ # do we have illumina paired data with tag _R1_ ?
40
32
R1 = [1 for x in manager.samples.values() if "_R1_" in x.split("/")[-1]]
41
33
R2 = [1 for x in manager.samples.values() if "_R2_" in x.split("/")[-1]]
42
34
35
+ PAIRED = False
43
36
if len(R1) == len(R2) and len(R1) != 0:
44
37
PAIRED = True
45
38
else:
46
39
R1 = [1 for x in manager.samples.values() if "_1." in x.split("/")[-1]]
47
40
R2 = [1 for x in manager.samples.values() if "_2." in x.split("/")[-1]]
48
41
if len(R1) == len(R2) and len(R1) != 0:
49
42
PAIRED = True
50
- manager.paired = PAIRED
43
+ manager._paired = PAIRED
51
44
52
45
53
46
# Some sanity checks
@@ -73,19 +66,40 @@ if 'general' in config and 'method_choice' in config['general'] and \
73
66
74
67
METHOD = "falco"
75
68
76
- __falco__input = manager.getrawdata()
77
- __falco__ouptut = "samples/{sample}/summary.txt"
78
- include: sm.modules["falco"]
79
- __qc_done__ = expand(__falco__ouptut, sample=manager.samples)
69
+ rule falco:
70
+ input: manager.getrawdata()
71
+ output: "samples/{sample}/summary.txt"
72
+ log:
73
+ "samples/{sample}/falco.log"
74
+ threads:
75
+ config['falco']['threads']
76
+ params:
77
+ options=config['falco']['options'],
78
+ working_directory="samples/{sample}"
79
+ resources:
80
+ **config['falco']['resources']
81
+ wrapper:
82
+ "main/wrappers/falco"
83
+ __multiqc__input = expand("samples/{sample}/summary.txt", sample=manager.samples)
80
84
81
85
else:
82
86
METHOD = "fastqc"
83
- __fastqc__input = manager.getrawdata()
84
- __fastqc__output = "samples/{sample}/fastqc.done"
85
- __fastqc__log = "samples/{sample}/fastqc.log"
86
- __fastqc__wkdir = "samples/{sample}"
87
- include: sm.modules["fastqc"]
88
- __qc_done__ = expand(__fastqc__output, sample=manager.samples)
87
+
88
+ rule fastqc:
89
+ input: manager.getrawdata()
90
+ output: "samples/{sample}/fastqc.done"
91
+ log:
92
+ "samples/{sample}/fastqc.log"
93
+ threads:
94
+ config['fastqc']['threads']
95
+ params:
96
+ options=config['fastqc']['options'],
97
+ working_directory="samples/{sample}"
98
+ resources:
99
+ **config['fastqc']['resources']
100
+ wrapper:
101
+ "main/wrappers/fastqc"
102
+ __multiqc__input = expand("samples/{sample}/fastqc.done", sample=manager.samples)
89
103
90
104
91
105
# define a list of files for the md5sum
@@ -130,43 +144,40 @@ comments += f"""<br><b><a href="https://github.com/sequana/sequana_pipetools">Se
130
144
# Multiqc rule
131
145
if config['multiqc']['do']:
132
146
133
- if METHOD == "falco":
134
- __multiqc__input = expand("samples/{sample}/summary.txt", sample=manager.samples)
135
- else:
136
- __multiqc__input = expand(__qc_done__, sample=manager.samples)
137
147
# do not specify fastqc itself alone, otherwise it fails (feb 2020)
138
-
139
148
config['multiqc']['options'] = config["multiqc"]["options"] + f" --comment '{comments}'"
140
149
141
150
142
- __multiqc__output = "multiqc/multiqc_report.html"
143
151
rule multiqc:
144
- input:
152
+ input:
145
153
__multiqc__input
146
- output:
147
- __multiqc__output
148
- params:
154
+ output:
155
+ "multiqc/multiqc_report.html"
156
+ params:
149
157
options=config['multiqc']['options'],
150
158
input_directory=config['multiqc']['input_directory'],
151
159
config_file=config['multiqc']['config_file'],
152
160
modules=config['multiqc']['modules']
153
- log:
161
+ log:
154
162
"multiqc/multiqc.log"
155
- wrapper:
163
+ resources:
164
+ **config["multiqc"]["resources"]
165
+ wrapper:
156
166
"main/wrappers/multiqc"
157
167
158
168
159
169
# ====================================================================== rulegraph
160
170
sequana_rulegraph_mapper = {}
161
171
if config['multiqc']['do']:
162
- sequana_rulegraph_mapper["multiqc"] = f "../{__multiqc__output} "
172
+ sequana_rulegraph_mapper["multiqc"] = "../multiqc/multiqc_report.html "
163
173
include: sm.modules['rulegraph']
164
174
165
175
166
-
167
176
rule plotting_and_stats:
168
- input: __qc_done__
177
+ input: expand("samples/{sample}/" + f"{METHOD}.done", sample=manager.samples)
169
178
output: "outputs/summary.png", "outputs/summary.json"
179
+ resources:
180
+ **config["multiqc"]["resources"]
170
181
run:
171
182
import glob
172
183
from sequana.fastqc import FastQC
@@ -229,7 +240,7 @@ onsuccess:
229
240
manager.teardown()
230
241
231
242
if config['multiqc']['do']:
232
- manager.clean_multiqc(__multiqc__output )
243
+ manager.clean_multiqc("multiqc/multiqc_report.html" )
233
244
234
245
# Now, the main HTML report
235
246
0 commit comments