Skip to content

Commit

Permalink
Fix a bug with caching of report assets
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmar-van-den-Berg committed Jan 30, 2025
1 parent a5d061b commit e1fa04d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ v2.3.1-dev
* **Breaking change**: Update the json output format
* **Breaking change**: Update Snakemake to version 8
* Fix a bug with the Java runtime environment for Picard
* Fix a bug with caching of report assets introduced in snakemake 8
* Run VarDict job with 8 threads

**********
Expand Down
28 changes: 18 additions & 10 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ rule generate_report:
scr=workflow.source_path("scripts/generate_report.py"),
# Ensure all report files are localised to the stupid Snakemake cache
report_files=report_files,
params:
templates="report/templates",
imgs="report/assets/img",
output:
"{sample}/hamlet_report.{sample}.pdf",
log:
Expand All @@ -194,9 +191,15 @@ rule generate_report:
containers["hamlet-scripts"]
shell:
"""
# Find the cached location of the report folder
css={input.css}
report=${{css%assets/style.css}}
templates="${{report}}templates"
imgs="${{report}}imgs"
python3 {input.scr} \
--templates-dir {params.templates} \
--imgs-dir {params.imgs} \
--templates-dir ${{templates}} \
--imgs-dir ${{imgs}} \
--css-path {input.css} \
--toc-path {input.toc} \
{input.summary} \
Expand All @@ -211,9 +214,8 @@ rule generate_html_report:
css=workflow.source_path("report/assets/style.css"),
toc=workflow.source_path("report/assets/toc.xsl"),
scr=workflow.source_path("scripts/generate_report.py"),
params:
templates="report/templates",
imgs="report/assets/img",
# Ensure all report files are localised to the stupid Snakemake cache
report_files=report_files,
output:
"{sample}/hamlet_report.{sample}.html",
log:
Expand All @@ -222,9 +224,15 @@ rule generate_html_report:
containers["hamlet-scripts"]
shell:
"""
# Find the cached location of the report folder
css={input.css}
report=${{css%assets/style.css}}
templates="${{report}}templates"
imgs="${{report}}imgs"
python3 {input.scr} \
--templates-dir {params.templates} \
--imgs-dir {params.imgs} \
--templates-dir ${{templates}} \
--imgs-dir ${{imgs}} \
--css-path {input.css} \
--toc-path {input.toc} \
{input.summary} \
Expand Down
36 changes: 19 additions & 17 deletions common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@ containers = {
}


def list_files(folder) -> list[str]:
"""Recursively list all files in folder"""
files = list()

for item in os.listdir(folder):
path = os.path.join(folder, item)
if os.path.isfile(path):
files.append(path)
elif os.path.isdir(path):
files += list_files(path)
else:
msg = f"Unknown path: {path=}"
raise RuntimeError(msg)
return files


def report_files(wildcards):
return list_files("report")
files = [
"report/templates/contents_about.html.j2",
"report/templates/contents_aln.html.j2",
"report/templates/contents_basic.html.j2",
"report/templates/contents_fusion.html.j2",
"report/templates/contents_var.html.j2",
"report/templates/cover.html.j2",
"report/templates/contents.html.j2",
"report/templates/contents_itd.html.j2",
"report/templates/contents_rna.html.j2",
"report/templates/contents_overview.html.j2",
"report/assets/style.css",
"report/assets/toc.xsl",
"report/assets/img/hamlet-logo.jpg",
"report/assets/img/lumc-logo.jpg",
"report/assets/img/Myeloblast_logo.png",
]

return [workflow.source_path(fname) for fname in files]


# The version of HAMLET
Expand Down

0 comments on commit e1fa04d

Please sign in to comment.