Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added module trgt/plot #7003

Merged
merged 5 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/nf-core/trgt/plot/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
dependencies:
- "bioconda::trgt=1.2.0"
56 changes: 56 additions & 0 deletions modules/nf-core/trgt/plot/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
process TRGT_PLOT {
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/trgt:1.2.0--h9ee0642_0':
'biocontainers/trgt:1.2.0--h9ee0642_0' }"

input:
tuple val(meta) , path(bam), path(bai), path(vcf), path(tbi), val(repeat_id)
tuple val(meta2), path(fasta)
tuple val(meta3), path(fai)
tuple val(meta4), path(repeats)

output:
tuple val(meta), path("*.{png,pdf,svg}"), emit: plot
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}_${repeat_id}"
// If user didn't specify an output path, plot to PNG
def output_arg = args.contains("--image") || args.contains("-o") ? "" : "--image ${prefix}.png"

"""
trgt plot \\
$args \\
--genome ${fasta} \\
--repeats ${repeats} \\
--spanning-reads ${bam} \\
--vcf ${vcf} \\
--repeat-id ${repeat_id} \\
$output_arg

cat <<-END_VERSIONS > versions.yml
"${task.process}":
trgt: \$(trgt --version |& sed '1!d ; s/trgt //')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.png

cat <<-END_VERSIONS > versions.yml
"${task.process}":
trgt: \$(trgt --version |& sed '1!d ; s/trgt //')
END_VERSIONS
"""
}
94 changes: 94 additions & 0 deletions modules/nf-core/trgt/plot/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "trgt_plot"
description: Visualize tandem repeats genotyped by TRGT
keywords:
- trgt
- repeat expansion
- plotting
- pacbio
- genomics
tools:
- "trgt":
description: "Tandem repeat genotyping and visualization from PacBio HiFi data"
homepage: "https://github.com/PacificBiosciences/trgt"
documentation: "https://github.com/PacificBiosciences/trgt/blob/main/docs/tutorial.md"
tool_dev_url: "https://github.com/PacificBiosciences/trgt"
doi: "10.1038/s41587-023-02057-3"
licence:
["Pacific Biosciences Software License (https://github.com/PacificBiosciences/trgt/blob/main/LICENSE.md)"]

input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- bam:
type: file
description: "Sorted reads spanning tandem repeat from TRGT output"
pattern: "*.bam"
- bai:
type: file
description: "Index for reads"
pattern: "*.bai"
- vcf:
type: file
description: "Sorted tandem repeat genotypes called by TRGT"
pattern: "*.vcf.gz"
- tbi:
type: file
description: "Index for genotypes"
pattern: "*.{tbi,csi}"
- repeat_id:
type: string
description: "ID of tandem repeat to plot"
- - meta2:
type: map
description: |
Groovy map containing reference information
e.g. `[ id: 'genome' ]`
- fasta:
type: file
description: "FASTA reference file"
pattern: "*.{fasta,fa,fna}"
- - meta3:
type: map
description: |
Groovy map containing reference information
e.g. `[ id: 'genome' ]`
- fai:
type: file
description: "Index for FASTA file"
pattern: "*.fai"
- - meta4:
type: map
description: |
Groovy map containing repeat information
e.g. `[ id: 'repeats' ]`
- repeats:
type: file
description: "BED file with repeat coordinates and structure"
pattern: "*.bed"

output:
- plot:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- "*.{png,pdf,svg}":
type: file
description: "Plot of region and reads spanning tandem repeat"
pattern: "*.{png,pdf,svg}"
- versions:
- "versions.yml":
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@Schmytzi"
maintainers:
- "@Schmytzi"
142 changes: 142 additions & 0 deletions modules/nf-core/trgt/plot/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// nf-core modules test trgt/plot
nextflow_process {

name "Test Process TRGT_PLOT"
script "../main.nf"
process "TRGT_PLOT"
config "./nextflow.config"

tag "modules"
tag "modules_nfcore"
tag "trgt"
tag "trgt/plot"
tag "trgt/genotype"
tag "samtools/faidx"
tag "samtools/sort"
tag "samtools/index"
tag "bcftools/sort"
tag "gunzip"

setup {
run("GUNZIP"){
script "../../../gunzip/main.nf"
process {
"""
input[0] = [
[ id : 'chr22' ],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr22_chr22_KI270734v1_random/sequence/genome.fa.gz', checkIfExists: true)
]
"""
}
}
run("SAMTOOLS_FAIDX"){
script "../../../samtools/faidx/main.nf"
process {
"""
input[0] = GUNZIP.out.gunzip
input[1] = [[],[]]
"""
}
}
run("TRGT_GENOTYPE"){
script "../../genotype/main.nf"
process {
"""
input[0] = [
[ id:'test' ],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/pacbio/bam/test.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/pacbio/bam/test.sorted.bam.bai', checkIfExists: true),
'XX'
]
input[1] = GUNZIP.out.gunzip
input[2] = SAMTOOLS_FAIDX.out.fai
input[3] = Channel.of('chr22\t18890357\t18890451\tID=TEST;MOTIFS=AT;STRUC=(AT)n')
.collectFile(name : 'repeats.bed', newLine: false)
.map { file -> [ [ id : 'chr22' ], file ] }
"""
}
}
run("SAMTOOLS_SORT"){
script "../../../samtools/sort/main.nf"
process {
"""
input[0] = TRGT_GENOTYPE.out.bam
input[1] = [[],[]]
"""
}
}
run("SAMTOOLS_INDEX"){
script "../../../samtools/index/main.nf"
process {
"""
input[0] = SAMTOOLS_SORT.out.bam
"""
}
}
run("BCFTOOLS_SORT"){
script "../../../bcftools/sort/main.nf"
process {
"""
input[0] = TRGT_GENOTYPE.out.vcf
"""
}
}
}

test("homo sapiens - [bam, bai, vcf, TEST], fasta, fai, bed") {
when {
process {
"""
input[0] = SAMTOOLS_SORT.out.bam
.join(SAMTOOLS_INDEX.out.bai)
.join(BCFTOOLS_SORT.out.vcf)
.join(BCFTOOLS_SORT.out.tbi)
.map { tuple -> tuple + 'TEST' }
input[1] = GUNZIP.out.gunzip
input[2] = SAMTOOLS_FAIDX.out.fai
input[3] = Channel.of('chr22\t18890357\t18890451\tID=TEST;MOTIFS=AT;STRUC=(AT)n')
.collectFile(name : 'repeats.bed', newLine: false)
.map { file -> [ [ id : 'chr22' ], file ] }
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(
file(process.out.plot.get(0).get(1)).name, //unstable
process.out.versions
).match() }
)
}
}

test("homo sapiens - [bam, bai, vcf, TEST], fasta, fai, bed - stub") {
options "-stub"
when {
process {
"""
input[0] = SAMTOOLS_SORT.out.bam
.join(SAMTOOLS_INDEX.out.bai)
.join(BCFTOOLS_SORT.out.vcf)
.join(BCFTOOLS_SORT.out.tbi)
.map { tuple -> tuple + 'TEST' }
input[1] = GUNZIP.out.gunzip
input[2] = SAMTOOLS_FAIDX.out.fai
input[3] = Channel.of('chr22\t18890357\t18890451\tID=TEST;MOTIFS=AT;STRUC=(AT)n')
.collectFile(name : 'repeats.bed', newLine: false)
.map { file -> [ [ id : 'chr22' ], file ] }
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(
file(process.out.plot.get(0).get(1)).name, //unstable
process.out.versions
).match() }
)
}
}
}
28 changes: 28 additions & 0 deletions modules/nf-core/trgt/plot/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"homo sapiens - [bam, bai, vcf, TEST], fasta, fai, bed - stub": {
"content": [
"test.png",
[
"versions.yml:md5,24cc939a0b88728bae8a2102feaf542c"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-11-18T13:58:28.083155724"
},
"homo sapiens - [bam, bai, vcf, TEST], fasta, fai, bed": {
"content": [
"test_TEST.png",
[
"versions.yml:md5,24cc939a0b88728bae8a2102feaf542c"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-11-18T13:57:59.291774232"
}
}
6 changes: 6 additions & 0 deletions modules/nf-core/trgt/plot/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
process {
withName: "BCFTOOLS_SORT" {
ext.args = "--write-index=tbi --output-type z"
ext.prefix = "sorted_"
}
}
Loading