diff --git a/workflow/Snakefile b/workflow/Snakefile index 06570ec..26055ed 100644 --- a/workflow/Snakefile +++ b/workflow/Snakefile @@ -64,9 +64,7 @@ rule finish: sample=pd.unique(samples_table.index.values), ), intersect_sam=expand( - OUT_DIR - / "{sample}" - / "alignments_intersecting_mirna_sorted_tag.sam", + OUT_DIR / "{sample}" / "alignments_intersecting_mirna_sorted_tag.sam", sample=pd.unique(samples_table.index.values), ), table=expand( diff --git a/workflow/rules/common.smk b/workflow/rules/common.smk index 4bf25bc..1565371 100644 --- a/workflow/rules/common.smk +++ b/workflow/rules/common.smk @@ -6,9 +6,7 @@ def get_sample(column_id: str, sample_id: int = None) -> str: """Get relevant per sample information.""" if sample_id: - return str( - samples_table[column_id][samples_table.index == sample_id].iloc[0] - ) + return str(samples_table[column_id][samples_table.index == sample_id].iloc[0]) else: return str(samples_table[column_id].iloc[0]) diff --git a/workflow/rules/map.smk b/workflow/rules/map.smk index 672b9c5..effa9a6 100644 --- a/workflow/rules/map.smk +++ b/workflow/rules/map.smk @@ -83,16 +83,13 @@ rule finish_map: rule start: input: reads=lambda wildcards: expand( - pd.Series( - samples_table.loc[wildcards.sample, "sample_file"] - ).values, + pd.Series(samples_table.loc[wildcards.sample, "sample_file"]).values, format=convert_lib_format(get_sample("format")), ), output: reads=OUT_DIR / "{sample}" / "{format}" / "reads.{format}", params: - cluster_log=CLUSTER_LOG - / "uncompress_zipped_files_{sample}_{format}.log", + cluster_log=CLUSTER_LOG / "uncompress_zipped_files_{sample}_{format}.log", log: LOCAL_LOG / "uncompress_zipped_files_{sample}_{format}.log", container: @@ -189,9 +186,7 @@ rule remove_adapters: output: reads=OUT_DIR / "{sample}" / "reads_trimmed_adapters.fasta", params: - adapter=lambda wildcards: get_sample( - "adapter", wildcards.sample - ).upper(), + adapter=lambda wildcards: get_sample("adapter", wildcards.sample).upper(), error_rate=config["error_rate"], minimum_length=config["minimum_length"], overlap=config["overlap"], @@ -283,8 +278,7 @@ rule map_transcriptome_segemehl: input: reads=OUT_DIR / "{sample}" / "reads_collapsed.fasta", transcriptome=OUT_DIR / "transcriptome_trimmed_id.fa", - transcriptome_index_segemehl=OUT_DIR - / "segemehl_transcriptome_index.idx", + transcriptome_index_segemehl=OUT_DIR / "segemehl_transcriptome_index.idx", output: tmap=OUT_DIR / "{sample}" / "segemehl_transcriptome_mappings.sam", params: @@ -650,8 +644,7 @@ rule remove_header_transcriptome_mappings: output: tmap=OUT_DIR / "{sample}" / "transcriptome_mappings_no_header.sam", params: - cluster_log=CLUSTER_LOG - / "remove_header_transcriptome_mappings_{sample}.log", + cluster_log=CLUSTER_LOG / "remove_header_transcriptome_mappings_{sample}.log", log: LOCAL_LOG / "remove_header_transcriptome_mappings_{sample}.log", container: @@ -762,8 +755,7 @@ rule sort_maps_by_id: rule remove_inferiors: input: sort=OUT_DIR / "{sample}" / "mappings_all_sorted_by_id.sam", - script=SCRIPTS_DIR - / "sam_remove_duplicates_inferior_alignments_multimappers.pl", + script=SCRIPTS_DIR / "sam_remove_duplicates_inferior_alignments_multimappers.pl", output: remove_inf=OUT_DIR / "{sample}" / "mappings_all_removed_inferiors.sam", params: diff --git a/workflow/rules/quantify.smk b/workflow/rules/quantify.smk index 422635a..15aa1e7 100644 --- a/workflow/rules/quantify.smk +++ b/workflow/rules/quantify.smk @@ -61,12 +61,8 @@ localrules: rule finish_quantify: input: - primir_intersect_sam=OUT_DIR - / "{sample}" - / "alignments_intersecting_primir.sam", - mirna_intersect_sam=OUT_DIR - / "{sample}" - / "alignments_intersecting_mirna.sam", + primir_intersect_sam=OUT_DIR / "{sample}" / "alignments_intersecting_primir.sam", + mirna_intersect_sam=OUT_DIR / "{sample}" / "alignments_intersecting_mirna.sam", intersect_sam=OUT_DIR / "{sample}" / "alignments_intersecting_mirna_sorted_tag.sam", @@ -131,8 +127,7 @@ rule filter_sam_by_intersecting_primir: output: sam=OUT_DIR / "{sample}" / "alignments_intersecting_primir.sam", params: - cluster_log=CLUSTER_LOG - / "filter_sam_by_intersecting_primir_{sample}.log", + cluster_log=CLUSTER_LOG / "filter_sam_by_intersecting_primir_{sample}.log", log: LOCAL_LOG / "filter_sam_by_intersecting_primir_{sample}.log", container: @@ -159,8 +154,7 @@ rule convert_intersecting_primir_sam_to_bam: output: maps=OUT_DIR / "{sample}" / "alignments_intersecting_primir.bam", params: - cluster_log=CLUSTER_LOG - / "convert_intersecting_primir_sam_to_bam_{sample}.log", + cluster_log=CLUSTER_LOG / "convert_intersecting_primir_sam_to_bam_{sample}.log", log: LOCAL_LOG / "convert_intersecting_primir_sam_to_bam_{sample}.log", container: @@ -203,9 +197,7 @@ rule index_intersecting_primir_bam: input: maps=OUT_DIR / "{sample}" / "alignments_intersecting_primir_sorted.bam", output: - maps=OUT_DIR - / "{sample}" - / "alignments_intersecting_primir_sorted.bam.bai", + maps=OUT_DIR / "{sample}" / "alignments_intersecting_primir_sorted.bam.bai", params: cluster_log=CLUSTER_LOG / "index_intersecting_primir_bam_{sample}.log", log: @@ -225,9 +217,7 @@ rule index_intersecting_primir_bam: rule intersect_extended_mirna: input: - alignment=OUT_DIR - / "{sample}" - / "alignments_intersecting_primir_sorted.bam", + alignment=OUT_DIR / "{sample}" / "alignments_intersecting_primir_sorted.bam", mirna=expand( OUT_DIR / "extended_mirna_annotation_{extension}_nt.gff3", extension=config["extension"], @@ -266,8 +256,7 @@ rule filter_sam_by_intersecting_mirna: output: sam=OUT_DIR / "{sample}" / "alignments_intersecting_mirna.sam", params: - cluster_log=CLUSTER_LOG - / "filter_sam_by__intersecting_mirna_{sample}.log", + cluster_log=CLUSTER_LOG / "filter_sam_by__intersecting_mirna_{sample}.log", log: LOCAL_LOG / "filter_sam_by_intersecting_mirna_{sample}.log", container: @@ -322,12 +311,9 @@ rule sort_intersecting_mirna_by_feat_tag: input: sam=OUT_DIR / "{sample}" / "alignments_intersecting_mirna_tag.sam", output: - sam=OUT_DIR - / "{sample}" - / "alignments_intersecting_mirna_sorted_tag.sam", + sam=OUT_DIR / "{sample}" / "alignments_intersecting_mirna_sorted_tag.sam", params: - cluster_log=CLUSTER_LOG - / "sort_intersecting_mirna_by_feat_tag_{sample}.log", + cluster_log=CLUSTER_LOG / "sort_intersecting_mirna_by_feat_tag_{sample}.log", log: LOCAL_LOG / "sort_intersecting_mirna_by_feat_tag_{sample}.log", container: @@ -345,9 +331,7 @@ rule sort_intersecting_mirna_by_feat_tag: rule quantify_mirna: input: - alignments=OUT_DIR - / "{sample}" - / "alignments_intersecting_mirna_sorted_tag.sam", + alignments=OUT_DIR / "{sample}" / "alignments_intersecting_mirna_sorted_tag.sam", script=SCRIPTS_DIR / "mirna_quantification.py", output: table=OUT_DIR / "TABLES" / "mirna_counts_{sample}", @@ -448,9 +432,7 @@ rule uncollapse_reads: maps=OUT_DIR / "{sample}" / "alignments_intersecting_mirna.sam", script=SCRIPTS_DIR / "sam_uncollapse.pl", output: - maps=OUT_DIR - / "{sample}" - / "alignments_intersecting_mirna_uncollapsed.sam", + maps=OUT_DIR / "{sample}" / "alignments_intersecting_mirna_uncollapsed.sam", params: cluster_log=CLUSTER_LOG / "uncollapse_reads_{sample}.log", log: @@ -474,16 +456,11 @@ rule uncollapse_reads: rule convert_uncollpased_reads_sam_to_bam: input: - maps=OUT_DIR - / "{sample}" - / "alignments_intersecting_mirna_uncollapsed.sam", + maps=OUT_DIR / "{sample}" / "alignments_intersecting_mirna_uncollapsed.sam", output: - maps=OUT_DIR - / "{sample}" - / "alignments_intersecting_mirna_uncollapsed.bam", + maps=OUT_DIR / "{sample}" / "alignments_intersecting_mirna_uncollapsed.bam", params: - cluster_log=CLUSTER_LOG - / "convert_uncollapsed_reads_sam_to_bam_{sample}.log", + cluster_log=CLUSTER_LOG / "convert_uncollapsed_reads_sam_to_bam_{sample}.log", log: LOCAL_LOG / "convert_uncollapsed_reads_sam_to_bam_{sample}.log", container: @@ -501,16 +478,13 @@ rule convert_uncollpased_reads_sam_to_bam: rule sort_uncollpased_reads_bam_by_position: input: - maps=OUT_DIR - / "{sample}" - / "alignments_intersecting_mirna_uncollapsed.bam", + maps=OUT_DIR / "{sample}" / "alignments_intersecting_mirna_uncollapsed.bam", output: maps=OUT_DIR / "{sample}" / "alignments_intersecting_mirna_uncollapsed_sorted.bam", params: - cluster_log=CLUSTER_LOG - / "sort_uncollapsed_reads_bam_by_position_{sample}.log", + cluster_log=CLUSTER_LOG / "sort_uncollapsed_reads_bam_by_position_{sample}.log", log: LOCAL_LOG / "sort_uncollapsed_reads_bam_by_position_{sample}.log", container: