Skip to content
Open
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
98 changes: 41 additions & 57 deletions modules/nf-core/chromograph/main.nf
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
process CHROMOGRAPH {
tag "$meta.id"
// $meta.id can be [] because autozyg is not required, so use all ids
tag "${[meta, meta2, meta3, meta4, meta5, meta6, meta7].collect { meta_map -> meta_map.id }.findAll().unique().join('_') ?: 'chromograph'}"
label 'process_single'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/chromograph:1.3.1--pyhdfd78af_2':
'biocontainers/chromograph:1.3.1--pyhdfd78af_2' }"
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
? 'https://depot.galaxyproject.org/singularity/chromograph:1.3.1--pyhdfd78af_2'
: 'biocontainers/chromograph:1.3.1--pyhdfd78af_2'}"

input:
tuple val(meta), path(autozyg)
Expand All @@ -17,79 +18,62 @@ process CHROMOGRAPH {
tuple val(meta7), path(sites)

output:
tuple val(meta), path("${prefix}"), emit: plots
path "versions.yml" , emit: versions
tuple val(meta), path("*.png"), emit: plots
path "versions.yml", emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def autozyg_param = autozyg ? "--autozyg ${autozyg}" : ''
def coverage_param = coverage ? "--coverage ${coverage}" : ''
def exome_param = exome ? "--exom ${exome}" : ''
def fracsnp_param = fracsnp ? "--fracsnp ${fracsnp}" : ''
def ideogram_param = ideogram ? "--ideogram ${ideogram}" : ''
def regions_param = regions ? "--regions ${regions}" : ''
def sites_param = sites ? "--sites ${sites}" : ''
def args = task.ext.args ?: ''
def autozyg_param = autozyg ? "--autozyg ${autozyg}" : ''
def coverage_param = coverage ? "--coverage ${coverage}" : ''
def exome_param = exome ? "--exom ${exome}" : ''
def fracsnp_param = fracsnp ? "--fracsnp ${fracsnp}" : ''
def ideogram_param = ideogram ? "--ideogram ${ideogram}" : ''
def regions_param = regions ? "--regions ${regions}" : ''
def sites_param = sites ? "--sites ${sites}" : ''

if (autozyg) {
prefix = task.ext.prefix ?: "${meta.id}"
} else if (coverage) {
prefix = task.ext.prefix ?: "${meta2.id}"
} else if (exome) {
prefix = task.ext.prefix ?: "${meta3.id}"
} else if (fracsnp) {
prefix = task.ext.prefix ?: "${meta4.id}"
} else if (ideogram) {
prefix = task.ext.prefix ?: "${meta5.id}"
} else if (regions) {
prefix = task.ext.prefix ?: "${meta6.id}"
} else {
prefix = task.ext.prefix ?: "${meta7.id}"
}
"""
chromograph \\
$args \\
$autozyg_param \\
$coverage_param \\
$exome_param \\
$fracsnp_param \\
$ideogram_param \\
$regions_param \\
$sites_param \\
--outd ${prefix}
${args} \\
${autozyg_param} \\
${coverage_param} \\
${exome_param} \\
${fracsnp_param} \\
${ideogram_param} \\
${regions_param} \\
${sites_param} \\
--outd .

cat <<-END_VERSIONS > versions.yml
"${task.process}":
chromograph: \$(echo \$(chromograph --version 2>&1) | sed 's/chromograph //' )
chromograph: \$(chromograph --version | sed 's/.* //' )
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def args = task.ext.args ?: ''
euploidy = args.contains('-e') || args.contains('--euploid')

if (autozyg) {
prefix = task.ext.prefix ?: "${meta.id}"
} else if (coverage) {
prefix = task.ext.prefix ?: "${meta2.id}"
} else if (exome) {
prefix = task.ext.prefix ?: "${meta3.id}"
} else if (fracsnp) {
prefix = task.ext.prefix ?: "${meta4.id}"
} else if (ideogram) {
prefix = task.ext.prefix ?: "${meta5.id}"
} else if (regions) {
prefix = task.ext.prefix ?: "${meta6.id}"
} else {
prefix = task.ext.prefix ?: "${meta7.id}"
}
"""
mkdir ${prefix}
${touchCmd(euploidy, autozyg)}
${touchCmd(euploidy, coverage)}
${touchCmd(euploidy, exome)}
${touchCmd(euploidy, fracsnp)}
${touchCmd(euploidy, ideogram)}
${touchCmd(euploidy, regions)}
${touchCmd(euploidy, sites)}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
chromograph: \$(echo \$(chromograph --version 2>&1) | sed 's/chromograph //' )
chromograph: \$(chromograph --version | sed 's/.* //' )
END_VERSIONS
"""
}

// Helper function to generate touch commands
def touchCmd(euploidy, input_file) {
def chrs = euploidy ? (1..22) + ['X', 'Y', 'M'] : [1]
input_file ? chrs.collect { chr -> "touch ${input_file}_chr${chr}.png" }.join('\n') : ''
}
7 changes: 3 additions & 4 deletions modules/nf-core/chromograph/meta.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/yaml-schema.json
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "chromograph"
description: Chromograph is a python package to create PNG images from genetics data
such as BED and WIG files.
Expand Down Expand Up @@ -88,10 +88,9 @@ output:
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- ${prefix}:
- "*.png":
type: file
description: Directory containing the plots in png format
pattern: "*.png"
description: Plot(s) in PNG format
ontologies: []
versions:
- versions.yml:
Expand Down
143 changes: 131 additions & 12 deletions modules/nf-core/chromograph/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,152 @@ nextflow_process {
tag "modules"
tag "modules_nfcore"
tag "chromograph"
config "./nextflow.config"

test("test_chromograph_sites") {
test("test_chromograph_sites_wig") {
when {
params {
module_args = ''
}
process {
"""
input[0] = [[],[]]
input[1] = Channel.of(
'fixedStep chrom=chr3 start=400601 step=100',
'11',
'22',
'33')
.collectFile(name: 'wig_input.wig', newLine: true)
.map { file -> [ [ id: file.name ], file ] }
input[2] = [[],[]]
input[3] = [[],[]]
input[4] = [[],[]]
input[5] = [[],[]]
input[6] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/updsites.bed', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}

test("test_chromograph_sites_wig_euploid") {
when {
params {
module_args = '--euploid'
}
process {
"""
input[0] = [[],[]]
input[1] = Channel.of(
'fixedStep chrom=chr3 start=400601 step=100',
'11',
'22',
'33')
.collectFile(name: 'wig_input.wig', newLine: true)
.map { file -> [ [ id: file.name ], file ] }
input[2] = [[],[]]
input[3] = [[],[]]
input[4] = [[],[]]
input[5] = [[],[]]
input[6] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/updsites.bed', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}

test("test_chromograph_sites_wig_stub") {

options "-stub"

when {
params {
module_args = ''
}
process {
"""
input[0] = [[:],[]]
input[1] = [[:],[]]
input[2] = [[:],[]]
input[3] = [[:],[]]
input[4] = [[:],[]]
input[5] = [[:],[]]
input[0] = [[],[]]
input[1] = Channel.of(
'fixedStep chrom=chr3 start=400601 step=100',
'11',
'22',
'33')
.collectFile(name: 'wig_input.wig', newLine: true)
.map { file -> [ [ id: file.name ], file ] }
input[2] = [[],[]]
input[3] = [[],[]]
input[4] = [[],[]]
input[5] = [[],[]]
input[6] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/updsites.bed', checkIfExists: true)
]
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/updsites.bed', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{assert process.success},
{assert process.out.plots.get(0).get(1) ==~ ".*/test"}
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("test_chromograph_sites_wig_euploid_stub") {

options "-stub"

when {
params {
module_args = '--euploid'
}
process {
"""
input[0] = [[],[]]
input[1] = Channel.of(
'fixedStep chrom=chr3 start=400601 step=100',
'11',
'22',
'33')
.collectFile(name: 'wig_input.wig', newLine: true)
.map { file -> [ [ id: file.name ], file ] }
input[2] = [[],[]]
input[3] = [[],[]]
input[4] = [[],[]]
input[5] = [[],[]]
input[6] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/updsites.bed', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
Loading
Loading