diff --git a/modules/nf-core/bamtofastq10x/environment.yml b/modules/nf-core/bamtofastq10x/environment.yml new file mode 100644 index 000000000000..d612f512e6f6 --- /dev/null +++ b/modules/nf-core/bamtofastq10x/environment.yml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +name: "bamtofastq10x" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - "bioconda::10x_bamtofastq=1.4.1" diff --git a/modules/nf-core/bamtofastq10x/main.nf b/modules/nf-core/bamtofastq10x/main.nf new file mode 100644 index 000000000000..be1b14415bee --- /dev/null +++ b/modules/nf-core/bamtofastq10x/main.nf @@ -0,0 +1,45 @@ +process BAMTOFASTQ10X { + tag "$meta.id" + label 'process_low' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/10x_bamtofastq:1.4.1--hdbdd923_2': + 'biocontainers/10x_bamtofastq:1.4.1--hdbdd923_2' }" + + input: + tuple val(meta), path(bam) + + output: + tuple val(meta), path("*.fastq.gz"), emit: fastq + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + bamtofastq \\ + $args \\ + $bam \\ + ${prefix}.fastq.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bamtofastq10x: \$(bamtofastq --version |& sed '1!d ; s/bamtofastq //') + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.fastq.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bamtofastq10x: \$(bamtofastq --version |& sed '1!d ; s/bamtofastq //') + END_VERSIONS + """ +} diff --git a/modules/nf-core/bamtofastq10x/meta.yml b/modules/nf-core/bamtofastq10x/meta.yml new file mode 100644 index 000000000000..2ac31a5cf827 --- /dev/null +++ b/modules/nf-core/bamtofastq10x/meta.yml @@ -0,0 +1,48 @@ +name: bamtofastq10x + +description: Tool for converting 10x BAMs produced by Cell Ranger, Space Ranger, Cell Ranger ATAC, Cell Ranger DNA, and Long Ranger back to FASTQ files that can be used as inputs to re-run analysis + +keywords: + - bam + - convert + - fastq + - 10x + +tools: + - bamtofastq10x: + description: Tool for converting 10x BAMs produced by Cell Ranger, Space Ranger, Cell Ranger ATAC, Cell Ranger DNA, and Long Ranger back to FASTQ files that can be used as inputs to re-run analysis + homepage: https://github.com/10XGenomics/bamtofastq + documentation: https://github.com/10XGenomics/bamtofastq + tool_dev_url: https://github.com/10XGenomics/bamtofastq + licence: ["MIT"] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - bam: + type: file + description: BAM file + pattern: "*.bam" +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + + - fastq: + type: file + description: fastq compressed file + pattern: "*.fastq.gz" + +authors: + - "@BlueBicycleBlog" +maintainers: + - "@BlueBicycleBlog" diff --git a/modules/nf-core/bamtofastq10x/tests/main.nf.test b/modules/nf-core/bamtofastq10x/tests/main.nf.test new file mode 100644 index 000000000000..2b455ae84470 --- /dev/null +++ b/modules/nf-core/bamtofastq10x/tests/main.nf.test @@ -0,0 +1,55 @@ +nextflow_process { + + name "Test Process BAMTOFASTQ10X" + script "../main.nf" + process "BAMTOFASTQ10X" + + tag "modules" + tag "modules_nfcore" + tag "bamtofastq10x" + + test("human - bam") { + when { + process { + """ + input[0] = Channel.of([ + [ id:'test' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/10xgenomics/10x_cr12.bam', checkIfExists: true) + ]) + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + + ) + } + } + + + test("human - bam - stub") { + + options "-stub" + + when { + process { + """ + input[0] = Channel.of([ + [ id:'test' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/10xgenomics/10x_cr12.bam', checkIfExists: true) + ]) + """ + } + } + + then { + assertAll( + { assert process.success } + ) + } + + } +} diff --git a/modules/nf-core/bamtofastq10x/tests/main.nf.test.snap b/modules/nf-core/bamtofastq10x/tests/main.nf.test.snap new file mode 100644 index 000000000000..d534674592d6 --- /dev/null +++ b/modules/nf-core/bamtofastq10x/tests/main.nf.test.snap @@ -0,0 +1,47 @@ +{ + "human - bam": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + [ + [ + "bamtofastq_S1_L000_I1_001.fastq.gz:md5,a33682ac881de7a7453d79721b7621a0", + "bamtofastq_S1_L000_R1_001.fastq.gz:md5,5ccebf77d8636d7a7cdfc59737aea79f", + "bamtofastq_S1_L000_R2_001.fastq.gz:md5,2ee7c90e4307deba74065cfd00a65002" + ] + ] + ] + ], + "1": [ + "versions.yml:md5,845cd1d09c8a3d0059da9d074a9e5436" + ], + "fastq": [ + [ + { + "id": "test" + }, + [ + [ + "bamtofastq_S1_L000_I1_001.fastq.gz:md5,a33682ac881de7a7453d79721b7621a0", + "bamtofastq_S1_L000_R1_001.fastq.gz:md5,5ccebf77d8636d7a7cdfc59737aea79f", + "bamtofastq_S1_L000_R2_001.fastq.gz:md5,2ee7c90e4307deba74065cfd00a65002" + ] + ] + ] + ], + "versions": [ + "versions.yml:md5,845cd1d09c8a3d0059da9d074a9e5436" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.0" + }, + "timestamp": "2024-05-22T16:43:24.999397" + } +} \ No newline at end of file diff --git a/modules/nf-core/bamtofastq10x/tests/tags.yml b/modules/nf-core/bamtofastq10x/tests/tags.yml new file mode 100644 index 000000000000..fe62227fef66 --- /dev/null +++ b/modules/nf-core/bamtofastq10x/tests/tags.yml @@ -0,0 +1,2 @@ +bamtofastq10x: + - "modules/nf-core/bamtofastq10x/**"