Skip to content

Commit

Permalink
Adding TRUST4 module (nf-core#4470)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* review comments applied

---------

Co-authored-by: mapo9 <[email protected]>
Co-authored-by: Mark Polster <[email protected]>
Co-authored-by: Gisela Gabernet <[email protected]>
Co-authored-by: Friederike Hanssen <[email protected]>
  • Loading branch information
5 people authored Mar 6, 2024
1 parent 81b9019 commit dd1b3c4
Show file tree
Hide file tree
Showing 7 changed files with 399 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/nf-core/trust4/environment.yml
Original file line number Diff line number Diff line change
@@ -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"
74 changes: 74 additions & 0 deletions modules/nf-core/trust4/main.nf
Original file line number Diff line number Diff line change
@@ -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
"""
}
75 changes: 75 additions & 0 deletions modules/nf-core/trust4/meta.yml
Original file line number Diff line number Diff line change
@@ -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"
117 changes: 117 additions & 0 deletions modules/nf-core/trust4/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -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" }
)
}

}

}
119 changes: 119 additions & 0 deletions modules/nf-core/trust4/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dd1b3c4

Please sign in to comment.