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

Patch/binsizes #11

Closed
wants to merge 7 commits into from
Closed
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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ testing*
*.pyc
bin/
.nf-test/
null/
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v1.1.1dev

## Improvements

1. Added several fail safe checks to the `--bin_sizes` parameter.
2. Dynamically set the tag of the `WISECONDERX_NEWREF` depending on the `--bin_sizes` parameter.

## v1.1.0 - Naive Junior - [15 Sep 2023]

## New features
Expand Down
5 changes: 3 additions & 2 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ process {
]

withName: WISECONDORX_NEWREF {
ext.prefix = {"${meta.id}_${meta.bin_size as Integer > 1000 ? meta.bin_size as Integer/1000 : meta.bin_size}${meta.bin_size as Integer > 1000 ? "k" : ""}bp"}
ext.args = { "--binsize ${meta.bin_size}" }
tag = { params.bin_sizes ? "${meta.bin_size}" : "${meta.id}" }
ext.prefix = { params.bin_sizes ? "${meta.id}_${meta.bin_size as Integer/1000}kbp" : "${meta.id}" }
ext.args = { params.bin_sizes ? "--binsize ${meta.bin_size}" : "" }
publishDir = [
enabled: true,
path: { "${params.outdir}" },
Expand Down
2 changes: 0 additions & 2 deletions conf/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ params {

genomes_ignore = true

bin_sizes = "10000,5"

fasta = params.test_data["homo_sapiens"]["genome"]["genome_fasta"]
fai = null //params.test_data["homo_sapiens"]["genome"]["genome_fasta_fai"]

Expand Down
4 changes: 2 additions & 2 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ params {

// Other options
no_metrics = false
bin_sizes = "1000000,500000,50000,30000,15000,10000,5000,1000"
bin_sizes = null

// References
genome = "GRCh38"
Expand Down Expand Up @@ -234,7 +234,7 @@ manifest {
description = """A nextflow pipeline for creating references for WisecondorX"""
mainScript = 'main.nf'
nextflowVersion = '!>=22.10.1'
version = '1.1.0'
version = '1.1.1dev'
doi = ''
}

Expand Down
13 changes: 10 additions & 3 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,16 @@
"description": "Don't create the metrics text file"
},
"bin_sizes": {
"type": "string",
"description": "A comma-delimited list of bin sizes to use for the analysis",
"default": "1000000,500000,50000,30000,15000,10000,5000,1000"
"anyOf": [
{
"type": "string",
"description": "A comma-delimited list of bin sizes to use for the analysis"
},
{
"type": "integer",
"description": "A comma-delimited list of bin sizes to use for the analysis"
}
]
}
}
},
Expand Down
22 changes: 19 additions & 3 deletions tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,35 @@ nextflow_pipeline {
script "main.nf"
options "-stub"

test("Success") {
test("Success - No bin sizes") {

when {
params {
prefix = "test_reference"
bin_sizes = "10000,5"
}
}

then {
assert workflow.success
assert file("${outputDir}/test_reference.npz").exists()
assert file("${outputDir}/metrics.txt").exists()
assert file("${outputDir}/multiqc_reports/multiqc_report.html").exists()
}
}

test("Success - Bin sizes") {

when {
params {
prefix = "test_reference"
bin_sizes = "5000,10000"
}
}

then {
assert workflow.success
assert file("${outputDir}/test_reference_10kbp.npz").exists()
assert file("${outputDir}/test_reference_5bp.npz").exists()
assert file("${outputDir}/test_reference_5kbp.npz").exists()
assert file("${outputDir}/metrics.txt").exists()
assert file("${outputDir}/multiqc_reports/multiqc_report.html").exists()
}
Expand Down
29 changes: 17 additions & 12 deletions workflows/cmgg-wisecondorx.nf
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ def summary_params = paramsSummaryMap(workflow)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

def checkPathParamList = [
params.input,
params.multiqc_config,
params.fasta,
params.fai
]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }

// Check mandatory parameters
if (params.input) { ch_input = file(params.input) } else { exit 1, 'Input samplesheet not specified!' }
if(params.bin_sizes) {
val_bin_sizes = params.bin_sizes instanceof String ? params.bin_sizes.split(",") : [params.bin_sizes as String]
val_bin_sizes.each { bin_size ->
min_bin_size = 5000
divider = 5
if(bin_size.toInteger() < min_bin_size) {
error("Bin size ${bin_size} is too small, must be larger than or equal to ${min_bin_size}")
}
else if(bin_size.toInteger() % divider != 0){
error("Bin size ${bin_size} is not divisible by ${divider}")
}
}
} else {
val_bin_sizes = [null]
}

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -187,9 +192,9 @@ workflow CMGGWISECONDORX {
[ new_meta, npz ]
}
.groupTuple() // All files should be present here, so no size is needed
.combine(params.bin_sizes.split(","))
.combine(val_bin_sizes)
.map { meta, npz, bin_size ->
new_meta = meta + [bin_size:bin_size]
new_meta = bin_size ? meta + [bin_size:bin_size] : meta
[ new_meta, npz ]
}
.set { ch_newref_input }
Expand Down
Loading