diff --git a/modules/nf-core/fastqscreen/buildfromindex/environment.yml b/modules/nf-core/fastqscreen/buildfromindex/environment.yml new file mode 100644 index 00000000000..5ffa9787c72 --- /dev/null +++ b/modules/nf-core/fastqscreen/buildfromindex/environment.yml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +name: "fastqscreen_buildfromindex" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - "bioconda::fastq-screen=0.15.3" diff --git a/modules/nf-core/fastqscreen/buildfromindex/main.nf b/modules/nf-core/fastqscreen/buildfromindex/main.nf new file mode 100644 index 00000000000..338401207f6 --- /dev/null +++ b/modules/nf-core/fastqscreen/buildfromindex/main.nf @@ -0,0 +1,69 @@ +process FASTQSCREEN_BUILDFROMINDEX { + label 'process_single' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/fastq-screen:0.15.3--pl5321hdfd78af_0': + 'biocontainers/fastq-screen:0.15.3--pl5321hdfd78af_0'}" + + input: + val(genome_names) + path(indexes), stageAs: "dir*" + + output: + path("FastQ_Screen_Genomes"), emit: database + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + dir = "FastQ_Screen_Genomes" + folder = indexes.collect { it.toString() } + database = [genome_names, folder].transpose() + copy_indexes = folder.collect { "cp -r ${it} $dir/${it}"}.join(" && ") + + // Folder name and index (within folder) name could be different - use bash to look for index name + config = database + .collect { "########## ${it[0]} \nDATABASE ${it[0]} $dir/${it[1]}/${it[1] + '_to_be_replaced'}" } + .join("\n\n") + .replace("\n", "\\n") + + """ + mkdir $dir + $copy_indexes + + echo "$config" > fastq_screen.conf + sed 's/\\\\n/\\n/g' fastq_screen.conf > $dir/fastq_screen.conf + echo "Replace folder name real index name" + + for f in ${folder.join(' ')} + do + TO_REPLACE=\${f}_to_be_replaced + + REPLACE_WITH=(\$f"/*.rev.1.bt2") + REPLACE_WITH=\$(basename \$REPLACE_WITH) + REPLACE_WITH=\${REPLACE_WITH%%.rev.1.bt2} + + sed "s/\$TO_REPLACE/\$REPLACE_WITH/g" $dir/fastq_screen.conf > new_conf.conf + mv new_conf.conf $dir/fastq_screen.conf + done + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + fastqscreen: \$(echo \$(fastq_screen --version 2>&1) | sed 's/^.*FastQ Screen v//; s/ .*\$//') + END_VERSIONS + """ + + stub: + dir = "FastQ_Screen_Genomes" + """ + mkdir $dir + touch $dir/fastq_screen.conf + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + fastqscreen: \$(echo \$(fastq_screen --version 2>&1) | sed 's/^.*FastQ Screen v//; s/ .*\$//') + END_VERSIONS + """ +} diff --git a/modules/nf-core/fastqscreen/buildfromindex/meta.yml b/modules/nf-core/fastqscreen/buildfromindex/meta.yml new file mode 100644 index 00000000000..3d5cb9b12cb --- /dev/null +++ b/modules/nf-core/fastqscreen/buildfromindex/meta.yml @@ -0,0 +1,34 @@ +name: "fastqscreen_buildfromindex" +description: Build fastq screen config file from bowtie index files +keywords: + - build + - index + - genome + - reference +tools: + - "fastqscreen": + description: "FastQ Screen allows you to screen a library of sequences in FastQ format against a set of sequence databases so you can see if the composition of the library matches with what you expect." + homepage: "https://www.bioinformatics.babraham.ac.uk/projects/fastq_screen/" + documentation: "https://stevenwingett.github.io/FastQ-Screen/" + tool_dev_url: "https://github.com/StevenWingett/FastQ-Screen/archive/refs/tags/v0.15.3.zip" + doi: "10.5281/zenodo.5838377" + licence: ["GPL-3.0-or-later"] +input: + - genome_names: + type: string + description: List of names for each index + - indexes: + type: directory + description: Bowtie2 genome directories containing index files +output: + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - database: + type: directory + description: fastq screen database folder containing config file and index folders + pattern: "FastQ_Screen_Genomes" +authors: + - "@snesic" + - "@JPejovicApis" diff --git a/modules/nf-core/fastqscreen/buildfromindex/tests/main.nf.test b/modules/nf-core/fastqscreen/buildfromindex/tests/main.nf.test new file mode 100644 index 00000000000..5357712af23 --- /dev/null +++ b/modules/nf-core/fastqscreen/buildfromindex/tests/main.nf.test @@ -0,0 +1,71 @@ +nextflow_process { + + name "Test Process FASTQSCREEN_BUILDFROMINDEX" + script "../main.nf" + process "FASTQSCREEN_BUILDFROMINDEX" + + tag "modules" + tag "modules_nfcore" + tag "fastqscreen" + tag "fastqscreen/buildfromindex" + tag "bowtie2/build" + + setup { + + run("BOWTIE2_BUILD") { + script "../../../bowtie2/build/main.nf" + process { + """ + input[0] = Channel.from([ + [[id: "sarscov2"], file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)], + [[id: "human"] , file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true)] + ]) + """ + } + } + + } + + test("sarscov2 - human") { + + when { + process { + """ + input[0] = BOWTIE2_BUILD.out.index.map{meta, index -> meta.id}.collect() + input[1] = BOWTIE2_BUILD.out.index.map{meta, index -> index}.collect() + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.database, process.out.versions).match() } + ) + } + + } + + test("sarscov2 - human - stub") { + + options "-stub" + + when { + process { + """ + input[0] = BOWTIE2_BUILD.out.index.map{meta, index -> meta.id}.collect() + input[1] = BOWTIE2_BUILD.out.index.map{meta, index -> index}.collect() + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/fastqscreen/buildfromindex/tests/main.nf.test.snap b/modules/nf-core/fastqscreen/buildfromindex/tests/main.nf.test.snap new file mode 100644 index 00000000000..0fe7d7d1342 --- /dev/null +++ b/modules/nf-core/fastqscreen/buildfromindex/tests/main.nf.test.snap @@ -0,0 +1,71 @@ +{ + "database": { + "content": [ + [ + [ + [ + "genome.1.bt2:md5,cbe3d0bbea55bc57c99b4bfa25b5fbdf", + "genome.2.bt2:md5,47b153cd1319abc88dda532462651fcf", + "genome.3.bt2:md5,4ed93abba181d8dfab2e303e33114777", + "genome.4.bt2:md5,c25be5f8b0378abf7a58c8a880b87626", + "genome.rev.1.bt2:md5,52be6950579598a990570fbcf5372184", + "genome.rev.2.bt2:md5,e3b4ef343dea4dd571642010a7d09597" + ], + [ + "genome.1.bt2:md5,2fbc8eeaf480f03b3a2362a782fa5755", + "genome.2.bt2:md5,a5300e3cf590d4cd8bd5521cac6337d6", + "genome.3.bt2:md5,d2a7a0e1c9891e847a15781c0695b84e", + "genome.4.bt2:md5,a55dc4b09e3e00586de6963800c95b9a", + "genome.rev.1.bt2:md5,93c07f7d04e5da6bf1322ad5f46ac806", + "genome.rev.2.bt2:md5,c3fa30132c0c9b9bc7868059e8e23466" + ], + "fastq_screen.conf:md5,ca56e866c7006a46bdfe4e751e787265" + ] + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-05-01T20:37:34.647221" + }, + "versions": { + "content": [ + [ + "versions.yml:md5,c2bcf85b00046c72d5dccd2dba8ac35c" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-05-01T20:37:35.126085" + }, + "sarscov2 - human - stub": { + "content": [ + { + "0": [ + [ + "fastq_screen.conf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,c2bcf85b00046c72d5dccd2dba8ac35c" + ], + "database": [ + [ + "fastq_screen.conf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,c2bcf85b00046c72d5dccd2dba8ac35c" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-05-01T20:39:14.913696" + } +} \ No newline at end of file diff --git a/modules/nf-core/fastqscreen/buildfromindex/tests/tags.yml b/modules/nf-core/fastqscreen/buildfromindex/tests/tags.yml new file mode 100644 index 00000000000..9c98e87006e --- /dev/null +++ b/modules/nf-core/fastqscreen/buildfromindex/tests/tags.yml @@ -0,0 +1,2 @@ +fastqscreen/buildfromindex: + - "modules/nf-core/fastqscreen/buildfromindex/**" diff --git a/modules/nf-core/fastqscreen/fastqscreen/environment.yml b/modules/nf-core/fastqscreen/fastqscreen/environment.yml new file mode 100644 index 00000000000..5097f091ac4 --- /dev/null +++ b/modules/nf-core/fastqscreen/fastqscreen/environment.yml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +name: "fastqscreen_fastqscreen" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - "bioconda::fastq-screen=0.15.3" diff --git a/modules/nf-core/fastqscreen/fastqscreen/main.nf b/modules/nf-core/fastqscreen/fastqscreen/main.nf new file mode 100644 index 00000000000..8686f2004de --- /dev/null +++ b/modules/nf-core/fastqscreen/fastqscreen/main.nf @@ -0,0 +1,54 @@ +process FASTQSCREEN_FASTQSCREEN { + tag "$meta.id" + label 'process_medium' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/fastq-screen:0.15.3--pl5321hdfd78af_0': + 'biocontainers/fastq-screen:0.15.3--pl5321hdfd78af_0'}" + + input: + tuple val(meta), path(reads) // .fastq files + path database + + output: + tuple val(meta), path("*.txt") , emit: txt + tuple val(meta), path("*.png") , emit: png + tuple val(meta), path("*.html"), emit: html + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def prefix = task.ext.prefix ?: "${meta.id}" + def args = task.ext.args ?: "" + + """ + fastq_screen --threads ${task.cpus} \\ + --aligner bowtie2 \\ + --conf ${database}/fastq_screen.conf \\ + $reads \\ + $args \\ + --outdir . + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + fastqscreen: \$(echo \$(fastq_screen --version 2>&1) | sed 's/^.*FastQ Screen v//; s/ .*\$//') + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch test_1_screen.html + touch test_1_screen.png + touch test_1_screen.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + fastqscreen: \$(echo \$(fastq_screen --version 2>&1) | sed 's/^.*FastQ Screen v//; s/ .*\$//') + END_VERSIONS + """ + +} diff --git a/modules/nf-core/fastqscreen/fastqscreen/meta.yml b/modules/nf-core/fastqscreen/fastqscreen/meta.yml new file mode 100644 index 00000000000..623dacf72a6 --- /dev/null +++ b/modules/nf-core/fastqscreen/fastqscreen/meta.yml @@ -0,0 +1,44 @@ +name: fastqscreen_fastqscreen +description: Align reads to multiple reference genomes using fastq-screen +keywords: + - align + - map + - fasta + - fastq + - genome + - reference +tools: + - "fastqscreen": + description: "FastQ Screen allows you to screen a library of sequences in FastQ format against a set of sequence databases so you can see if the composition of the library matches with what you expect." + homepage: "https://www.bioinformatics.babraham.ac.uk/projects/fastq_screen/" + documentation: "https://stevenwingett.github.io/FastQ-Screen/" + tool_dev_url: "https://github.com/StevenWingett/FastQ-Screen/archive/refs/tags/v0.15.3.zip" + doi: "10.5281/zenodo.5838377" + licence: ["GPL-3.0-or-later"] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - reads: + type: file + description: | + List of input FastQ files of size 1 and 2 for single-end and paired-end data, + respectively. + - database: + type: directory + description: fastq screen database folder containing config file and index folders + pattern: "FastQ_Screen_Genomes" +output: + - fastq_screen: + type: directory + description: Output fastq_screen file containing alignment statistics + pattern: "*.{_fq_screen}" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@snesic" + - "@JPejovicApis" diff --git a/modules/nf-core/fastqscreen/fastqscreen/tests/main.nf.test b/modules/nf-core/fastqscreen/fastqscreen/tests/main.nf.test new file mode 100644 index 00000000000..6d858a4db2d --- /dev/null +++ b/modules/nf-core/fastqscreen/fastqscreen/tests/main.nf.test @@ -0,0 +1,87 @@ +nextflow_process { + + name "Test Process FASTQSCREEN_FASTQSCREEN" + script "../main.nf" + process "FASTQSCREEN_FASTQSCREEN" + + tag "modules" + tag "modules_nfcore" + tag "bowtie2/build" + tag "fastqscreen" + tag "fastqscreen/buildfromindex" + tag "fastqscreen/fastqscreen" + + setup { + + run("BOWTIE2_BUILD") { + script "../../../bowtie2/build/main.nf" + process { + """ + input[0] = Channel.from([ + [[id: "sarscov2"], file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)], + [[id: "human"] , file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true)] + ]) + """ + } + } + + run("FASTQSCREEN_BUILDFROMINDEX") { + script "../../../fastqscreen/buildfromindex/main.nf" + process { + """ + input[0] = BOWTIE2_BUILD.out.index.map{meta, index -> meta.id}.collect() + input[1] = BOWTIE2_BUILD.out.index.map{meta, index -> index}.collect() + """ + } + } + } + + test("sarscov2 - human") { + + when { + process { + """ + input[0] = [[ id:'test', single_end:true ], + [file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) ] + ] + input[1] = FASTQSCREEN_BUILDFROMINDEX.out.database + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.version).match("version") }, + { assert file(process.out.txt.get(0).get(1)).exists() }, + { assert file(process.out.png.get(0).get(1)).exists() }, + { assert file(process.out.html.get(0).get(1)).exists() } + ) + } + + } + + test("sarscov2 - human - stub") { + + options "-stub" + when { + process { + """ + input[0] = [[ id:'test', single_end:true ], + [file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) ] + ] + input[1] = FASTQSCREEN_BUILDFROMINDEX.out.database + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/fastqscreen/fastqscreen/tests/main.nf.test.snap b/modules/nf-core/fastqscreen/fastqscreen/tests/main.nf.test.snap new file mode 100644 index 00000000000..b2450191939 --- /dev/null +++ b/modules/nf-core/fastqscreen/fastqscreen/tests/main.nf.test.snap @@ -0,0 +1,81 @@ +{ + "version": { + "content": null, + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-04-30T14:22:56.541922683" + }, + "sarscov2 - human - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": true + }, + "test_1_screen.txt:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + [ + { + "id": "test", + "single_end": true + }, + "test_1_screen.png:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + [ + { + "id": "test", + "single_end": true + }, + "test_1_screen.html:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "3": [ + "versions.yml:md5,8ac0239b5103352958d9a9e562b23103" + ], + "html": [ + [ + { + "id": "test", + "single_end": true + }, + "test_1_screen.html:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "png": [ + [ + { + "id": "test", + "single_end": true + }, + "test_1_screen.png:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "txt": [ + [ + { + "id": "test", + "single_end": true + }, + "test_1_screen.txt:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,8ac0239b5103352958d9a9e562b23103" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-04-30T14:23:12.70922619" + } +} \ No newline at end of file diff --git a/modules/nf-core/fastqscreen/fastqscreen/tests/tags.yml b/modules/nf-core/fastqscreen/fastqscreen/tests/tags.yml new file mode 100644 index 00000000000..b03bfb4597b --- /dev/null +++ b/modules/nf-core/fastqscreen/fastqscreen/tests/tags.yml @@ -0,0 +1,2 @@ +fastqscreen/fastqscreen: + - "modules/nf-core/fastqscreen/fastqscreen/**"