Highly parallelised multi-taxonomic profiling of shotgun and long-read metagenomic data

public public 1yr ago Version: 1.0.1 0 bookmarks
Loading...

Introduction

nf-core/taxprofiler is a bioinformatics best-practice analysis pipeline for taxonomic classification and profiling of shotgun metagenomic data. It allows for in-parallel taxonomic identification of reads or taxonomic abundance estimation with multiple classification and profiling tools against multiple databases, produces standardised output tables.

The pipeline is built using Nextflow , a workflow tool to run tasks across multiple compute infrastructures in a very portable manner. It uses Docker/Singularity containers making installation trivial and results highly reproducible. The Nextflow DSL2 implementation of this pipeline uses one container per process which makes it much easier to maintain and update software dependencies. Where possible, these processes have been submitted to and installed from nf-core/modules in order to make them available to all nf-core pipelines, and to everyone within the Nextflow community!

On release, automated continuous integration tests run the pipeline on a full-sized dataset on the AWS cloud infrastructure. This ensures that the pipeline runs on AWS, has sensible resource allocation defaults set to run on real-world datasets, and permits the persistent storage of results to benchmark between pipeline releases and other analysis sources.The results obtained from the full-sized test can be viewed on the nf-core website .

The nf-core/taxprofiler CI test dataset uses sequencing data from Maixner et al. (2021) Curr. Bio. . The AWS full test dataset uses sequencing data and reference genomes from Meslier (2022) Sci. Data

Pipeline summary

  1. Read QC ( FastQC or falco as an alternative option)

  2. Performs optional read pre-processing

  3. Supports statistics for host-read removal ( Samtools )

  4. Performs taxonomic classification and/or profiling using one or more of:

  5. Perform optional post-processing with:

  6. Standardises output tables ( Taxpasta )

  7. Present QC for raw reads ( MultiQC )

  8. Plotting Kraken2, Centrifuge, Kaiju and MALT results ( Krona )

Quick Start

  1. Install Nextflow ( >=22.10.1 ).

  2. Install any of Docker , Singularity (you can follow this tutorial ), Podman , Shifter or Charliecloud for full pipeline reproducibility (you can use Conda both to install Nextflow itself and also to manage software within pipelines. Please only use it within pipelines as a last resort; see docs ) .

  3. Download the pipeline and test it on a minimal dataset with a single command:

    nextflow run nf-core/taxprofiler -profile test,YOURPROFILE --outdir <OUTDIR>
    

    Note that some form of configuration will be needed so that Nextflow knows how to fetch the required software. This is usually done in the form of a config profile ( YOURPROFILE in the example command above). You can chain multiple config profiles in a comma-separated string.

    • The pipeline comes with config profiles called docker , singularity , podman , shifter , charliecloud and conda which instruct the pipeline to use the named tool for software management. For example, -profile test,docker .

    • Please check nf-core/configs to see if a custom config file to run nf-core pipelines already exists for your Institute. If so, you can simply use -profile <institute> in your command. This will enable either docker or singularity and set the appropriate execution settings for your local compute environment.

    • If you are using singularity , please use the nf-core download command to download images first, before running the pipeline. Setting the NXF_SINGULARITY_CACHEDIR or singularity.cacheDir Nextflow options enables you to store and re-use the images from a central location for future pipeline runs.

    • If you are using conda , it is highly recommended to use the NXF_CONDA_CACHEDIR or conda.cacheDir settings to store the environments in a central location for future pipeline runs.

  4. Start running your own analysis!

    nextflow run nf-core/taxprofiler --input samplesheet.csv --databases database.csv --outdir <OUTDIR> --run_<TOOL1> --run_<TOOL1> -profile <docker/singularity/podman/shifter/charliecloud/conda/institute>
    

Documentation

The nf-core/taxprofiler pipeline comes with documentation about the pipeline usage , parameters and output .

Credits

nf-core/taxprofiler was originally written by James A. Fellows Yates , Moritz Beber , and Sofia Stamouli .

We thank the following people for their contributions to the development of this pipeline:

Lauri Mesilaakso , Tanja Normark , Maxime Borry , Thomas A. Christensen II , Jianhong Ou , Rafal Stepien , Mahwash Jamy , and the nf-core/community .

We also are grateful for the feedback and comments from:

Credit and thanks also goes to Zandra Fagernäs for the logo.

Contributions and Support

If you would like to contribute to this pipeline, please see the contributing guidelines .

For further information or help, don't hesitate to get in touch on the Slack #taxprofiler channel (you can join with this invite ).

Citations

If you use nf-core/taxprofiler for your analysis, please cite it using the following doi: 10.5281/zenodo.7728364

An extensive list of references for the tools used by the pipeline can be found in the CITATIONS.md file.

You can cite the nf-core publication as follows:

The nf-core framework for community-curated bioinformatics pipelines.

Philip Ewels, Alexander Peltzer, Sven Fillinger, Harshil Patel, Johannes Alneberg, Andreas Wilm, Maxime Ulysse Garcia, Paolo Di Tommaso & Sven Nahnsen.

Nat Biotechnol. 2020 Feb 13. doi: 10.1038/s41587-020-0439-x .

Code Snippets

23
24
25
26
27
28
29
30
"""
cut -f1-3,6-8 '${report}' > '${result}'

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    cut: \$(echo \$(cut --version 2>&1) | sed 's/^.*(GNU coreutils) //; s/ Copyright.*\$//')
END_VERSIONS
"""
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
# Copy the file to a new name
cp ${krona} ${prefix}.txt

# Remove ugly 'x__' prefixes for each of the taxonomic levels
LEVELS=(d k p c o f g s)
for L in "\${LEVELS[@]}"; do
    sed -i "s/\${L}__//g" ${prefix}.txt
done

# Remove underscores that are standing in place of spaces
sed -i "s/_/ /g" ${prefix}.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    sed: \$(echo \$(sed --version 2>&1) | sed 's/^.*GNU sed) //; s/ .*\$//')
END_VERSIONS
"""
21
22
23
24
25
26
27
28
29
30
"""
check_samplesheet.py \\
    $samplesheet \\
    samplesheet.valid.csv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    python: \$(python --version | sed 's/Python //g')
END_VERSIONS
"""
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
"""
AdapterRemoval  \\
    --file1 $reads \\
    $args \\
    $list \\
    --basename ${prefix} \\
    --threads ${task.cpus} \\
    --seed 42 \\
    --gzip

ensure_fastq() {
    if [ -f "\${1}" ]; then
        mv "\${1}" "\${1::-3}.fastq.gz"
    fi

}

ensure_fastq '${prefix}.truncated.gz'
ensure_fastq '${prefix}.discarded.gz'

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    adapterremoval: \$(AdapterRemoval --version 2>&1 | sed -e "s/AdapterRemoval ver. //g")
END_VERSIONS
"""
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
"""
AdapterRemoval  \\
    --file1 ${reads[0]} \\
    --file2 ${reads[1]} \\
    $args \\
    $list \\
    --basename ${prefix} \\
    --threads $task.cpus \\
    --seed 42 \\
    --gzip

ensure_fastq() {
    if [ -f "\${1}" ]; then
        mv "\${1}" "\${1::-3}.fastq.gz"
    fi

}

ensure_fastq '${prefix}.truncated.gz'
ensure_fastq '${prefix}.discarded.gz'
ensure_fastq '${prefix}.pair1.truncated.gz'
ensure_fastq '${prefix}.pair2.truncated.gz'
ensure_fastq '${prefix}.collapsed.gz'
ensure_fastq '${prefix}.collapsed.truncated.gz'
ensure_fastq '${prefix}.paired.gz'

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    adapterremoval: \$(AdapterRemoval --version 2>&1 | sed -e "s/AdapterRemoval ver. //g")
END_VERSIONS
"""
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
maxmem=\$(echo \"$task.memory\"| sed 's/ GB/g/g')
bbduk.sh \\
    -Xmx\$maxmem \\
    $raw \\
    $trimmed \\
    threads=$task.cpus \\
    $args \\
    $contaminants_fa \\
    &> ${prefix}.bbduk.log
cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bbmap: \$(bbversion.sh | grep -v "Duplicate cpuset")
END_VERSIONS
"""
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
"""
INDEX=`find -L ./ -name "*.rev.1.bt2" | sed "s/\\.rev.1.bt2\$//"`
[ -z "\$INDEX" ] && INDEX=`find -L ./ -name "*.rev.1.bt2l" | sed "s/\\.rev.1.bt2l\$//"`
[ -z "\$INDEX" ] && echo "Bowtie2 index files not found" 1>&2 && exit 1

bowtie2 \\
    -x \$INDEX \\
    $reads_args \\
    --threads $task.cpus \\
    $unaligned \\
    $args \\
    2> ${prefix}.bowtie2.log \\
    | samtools $samtools_command $args2 --threads $task.cpus -o ${prefix}.${extension} -

if [ -f ${prefix}.unmapped.fastq.1.gz ]; then
    mv ${prefix}.unmapped.fastq.1.gz ${prefix}.unmapped_1.fastq.gz
fi

if [ -f ${prefix}.unmapped.fastq.2.gz ]; then
    mv ${prefix}.unmapped.fastq.2.gz ${prefix}.unmapped_2.fastq.gz
fi

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bowtie2: \$(echo \$(bowtie2 --version 2>&1) | sed 's/^.*bowtie2-align-s version //; s/ .*\$//')
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
    pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""
80
81
82
83
84
85
86
87
88
89
90
91
92
"""
touch ${prefix}.${extension}
touch ${prefix}.bowtie2.log
touch ${prefix}.unmapped_1.fastq.gz
touch ${prefix}.unmapped_2.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bowtie2: \$(echo \$(bowtie2 --version 2>&1) | sed 's/^.*bowtie2-align-s version //; s/ .*\$//')
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
    pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""
NextFlow From line 80 of align/main.nf
22
23
24
25
26
27
28
29
"""
mkdir bowtie2
bowtie2-build $args --threads $task.cpus $fasta bowtie2/${fasta.baseName}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bowtie2: \$(echo \$(bowtie2 --version 2>&1) | sed 's/^.*bowtie2-align-s version //; s/ .*\$//')
END_VERSIONS
"""
32
33
34
35
36
37
38
39
40
41
"""
mkdir bowtie2
touch bowtie2/${fasta.baseName}.{1..4}.bt2
touch bowtie2/${fasta.baseName}.rev.{1,2}.bt2

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bowtie2: \$(echo \$(bowtie2 --version 2>&1) | sed 's/^.*bowtie2-align-s version //; s/ .*\$//')
END_VERSIONS
"""
30
31
32
33
34
35
36
37
38
39
40
41
"""
bracken \\
    ${args} \\
    -d '${database}' \\
    -i '${kraken_report}' \\
    -o '${bracken_report}'

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    bracken: ${VERSION}
END_VERSIONS
"""
26
27
28
29
30
31
32
33
34
35
36
"""
combine_bracken_outputs.py \\
    $args \\
    --files ${input} \\
    -o ${prefix}.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    combine_bracken_output: ${VERSION}
END_VERSIONS
"""
26
27
28
29
30
31
32
33
"""
cat ${readList.join(' ')} > ${prefix}.merged.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
END_VERSIONS
"""
NextFlow From line 26 of fastq/main.nf
40
41
42
43
44
45
46
47
48
"""
cat ${read1.join(' ')} > ${prefix}_1.merged.fastq.gz
cat ${read2.join(' ')} > ${prefix}_2.merged.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
END_VERSIONS
"""
NextFlow From line 40 of fastq/main.nf
57
58
59
60
61
62
63
64
"""
touch ${prefix}.merged.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
END_VERSIONS
"""
NextFlow From line 57 of fastq/main.nf
68
69
70
71
72
73
74
75
76
"""
touch ${prefix}_1.merged.fastq.gz
touch ${prefix}_2.merged.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
END_VERSIONS
"""
NextFlow From line 68 of fastq/main.nf
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
## we add "-no-name ._" to ensure silly Mac OSX metafiles files aren't included
db_name=`find -L ${db} -name "*.1.cf" -not -name "._*"  | sed 's/\\.1.cf\$//'`
centrifuge \\
    -x \$db_name \\
    -p $task.cpus \\
    $paired \\
    --report-file ${prefix}.report.txt \\
    -S ${prefix}.results.txt \\
    $unaligned \\
    $aligned \\
    $args

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    centrifuge: \$( centrifuge --version  | sed -n 1p | sed 's/^.*centrifuge-class version //')
END_VERSIONS
"""
24
25
26
27
28
29
30
31
32
"""
db_name=`find -L ${db} -name "*.1.cf" -not -name "._*"  | sed 's/\\.1.cf\$//'`
centrifuge-kreport -x \$db_name ${report} > ${prefix}.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    centrifuge: \$( centrifuge --version  | sed -n 1p | sed 's/^.*centrifuge-class version //')
END_VERSIONS
"""
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
DB=`find -L ./ -name "*.dmnd" | sed 's/\\.dmnd\$//'`

diamond \\
    blastx \\
    --threads $task.cpus \\
    --db \$DB \\
    --query $fasta \\
    --outfmt ${outfmt} ${columns} \\
    $args \\
    --out ${prefix}.${out_ext} \\
    --log

mv diamond.log ${prefix}.log

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    diamond: \$(diamond --version 2>&1 | tail -n 1 | sed 's/^diamond version //')
END_VERSIONS
"""
26
27
28
29
30
31
32
33
"""
falco $args --threads $task.cpus ${reads} -D ${prefix}_data.txt -S ${prefix}_summary.txt -R ${prefix}_report.html

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    falco:\$( falco --version | sed -e "s/falco//g" )
END_VERSIONS
"""
35
36
37
38
39
40
41
42
43
44
"""
[ ! -f  ${prefix}_1.fastq.gz ] && ln -s ${reads[0]} ${prefix}_1.fastq.gz
[ ! -f  ${prefix}_2.fastq.gz ] && ln -s ${reads[1]} ${prefix}_2.fastq.gz
falco $args --threads $task.cpus ${prefix}_1.fastq.gz ${prefix}_2.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    falco:\$( falco --version | sed -e "s/falco//g" )
END_VERSIONS
"""
49
50
51
52
53
54
55
56
57
58
"""
touch ${prefix}_data.txt
touch ${prefix}_fastqc_data.html
touch ${prefix}_summary.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    falco: \$( falco --version | sed -e "s/falco v//g" )
END_VERSIONS
"""
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
[ ! -f  ${prefix}.fastq.gz ] && ln -sf $reads ${prefix}.fastq.gz

fastp \\
    --stdout \\
    --in1 ${prefix}.fastq.gz \\
    --thread $task.cpus \\
    --json ${prefix}.fastp.json \\
    --html ${prefix}.fastp.html \\
    $adapter_list \\
    $fail_fastq \\
    $args \\
    2> ${prefix}.fastp.log \\
| gzip -c > ${prefix}.fastp.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g")
END_VERSIONS
"""
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"""
[ ! -f  ${prefix}.fastq.gz ] && ln -sf $reads ${prefix}.fastq.gz

fastp \\
    --in1 ${prefix}.fastq.gz \\
    --out1  ${prefix}.fastp.fastq.gz \\
    --thread $task.cpus \\
    --json ${prefix}.fastp.json \\
    --html ${prefix}.fastp.html \\
    $adapter_list \\
    $fail_fastq \\
    $args \\
    2> ${prefix}.fastp.log

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g")
END_VERSIONS
"""
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
"""
[ ! -f  ${prefix}_1.fastq.gz ] && ln -sf ${reads[0]} ${prefix}_1.fastq.gz
[ ! -f  ${prefix}_2.fastq.gz ] && ln -sf ${reads[1]} ${prefix}_2.fastq.gz
fastp \\
    --in1 ${prefix}_1.fastq.gz \\
    --in2 ${prefix}_2.fastq.gz \\
    --out1 ${prefix}_1.fastp.fastq.gz \\
    --out2 ${prefix}_2.fastp.fastq.gz \\
    --json ${prefix}.fastp.json \\
    --html ${prefix}.fastp.html \\
    $adapter_list \\
    $fail_fastq \\
    $merge_fastq \\
    --thread $task.cpus \\
    --detect_adapter_for_pe \\
    $args \\
    2> ${prefix}.fastp.log

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    fastp: \$(fastp --version 2>&1 | sed -e "s/fastp //g")
END_VERSIONS
"""
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
printf "%s %s\\n" $rename_to | while read old_name new_name; do
    [ -f "\${new_name}" ] || ln -s \$old_name \$new_name
done

fastqc \\
    $args \\
    --threads $task.cpus \\
    $renamed_files

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    fastqc: \$( fastqc --version | sed -e "s/FastQC v//g" )
END_VERSIONS
"""
46
47
48
49
50
51
52
53
54
"""
touch ${prefix}.html
touch ${prefix}.zip

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    fastqc: \$( fastqc --version | sed -e "s/FastQC v//g" )
END_VERSIONS
"""
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
filtlong \\
    $short_reads \\
    $args \\
    $longreads \\
    2> ${prefix}.log \\
    | gzip -n > ${prefix}.fastq.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    filtlong: \$( filtlong --version | sed -e "s/Filtlong v//g" )
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
# Not calling gunzip itself because it creates files
# with the original group ownership rather than the
# default one for that user / the work directory
gzip \\
    -cd \\
    $args \\
    $archive \\
    > $gunzip

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    gunzip: \$(echo \$(gunzip --version 2>&1) | sed 's/^.*(gzip) //; s/ Copyright.*\$//')
END_VERSIONS
"""
NextFlow From line 23 of gunzip/main.nf
41
42
43
44
45
46
47
"""
touch $gunzip
cat <<-END_VERSIONS > versions.yml
"${task.process}":
    gunzip: \$(echo \$(gunzip --version 2>&1) | sed 's/^.*(gzip) //; s/ Copyright.*\$//')
END_VERSIONS
"""
NextFlow From line 41 of gunzip/main.nf
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
dbnodes=`find -L ${db} -name "*nodes.dmp"`
dbnames=`find -L ${db} -name "*names.dmp"`
kaiju2krona \\
    $args \\
    -t \$dbnodes \\
    -n \$dbnames \\
    -i ${tsv} \\
    -o ${prefix}.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    kaiju: \$(echo \$( kaiju -h 2>&1 | sed -n 1p | sed 's/^.*Kaiju //' ))
END_VERSIONS
"""
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
dbnodes=`find -L ${db} -name "*nodes.dmp"`
dbname=`find -L ${db} -name "*.fmi" -not -name "._*"`
kaiju2table   $args \\
    -t \$dbnodes \\
    -n \$dbname \\
    -r ${taxon_rank} \\
    -o ${prefix}.txt \\
    ${results}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    kaiju: \$(echo \$( kaiju -h 2>&1 | sed -n 1p | sed 's/^.*Kaiju //' ))
END_VERSIONS
"""
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
dbnodes=`find -L ${db} -name "*nodes.dmp"`
dbname=`find -L ${db} -name "*.fmi" -not -name "._*"`
kaiju \\
    $args \\
    -z $task.cpus \\
    -t \$dbnodes \\
    -f \$dbname \\
    -o ${prefix}.tsv \\
    $input

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    kaiju: \$(echo \$( kaiju -h 2>&1 | sed -n 1p | sed 's/^.*Kaiju //' ))
END_VERSIONS
"""
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
kraken2 \\
    --db $db \\
    --threads $task.cpus \\
    --report ${prefix}.kraken2.report.txt \\
    --gzip-compressed \\
    $unclassified_option \\
    $classified_option \\
    $readclassification_option \\
    $paired \\
    $args \\
    $reads

$compress_reads_command

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    kraken2: \$(echo \$(kraken2 --version 2>&1) | sed 's/^.*Kraken version //; s/ .*\$//')
    pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
32
33
"""
combine_kreports.py \\
    -r ${kreports} \\
    -o ${prefix}.txt \\
    ${args}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    combine_kreports.py: ${VERSION}
END_VERSIONS
"""
25
26
27
28
29
30
31
32
33
34
35
"""
kreport2krona.py \\
    -r ${kreport} \\
    -o ${prefix}.txt \\
    ${args}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    kreport2krona.py: ${VERSION}
END_VERSIONS
"""
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
"""
krakenuniq \\
    --db $db \\
    --preload \\
    --preload-size $ram_chunk_size \\
    --threads $task.cpus \\
    $args

strip_suffix() {
    local result=\$1
    # Strip any file extensions.
    echo "\${result%%.*}"
}

printf "%s\\n" ${fastqs} | while read FASTQ; do \\
    PREFIX="\$(strip_suffix "\${FASTQ}")"

    krakenuniq \\
        --db $db \\
        --threads $task.cpus \\
        $report \\
        $output_option \\
        $unclassified_option \\
        $classified_option \\
        $output_option \\
        $args2 \\
        "\${FASTQ}"
done

$compress_reads_command

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    krakenuniq: \$(echo \$(krakenuniq --version 2>&1) | sed 's/^.*KrakenUniq version //; s/ .*\$//')
END_VERSIONS
"""
 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
"""
krakenuniq \\
    --db $db \\
    --preload \\
    --preload-size $ram_chunk_size \\
    --threads $task.cpus \\
    $args

strip_suffix() {
    local result
    read result
    # Strip any trailing dot or underscore.
    result="\${result%_}"
    echo "\${result%.}"
}

printf "%s %s\\n" ${fastqs} | while read FASTQ; do \\
    read -r -a FASTQ <<< "\${FASTQ}"
    PREFIX="\$(printf "%s\\n" "\${FASTQ[@]}" |  sed -e 'N;s/^\\(.*\\).*\\n\\1.*\$/\\1\\n\\1/;D' | strip_suffix)"

    krakenuniq \\
        --db $db \\
        --threads $task.cpus \\
        $report \\
        $output_option \\
        $unclassified_option \\
        $classified_option \\
        $output_option \\
        --paired \\
        $args2 \\
        "\${FASTQ[@]}"
done

$compress_reads_command

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    krakenuniq: \$(echo \$(krakenuniq --version 2>&1) | sed 's/^.*KrakenUniq version //; s/ .*\$//')
END_VERSIONS
"""
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
"""
echo krakenuniq \\
    --db $db \\
    --preload \\
    --preload-size $ram_chunk_size \\
    --threads $task.cpus \\
    $args

strip_suffix() {
    local result=\$1
    # Strip any file extensions.
    echo "\${result%%.*}"
}

printf "%s\\n" ${fastqs} | while read FASTQ; do \\
    echo "\${FASTQ}"
    PREFIX="\$(strip_suffix "\${FASTQ}")"
    echo "\${PREFIX}"

    echo krakenuniq \\
        --db $db \\
        --threads $task.cpus \\
        $report \\
        $output_option \\
        $unclassified_option \\
        $classified_option \\
        $output_option \\
        $args2 \\
        "\${FASTQ}"

    touch "\${PREFIX}.classified.fastq.gz"
    touch "\${PREFIX}.krakenuniq.classified.txt"
    touch "\${PREFIX}.krakenuniq.report.txt"
    touch "\${PREFIX}.unclassified.fastq.gz"
done

echo $compress_reads_command

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    krakenuniq: \$(echo \$(krakenuniq --version 2>&1) | sed 's/^.*KrakenUniq version //; s/ .*\$//')
END_VERSIONS
"""
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
"""
echo krakenuniq \\
    --db $db \\
    --preload \\
    --preload-size $ram_chunk_size \\
    --threads $task.cpus \\
    $args

strip_suffix() {
    local result
    read result
    # Strip any trailing dot or underscore.
    result="\${result%_}"
    echo "\${result%.}"
}

printf "%s %s\\n" ${fastqs} | while read FASTQ; do \\
    read -r -a FASTQ <<< "\${FASTQ}"
    echo "\${FASTQ[@]}"
    PREFIX="\$(printf "%s\\n" "\${FASTQ[@]}" |  sed -e 'N;s/^\\(.*\\).*\\n\\1.*\$/\\1\\n\\1/;D' | strip_suffix)"
    echo "\${PREFIX}"

    echo krakenuniq \\
        --db $db \\
        --threads $task.cpus \\
        $report \\
        $output_option \\
        $unclassified_option \\
        $classified_option \\
        $output_option \\
        --paired \\
        $args2 \\
        "\${FASTQ[@]}"

    touch "\${PREFIX}.classified_1.fastq.gz" "\${PREFIX}.classified_2.fastq.gz"
    touch "\${PREFIX}.krakenuniq.classified.txt"
    touch "\${PREFIX}.krakenuniq.report.txt"
    touch "\${PREFIX}.unclassified_1.fastq.gz" "\${PREFIX}.unclassified_2.fastq.gz"
done

echo $compress_reads_command

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    krakenuniq: \$(echo \$(krakenuniq --version 2>&1) | sed 's/^.*KrakenUniq version //; s/ .*\$//')
END_VERSIONS
"""
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
TAXONOMY=\$(find -L . -name '*.tab' -exec dirname {} \\;)
echo \$TAXONOMY

ktImportTaxonomy \\
    $args \\
    -o ${prefix}.html \\
    -tax \$TAXONOMY/ \\
    $report

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    krona: $VERSION
END_VERSIONS
"""
23
24
25
26
27
28
29
30
31
32
33
"""
ktImportText  \\
    $args \\
    -o ${prefix}.html \\
    $report

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    krona: \$( echo \$(ktImportText 2>&1) | sed 's/^.*KronaTools //g; s/- ktImportText.*\$//g')
END_VERSIONS
"""
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
malt-run \\
    -t $task.cpus \\
    -v \\
    -o . \\
    $args \\
    --inFile ${fastqs.join(' ')} \\
    --index $index/ |&tee ${prefix}-malt-run.log

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    malt: \$(malt-run --help  2>&1 | grep -o 'version.* ' | cut -f 1 -d ',' | cut -f2 -d ' ')
END_VERSIONS
"""
26
27
28
29
30
31
32
33
34
35
36
37
"""
rma2info \\
    -i ${rma6} \\
    -o ${prefix}.txt.gz \\
    ${summary} \\
    $args

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    megan: \$(echo \$(rma2info 2>&1) | grep version | sed 's/.*version //g;s/, built.*//g')
END_VERSIONS
"""
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
minimap2 \\
    $args \\
    -t $task.cpus \\
    "${reference ?: reads}" \\
    "$reads" \\
    $cigar_paf \\
    $set_cigar_bam \\
    $bam_output


cat <<-END_VERSIONS > versions.yml
"${task.process}":
    minimap2: \$(minimap2 --version 2>&1)
END_VERSIONS
"""
22
23
24
25
26
27
28
29
30
31
32
33
"""
minimap2 \\
    -t $task.cpus \\
    -d ${fasta.baseName}.mmi \\
    $args \\
    $fasta

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    minimap2: \$(minimap2 --version 2>&1)
END_VERSIONS
"""
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
motus \\
    merge \\
    -db $db \\
    ${cmd_input} \\
    $args \\
    -o ${prefix}.${suffix}

## Take version from the mOTUs/profile module output, as cannot reconstruct
## version without having database staged in this directory.
VERSION=\$(cat ${profile_version_yml} | grep '/*motus:.*' | sed 's/.*otus: //g')

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    motus: \$VERSION
END_VERSIONS
"""
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
motus profile \\
    $args \\
    $inputs \\
    $refdb \\
    -t $task.cpus \\
    -n $prefix \\
    -o ${prefix}.out \\
    2> ${prefix}.log

## mOTUs version number is not available from command line.
## mOTUs save the version number in index database folder.
## mOTUs will check the database version is same version as exec version.
if [ "$db" == "" ]; then
    VERSION=\$(echo \$(motus -h 2>&1) | sed 's/^.*Version: //; s/References.*\$//')
else
    VERSION=\$(grep motus $db/db_mOTU_versions | sed 's/motus\\t//g')
fi
cat <<-END_VERSIONS > versions.yml
"${task.process}":
    motus: \$VERSION
END_VERSIONS
"""
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
multiqc \\
    --force \\
    $args \\
    $config \\
    $extra_config \\
    .

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    multiqc: \$( multiqc --version | sed -e "s/multiqc, version //g" )
END_VERSIONS
"""
43
44
45
46
47
48
49
50
51
52
"""
touch multiqc_data
touch multiqc_plots
touch multiqc_report.html

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    multiqc: \$( multiqc --version | sed -e "s/multiqc, version //g" )
END_VERSIONS
"""
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
## To ensure ID matches rest of pipeline based on meta.id rather than input file name

[[ -f ${prefix}.fastq.gz   ]] || ln -s $reads ${prefix}.fastq.gz

porechop \\
    -i ${prefix}.fastq.gz \\
    -t $task.cpus \\
    $args \\
    -o ${prefix}_porechopped.fastq.gz \\
    > ${prefix}.log

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    porechop: \$( porechop --version )
END_VERSIONS
"""
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
prinseq++ \\
    -threads $task.cpus \\
    -fastq ${reads} \\
    -out_name ${prefix} \\
    -out_gz \\
    -VERBOSE 1 \\
    $args \\
    | tee ${prefix}.log

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    prinseqplusplus: \$(echo \$(prinseq++ --version | cut -f 2 -d ' ' ))
END_VERSIONS
"""
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
prinseq++ \\
    -threads $task.cpus \\
    -fastq ${reads[0]} \\
    -fastq2 ${reads[1]} \\
    -out_name ${prefix} \\
    -out_gz \\
    -VERBOSE 1 \\
    $args \\
    | tee ${prefix}.log

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    prinseqplusplus: \$(echo \$(prinseq++ --version | cut -f 2 -d ' ' ))
END_VERSIONS
"""
24
25
26
27
28
29
30
31
32
33
34
35
"""
samtools \\
    index \\
    -@ ${task.cpus-1} \\
    $args \\
    $input

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
38
39
40
41
42
43
44
45
46
47
"""
touch ${input}.bai
touch ${input}.crai
touch ${input}.csi

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
NextFlow From line 38 of index/main.nf
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
samtools \\
    stats \\
    --threads ${task.cpus} \\
    ${reference} \\
    ${input} \\
    > ${prefix}.stats

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
41
42
43
44
45
46
47
48
"""
touch ${prefix}.stats

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
NextFlow From line 41 of stats/main.nf
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
samtools \\
    view \\
    --threads ${task.cpus-1} \\
    ${reference} \\
    ${readnames} \\
    $args \\
    -o ${prefix}.${file_type} \\
    $input \\
    $args2

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
57
58
59
60
61
62
63
64
65
"""
touch ${prefix}.bam
touch ${prefix}.cram

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
END_VERSIONS
"""
NextFlow From line 57 of view/main.nf
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
taxpasta merge \\
    $args \\
    $taxonomy_option \\
    $samplesheet_input \\
    $profiles


cat <<-END_VERSIONS > versions.yml
"${task.process}":
    taxpasta: \$(taxpasta --version)
END_VERSIONS
"""
NextFlow From line 34 of merge/main.nf
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
"""
mkdir $prefix

## Ensures --strip-components only applied when top level of tar contents is a directory
## If just files or multiple directories, place all in prefix
if [[ \$(tar -taf ${archive} | grep -o -P "^.*?\\/" | uniq | wc -l) -eq 1 ]]; then
    tar \\
        -C $prefix --strip-components 1 \\
        -xavf \\
        $args \\
        $archive \\
        $args2
else
    tar \\
        -C $prefix \\
        -xavf \\
        $args \\
        $archive \\
        $args2
fi

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//')
END_VERSIONS
"""
NextFlow From line 25 of untar/main.nf
54
55
56
57
58
59
60
61
62
"""
mkdir $prefix
touch ${prefix}/file.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
    untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//')
END_VERSIONS
"""
NextFlow From line 54 of untar/main.nf
ShowHide 42 more snippets with no or duplicated tags.

Login to post a comment if you would like to share your experience with this workflow.

Do you know this workflow well? If so, you can request seller status , and start supporting this workflow.

Related Workflows

cellranger-snakemake-gke
snakemake workflow to run cellranger on a given bucket using gke.
A Snakemake workflow for running cellranger on a given bucket using Google Kubernetes Engine. The usage of this workflow ...