@@ -7,7 +7,7 @@ rule all_qc:
77 input :
88 TARGET_QC
99
10- ruleorder : adapter_removal_unpaired > adapter_removal_paired
10+ ruleorder : adapter_removal_paired > adapter_removal_unpaired
1111
1212rule adapter_removal_unpaired :
1313 input :
@@ -79,7 +79,7 @@ rule adapter_removal_paired:
7979 ln -s {input.r1} {output.gr1} && ln -s {input.r2} {output.gr2}
8080 """ )
8181
82- ruleorder : trimmomatic_unpaired > trimmomatic_paired
82+ ruleorder : trimmomatic_paired > trimmomatic_unpaired
8383
8484rule trimmomatic_unpaired :
8585 input :
@@ -149,21 +149,34 @@ rule fastqc:
149149 outdir = str (QC_FP / 'reports' )
150150 shell :
151151 "fastqc -o {params.outdir} {input.reads} -extract"
152-
152+
153+ rule find_low_complexity :
154+ input :
155+ expand (
156+ str (QC_FP / '02_trimmomatic' / '{{sample}}_{rp}.fastq.gz' ),
157+ rp = Pairs )
158+ output :
159+ str (QC_FP / 'log' / 'komplexity' / '{sample}.filtered_ids' )
160+ shell :
161+ """
162+ for rp in {input}; do
163+ gzip -dc $rp | kz | \
164+ awk '{{ if ($4<{Cfg[qc][kz_threshold]}) print $1 }}' >> {output}
165+ done
166+ """
167+
153168rule remove_low_complexity :
154169 input :
155- str (QC_FP / '02_trimmomatic' / '{sample}_{rp}.fastq.gz' )
170+ reads = str (QC_FP / '02_trimmomatic' / '{sample}_{rp}.fastq.gz' ),
171+ ids = str (QC_FP / 'log' / 'komplexity' / '{sample}.filtered_ids' )
156172 output :
157173 str (QC_FP / '03_komplexity' / '{sample}_{rp}.fastq.gz' )
158- run :
159- if Cfg ['qc' ]['mask_low_complexity' ]:
160- shell ("""
161- kz --mask -t {Cfg[qc][kz_threshold]} -w {Cfg[qc][kz_window]} \
162- < <(gzip -cd {input}) | gzip -c > {output}
163- """ )
164- else :
165- shell ("ln -s {input} {output}" )
166-
174+ shell :
175+ """
176+ gzip -dc {input.reads} | rbt fastq-filter {input.ids} |\
177+ gzip > {output}
178+ """
179+
167180rule qc_final :
168181 input :
169182 str (QC_FP / '03_komplexity' / '{sample}_{rp}.fastq.gz' )
0 commit comments