From dd1b3c45e2ad67a293228223c2e91fb083210873 Mon Sep 17 00:00:00 2001 From: Meirelles_JL <43253685+Joaodemeirelles@users.noreply.github.com> Date: Wed, 6 Mar 2024 08:18:55 +0100 Subject: [PATCH] Adding TRUST4 module (#4470) * Adding TRUST4 module * remove old pytest version * trust4 * trust4 * linting * modules/nf-core/trust4/environment.yml * Update modules/nf-core/trust4/main.nf Co-authored-by: Friederike Hanssen * review comments applied --------- Co-authored-by: mapo9 Co-authored-by: Mark Polster <58596435+mapo9@users.noreply.github.com> Co-authored-by: Gisela Gabernet Co-authored-by: Friederike Hanssen --- modules/nf-core/trust4/environment.yml | 9 ++ modules/nf-core/trust4/main.nf | 74 +++++++++++ modules/nf-core/trust4/meta.yml | 75 +++++++++++ modules/nf-core/trust4/tests/main.nf.test | 117 +++++++++++++++++ .../nf-core/trust4/tests/main.nf.test.snap | 119 ++++++++++++++++++ modules/nf-core/trust4/tests/tags.yml | 2 + tests/config/pytest_modules.yml | 3 + 7 files changed, 399 insertions(+) create mode 100644 modules/nf-core/trust4/environment.yml create mode 100644 modules/nf-core/trust4/main.nf create mode 100644 modules/nf-core/trust4/meta.yml create mode 100644 modules/nf-core/trust4/tests/main.nf.test create mode 100644 modules/nf-core/trust4/tests/main.nf.test.snap create mode 100644 modules/nf-core/trust4/tests/tags.yml diff --git a/modules/nf-core/trust4/environment.yml b/modules/nf-core/trust4/environment.yml new file mode 100644 index 00000000000..9270eee2305 --- /dev/null +++ b/modules/nf-core/trust4/environment.yml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +name: "trust4" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - "bioconda::trust4=1.0.13" diff --git a/modules/nf-core/trust4/main.nf b/modules/nf-core/trust4/main.nf new file mode 100644 index 00000000000..468d3304a1c --- /dev/null +++ b/modules/nf-core/trust4/main.nf @@ -0,0 +1,74 @@ +process TRUST4 { + tag "$meta.id" + label 'process_medium' + + conda "bioconda::trust4=1.0.13" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/trust4:1.0.13--h43eeafb_0': + 'biocontainers/trust4:1.0.13--h43eeafb_0' }" + + input: + tuple val(meta), path(bam), path(reads) + tuple val(meta2), path(fasta) + tuple val(meta3), path(vdj_reference) + + output: + tuple val(meta), path("*.tsv") , emit: tsv + tuple val(meta), path("*_airr.tsv") , emit: airr_tsv + tuple val(meta), path("*_report.tsv") , emit: report_tsv + tuple val(meta), path("*.fa") , emit: fasta + tuple val(meta), path("*.out") , emit: out + tuple val(meta), path("*.fq") , emit: fq + 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}" + def bam_mode = bam ? "-b ${bam}" : '' + def single_end_mode = reads && meta.single_end ? "-u ${reads}" : '' + // reference is optional for fastq input + def reference = vdj_reference ? "--ref ${vdj_reference}" : "" + // separate forward from reverse pairs + def (forward, reverse) = reads.collate(2).transpose() + def paired_end_mode = reads && (meta.single_end == false) ? "-1 ${forward[0]} -2 ${reverse[0]}" : '' + """ + echo $reference + run-trust4 \\ + ${bam_mode} \\ + ${single_end_mode} \\ + ${paired_end_mode} \\ + -t $task.cpus \\ + -f ${fasta} \\ + -o ${prefix} \\ + ${reference} \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + trust4: \$(run-trust4 2>&1 | grep -o 'v[0-9.]*-r[0-9]*' | sed 's/^/TRUST4 using /' ) + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}_airr.tsv + touch ${prefix}_airr_align.tsv + touch ${prefix}_report.tsv + touch ${prefix}_assembled_reads.fa + touch ${prefix}_annot.fa + touch ${prefix}_cdr3.out + touch ${prefix}_raw.out + touch ${prefix}_final.out + touch ${prefix}_toassemble.fq + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + trust4: \$(run-trust4 2>&1 | grep -o 'v[0-9.]*-r[0-9]*' | sed 's/^/TRUST4 using /' ) + END_VERSIONS + """ +} diff --git a/modules/nf-core/trust4/meta.yml b/modules/nf-core/trust4/meta.yml new file mode 100644 index 00000000000..89bc4d29679 --- /dev/null +++ b/modules/nf-core/trust4/meta.yml @@ -0,0 +1,75 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "trust4" +description: Run TRUST4 on RNA-seq data +keywords: + - sort + - example + - genomics +tools: + - "trust4": + description: "TCR and BCR assembly from bulk or single-cell RNA-seq data" + homepage: "https://github.com/liulab-dfci/TRUST4" + documentation: "https://github.com/liulab-dfci/TRUST4" + tool_dev_url: "https://github.com/liulab-dfci/TRUST4" + licence: ["GPL v3"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - bam: + type: file + description: BAM file from bulk or single-cell RNA-seq data + pattern: "*.bam" + - reads: + type: file + description: List of input FastQ files of size 1 and 2 for single-end and paired-end data, respectively + - fasta: + type: file + description: Path to the fasta file coordinate and sequence of V/D/J/C genes + - ref: + type: file + description: Path to detailed V/D/J/C gene reference file, such as from IMGT database. + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - tsv: + type: file + description: tsv files created by TRUST4 + pattern: "*.tsv" + - airr_tsv: + type: file + description: TRUST4 results in AIRR format + pattern: "*_airr.tsv" + - report_tsv: + type: file + description: TRUST4 report in tsv format + pattern: "*_report.tsv" + - fasta: + type: file + description: Fasta files created by TRUST4 + pattern: "*.fa" + - out: + type: file + description: Further report files + pattern: "*.out" + - fq: + type: file + description: Fastq files created by TRUST4 + pattern: "*.fq" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@mapo9, @Joaodemeirelles" +maintainers: + - "@mapo9" diff --git a/modules/nf-core/trust4/tests/main.nf.test b/modules/nf-core/trust4/tests/main.nf.test new file mode 100644 index 00000000000..f4ccdbbc6e4 --- /dev/null +++ b/modules/nf-core/trust4/tests/main.nf.test @@ -0,0 +1,117 @@ +nextflow_process { + + name "Test Process TRUST4" + script "../main.nf" + process "TRUST4" + + tag "modules" + tag "modules_nfcore" + tag "trust4" + + test("sarscov2 - single_end") { + + when { + process { + """ + input[0] = Channel.of([ + [ id:'test', single_end:true ], // meta map + [], // bam + [file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true)] // reads + ]) + input[1] = [[ id:'test'],[file(params.test_data['sarscov2']['genome']['transcriptome_fasta'], checkIfExists: true)]] // fasta + input[2] = [[ id:'test'],[]] // ref + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.airr_tsv, + process.out.fq, + process.out.fasta, + process.out.report_tsv, + process.out.versions, + ).match() }, + { assert process.out.out[0][1][0] ==~ ".*/test_cdr3.out" }, + { assert process.out.out[0][1][1] ==~ ".*/test_final.out" }, + { assert process.out.out[0][1][2] ==~ ".*/test_raw.out" }, + { assert process.out.tsv[0][1][0] ==~ ".*/test_airr.tsv" }, + { assert process.out.tsv[0][1][1] ==~ ".*/test_airr_align.tsv" }, + { assert process.out.tsv[0][1][2] ==~ ".*/test_report.tsv" } + ) + } + + } + + test("sarscov2 - paired_end") { + + when { + process { + """ + input[0] = Channel.of([ + [ id:'test', single_end:false ], // meta map + [], // bam + [file(params.test_data['sarscov2']['illumina']['test2_1_fastq_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test2_2_fastq_gz'], checkIfExists: true)] // reads + ]) + input[1] = [[ id:'test'],[file(params.test_data['sarscov2']['genome']['transcriptome_fasta'], checkIfExists: true)]] // fasta + input[2] = [[ id:'test'],[]] // ref + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.airr_tsv, + process.out.fq, + process.out.fasta, + process.out.report_tsv, + process.out.versions, + ).match() }, + { assert process.out.out[0][1][0] ==~ ".*/test_cdr3.out" }, + { assert process.out.out[0][1][1] ==~ ".*/test_final.out" }, + { assert process.out.out[0][1][2] ==~ ".*/test_raw.out" }, + { assert process.out.tsv[0][1][0] ==~ ".*/test_airr.tsv" }, + { assert process.out.tsv[0][1][1] ==~ ".*/test_airr_align.tsv" }, + { assert process.out.tsv[0][1][2] ==~ ".*/test_report.tsv" } + ) + } + + } + + test("sarscov2 - single_end - stub") { + + options "-stub" + + when { + process { + """ + input[0] = Channel.of([ + [ id:'test', single_end:true ], // meta map + [], + [file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true)] + ]) + input[1] = [[ id:'test'],[file(params.test_data['sarscov2']['genome']['transcriptome_fasta'], checkIfExists: true)]] + input[2] = [[ id:'test'],[]] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match("versions") }, + { assert process.out.out[0][1][0] ==~ ".*/test_cdr3.out" }, + { assert process.out.out[0][1][1] ==~ ".*/test_final.out" }, + { assert process.out.out[0][1][2] ==~ ".*/test_raw.out" }, + { assert process.out.tsv[0][1][0] ==~ ".*/test_airr.tsv" }, + { assert process.out.tsv[0][1][1] ==~ ".*/test_airr_align.tsv" }, + { assert process.out.tsv[0][1][2] ==~ ".*/test_report.tsv" } + ) + } + + } + +} diff --git a/modules/nf-core/trust4/tests/main.nf.test.snap b/modules/nf-core/trust4/tests/main.nf.test.snap new file mode 100644 index 00000000000..235dc835de2 --- /dev/null +++ b/modules/nf-core/trust4/tests/main.nf.test.snap @@ -0,0 +1,119 @@ +{ + "sarscov2 - single_end": { + "content": [ + [ + [ + { + "id": "test", + "single_end": true + }, + "test_airr.tsv:md5,572c69a08a82acc5ff9a2bf95488b0a4" + ] + ], + [ + [ + { + "id": "test", + "single_end": true + }, + "test_toassemble.fq:md5,bd7ab2f9ea96290e58e868e4aabccf1f" + ] + ], + [ + [ + { + "id": "test", + "single_end": true + }, + [ + "test_annot.fa:md5,4b07aefcac3763f7f3d242d9371060df", + "test_assembled_reads.fa:md5,2c9601da894105f2fe6c068659214db3" + ] + ] + ], + [ + [ + { + "id": "test", + "single_end": true + }, + "test_report.tsv:md5,51623a22f060007a69207b1ebdf3a7cd" + ] + ], + [ + "versions.yml:md5,ef2e18f5d083f09211fb613305df93e8" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-03-05T09:26:54.964669" + }, + "versions": { + "content": [ + [ + "versions.yml:md5,ef2e18f5d083f09211fb613305df93e8" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-03-05T09:28:30.347794" + }, + "sarscov2 - paired_end": { + "content": [ + [ + [ + { + "id": "test", + "single_end": false + }, + "test_airr.tsv:md5,572c69a08a82acc5ff9a2bf95488b0a4" + ] + ], + [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_toassemble_1.fq:md5,bd7ab2f9ea96290e58e868e4aabccf1f", + "test_toassemble_2.fq:md5,0211588305d478e10879fb35b93e13d5" + ] + ] + ], + [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_annot.fa:md5,4207f198195fa19b505ffa67feba776a", + "test_assembled_reads.fa:md5,60f27ccec04b5b1826ecf1fd87fd4ad6" + ] + ] + ], + [ + [ + { + "id": "test", + "single_end": false + }, + "test_report.tsv:md5,51623a22f060007a69207b1ebdf3a7cd" + ] + ], + [ + "versions.yml:md5,ef2e18f5d083f09211fb613305df93e8" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-03-05T09:28:25.725943" + } +} \ No newline at end of file diff --git a/modules/nf-core/trust4/tests/tags.yml b/modules/nf-core/trust4/tests/tags.yml new file mode 100644 index 00000000000..cacc72be669 --- /dev/null +++ b/modules/nf-core/trust4/tests/tags.yml @@ -0,0 +1,2 @@ +trust4: + - "modules/nf-core/trust4/**" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 2986503251c..b0abf76e5a7 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -2332,6 +2332,9 @@ transdecoder/longorf: transdecoder/predict: - modules/nf-core/transdecoder/predict/** - tests/modules/nf-core/transdecoder/predict/** +trinity: + - modules/nf-core/trinity/** + - tests/modules/nf-core/trinity/** truvari/bench: - modules/nf-core/truvari/bench/** - tests/modules/nf-core/truvari/bench/**