@@ -83,14 +83,34 @@ rule fastqc_raw:
83
83
params :
84
84
rname = "rawfqc" ,
85
85
outdir = join (workpath , "{name}" , "fastqc" ),
86
+ tmpdir = tmpdir ,
86
87
conda : depending (join (workpath , config ['conda' ]['modr' ]), use_conda )
87
88
container : depending (config ['images' ]['modr' ], use_singularity )
88
89
threads : int (allocated ("threads" , "fastqc_raw" , cluster ))
89
90
shell : """
91
+ # Setups temporary directory for
92
+ # intermediate files with built-in
93
+ # mechanism for deletion on exit
94
+ if [ ! -d "{params.tmpdir}" ]; then mkdir -p "{params.tmpdir}"; fi
95
+ tmp=$(mktemp -d -p "{params.tmpdir}")
96
+ trap 'rm -rf "${{tmp}}"' EXIT
97
+
98
+ # Running fastqc with local
99
+ # disk or a tmpdir, fastqc
100
+ # has been observed to lock
101
+ # up gpfs filesystems, adding
102
+ # this on request by HPC staff
90
103
fastqc \\
91
104
-t {threads} \\
92
- -o {params.outdir} \\
105
+ -o "${{tmp}}" \\
93
106
{input.fq}
107
+
108
+ # Copy output files from tmpdir
109
+ # to output directory
110
+ find "${{tmp}}" \\
111
+ -type f \\
112
+ \\ ( -name '*.html' -o -name '*.zip' \\ ) \\
113
+ -exec cp {{}} {params.outdir} \\ ;
94
114
"""
95
115
96
116
@@ -110,14 +130,34 @@ rule fastqc_filtered:
110
130
params :
111
131
rname = "filtfqc" ,
112
132
outdir = join (workpath , "{name}" , "fastqc" ),
133
+ tmpdir = tmpdir ,
113
134
conda : depending (join (workpath , config ['conda' ]['modr' ]), use_conda )
114
135
container : depending (config ['images' ]['modr' ], use_singularity )
115
136
threads : int (allocated ("threads" , "fastqc_filtered" , cluster ))
116
137
shell : """
138
+ # Setups temporary directory for
139
+ # intermediate files with built-in
140
+ # mechanism for deletion on exit
141
+ if [ ! -d "{params.tmpdir}" ]; then mkdir -p "{params.tmpdir}"; fi
142
+ tmp=$(mktemp -d -p "{params.tmpdir}")
143
+ trap 'rm -rf "${{tmp}}"' EXIT
144
+
145
+ # Running fastqc with local
146
+ # disk or a tmpdir, fastqc
147
+ # has been observed to lock
148
+ # up gpfs filesystems, adding
149
+ # this on request by HPC staff
117
150
fastqc \\
118
151
-t {threads} \\
119
- -o {params.outdir} \\
152
+ -o "${{tmp}}" \\
120
153
{input.fq}
154
+
155
+ # Copy output files from tmpdir
156
+ # to output directory
157
+ find "${{tmp}}" \\
158
+ -type f \\
159
+ \\ ( -name '*.html' -o -name '*.zip' \\ ) \\
160
+ -exec cp {{}} {params.outdir} \\ ;
121
161
"""
122
162
123
163
0 commit comments