Skip to content

Commit

Permalink
refactor: add onstart directive in Snakefile (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
AngryMaciek committed Aug 14, 2021
1 parent c76c6f0 commit 5e50c5c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 58 deletions.
2 changes: 1 addition & 1 deletion envs/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
- shellcheck=0.7.0
- snakemake=5.24.2
- unzip=6.0

...
58 changes: 5 additions & 53 deletions workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -98,10 +66,6 @@ rule plot_sequence_logos:
"workflow",
"scripts",
"sequence_logos.py"
),
TEMP_ = os.path.join(
"{outdir}",
"outdir"
)

output:
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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}",
Expand Down
8 changes: 4 additions & 4 deletions workflow/scripts/heatmap.r
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5e50c5c

Please sign in to comment.