Skip to content

Commit

Permalink
refactor: fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
deliaBlue committed Nov 16, 2023
1 parent 4ce5e60 commit fce88d3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 62 deletions.
4 changes: 1 addition & 3 deletions workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 1 addition & 3 deletions workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
20 changes: 6 additions & 14 deletions workflow/rules/map.smk
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
58 changes: 16 additions & 42 deletions workflow/rules/quantify.smk
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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"],
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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}",
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit fce88d3

Please sign in to comment.