Skip to content

Commit

Permalink
Bypass params validation for bin_size and co
Browse files Browse the repository at this point in the history
  • Loading branch information
Mia0509 committed Nov 8, 2023
1 parent fe4ac65 commit ce2cd3a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 11 deletions.
2 changes: 1 addition & 1 deletion conf/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ params {
res_compartments = '2000'

// Ignore `--input` as otherwise the parameter validation will throw an error
schema_ignore_params = 'genomes,digest,input_paths,input'
schema_ignore_params = 'genomes,digest,input_paths,input,bin_size,res_dist_decay,res_tads,res_compartments'
}
3 changes: 3 additions & 0 deletions conf/test_full.config
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ params {
bin_size = '40000,250000,500000,1000000'
res_compartments = '500000,250000'
res_tads = '40000,20000'

//Ignore parameters with special validation
schema_ignore_params = 'bin_size,res_dist_decay,res_tads,res_compartments'
}
26 changes: 26 additions & 0 deletions lib/WorkflowHic.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
//

import nextflow.Nextflow
import nextflow.Channel
import groovy.text.SimpleTemplateEngine
import groovyx.gpars.dataflow.DataflowWriteChannel

class WorkflowHic {

Expand All @@ -18,6 +20,11 @@ class WorkflowHic {
Nextflow.error "Unknown digestion protocol. Currently, the available digestion options are ${params.digest.keySet().join(", ")}. Please set manually the '--restriction_site' and '--ligation_site' parameters."
}

checkParamIntList(params.bin_size, log)
checkParamIntList(params.res_dist_decay, log)
checkParamIntList(params.res_tads, log)
checkParamIntList(params.res_compartments, log)

// Check Digestion or DNase Hi-C mode
//if (!params.dnase && !params.ligation_site) {
// Nextflow.error "Ligation motif not found. Please either use the `--digestion` parameters or specify the `--restriction_site` and `--ligation_site`. For DNase Hi-C, please use '--dnase' option"
Expand Down Expand Up @@ -82,4 +89,23 @@ class WorkflowHic {
Nextflow.error(error_string)
}
}

// Check the params 'list of Integer' or Integer (ex bin_size)
public static void checkParamIntList(def param2check, log) {
if (param2check !instanceof Integer && !(param2check instanceof String && param2check ==~ /(\d+)(,\d+)*/)){
println "\n"
log.error "ERROR: ${param2check} must be integer or list of integer"
Nextflow.error('Exiting!')
}
}

// In hic.nf: check if the param is int. If true, don't splitCsv and flatten to avoid error
public static DataflowWriteChannel checkIfInt(def param2check) {
if (param2check instanceof Integer) {
return Channel.from( param2check ).toInteger()
}
else {
return Channel.from( param2check ).splitCsv().flatten().toInteger()
}
}
}
2 changes: 1 addition & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ params {
version = false
validate_params = true
show_hidden_params = false
schema_ignore_params = 'genomes,digest'
schema_ignore_params = 'genomes,digest,bin_size,res_dist_decay,res_tads,res_compartments'

// Config options
custom_config_version = 'master'
Expand Down
18 changes: 9 additions & 9 deletions workflows/hic.nf
Original file line number Diff line number Diff line change
Expand Up @@ -41,40 +41,40 @@ if (params.digestion){
//****************************************
// Combine all maps resolution for downstream analysis

ch_map_res = Channel.from( params.bin_size ).splitCsv().flatten().toInteger()
ch_map_res = WorkflowHic.checkIfInt(params.bin_size)

if (params.res_zoomify){
ch_zoom_res = Channel.from( params.res_zoomify ).splitCsv().flatten().toInteger()
ch_map_res = ch_map_res.concat(ch_zoom_res)
}

if (params.res_tads && !params.skip_tads){
ch_tads_res = Channel.from( "${params.res_tads}" ).splitCsv().flatten().toInteger()
ch_tads_res = WorkflowHic.checkIfInt(params.res_tads)
ch_map_res = ch_map_res.concat(ch_tads_res)
}else{
ch_tads_res=Channel.empty()
if (!params.skip_tads){
log.warn "[nf-core/hic] Hi-C resolution for TADs calling not specified. See --res_tads"
log.warn "[nf-core/hic] Hi-C resolution for TADs calling not specified. See --res_tads"
}
}

if (params.res_dist_decay && !params.skip_dist_decay){
ch_ddecay_res = Channel.from( "${params.res_dist_decay}" ).splitCsv().flatten().toInteger()
ch_ddecay_res = WorkflowHic.checkIfInt(params.res_dist_decay)
ch_map_res = ch_map_res.concat(ch_ddecay_res)
}else{
ch_ddecay_res = Channel.empty()
if (!params.skip_dist_decay){
log.warn "[nf-core/hic] Hi-C resolution for distance decay not specified. See --res_dist_decay"
log.warn "[nf-core/hic] Hi-C resolution for distance decay not specified. See --res_dist_decay"
}
}

if (params.res_compartments && !params.skip_compartments){
ch_comp_res = Channel.from( "${params.res_compartments}" ).splitCsv().flatten().toInteger()
ch_comp_res = WorkflowHic.checkIfInt(params.res_compartments)
ch_map_res = ch_map_res.concat(ch_comp_res)
}else{
ch_comp_res = Channel.empty()
if (!params.skip_compartments){
log.warn "[nf-core/hic] Hi-C resolution for compartment calling not specified. See --res_compartments"
log.warn "[nf-core/hic] Hi-C resolution for compartment calling not specified. See --res_compartments"
}
}

Expand All @@ -99,7 +99,7 @@ ch_multiqc_custom_methods_description = params.multiqc_methods_description ? fil
//
// MODULE: Local to the pipeline
//
include { HIC_PLOT_DIST_VS_COUNTS } from '../modules/local/hicexplorer/hicPlotDistVsCounts'
include { HIC_PLOT_DIST_VS_COUNTS } from '../modules/local/hicexplorer/hicPlotDistVsCounts'
include { MULTIQC } from '../modules/local/multiqc'

//
Expand Down Expand Up @@ -239,7 +239,7 @@ workflow HIC {
.filter{ it[0].resolution == it[2] }
.map { it -> [it[0], it[1]]}
.set{ ch_cool_tads }

TADS(
ch_cool_tads
)
Expand Down

0 comments on commit ce2cd3a

Please sign in to comment.