@@ -89,10 +89,8 @@ def helpMessage() {
8989
9090 Choice of USEARCH32 vs USEARCH64
9191 --mode [str] Default is '${ params.mode} '; for running with 64 version the mode has to be set to --mode 'usearch64'
92- and below --search64 option has to be specified as well; can set to --mode 'vsearch' (only if --skipDemux is also chosen)
93- below --vsearch option has to be specified as well
92+ and below --search64 option has to be specified as well; can set to --mode 'vsearch'
9493 --usearch64 [dir] Full path to where usearch64 bit version is stored locally
95- --vsearch [dir] Full path to where vsearch bit version is stored locally
9694
9795 LULU
9896 --lulu [file] An R script to run post-clustering curation with default settings of LULU;
@@ -134,7 +132,6 @@ qcov = params.qcov
134132lulu = file(params. lulu)
135133mode = params. mode
136134usearch64 = params. usearch64
137- vsearch = params. vsearch
138135minMatch_lulu = params. minMatch_lulu
139136
140137// Setting up channels & inputs for taxonomy assignment step
@@ -322,20 +319,24 @@ process '03_Length_filtered' {
322319
323320 script:
324321 if (params. illumina_demultiplexed)
325- """
326- cat "${ fastq_files} " > "${ sample_id} _QF_Dmux.fastq"
327- obiannotate -S sample:'"_".join(sequence.getDefinition().strip().split("_")[1:])' "${ sample_id} _QF_Dmux.fastq" > "${ sample_id} _labelled.fastq"
328- if ${ params.remove_ambiguous_tags} ; then
329- obigrep -l $minLen "${ sample_id} _labelled.fastq" | obigrep -v -D '1:N:0:.*[NBDHVKYSWRM].*_' > "${ sample_id} _QF_Dmux_minLF.fastq"
330- else
331- obigrep -l $minLen "${ sample_id} _labelled.fastq" > ${ sample_id} _QF_Dmux_minLF.fastq
332- fi
333- """
322+ {
323+ """
324+ cat "${ fastq_files} " > "${ sample_id} _QF_Dmux.fastq"
325+ obiannotate -S sample:'"_".join(sequence.getDefinition().strip().split("_")[1:])' "${ sample_id} _QF_Dmux.fastq" > "${ sample_id} _labelled.fastq"
326+ if ${ params.remove_ambiguous_tags} ; then
327+ obigrep -l $minLen "${ sample_id} _labelled.fastq" | obigrep -v -D '1:N:0:.*[NBDHVKYSWRM].*_' > "${ sample_id} _QF_Dmux_minLF.fastq"
328+ else
329+ obigrep -l $minLen "${ sample_id} _labelled.fastq" > ${ sample_id} _QF_Dmux_minLF.fastq
330+ fi
331+ """
332+ }
334333 else
335- """
336- cat ${ fastq_files} > "${ sample_id} _QF_Dmux.fastq"
337- obigrep -l $minLen -p 'forward_tag is not None and reverse_tag is not None' "${ sample_id} _QF_Dmux.fastq" > "${ sample_id} _QF_Dmux_minLF.fastq"
338- """
334+ {
335+ """
336+ cat ${ fastq_files} > "${ sample_id} _QF_Dmux.fastq"
337+ obigrep -l $minLen -p 'forward_tag is not None and reverse_tag is not None' "${ sample_id} _QF_Dmux.fastq" > "${ sample_id} _QF_Dmux_minLF.fastq"
338+ """
339+ }
339340}
340341
341342
@@ -390,7 +391,7 @@ process '05_relabel_Cat_vsearch' {
390391 do
391392 label=\$ (echo \$ files | cut -d '/' -f 3 | cut -d '.' -f 1)
392393 # $usearch64 -fastx_relabel \$ files -prefix \$ {label}. -fastqout \$ {label}.relabeled.fastq
393- vsearch --fastx_filter \$ files --relabel \$ {label}. --fastqout \$ {label}.relabeled.fastq
394+ vsearch --threads ${ task.cpus } -- fastx_filter \$ files --relabel \$ {label}. --fastqout \$ {label}.relabeled.fastq
394395 done
395396
396397 for files in *.relabeled.fastq
@@ -407,7 +408,7 @@ process '05_relabel_Cat_vsearch' {
407408 # $usearch64 -fastx_get_sample_names *_relabeled4Usearch.fastq -output sample.txt
408409
409410 # $usearch64 -fastq_filter *_relabeled4Usearch.fastq -fastaout ${ sample_id} .fasta
410- vsearch --fastx_filter *_relabeled4Usearch.fastq --fastaout ${ sample_id} .fasta
411+ vsearch --threads ${ task.cpus } -- fastx_filter *_relabeled4Usearch.fastq --fastaout ${ sample_id} .fasta
411412
412413 awk '/^>/ {print(\$ 0)}; /^[^>]/ {print(toupper(\$ 0))}' *.fasta > ${ sample_id} _upper.fasta
413414 """
@@ -428,53 +429,55 @@ process '05_relabel_Cat_usearch' {
428429
429430
430431 script:
431- if (mode == ' usearch32' )
432- """
433- for files in ${ fastqs}
434- do
435- label=\$ (echo \$ files | cut -d '/' -f 3 | cut -d '.' -f 1)
436- usearch -fastx_relabel \$ files -prefix \$ {label}. -fastqout \$ {label}.relabeled.fastq
437- done
438-
439- for files in *.relabeled.fastq
440- do
441- name=\$ (echo \$ files | cut -d '/' -f '2' | cut -d '.' -f 1)
442- echo \$ {name} >> CountOfSeq.txt
443- grep "^@\$ {name}" \$ files | wc -l >> CountOfSeq.txt
444- done
445-
446- cat *.relabeled.fastq > "${ sample_id} _QF_Dmux_minLF_relabeled4Usearch.fastq"
447-
448- usearch -fastx_get_sample_names *_relabeled4Usearch.fastq -output sample.txt
449-
450- usearch -fastq_filter *_relabeled4Usearch.fastq -fastaout ${ sample_id} .fasta
451-
452- awk '/^>/ {print(\$ 0)}; /^[^>]/ {print(toupper(\$ 0))}' *.fasta > ${ sample_id} _upper.fasta
453-
454- """
455- else if (mode == ' usearch64' )
456- """
457- for files in ${ fastqs}
458- do
459- label=\$ (echo \$ files | cut -d '/' -f 3 | cut -d '.' -f 1)
460- $usearch64 -fastx_relabel \$ files -prefix \$ {label}. -fastqout \$ {label}.relabeled.fastq
461- done
432+ if (mode == ' usearch32' ) {
433+ """
434+ for files in ${ fastqs}
435+ do
436+ label=\$ (echo \$ files | cut -d '/' -f 3 | cut -d '.' -f 1)
437+ usearch -fastx_relabel \$ files -prefix \$ {label}. -fastqout \$ {label}.relabeled.fastq
438+ done
439+
440+ for files in *.relabeled.fastq
441+ do
442+ name=\$ (echo \$ files | cut -d '/' -f '2' | cut -d '.' -f 1)
443+ echo \$ {name} >> CountOfSeq.txt
444+ grep "^@\$ {name}" \$ files | wc -l >> CountOfSeq.txt
445+ done
462446
463- for files in *.relabeled.fastq
464- do
465- name=\$ (echo \$ files | cut -d '/' -f '2' | cut -d '.' -f 1)
466- echo \$ {name} >> CountOfSeq.txt
467- grep "^@\$ {name}" \$ files | wc -l >> CountOfSeq.txt
468- done
469-
470- cat *.relabeled.fastq > "${ sample_id} _QF_Dmux_minLF_relabeled4Usearch.fastq"
471-
472- $usearch64 -fastx_get_sample_names *_relabeled4Usearch.fastq -output sample.txt
473-
474- $usearch64 -fastq_filter *_relabeled4Usearch.fastq -fastaout ${ sample_id} .fasta
447+ cat *.relabeled.fastq > "${ sample_id} _QF_Dmux_minLF_relabeled4Usearch.fastq"
448+
449+ usearch -fastx_get_sample_names *_relabeled4Usearch.fastq -output sample.txt
450+
451+ usearch -fastq_filter *_relabeled4Usearch.fastq -fastaout ${ sample_id} .fasta
452+
453+ awk '/^>/ {print(\$ 0)}; /^[^>]/ {print(toupper(\$ 0))}' *.fasta > ${ sample_id} _upper.fasta
454+
455+ """
456+ }
457+ else if (mode == ' usearch64' ) {
458+ """
459+ for files in ${ fastqs}
460+ do
461+ label=\$ (echo \$ files | cut -d '/' -f 3 | cut -d '.' -f 1)
462+ $usearch64 -fastx_relabel \$ files -prefix \$ {label}. -fastqout \$ {label}.relabeled.fastq
463+ done
475464
476- awk '/^>/ {print(\$ 0)}; /^[^>]/ {print(toupper(\$ 0))}' *.fasta > ${ sample_id} _upper.fasta
477- """
465+ for files in *.relabeled.fastq
466+ do
467+ name=\$ (echo \$ files | cut -d '/' -f '2' | cut -d '.' -f 1)
468+ echo \$ {name} >> CountOfSeq.txt
469+ grep "^@\$ {name}" \$ files | wc -l >> CountOfSeq.txt
470+ done
471+
472+ cat *.relabeled.fastq > "${ sample_id} _QF_Dmux_minLF_relabeled4Usearch.fastq"
473+
474+ $usearch64 -fastx_get_sample_names *_relabeled4Usearch.fastq -output sample.txt
475+
476+ $usearch64 -fastq_filter *_relabeled4Usearch.fastq -fastaout ${ sample_id} .fasta
477+
478+ awk '/^>/ {print(\$ 0)}; /^[^>]/ {print(toupper(\$ 0))}' *.fasta > ${ sample_id} _upper.fasta
479+ """
480+ }
478481 }
479482
480483ch = mode == ' vsearch' ? relabel_ch_vsearch : relabel_ch_usearch
@@ -503,12 +506,12 @@ process '06_Uniques_ZOTUs_vsearch' {
503506
504507 script:
505508 """
506- vsearch --derep_fulllength ${ upper_fasta} --sizeout --output "${ sample_id} _Unq.fasta"
509+ vsearch --threads ${ task.cpus } -- derep_fulllength ${ upper_fasta} --sizeout --output "${ sample_id} _Unq.fasta"
507510
508- vsearch --cluster_unoise "${ sample_id} _Unq.fasta" --centroids "${ sample_id} _centroids.fasta" --minsize $minsize
509- vsearch --uchime3_denovo "${ sample_id} _centroids.fasta" --nonchimeras "${ sample_id} _zotus.fasta" --relabel zotu
511+ vsearch --threads ${ task.cpus } -- cluster_unoise "${ sample_id} _Unq.fasta" --centroids "${ sample_id} _centroids.fasta" --minsize $minsize
512+ vsearch --threads ${ task.cpus } -- uchime3_denovo "${ sample_id} _centroids.fasta" --nonchimeras "${ sample_id} _zotus.fasta" --relabel zotu
510513
511- vsearch --usearch_global ${ upper_fasta} --db "${ sample_id} _zotus.fasta" --id 0.97 --otutabout zotuTable.txt
514+ vsearch --threads ${ task.cpus } -- usearch_global ${ upper_fasta} --db "${ sample_id} _zotus.fasta" --id 0.97 --otutabout zotuTable.txt
512515 """
513516}
514517
@@ -528,21 +531,25 @@ process '06_Uniques_ZOTUs_usearch' {
528531
529532 script:
530533 if (mode == ' usearch32' )
531- """
532- usearch -fastx_uniques ${ upper_fasta} -sizeout -fastaout "${ sample_id} _Unq.fasta"
533-
534- usearch -unoise3 "${ sample_id} _Unq.fasta" -zotus "${ sample_id} _zotus.fasta" -tabbedout "${ sample_id} _Unq_unoise3.txt" -minsize $minsize
535-
536- usearch -otutab ${ upper_fasta} -zotus ${ sample_id} _zotus.fasta -otutabout zotuTable.txt -mapout zmap.txt
537- """
534+ {
535+ """
536+ usearch -fastx_uniques ${ upper_fasta} -sizeout -fastaout "${ sample_id} _Unq.fasta"
537+
538+ usearch -unoise3 "${ sample_id} _Unq.fasta" -zotus "${ sample_id} _zotus.fasta" -tabbedout "${ sample_id} _Unq_unoise3.txt" -minsize $minsize
539+
540+ usearch -otutab ${ upper_fasta} -zotus ${ sample_id} _zotus.fasta -otutabout zotuTable.txt -mapout zmap.txt
541+ """
542+ }
538543 else if (mode == ' usearch64' )
539- """
540- $usearch64 -fastx_uniques ${ upper_fasta} -sizeout -fastaout "${ sample_id} _Unq.fasta"
541-
542- $usearch64 -unoise3 "${ sample_id} _Unq.fasta" -zotus "${ sample_id} _zotus.fasta" -tabbedout "${ sample_id} _Unq_unoise3.txt" -minsize $minsize
543-
544- $usearch64 -otutab ${ upper_fasta} -zotus ${ sample_id} _zotus.fasta -otutabout zotuTable.txt -mapout zmap.txt
545- """
544+ {
545+ """
546+ $usearch64 -fastx_uniques ${ upper_fasta} -sizeout -fastaout "${ sample_id} _Unq.fasta"
547+
548+ $usearch64 -unoise3 "${ sample_id} _Unq.fasta" -zotus "${ sample_id} _zotus.fasta" -tabbedout "${ sample_id} _Unq_unoise3.txt" -minsize $minsize
549+
550+ $usearch64 -otutab ${ upper_fasta} -zotus ${ sample_id} _zotus.fasta -otutabout zotuTable.txt -mapout zmap.txt
551+ """
552+ }
546553}
547554
548555zotu_ch = mode == ' vsearch' ? zotu_ch_vsearch : zotu_ch_usearch
0 commit comments