From 5e50c5c8214066fd436a578e15e0368f665848d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciek=20B=C4=85k?= Date: Sat, 14 Aug 2021 16:28:24 +0200 Subject: [PATCH] refactor: add onstart directive in Snakefile (#57) --- envs/dev.yml | 2 +- workflow/Snakefile | 58 ++++---------------------------------- workflow/scripts/heatmap.r | 8 +++--- 3 files changed, 10 insertions(+), 58 deletions(-) diff --git a/envs/dev.yml b/envs/dev.yml index 1c652c6..8f7692b 100644 --- a/envs/dev.yml +++ b/envs/dev.yml @@ -34,5 +34,5 @@ - shellcheck=0.7.0 - snakemake=5.24.2 - unzip=6.0 - + ... diff --git a/workflow/Snakefile b/workflow/Snakefile index 8d35298..bbbc9ef 100755 --- a/workflow/Snakefile +++ b/workflow/Snakefile @@ -32,6 +32,11 @@ def gather_motifs_names(pwm_dir): l = [i.split("/")[-1] for i in glob.glob(regex)] return(l) +onstart: + shell("mkdir -p " + config["outdir"]) + shell("mkdir -p " + config["outdir"] + "/local_log") + shell("mkdir -p " + config["outdir"] + "/cluster_log") + rule all: """ Target rule with final output of the pipeline @@ -45,43 +50,6 @@ rule all: outdir = config["outdir"] ) -rule create_results_directory: - """ - Create directories for the results - """ - output: - TEMP_ = temp( - os.path.join( - "{outdir}", - "outdir" - ) - ) - - params: - DIR_output_dir = "{outdir}", - LOG_local_log = os.path.join( - "{outdir}", - "local_log" - ), - LOG_cluster_log = os.path.join( - "{outdir}", - "cluster_log" - ) - - conda: - "envs/bash.yml" - - singularity: - "docker://bash:4.4.18" - - shell: - """ - mkdir -p {params.DIR_output_dir}; \ - mkdir -p {params.LOG_local_log}; \ - mkdir -p {params.LOG_cluster_log}; \ - touch {output.TEMP_} - """ - rule plot_sequence_logos: """ Plot sequence logo for the motifs @@ -98,10 +66,6 @@ rule plot_sequence_logos: "workflow", "scripts", "sequence_logos.py" - ), - TEMP_ = os.path.join( - "{outdir}", - "outdir" ) output: @@ -159,12 +123,6 @@ rule prepare_MotEvo_parameters: """ Prepare text file with parameters for MotEvo runs """ - input: - TEMP_ = os.path.join( - "{outdir}", - "outdir" - ) - output: TXT_MotEvo_parameters = os.path.join( "{outdir}", @@ -248,12 +206,6 @@ rule prepare_sequence_for_MotEvo: """ Create a FASTA-formatted file with the input sequence """ - input: - TEMP_ = os.path.join( - "{outdir}", - "outdir" - ) - output: FASTA_MotEvo_input = os.path.join( "{outdir}", diff --git a/workflow/scripts/heatmap.r b/workflow/scripts/heatmap.r index ec5f2e9..7a72462 100644 --- a/workflow/scripts/heatmap.r +++ b/workflow/scripts/heatmap.r @@ -21,25 +21,25 @@ library(ggtext) # list the command-line arguments option_list <- list( - make_option(c("--input_tsv"), + make_option("--input_tsv", action = "store", dest = "input_tsv", type = "character", help = "location and name of the tsv file" ), - make_option(c("--input_sequence"), + make_option("--input_sequence", action = "store", dest = "input_sequence", type = "character", help = "full input_sequence" ), - make_option(c("--outfile"), + make_option("--outfile", action = "store", dest = "output_tsv", type = "character", help = "location and name of output heatmap" ), - make_option(c("--sequence_logos_directory"), + make_option("--sequence_logos_directory", action = "store", dest = "sequence_logos_directory", type = "character",