Skip to content

Commit

Permalink
Merge pull request #6 from snakemake-workflows/lint-and-fmt
Browse files Browse the repository at this point in the history
chore: Address snakemake lints
  • Loading branch information
tedil authored Sep 14, 2022
2 parents 82abf1f + 5be61ca commit e3997a5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
4 changes: 4 additions & 0 deletions workflow/envs/bash.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
channels:
- conda-forge
dependencies:
- bash =5.1
9 changes: 3 additions & 6 deletions workflow/rules/annotate.smk
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
CYRCULAR_INFO_FIELDS = ["CircleLength", "CircleSegmentCount", "SplitReads", "Support"]


rule extract_vcf_header_lines_for_bcftools_annotate:
input:
vcf="results/calling/candidates/{sample}.sorted.bcf",
Expand Down Expand Up @@ -39,9 +36,9 @@ rule copy_annotation_from_cyrcular:
conda:
"../envs/vcf_annotate.yaml"
params:
header="CHROM,POS,ID,REF,ALT," + ",".join(CYRCULAR_INFO_FIELDS),
table_expr="CHROM,POS,ID,REF,ALT," + ",".join(map(lambda s: "INFO['" + s + "']", CYRCULAR_INFO_FIELDS)),
columns="CHROM,POS,~ID,REF,ALT," + ",".join(CYRCULAR_INFO_FIELDS),
header=copy_annotation_vembrane_header_expr(),
table_expr=copy_annotation_table_expr(),
columns=copy_annotation_bcftools_annotate_columns(),
shell:
"""
vembrane table --header {params.header:q} {params.table_expr:q} {input.candidates_with_annotation} > {output.annotation} 2> {log}
Expand Down
18 changes: 18 additions & 0 deletions workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,21 @@ BND_RE = re.compile(r""".*([]\[])((?P<seqname>.+):(?P<position>[0-9]+))([]\[])?.

def parse_bnd_alt(s: str):
return BND_RE.search(s)["seqname"], int(BND_RE.search(s)["position"])


## rules/annotation.smk specific
CYRCULAR_INFO_FIELDS = ["CircleLength", "CircleSegmentCount", "SplitReads", "Support"]


def copy_annotation_table_expr():
return "CHROM,POS,ID,REF,ALT," + ",".join(
map(lambda s: f"INFO['{s}']", CYRCULAR_INFO_FIELDS)
)


def copy_annotation_vembrane_header_expr():
return "CHROM,POS,ID,REF,ALT," + ",".join(CYRCULAR_INFO_FIELDS)


def copy_annotation_bcftools_annotate_columns():
return "CHROM,POS,~ID,REF,ALT," + ",".join(CYRCULAR_INFO_FIELDS)
12 changes: 10 additions & 2 deletions workflow/rules/datavzrd.smk
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ rule copy_qc_plots_for_datavzrd:
output_dir=lambda wc: directory(
f"results/datavzrd-report/all.fdr-controlled/circles-{wc.group}/qc_plots"
),
log:
"logs/datavzrd/copy_qc_plots/{group}.log",
conda:
"../envs/bash.yaml"
shell:
"""
mkdir -p {params.output_dir}
mkdir -p {params.output_dir} 2> {log}
for f in `find {input.plots} -regex '.*/graph_[0-9]+_[0-9]+\.html'`; do ( cp "$f" {params.output_dir} ); done
touch {output.marker}
touch {output.marker} 2>> {log}
"""


Expand All @@ -44,6 +48,10 @@ rule copy_graph_plots_for_datavzrd:
output_dir=lambda wc: directory(
f"results/datavzrd-report/all.fdr-controlled/circles-{wc.group}/graphs"
),
log:
"logs/datavzrd/copy_graph_plots/{group}.log",
conda:
"../envs/bash.yaml"
shell:
"""
mkdir -p {params.output_dir}
Expand Down

0 comments on commit e3997a5

Please sign in to comment.