diff --git a/conf/test.config b/conf/test.config index 1501b02..faea1b8 100644 --- a/conf/test.config +++ b/conf/test.config @@ -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' } diff --git a/conf/test_full.config b/conf/test_full.config index f7b39d4..8d223cd 100644 --- a/conf/test_full.config +++ b/conf/test_full.config @@ -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' } diff --git a/lib/WorkflowHic.groovy b/lib/WorkflowHic.groovy index f14c26c..0adbc1a 100755 --- a/lib/WorkflowHic.groovy +++ b/lib/WorkflowHic.groovy @@ -3,7 +3,9 @@ // import nextflow.Nextflow +import nextflow.Channel import groovy.text.SimpleTemplateEngine +import groovyx.gpars.dataflow.DataflowWriteChannel class WorkflowHic { @@ -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" @@ -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() + } + } } diff --git a/nextflow.config b/nextflow.config index 24d1bc0..6e3526c 100644 --- a/nextflow.config +++ b/nextflow.config @@ -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' diff --git a/workflows/hic.nf b/workflows/hic.nf index 2ffa5b4..9af99e6 100644 --- a/workflows/hic.nf +++ b/workflows/hic.nf @@ -41,7 +41,7 @@ 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() @@ -49,32 +49,32 @@ if (params.res_zoomify){ } 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" } } @@ -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' // @@ -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 )