diff --git a/snakemodules/analysis.smk b/snakemodules/analysis.smk index 7fef97407653e379804b3e73d221887b4ba03a31..a32b477895c11c97c1d368e9d9c09f9221b6b02f 100644 --- a/snakemodules/analysis.smk +++ b/snakemodules/analysis.smk @@ -44,6 +44,9 @@ if config["SICKLE"]=="no": group: "unmapped_analysis" notebook: os.path.join(WORKFLOW_PATH,"snakemodules/notebooks/read_numbers_in_bar_graph.py.ipynb") + + + if config["remove_contamination"]=="yes": @@ -91,6 +94,7 @@ if config["SICKLE"]=="no": group: "unmapped_analysis_no_filtler_after_clean" notebook: os.path.join(WORKFLOW_PATH,"snakemodules/notebooks/read_numbers_in_bar_graph.py.ipynb") + elif config["SICKLE"]=="yes": @@ -139,6 +143,8 @@ elif config["SICKLE"]=="yes": group: "unmapped_analysis_before_filter" notebook: os.path.join(WORKFLOW_PATH,"snakemodules/notebooks/read_numbers_in_bar_graph.py.ipynb") + + rule email_unmapped_analysis_after_filter: @@ -185,6 +191,8 @@ elif config["SICKLE"]=="yes": group: "unmapped_analysis_after_filter" notebook: os.path.join(WORKFLOW_PATH,"snakemodules/notebooks/read_numbers_in_bar_graph.py.ipynb") + + elif config["remove_contamination"]=="yes": @@ -232,6 +240,7 @@ elif config["SICKLE"]=="yes": group: "unmapped_analysis_before_clean_filter" notebook: os.path.join(WORKFLOW_PATH,"snakemodules/notebooks/read_numbers_in_bar_graph.py.ipynb") + rule email_unmapped_analysis_after_clean: @@ -324,6 +333,7 @@ elif config["SICKLE"]=="yes": group: "unmapped_analysis_after_clean_filter" notebook: os.path.join(WORKFLOW_PATH,"snakemodules/notebooks/read_numbers_in_bar_graph.py.ipynb") + @@ -472,4 +482,3 @@ rule coverage_analysis: group: "coverage_analysis" notebook: os.path.join(WORKFLOW_PATH,"snakemodules/notebooks/contig_coverage_heatmap.py.ipynb") - diff --git a/snakemodules/contigmap.smk b/snakemodules/contigmap.smk index 84d8bfb35858b05c69132ecd280f956d9603fa7e..165d41af90fcf4dcb6c426a3c58256f8b42c083b 100644 --- a/snakemodules/contigmap.smk +++ b/snakemodules/contigmap.smk @@ -169,7 +169,7 @@ rule coordinate_sort_unsorted: input: WORK_DIR + "/{sample}/merged.bam" output: - WORK_DIR + "/{sample}/non_ref_new.bam" + temp(WORK_DIR + "/{sample}/non_ref_new.bam") conda: os.path.join(WORKFLOW_PATH,"snakemodules/envs/samtools.yml") resources: @@ -192,7 +192,7 @@ rule index_sorted: input: WORK_DIR + "/{sample}/non_ref_new.bam" output: - WORK_DIR + "/{sample}/non_ref_new.bam.bai" + temp(WORK_DIR + "/{sample}/non_ref_new.bam.bai") conda: os.path.join(WORKFLOW_PATH,"snakemodules/envs/samtools.yml") resources: diff --git a/snakemodules/crop_remapped.smk b/snakemodules/crop_remapped.smk index d91fafc0e4ad8531cd16ed7df22c17f6cceaf0f0..87a3c96b52a13182fd06897f951ad9507d2fa859 100644 --- a/snakemodules/crop_remapped.smk +++ b/snakemodules/crop_remapped.smk @@ -23,9 +23,9 @@ if config["SICKLE"]=="no": find_bam_file # INPUT_DIR + "/{sample}/{sample}.bam" output: - WORK_DIR + "/{sample}/single.fastq", - WORK_DIR + "/{sample}/paired.1.fastq", - WORK_DIR + "/{sample}/paired.2.fastq", + temp(WORK_DIR + "/{sample}/single.fastq"), + temp(WORK_DIR + "/{sample}/paired.1.fastq"), + temp(WORK_DIR + "/{sample}/paired.2.fastq"), temp(WORK_DIR + "/{sample}/mates.bam"), WORK_DIR + "/{sample}/POPINS_SAMPLE_INFO" params: @@ -56,7 +56,7 @@ if config["SICKLE"]=="no": os.path.join(RESULTS_DIR, "read_numbers.png") if config["ANALYSIS"]=="yes" else [], mates = WORK_DIR + "/{sample}/mates.bam" output: - WORK_DIR + "/{sample}/non_ref.bam" + temp(WORK_DIR + "/{sample}/non_ref.bam") conda: os.path.join(WORKFLOW_PATH,"snakemodules/envs/samtools.yml") resources: @@ -78,9 +78,9 @@ elif config["SICKLE"]=="yes": input: INPUT_DIR + "/{sample}/{sample}.bam" output: - WORK_DIR + "/{sample}/single.fastq", - WORK_DIR + "/{sample}/paired.1.fastq", - WORK_DIR + "/{sample}/paired.2.fastq", + temp(WORK_DIR + "/{sample}/single.fastq"), + temp(WORK_DIR + "/{sample}/paired.1.fastq"), + temp(WORK_DIR + "/{sample}/paired.2.fastq"), temp(WORK_DIR + "/{sample}/mates.bam"), WORK_DIR + "/{sample}/POPINS_SAMPLE_INFO" params: @@ -109,7 +109,7 @@ elif config["SICKLE"]=="yes": # os.path.join(RESULTS_DIR, "read_numbers.png") if config["ANALYSIS"]=="yes" else [], mates = WORK_DIR + "/{sample}/mates.bam" output: - WORK_DIR + "/{sample}/non_ref.bam" + temp(WORK_DIR + "/{sample}/non_ref.bam") conda: os.path.join(WORKFLOW_PATH,"snakemodules/envs/samtools.yml") resources: diff --git a/snakemodules/crop_unmapped.smk b/snakemodules/crop_unmapped.smk index 1f0e9a3fa40ec6751cf08400c4b744c3c1f0897c..dc98159931fa7fc2ea56c1f3e9dfb0ef46e136d0 100644 --- a/snakemodules/crop_unmapped.smk +++ b/snakemodules/crop_unmapped.smk @@ -21,9 +21,9 @@ if config["SICKLE"]=="no": find_bam_file # INPUT_DIR + "/{sample}/{sample}.bam" output: - WORK_DIR + "/{sample}/single.fastq", - WORK_DIR + "/{sample}/paired.1.fastq", - WORK_DIR + "/{sample}/paired.2.fastq", + temp(WORK_DIR + "/{sample}/single.fastq"), + temp(WORK_DIR + "/{sample}/paired.1.fastq"), + temp(WORK_DIR + "/{sample}/paired.2.fastq"), temp(WORK_DIR + "/{sample}/mates.bam"), WORK_DIR + "/{sample}/POPINS_SAMPLE_INFO" params: @@ -54,7 +54,7 @@ if config["SICKLE"]=="no": os.path.join(RESULTS_DIR, "read_numbers.png") if config["ANALYSIS"]=="yes" else [], mates = WORK_DIR + "/{sample}/mates.bam" output: - WORK_DIR + "/{sample}/non_ref.bam" + temp(WORK_DIR + "/{sample}/non_ref.bam") conda: os.path.join(WORKFLOW_PATH,"snakemodules/envs/samtools.yml") resources: @@ -76,9 +76,9 @@ elif config["SICKLE"]=="yes": input: INPUT_DIR + "/{sample}/{sample}.bam" output: - WORK_DIR + "/{sample}/single.fastq", - WORK_DIR + "/{sample}/paired.1.fastq", - WORK_DIR + "/{sample}/paired.2.fastq", + temp(WORK_DIR + "/{sample}/single.fastq"), + temp(WORK_DIR + "/{sample}/paired.1.fastq"), + temp(WORK_DIR + "/{sample}/paired.2.fastq"), temp(WORK_DIR + "/{sample}/mates.bam"), WORK_DIR + "/{sample}/POPINS_SAMPLE_INFO" params: @@ -107,7 +107,7 @@ elif config["SICKLE"]=="yes": # os.path.join(RESULTS_DIR, "read_numbers.png") if config["ANALYSIS"]=="yes" else [], mates = WORK_DIR + "/{sample}/mates.bam" output: - WORK_DIR + "/{sample}/non_ref.bam" + temp(WORK_DIR + "/{sample}/non_ref.bam") resources: mem_per_thread = resources["samtools_multithread"]["mem_per_thread"], mem_mb = lambda wildcards, input, threads, attempt: resources["samtools_multithread"]["mem_per_thread"] * threads, diff --git a/snakemodules/genotype.smk b/snakemodules/genotype.smk index b489683bf064fd230fe5cb3fa375c95b48a08378..f61bd44305bff4973c81b349ef43ddc9c2389a44 100644 --- a/snakemodules/genotype.smk +++ b/snakemodules/genotype.smk @@ -28,7 +28,7 @@ rule popins2_genotype: input: rules.sort_vcf.output output: - WORK_DIR + "/{sample}/insertions.vcf" + temp(WORK_DIR + "/{sample}/insertions.vcf") resources: mem_mb = resources["standard_2G"]["mem"], runtime = resources["standard_2G"]["time"] diff --git a/snakemodules/kraken.smk b/snakemodules/kraken.smk index ea2abfed170aee5fc7ab3e09897d3bb1a0bf82c1..e53b0e461cd25cab2b01993a5c67415780828fc9 100644 --- a/snakemodules/kraken.smk +++ b/snakemodules/kraken.smk @@ -8,15 +8,15 @@ rule kraken_map: p2 = WORK_DIR + "/{sample}/paired.2.fastq" output: single_report = WORK_DIR + "/{sample}/contaminate_info/single_report.txt", - single_output = WORK_DIR + "/{sample}/contaminate_info/single_output.txt", - u_single = WORK_DIR + "/{sample}/contaminate_info/useq_single.fq", - c_single = WORK_DIR + "/{sample}/contaminate_info/cseq_single.fq", + single_output = temp(WORK_DIR + "/{sample}/contaminate_info/single_output.txt"), + u_single = temp(WORK_DIR + "/{sample}/contaminate_info/useq_single.fq"), + c_single = temp(WORK_DIR + "/{sample}/contaminate_info/cseq_single.fq"), paired_report = WORK_DIR + "/{sample}/contaminate_info/paired_report.txt", - paired_output = WORK_DIR + "/{sample}/contaminate_info/paired_output.txt", - c_paired_1 = WORK_DIR + "/{sample}/contaminate_info/cseqs_1.fq", - c_paired_2 = WORK_DIR + "/{sample}/contaminate_info/cseqs_2.fq", - u_paired_1 = WORK_DIR + "/{sample}/contaminate_info/useqs_1.fq", - u_paired_2 = WORK_DIR + "/{sample}/contaminate_info/useqs_2.fq" + paired_output = temp(WORK_DIR + "/{sample}/contaminate_info/paired_output.txt"), + c_paired_1 = temp(WORK_DIR + "/{sample}/contaminate_info/cseqs_1.fq"), + c_paired_2 = temp(WORK_DIR + "/{sample}/contaminate_info/cseqs_2.fq"), + u_paired_1 = temp(WORK_DIR + "/{sample}/contaminate_info/useqs_1.fq"), + u_paired_2 = temp(WORK_DIR + "/{sample}/contaminate_info/useqs_2.fq") singularity: "docker://staphb/kraken2:latest" conda: @@ -63,9 +63,9 @@ rule obtain_classified_human_reads: paired_fq2 = rules.kraken_map.output.c_paired_2, script= os.path.join(WORKFLOW_PATH,config["python_script"]) output: - hc_single = WORK_DIR + "/{sample}/contaminate_info/human_classified_single.fastq", - hc_paired_1 = WORK_DIR + "/{sample}/contaminate_info/human_classified_paired_1.fastq", - hc_paired_2 = WORK_DIR + "/{sample}/contaminate_info/human_classified_paired_2.fastq" + hc_single = temp(WORK_DIR + "/{sample}/contaminate_info/human_classified_single.fastq"), + hc_paired_1 = temp(WORK_DIR + "/{sample}/contaminate_info/human_classified_paired_1.fastq"), + hc_paired_2 = temp(WORK_DIR + "/{sample}/contaminate_info/human_classified_paired_2.fastq") conda: os.path.join(WORKFLOW_PATH,"snakemodules/envs/biopython.yml") resources: @@ -146,7 +146,7 @@ rule samtools_remap_classified_human: sam = rules.bwa_remap_classified_human.output.remapped_sam output: remapped_unsorted = temp(WORK_DIR + "/{sample}/contaminate_info/remapped_human_unsorted.bam"), - remapped_bam = WORK_DIR + "/{sample}/contaminate_info/remapped.bam" + remapped_bam = temp(WORK_DIR + "/{sample}/contaminate_info/remapped.bam") conda: os.path.join(WORKFLOW_PATH,"snakemodules/envs/samtools.yml") resources: @@ -169,7 +169,7 @@ rule index_reads: input: bam = rules.samtools_remap_classified_human.output.remapped_bam output: - bai = WORK_DIR + "/{sample}/contaminate_info/remapped.bam.bai" + bai = temp(WORK_DIR + "/{sample}/contaminate_info/remapped.bam.bai") conda: os.path.join(WORKFLOW_PATH,"snakemodules/envs/samtools.yml") resources: @@ -191,9 +191,9 @@ rule crop_remapped: bam = rules.samtools_remap_classified_human.output.remapped_bam, bai = rules.index_reads.output.bai output: - single = WORK_DIR + "/{sample}/remapped_single.fastq", - p1 = WORK_DIR + "/{sample}/remapped_paired.1.fastq", - p2 = WORK_DIR + "/{sample}/remapped_paired.2.fastq", + single = temp(WORK_DIR + "/{sample}/remapped_single.fastq"), + p1 = temp(WORK_DIR + "/{sample}/remapped_paired.1.fastq"), + p2 = temp(WORK_DIR + "/{sample}/remapped_paired.2.fastq"), unsorted = temp(WORK_DIR + "/{sample}/remapped_mates.unsorted.bam") resources: mem_mb = resources["standard_2G"]["mem"], @@ -220,7 +220,7 @@ rule remapping_samsort_mates: input: WORK_DIR + "/{sample}/remapped_mates.unsorted.bam" output: - WORK_DIR + "/{sample}/remapped_mates.bam" + temp(WORK_DIR + "/{sample}/remapped_mates.bam") conda: os.path.join(WORKFLOW_PATH,"snakemodules/envs/samtools.yml") resources: @@ -242,7 +242,7 @@ rule merge_set_mate: non_ref = WORK_DIR + "/{sample}/non_ref.bam", rm_ref = WORK_DIR + "/{sample}/remapped_mates.bam" output: - WORK_DIR + "/{sample}/remapped_non_ref.bam" + temp(WORK_DIR + "/{sample}/remapped_non_ref.bam") resources: mem_mb = resources["standard_2G"]["mem"], runtime = resources["standard_2G"]["time"] @@ -270,9 +270,9 @@ rule contaminate_removed: u_p1 = rules.kraken_map.output.u_paired_1, u_p2 = rules.kraken_map.output.u_paired_2 output: - single_clean = WORK_DIR + "/{sample}/single_clean.fastq", - p1_clean = WORK_DIR + "/{sample}/paired_1_clean.fastq", - p2_clean = WORK_DIR + "/{sample}/paired_2_clean.fastq" + single_clean = temp(WORK_DIR + "/{sample}/single_clean.fastq"), + p1_clean = temp(WORK_DIR + "/{sample}/paired_1_clean.fastq"), + p2_clean = temp(WORK_DIR + "/{sample}/paired_2_clean.fastq") resources: mem_mb = resources["standard_2G"]["mem"], runtime = resources["standard_2G"]["time"] diff --git a/snakemodules/minia.smk b/snakemodules/minia.smk index a08164343074e06dda7beed00dca1ca9959eb7b7..b2d318b1193b923f89485ac3bc9181035d3eacd1 100644 --- a/snakemodules/minia.smk +++ b/snakemodules/minia.smk @@ -8,7 +8,7 @@ if config["SICKLE"]=="yes": pair_1 = WORK_DIR + "/{sample}/sickle.paired_1_clean.fastq", pair_2 = WORK_DIR + "/{sample}/sickle.paired_2_clean.fastq" output: - WORK_DIR + "/{sample}/{assemblr}.contigs.fa" + temp(WORK_DIR + "/{sample}/{assemblr}.contigs.fa") conda: os.path.join(WORKFLOW_PATH,"snakemodules/envs/py27.yml") resources: @@ -36,7 +36,7 @@ if config["SICKLE"]=="yes": pair_1 = WORK_DIR + "/{sample}/sickle.paired.1.fastq", pair_2 = WORK_DIR + "/{sample}/sickle.paired.2.fastq" output: - WORK_DIR + "/{sample}/{assemblr}.contigs.fa" + temp(WORK_DIR + "/{sample}/{assemblr}.contigs.fa") conda: os.path.join(WORKFLOW_PATH,"snakemodules/envs/py27.yml") resources: @@ -64,7 +64,7 @@ elif config["SICKLE"]=="no": pair_1 = WORK_DIR + "/{sample}/paired_1_clean.fastq", pair_2 = WORK_DIR + "/{sample}/paired_2_clean.fastq" output: - WORK_DIR + "/{sample}/{assemblr}.contigs.fa" + temp(WORK_DIR + "/{sample}/{assemblr}.contigs.fa") conda: os.path.join(WORKFLOW_PATH,"snakemodules/envs/py27.yml") resources: @@ -92,7 +92,7 @@ elif config["SICKLE"]=="no": pair_1 = WORK_DIR + "/{sample}/paired.1.fastq", pair_2 = WORK_DIR + "/{sample}/paired.2.fastq" output: - WORK_DIR + "/{sample}/{assemblr}.contigs.fa" + temp(WORK_DIR + "/{sample}/{assemblr}.contigs.fa") conda: os.path.join(WORKFLOW_PATH,"snakemodules/envs/py27.yml") resources: diff --git a/snakemodules/position.smk b/snakemodules/position.smk index d96a633305dd1dfbb04bc1ed5a4cebb2546f0ed6..d1769ce74f8825602c23455c8784fff10ce7f479 100644 --- a/snakemodules/position.smk +++ b/snakemodules/position.smk @@ -8,7 +8,7 @@ if config["remove_contamination"] == 'yes': os.path.join(RESULTS_DIR, "heatmap_coverage.png") if config["ANALYSIS"]=="yes" else [], WORK_DIR + "/{sample}/remapped_non_ref.bam" output: - WORK_DIR + "/{sample}/locations.txt" + temp(WORK_DIR + "/{sample}/locations.txt") resources: mem_mb = resources["standard_4G"]["mem"], runtime = resources["standard_4G"]["time"] @@ -34,7 +34,7 @@ elif config["remove_contamination"] == 'no': os.path.join(RESULTS_DIR, "heatmap_coverage.png") if config["ANALYSIS"]=="yes" else [], expand(WORK_DIR + "/{s}/{f}", s=SAMPLES, f=["non_ref_new.bam","non_ref.bam"]) output: - WORK_DIR + "/{sample}/locations.txt" + temp(WORK_DIR + "/{sample}/locations.txt") resources: mem_mb = resources["standard_4G"]["mem"], runtime = resources["standard_4G"]["time"] diff --git a/snakemodules/velvet.smk b/snakemodules/velvet.smk index 1f5ba1916f69de41b72d5ebdf90d9cddf747f6ab..7dcb2d45d01e5677dcc0fe8d0c38a7025882a283 100644 --- a/snakemodules/velvet.smk +++ b/snakemodules/velvet.smk @@ -7,7 +7,7 @@ if config["SICKLE"]=="yes": pair_1 = WORK_DIR + "/{sample}/sickle.paired_1_clean.fastq", pair_2 = WORK_DIR + "/{sample}/sickle.paired_2_clean.fastq" output: - WORK_DIR + "/{sample}/{assemblr}.contigs.fa" + temp(WORK_DIR + "/{sample}/{assemblr}.contigs.fa") params: kmerlength = config["kmerlength"] conda: @@ -37,7 +37,7 @@ if config["SICKLE"]=="yes": pair_1 = WORK_DIR + "/{sample}/sickle.paired.1.fastq", pair_2 = WORK_DIR + "/{sample}/sickle.paired.2.fastq" output: - WORK_DIR + "/{sample}/{assemblr}.contigs.fa" + temp(WORK_DIR + "/{sample}/{assemblr}.contigs.fa") params: kmerlength = config["kmerlength"] conda: @@ -67,7 +67,7 @@ elif config["SICKLE"]=="no": pair_1 = WORK_DIR + "/{sample}/paired_1_clean.fastq", pair_2 = WORK_DIR + "/{sample}/paired_2_clean.fastq" output: - WORK_DIR + "/{sample}/{assemblr}.contigs.fa" + temp(WORK_DIR + "/{sample}/{assemblr}.contigs.fa") params: kmerlength = config["kmerlength"] conda: @@ -97,7 +97,7 @@ elif config["SICKLE"]=="no": pair_1 = WORK_DIR + "/{sample}/paired.1.fastq", pair_2 = WORK_DIR + "/{sample}/paired.2.fastq" output: - WORK_DIR + "/{sample}/{assemblr}.contigs.fa" + temp(WORK_DIR + "/{sample}/{assemblr}.contigs.fa") params: kmerlength = config["kmerlength"] conda: