Skip to content

Commit

Permalink
Logs are now in outdir and are referenced in rules
Browse files Browse the repository at this point in the history
  • Loading branch information
supermaxiste committed Aug 11, 2023
1 parent a1386bd commit bff0810
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 139 deletions.
16 changes: 8 additions & 8 deletions rules/alignment.smk
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ rule bismark_prepare_genome_1:
os.path.split(os.path.split(output.control)[0])[0]
)[0],
benchmark:
f"{OUTPUT_DIR}benchmark/prepare_genome.txt"
f"{OUTPUT_DIR}benchmark/prepare_genome_1.txt"
conda:
"../envs/environment.yaml"
shell:
"bismark_genome_preparation {params.genome1}"
"bismark_genome_preparation {params.genome1} 2>&1 {log}"


## Run Bismark to prepare synthetic bisulfite converted genomes
Expand All @@ -38,11 +38,11 @@ rule bismark_prepare_genome_2:
os.path.split(os.path.split(output.control)[0])[0]
)[0],
benchmark:
f"{OUTPUT_DIR}benchmark/prepare_genome.txt"
f"{OUTPUT_DIR}benchmark/prepare_genome_2.txt"
conda:
"../envs/environment.yaml"
shell:
"bismark_genome_preparation {params.genome2}"
"bismark_genome_preparation {params.genome2} 2>&1 {log}"


## Run Bismark to perform alignment to the first parental genome (GENOME_PARENT_1) if reads are single-end.
Expand Down Expand Up @@ -76,7 +76,7 @@ rule bismark_alignment_SE_1:
"../envs/environment.yaml"
threads: CORES
shell:
"bismark --prefix {params.prefix} --multicore {params.bismark_cores} -o {params.output} --temp_dir {params.output} --genome {params.genome1} {input.fastq}"
"bismark --prefix {params.prefix} --multicore {params.bismark_cores} -o {params.output} --temp_dir {params.output} --genome {params.genome1} {input.fastq} 2>&1 {log}"


## Run Bismark to perform alignment to the second parental genome (GENOME_PARENT_2) if reads are single-end.
Expand Down Expand Up @@ -110,7 +110,7 @@ rule bismark_alignment_SE_2:
"../envs/environment.yaml"
threads: CORES
shell:
"bismark --prefix {params.prefix} --multicore {params.bismark_cores} -o {params.output} --temp_dir {params.output} --genome {params.genome2} {input.fastq}"
"bismark --prefix {params.prefix} --multicore {params.bismark_cores} -o {params.output} --temp_dir {params.output} --genome {params.genome2} {input.fastq} 2>&1 {log}"


## Run Bismark to perform alignment to the first parental genome (GENOME_PARENT_1) if reads are paired-end.
Expand Down Expand Up @@ -147,7 +147,7 @@ rule bismark_alignment_PE_1:
"../envs/environment.yaml"
threads: CORES
shell:
"bismark --prefix {params.prefix} --multicore {params.bismark_cores} --genome {params.genome1} -1 {input.fastq1} -2 {input.fastq2} -o {params.output} --temp_dir {params.output}"
"bismark --prefix {params.prefix} --multicore {params.bismark_cores} --genome {params.genome1} -1 {input.fastq1} -2 {input.fastq2} -o {params.output} --temp_dir {params.output} 2>&1 {log}"


## Run Bismark to perform alignment to the second parental genome (GENOME_PARENT_2) if reads are paired-end.
Expand Down Expand Up @@ -184,4 +184,4 @@ rule bismark_alignment_PE_2:
"../envs/environment.yaml"
threads: CORES
shell:
"bismark --prefix {params.prefix} --multicore {params.bismark_cores} --genome {params.genome2} -1 {input.fastq1} -2 {input.fastq2} -o {params.output} --temp_dir {params.output}"
"bismark --prefix {params.prefix} --multicore {params.bismark_cores} --genome {params.genome2} -1 {input.fastq1} -2 {input.fastq2} -o {params.output} --temp_dir {params.output} 2>&1 {log}"
12 changes: 6 additions & 6 deletions rules/build_eagle.smk
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ rule download_eagle:
conda:
ENV_PATH
shell:
"wget https://github.com/tony-kuo/eagle/archive/v{params.eagle_version}.tar.gz -O {output.eagle_tar}"
"wget https://github.com/tony-kuo/eagle/archive/v{params.eagle_version}.tar.gz -O {output.eagle_tar} 2>&1 {log}"


rule extract_eagle:
Expand All @@ -63,7 +63,7 @@ rule extract_eagle:
conda:
ENV_PATH
shell:
"tar -C {params.build_prefix} -vxf {input.eagle_tar}"
"tar -C {params.build_prefix} -vxf {input.eagle_tar} 2>&1 {log}"


rule download_htslib:
Expand All @@ -77,7 +77,7 @@ rule download_htslib:
conda:
ENV_PATH
shell:
"wget https://github.com/samtools/htslib/releases/download/{params.htslib_version}/{params.htslib_tar_name} -O {output.htslib_tar}"
"wget https://github.com/samtools/htslib/releases/download/{params.htslib_version}/{params.htslib_tar_name} -O {output.htslib_tar} 2>&1 {log}"


rule extract_htslib:
Expand All @@ -92,7 +92,7 @@ rule extract_htslib:
conda:
ENV_PATH
shell:
"tar -C {params.build_prefix} -vxf {input.htslib_tar}"
"tar -C {params.build_prefix} -vxf {input.htslib_tar} 2>&1 {log}"


rule build_eagle:
Expand All @@ -111,7 +111,7 @@ rule build_eagle:
ENV_PATH
threads: CORES
shell:
"{params.eagle_mk_env} make -j {threads} -C {params.eagle_dir_path} {params.eagle_mk_flags}"
"{params.eagle_mk_env} make -j {threads} -C {params.eagle_dir_path} {params.eagle_mk_flags} 2>&1 {log}"


rule install_eagle:
Expand All @@ -128,4 +128,4 @@ rule install_eagle:
conda:
ENV_PATH
shell:
"{params.eagle_mk_env} make -C {params.eagle_dir_path} install {params.eagle_mk_flags}"
"{params.eagle_mk_env} make -C {params.eagle_dir_path} install {params.eagle_mk_flags} 2>&1 {log}"
4 changes: 2 additions & 2 deletions rules/deduplication.smk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rule deduplication_SE:
conda:
"../envs/environment.yaml"
shell:
"deduplicate_bismark -s --output_dir {params} --bam {input}"
"deduplicate_bismark -s --output_dir {params} --bam {input} 2>&1 {log}"


## Run deduplication of the alignments to remove duplicated reads for PE reads (GENOME_PARENT_1)
Expand All @@ -50,4 +50,4 @@ rule deduplication_PE:
conda:
"../envs/environment.yaml"
shell:
"deduplicate_bismark -p --output_dir {params} --bam {input}"
"deduplicate_bismark -p --output_dir {params} --bam {input} 2>&1 {log}"
50 changes: 25 additions & 25 deletions rules/differential_methylation_analysis.smk
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ rule context_separation_parent_1:
o2=f"{OUTPUT_DIR}DMR_analysis/context_separation/parent1/{{sample}}_CHG.cov",
o3=f"{OUTPUT_DIR}DMR_analysis/context_separation/parent1/{{sample}}_CHH.cov",
log:
f"logs/context_separation_{{sample}}_p1.log",
f"{OUTPUT_DIR}/logs/context_separation_{{sample}}_p1.log",
params:
sample_name=f"{{sample}}",
output=lambda w, output: os.path.split(output.o1)[0],
conda:
"../envs/environment_downstream.yaml"
shell:
"Rscript scripts/CoverageFileGeneratorComplete.R {input.p1} {params.output} {params.sample_name}"
"Rscript scripts/CoverageFileGeneratorComplete.R {input.p1} {params.output} {params.sample_name} 2>&1 {log}"


## Run R script to remove all rows with no cytosines and generate three files for each cytosine context for parent 2
Expand All @@ -38,14 +38,14 @@ rule context_separation_parent_2:
o2=f"{OUTPUT_DIR}DMR_analysis/context_separation/parent2/{{sample}}_CHG.cov",
o3=f"{OUTPUT_DIR}DMR_analysis/context_separation/parent2/{{sample}}_CHH.cov",
log:
f"logs/context_separation_{{sample}}_p2.log",
f"{OUTPUT_DIR}/logs/context_separation_{{sample}}_p2.log",
params:
sample_name=f"{{sample}}",
output=lambda w, output: os.path.split(output.o1)[0],
conda:
"../envs/environment_downstream.yaml"
shell:
"Rscript scripts/CoverageFileGeneratorComplete.R {input.p1} {params.output} {params.sample_name}"
"Rscript scripts/CoverageFileGeneratorComplete.R {input.p1} {params.output} {params.sample_name} 2>&1 {log}"


## Run R script to remove all rows with no cytosines and generate three files for each cytosine context for parent 1
Expand All @@ -58,7 +58,7 @@ rule combine_context_allo:
output:
f"{OUTPUT_DIR}Bismark/extraction/{{sample}}_12/{{sample}}.CX_report.txt",
log:
f"logs/combine_context_{{sample}}_12.log",
f"{OUTPUT_DIR}/logs/combine_context_{{sample}}_12.log",
shell:
"cat {input.p1} {input.p2} > {output}"

Expand All @@ -71,14 +71,14 @@ rule context_separation_allo:
o2=f"{OUTPUT_DIR}DMR_analysis/context_separation/allopolyploid/{{sample}}_CHG.cov",
o3=f"{OUTPUT_DIR}DMR_analysis/context_separation/allopolyploid/{{sample}}_CHH.cov",
log:
f"logs/context_separation_{{sample}}_allo.log",
f"{OUTPUT_DIR}/logs/context_separation_{{sample}}_allo.log",
params:
sample_name=f"{{sample}}",
output=lambda w, output: os.path.split(output.o1)[0],
conda:
"../envs/environment_downstream.yaml"
shell:
"Rscript scripts/CoverageFileGeneratorComplete.R {input} {params.output} {params.sample_name}"
"Rscript scripts/CoverageFileGeneratorComplete.R {input} {params.output} {params.sample_name} 2>&1 {log}"


# Run dmrseq for CG context for parent1 subgenome
Expand All @@ -91,7 +91,7 @@ rule dmrseq_CG_1:
output:
comparison1=f"{OUTPUT_DIR}DMR_analysis/dmrseq/CG_context/parent1_v_allo.txt",
log:
f"logs/dmrseq_CG_1.log",
f"{OUTPUT_DIR}/logs/dmrseq_CG_1.log",
benchmark:
f"{OUTPUT_DIR}benchmark/dmrseq_CG.txt"
params:
Expand All @@ -102,7 +102,7 @@ rule dmrseq_CG_1:
conda:
"../envs/environment_R.yaml"
shell:
"Rscript scripts/dmrseq.R {params.n_samples_p1} {params.n_samples_allo} {output.comparison1} {threads} {input.p1} {input.allo}"
"Rscript scripts/dmrseq.R {params.n_samples_p1} {params.n_samples_allo} {output.comparison1} {threads} {input.p1} {input.allo} 2>&1 {log}"


# Run dmrseq for CG context for parent2 subgenome
Expand All @@ -115,7 +115,7 @@ rule dmrseq_CG_2:
output:
comparison2=f"{OUTPUT_DIR}DMR_analysis/dmrseq/CG_context/parent2_v_allo.txt",
log:
f"logs/dmrseq_CG_2.log",
f"{OUTPUT_DIR}/logs/dmrseq_CG_2.log",
benchmark:
f"{OUTPUT_DIR}benchmark/dmrseq_CG.txt"
params:
Expand All @@ -126,7 +126,7 @@ rule dmrseq_CG_2:
conda:
"../envs/environment_R.yaml"
shell:
"Rscript scripts/dmrseq.R {params.n_samples_p2} {params.n_samples_allo} {output.comparison2} {threads} {input.p2} {input.allo}"
"Rscript scripts/dmrseq.R {params.n_samples_p2} {params.n_samples_allo} {output.comparison2} {threads} {input.p2} {input.allo} 2>&1 {log}"


# Run dmrseq for CHG context for parent1 subgenome
Expand All @@ -139,7 +139,7 @@ rule dmrseq_CHG_1:
output:
comparison1=f"{OUTPUT_DIR}DMR_analysis/dmrseq/CHG_context/parent1_v_allo.txt",
log:
f"logs/dmrseq_CHG_1.log",
f"{OUTPUT_DIR}/logs/dmrseq_CHG_1.log",
benchmark:
f"{OUTPUT_DIR}benchmark/dmrseq_CHG.txt"
params:
Expand All @@ -150,7 +150,7 @@ rule dmrseq_CHG_1:
conda:
"../envs/environment_R.yaml"
shell:
"Rscript scripts/dmrseq.R {params.n_samples_p1} {params.n_samples_allo} {output.comparison1} {threads} {input.p1} {input.allo}"
"Rscript scripts/dmrseq.R {params.n_samples_p1} {params.n_samples_allo} {output.comparison1} {threads} {input.p1} {input.allo} 2>&1 {log}"


# Run dmrseq for CHG context for parent2 subgenome
Expand All @@ -163,7 +163,7 @@ rule dmrseq_CHG_2:
output:
comparison2=f"{OUTPUT_DIR}DMR_analysis/dmrseq/CHG_context/parent2_v_allo.txt",
log:
f"logs/dmrseq_CHG_2.log",
f"{OUTPUT_DIR}/logs/dmrseq_CHG_2.log",
benchmark:
f"{OUTPUT_DIR}benchmark/dmrseq_CHG.txt"
params:
Expand All @@ -174,7 +174,7 @@ rule dmrseq_CHG_2:
conda:
"../envs/environment_R.yaml"
shell:
"Rscript scripts/dmrseq.R {params.n_samples_p2} {params.n_samples_allo} {output.comparison2} {threads} {input.p2} {input.allo}"
"Rscript scripts/dmrseq.R {params.n_samples_p2} {params.n_samples_allo} {output.comparison2} {threads} {input.p2} {input.allo} 2>&1 {log}"


# Run dmrseq for CHH context for parent1 subgenome
Expand All @@ -187,7 +187,7 @@ rule dmrseq_CHH_1:
output:
comparison1=f"{OUTPUT_DIR}DMR_analysis/dmrseq/CHH_context/parent1_v_allo.txt",
log:
f"logs/dmrseq_CHH_1.log",
f"{OUTPUT_DIR}/logs/dmrseq_CHH_1.log",
benchmark:
f"{OUTPUT_DIR}benchmark/dmrseq_CHH.txt"
params:
Expand All @@ -198,7 +198,7 @@ rule dmrseq_CHH_1:
conda:
"../envs/environment_R.yaml"
shell:
"Rscript scripts/dmrseq.R {params.n_samples_p1} {params.n_samples_allo} {output.comparison1} {threads} {input.p1} {input.allo}"
"Rscript scripts/dmrseq.R {params.n_samples_p1} {params.n_samples_allo} {output.comparison1} {threads} {input.p1} {input.allo} 2>&1 {log}"


# Run dmrseq for CHH context for parent2 subgenome
Expand All @@ -211,7 +211,7 @@ rule dmrseq_CHH_2:
output:
comparison2=f"{OUTPUT_DIR}DMR_analysis/dmrseq/CHH_context/parent2_v_allo.txt",
log:
f"logs/dmrseq_CHH_2.log",
f"{OUTPUT_DIR}/logs/dmrseq_CHH_2.log",
benchmark:
f"{OUTPUT_DIR}benchmark/dmrseq_CHH.txt"
params:
Expand All @@ -222,7 +222,7 @@ rule dmrseq_CHH_2:
conda:
"../envs/environment_R.yaml"
shell:
"Rscript scripts/dmrseq.R {params.n_samples_p2} {params.n_samples_allo} {output.comparison2} {threads} {input.p2} {input.allo}"
"Rscript scripts/dmrseq.R {params.n_samples_p2} {params.n_samples_allo} {output.comparison2} {threads} {input.p2} {input.allo} 2>&1 {log}"


## Rules for dmrseq comparing polyploids to polyploids or diploids to diploids based on conditions given in the metadata file
Expand All @@ -237,7 +237,7 @@ rule dmrseq_CG_special:
if config["DIPLOID_ONLY"]
else f"{OUTPUT_DIR}DMR_analysis/dmrseq/CG_context/A_v_B_polyploid.txt",
log:
f"logs/dmrseq_CG_special.log",
f"{OUTPUT_DIR}/logs/dmrseq_CG_special.log",
benchmark:
f"{OUTPUT_DIR}benchmark/dmrseq_CG_special.txt"
params:
Expand All @@ -247,7 +247,7 @@ rule dmrseq_CG_special:
conda:
"../envs/environment_R.yaml"
shell:
"Rscript scripts/dmrseq.R {params.samples_B} {params.samples_A} {output.comparison} {threads} {input.condB} {input.condA}"
"Rscript scripts/dmrseq.R {params.samples_B} {params.samples_A} {output.comparison} {threads} {input.condB} {input.condA} 2>&1 {log}"


rule dmrseq_CHG_special:
Expand All @@ -259,7 +259,7 @@ rule dmrseq_CHG_special:
if config["DIPLOID_ONLY"]
else f"{OUTPUT_DIR}DMR_analysis/dmrseq/CHG_context/A_v_B_polyploid.txt",
log:
f"logs/dmrseq_CHG_special.log",
f"{OUTPUT_DIR}/logs/dmrseq_CHG_special.log",
benchmark:
f"{OUTPUT_DIR}benchmark/dmrseq_CHG_special.txt"
params:
Expand All @@ -269,7 +269,7 @@ rule dmrseq_CHG_special:
conda:
"../envs/environment_R.yaml"
shell:
"Rscript scripts/dmrseq.R {params.samples_B} {params.samples_A} {output.comparison} {threads} {input.condB} {input.condA}"
"Rscript scripts/dmrseq.R {params.samples_B} {params.samples_A} {output.comparison} {threads} {input.condB} {input.condA} 2>&1 {log}"


rule dmrseq_CHH_special:
Expand All @@ -281,7 +281,7 @@ rule dmrseq_CHH_special:
if config["DIPLOID_ONLY"]
else f"{OUTPUT_DIR}DMR_analysis/dmrseq/CHH_context/A_v_B_polyploid.txt",
log:
f"logs/dmrseq_CHH_special.log",
f"{OUTPUT_DIR}/logs/dmrseq_CHH_special.log",
benchmark:
f"{OUTPUT_DIR}benchmark/dmrseq_CHH_special.txt"
params:
Expand All @@ -291,4 +291,4 @@ rule dmrseq_CHH_special:
conda:
"../envs/environment_R.yaml"
shell:
"Rscript scripts/dmrseq.R {params.samples_B} {params.samples_A} {output.comparison} {threads} {input.condB} {input.condA}"
"Rscript scripts/dmrseq.R {params.samples_B} {params.samples_A} {output.comparison} {threads} {input.condB} {input.condA} 2>&1 {log}"
Loading

0 comments on commit bff0810

Please sign in to comment.