From 2e14753e6ac7d88d4d0934368f7c9d9e5f845729 Mon Sep 17 00:00:00 2001 From: renewiegandt Date: Fri, 5 Apr 2019 12:44:28 +0200 Subject: [PATCH 1/4] Added TODO --- bin/2.2_motif_estimation/png_to_pdf.R | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/bin/2.2_motif_estimation/png_to_pdf.R b/bin/2.2_motif_estimation/png_to_pdf.R index 7c86920..4ea85b9 100644 --- a/bin/2.2_motif_estimation/png_to_pdf.R +++ b/bin/2.2_motif_estimation/png_to_pdf.R @@ -39,16 +39,16 @@ png_to_pdf <- function(png_top, png_list, cluster_ids, new_id, out = "cluster.pd grobs <- lapply(png_split,function(p){rasterGrob(readPNG(p),interpolate = FALSE)}) split_grobs <- split(grobs, rep(1:ceiling(length(grobs)/3), each = 3)[1:length(grobs)]) - + rows <- lapply(seq(1,length(split_grobs)), function(sg){ arrangeGrob(grobs = split_grobs[[sg]], top = textGrob(paste0("Cluster ",cluster_list[sg]),gp = gpar(fontsize = 20,font = 3)), ncol = 3) }) split_rows <- split(rows, rep(1:ceiling(length(rows)/4), each = 4)[1:length(rows)]) - + pdf(out,width = 17, height = 11) grid.arrange(grobs = top_grob, nrow = 3, top = textGrob(paste0("New Cluster ",new_id),gp = gpar(fontsize = 30,font = 3))) lapply(split_rows, function(r){ - grid.arrange(grobs = r, nrow = 4, top = textGrob("Generated from...",gp = gpar(fontsize = 30,font = 3))) + grid.arrange(grobs = r, nrow = 4, top = textGrob("Generated from...",gp = gpar(fontsize = 30,font = 3))) }) dev.off() @@ -68,20 +68,21 @@ get_index <- function(index_file){ index <- f[,c(2,8)] index$V8 <- strsplit(index$V8,",") return(index[unlist(lapply(index$V8, function(v){ifelse(length(v) > 1, TRUE, FALSE)}))]) - -} +} +@TODO png_to_pdf_set_up <- function(png_top, png_list, index_file){ - + index <- get_index(index_file) t <- lapply(seq(nrow(index)), function(i){ new_id <- index[i,1] cluster_ids <- index[i,2] out <- paste0("Summary_cluster_", new_id, ".pdf") - png_to_pdf(png_top = ,png_list = ,cluster_ids = cluster_ids, new_id = new_id, out = out ) + #regex_png <- paste0("*_cluster_", new_id , "/logo${NUM}.png") #???? + png_to_pdf(png_top = "TODO" ,png_list = "TODO" ,cluster_ids = cluster_ids, new_id = new_id, out = out ) }) - + } @@ -89,6 +90,3 @@ png_to_pdf_set_up <- function(png_top, png_list, index_file){ if (!interactive()) { png_to_pdf_set_up(opt$png_new, opt$png_old , opt$index) } - - - From f210c5e7f65f57a09a455d536a287a00edd53fbb Mon Sep 17 00:00:00 2001 From: renewiegandt Date: Fri, 12 Apr 2019 14:44:32 +0200 Subject: [PATCH 2/4] Improved error handling if parameter is missing --- pipeline.nf | 92 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 37 deletions(-) diff --git a/pipeline.nf b/pipeline.nf index 44104e7..c50ba2d 100644 --- a/pipeline.nf +++ b/pipeline.nf @@ -68,7 +68,60 @@ disable_mo_clu = 1 //evaluation params.max_uropa_runs = 10 -if (params.bigwig == "" || params.bed == "" || params.organism == "" || params.genome_fasta == "" || params.motif_db == "" || params.config == "" || (params.gtf_annotation == "" && params.gtf_merged == "" ) || "${params.help}" != "0" ) { +/* +Checking for parameter input! +*/ +int_params = ["window_length", "step", "min_size_fp", "max_size_fp", "kmer", + "aprox_motif_len", "motif_occurrence", "min_seq_length", "global", + "sequence_coverage", "memory", "throw_away_seq", "strand", + "min_seq", "motif_min_key", "motif_max_key", "iteration", + "edge_weight", "best_motif", "min_gap", "gap_penalty", "edge_weight", + "threads", "max_uropa_runs"] +file_params = ["bigwig", "bed", "genome_fasta", "motif_db", "config", "gtf_annotation",] +all_params = int_params + file_params + ["organism" , "identity", "tfbsscan_method", + "percentage", "tomtom_treshold", "motif_similarity_thresh", "out", + "tissues", "gtf_merged", "cluster_motif", "tfbs_path", "help", "seed"] +req_params = file_params + ["organism"] + +valid_organism = ["hg38", "hg19", "mm9", "mm10"] +valid_tfbsscan_methods = ["moods","fimo"] +val_missing = false +send_help = false +missing_params = [] + +params.each { key, value -> + if (req_params.contains(key)){ + if (key == "gtf_annotation" && value == "" && params.gtf_merged == ""){ + val_missing = true + } else { + if (value == ""){ + val_missing = true + missing_params + key + } + } + } + if (!(all_params.contains(key))){ + println("Warning: Parameter $key is unknown. Please check for typos or the parameter list!") + } + if(int_params.contains(key)) { + if (!("${value}" ==~ /\d+/ )){ + println("ERROR: $key needs to be an Integer") + System.exit(2) + } + } + if(file_params.contains(key) || (key == "gtf_merged" && value != "") ) { + if(!file(value).exists()) { + println("ERROR: $key not found. Please check the given path.") + System.exit(2) + } + } +} + +if (val_missing){ + send_help = true + println("Error: Following required parameters are missing: $missing_params") +} +if (send_help || "${params.help}" != "0") { log.info """ Usage: nextflow run pipeline.nf --bigwig [BigWig-file] --bed [BED-file] --genome_fasta [FASTA-file] --motif_db [MEME-file] --config [UROPA-config-file] @@ -79,7 +132,7 @@ if (params.bigwig == "" || params.bed == "" || params.organism == "" || params.g --motif_db Path to motif-database in MEME-format --config Path to UROPA configuration file --gtf_annotation Path to gtf annotation file - --organism Input organism [hg38 | hg19 | mm9 | mm10] + --organism Input organism [hg38 | hg19 | mm9 | mm10] --out Output Directory (Default: './out/') Optional arguments: @@ -133,7 +186,6 @@ if (params.bigwig == "" || params.bed == "" || params.organism == "" || params.g Evaluation: --max_uropa_runs INT Maximum number UROPA runs running parallelized (Default: 10) All arguments can be set in the configuration files - ``` """ System.exit(2) } else { @@ -152,40 +204,6 @@ if (params.bigwig == "" || params.bed == "" || params.organism == "" || params.g -/* -Checking for parameter input! -*/ -int_params = ["window_length", "step", "min_size_fp", "max_size_fp", "kmer", - "aprox_motif_len", "motif_occurrence", "min_seq_length", "global", - "sequence_coverage", "memory", "throw_away_seq", "strand", - "min_seq", "motif_min_key", "motif_max_key", "iteration", - "edge_weight", "best_motif", "min_gap", "gap_penalty", "edge_weight", - "threads", "max_uropa_runs"] -req_params = ["bigwig", "bed", "genome_fasta", "motif_db", "config"] -all_params = int_params + req_params + ["organism" , "identity", "tfbsscan_method", - "percentage", "tomtom_treshold", "motif_similarity_thresh", "out", - "tissues", "gtf_merged", "cluster_motif", "tfbs_path", "help", "gtf_annotation", "seed"] - -valid_organism = ["hg38", "hg19", "mm9", "mm10"] -valid_tfbsscan_methods = ["moods","fimo"] - -params.each { key, value -> - if (!(all_params.contains(key))){ - println("Warning: Parameter $key is unknown. Please check for typos or the parameter list!") - } - if(int_params.contains(key)) { - if (!("${value}" ==~ /\d+/ )){ - println("ERROR: $key needs to be an Integer") - System.exit(2) - } - } - if(req_params.contains(key) || (key == "gtf_merged" && value != "") ) { - if(!file(value).exists()) { - println("ERROR: $key not found. Please check the given path.") - System.exit(2) - } - } -} if (!("${params.identity}" ==~ /^0\.[8-9][[0-9]*]?|^1(\.0)?/ )){ println("ERROR: --identity needs to be float in range 0.8 to 1.0") System.exit(2) From 3caf9979ac25904b38c49d96b3901b54a0e6fb2a Mon Sep 17 00:00:00 2001 From: renewiegandt Date: Tue, 16 Apr 2019 10:21:47 +0200 Subject: [PATCH 3/4] Added error message for missing required parameters --- pipeline.nf | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/pipeline.nf b/pipeline.nf index c50ba2d..1c1230b 100644 --- a/pipeline.nf +++ b/pipeline.nf @@ -89,32 +89,19 @@ val_missing = false send_help = false missing_params = [] +//@TODO remove iteration over all parameter params.each { key, value -> if (req_params.contains(key)){ if (key == "gtf_annotation" && value == "" && params.gtf_merged == ""){ val_missing = true + missing_params.add("$key or gtf_merged") } else { if (value == ""){ val_missing = true - missing_params + key + missing_params.add(key) } } } - if (!(all_params.contains(key))){ - println("Warning: Parameter $key is unknown. Please check for typos or the parameter list!") - } - if(int_params.contains(key)) { - if (!("${value}" ==~ /\d+/ )){ - println("ERROR: $key needs to be an Integer") - System.exit(2) - } - } - if(file_params.contains(key) || (key == "gtf_merged" && value != "") ) { - if(!file(value).exists()) { - println("ERROR: $key not found. Please check the given path.") - System.exit(2) - } - } } if (val_missing){ @@ -122,8 +109,8 @@ if (val_missing){ println("Error: Following required parameters are missing: $missing_params") } if (send_help || "${params.help}" != "0") { - log.info """ - Usage: nextflow run pipeline.nf --bigwig [BigWig-file] --bed [BED-file] --genome_fasta [FASTA-file] --motif_db [MEME-file] --config [UROPA-config-file] +log.info """ +Usage: nextflow run pipeline.nf --bigwig [BigWig-file] --bed [BED-file] --genome_fasta [FASTA-file] --motif_db [MEME-file] --config [UROPA-config-file] Required arguments: --bigwig Path to BigWig-file @@ -185,8 +172,8 @@ if (send_help || "${params.help}" != "0") { config Evaluation: --max_uropa_runs INT Maximum number UROPA runs running parallelized (Default: 10) - All arguments can be set in the configuration files - """ +All arguments can be set in the configuration files +""" System.exit(2) } else { Channel.fromPath(params.bigwig).map {it -> [it.simpleName, it]}.set {bigwig_input} @@ -202,7 +189,23 @@ if (send_help || "${params.help}" != "0") { } } - +params.each { key, value -> + if (!(all_params.contains(key))){ + println("Warning: Parameter $key is unknown. Please check for typos or the parameter list!") + } + if(int_params.contains(key)) { + if (!("${value}" ==~ /\d+/ )){ + println("ERROR: $key needs to be an Integer") + System.exit(2) + } + } + if(file_params.contains(key) || (key == "gtf_merged" && value != "") ) { + if(!file(value).exists()) { + println("ERROR: $key not found. Please check the given path.") + System.exit(2) + } + } +} if (!("${params.identity}" ==~ /^0\.[8-9][[0-9]*]?|^1(\.0)?/ )){ println("ERROR: --identity needs to be float in range 0.8 to 1.0") From 1b4d9c3fa1504a56777ffc7870ef388db1cc9978 Mon Sep 17 00:00:00 2001 From: renewiegandt Date: Tue, 16 Apr 2019 10:31:54 +0200 Subject: [PATCH 4/4] Reworked check on required parameters --- pipeline.nf | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pipeline.nf b/pipeline.nf index 1c1230b..2084666 100644 --- a/pipeline.nf +++ b/pipeline.nf @@ -89,14 +89,15 @@ val_missing = false send_help = false missing_params = [] -//@TODO remove iteration over all parameter -params.each { key, value -> +req_params.each { key -> if (req_params.contains(key)){ - if (key == "gtf_annotation" && value == "" && params.gtf_merged == ""){ - val_missing = true - missing_params.add("$key or gtf_merged") + if (key == "gtf_annotation") { + if (params[key] == "" && params.gtf_merged == "") { + val_missing = true + missing_params.add("$key or gtf_merged") + } } else { - if (value == ""){ + if (params[key] == ""){ val_missing = true missing_params.add(key) } @@ -108,6 +109,7 @@ if (val_missing){ send_help = true println("Error: Following required parameters are missing: $missing_params") } + if (send_help || "${params.help}" != "0") { log.info """ Usage: nextflow run pipeline.nf --bigwig [BigWig-file] --bed [BED-file] --genome_fasta [FASTA-file] --motif_db [MEME-file] --config [UROPA-config-file]