Skip to content
Snippets Groups Projects
Verified Commit 20dc4280 authored by Mia Croiset's avatar Mia Croiset
Browse files

simplify int check and function for channel check

parent ed5b729c
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,9 @@
//
import nextflow.Nextflow
import nextflow.Channel
import groovy.text.SimpleTemplateEngine
import groovyx.gpars.dataflow.DataflowWriteChannel
class WorkflowHic {
......@@ -90,13 +92,19 @@ class WorkflowHic {
// 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+)*/)){
//good format, do nothing
}
else {
println "\n"
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()
}
}
}
......@@ -41,23 +41,21 @@ if (params.digestion){
//****************************************
// Combine all maps resolution for downstream analysis
if (params.bin_size instanceof Integer) {
/* if (params.bin_size instanceof Integer) {
ch_map_res = Channel.from( params.bin_size ).toInteger()
}
else {
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 && params.res_tads instanceof Integer){
ch_tads_res = Channel.from( "${params.res_tads}" ).toInteger()
ch_map_res = ch_map_res.concat(ch_tads_res)
}else if (params.res_tads && !params.skip_tads){
ch_tads_res = Channel.from( "${params.res_tads}" ).splitCsv().flatten().toInteger()
if (params.res_tads && !params.skip_tads){
ch_tads_res = WorkflowHic.checkIfInt(params.res_tads)
ch_map_res = ch_map_res.concat(ch_tads_res)
}else{
ch_tads_res=Channel.empty()
......@@ -66,11 +64,8 @@ if (params.res_tads && !params.skip_tads && params.res_tads instanceof Integer){
}
}
if (params.res_dist_decay && !params.skip_dist_decay && params.res_dist_decay instanceof Integer){
ch_ddecay_res = Channel.from( "${params.res_dist_decay}" ).toInteger()
ch_map_res = ch_map_res.concat(ch_ddecay_res)
}else if (params.res_dist_decay && !params.skip_dist_decay){
ch_ddecay_res = Channel.from( "${params.res_dist_decay}" ).splitCsv().flatten().toInteger()
if (params.res_dist_decay && !params.skip_dist_decay){
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()
......@@ -79,11 +74,8 @@ if (params.res_dist_decay && !params.skip_dist_decay && params.res_dist_decay in
}
}
if (params.res_compartments && !params.skip_compartments && params.res_compartments instanceof Integer){
ch_comp_res = Channel.from( "${params.res_compartments}" ).toInteger()
ch_map_res = ch_map_res.concat(ch_comp_res)
}else if (params.res_compartments && !params.skip_compartments){
ch_comp_res = Channel.from( "${params.res_compartments}" ).splitCsv().flatten().toInteger()
if (params.res_compartments && !params.skip_compartments){
ch_comp_res = WorkflowHic.checkIfInt(params.res_compartments)
ch_map_res = ch_map_res.concat(ch_comp_res)
}else{
ch_comp_res = Channel.empty()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment