Skip to content

Commit 554c699

Browse files
authored
add option to specify additional HTMLs in docs (#28)
You can now specify an `add_htmls_to_docs` variable in your `Snakefile` that specifies additional files to include in the docs, like this: # add extra HTML to docs add_htmls_to_docs = { "Additional files": { "Example HTML file": "results/extra_htmls/example_html.html", }, } Also, `snakemake` was upgraded to 8.5.4.
1 parent 2e80ff8 commit 554c699

File tree

8 files changed

+73
-2
lines changed

8 files changed

+73
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
### version 2.2.0
4+
- Add the `add_htmls_to_docs` option, which can be specified in `Snakefile` to add additional HTML documentation to pipeline.
5+
- Update to `snakemake` 8.5.4.
6+
37
### version 2.1.0
48
- Add an option to specify `miscellaneous_plates` which are plates that just have their barcodes counted (addresses [this issue](https://github.com/jbloomlab/seqneut-pipeline/issues/26)).
59

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,17 @@ Looking at this documentation is a good way to QC the data and understand the re
511511

512512
The documentation for the test example for this pipeline is at [https://jbloomlab.github.io/seqneut-pipeline/](https://jbloomlab.github.io/seqneut-pipeline/).
513513

514+
If you want to add additional HTML files to the docs, specify a dict in the top-level `Snakefile` with the name `add_htmls_to_docs` like this:
515+
```
516+
add_htmls_to_docs = {
517+
"Additional files": {
518+
"Example HTML file": "results/extra_htmls/example_html.html",
519+
<other keys specifying file names and their paths>
520+
},
521+
<other nested dicts with a heading and then name: file key-value pairs>
522+
}
523+
```
524+
514525
## Test example and testing via GitHub Actions
515526
The [./test_example](test_example) subdirectory contains a small test example that illustrates use of the pipeline.
516527

docs/example_html.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<body>
4+
Example HTML file
5+
</body>
6+
</html>

docs/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ <h1 id="test-example-for-seqneut-pipeline">Test example for <a href="https://git
99
<li><a href="#per-serum-neutralization-titers">Per-serum neutralization titers</a></li>
1010
<li><a href="#per-plate-counts-and-curve-fits">Per-plate counts and curve fits</a></li>
1111
<li><a href="#summary-of-data-dropped-during-quality-control">Summary of data dropped during quality control</a></li>
12+
<li><a href="#additional-files">Additional files</a></li>
1213
</ul>
1314
</div>
1415
<h2 id="titers-for-all-sera">Titers for all sera</h2>
@@ -26,4 +27,6 @@ <h2 id="per-plate-counts-and-curve-fits">Per-plate counts and curve fits</h2>
2627
<li><a href="process_plate11.html">plate11</a></li>
2728
</ul>
2829
<h2 id="summary-of-data-dropped-during-quality-control">Summary of data dropped during quality control</h2>
29-
<p><a href="aggregate_qc_drops.html">Notebook summarizing QC drops</a></p>
30+
<p><a href="aggregate_qc_drops.html">Notebook summarizing QC drops</a></p>
31+
<h2 id="additional-files">Additional files</h2>
32+
<p><a href="example_html.html">Example HTML file</a></p>

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies:
1717
- python=3.11
1818
- ruamel.yaml=0.18.5
1919
- snakefmt
20-
- snakemake=8.0.1
20+
- snakemake=8.5.4
2121
- ruff
2222
- pip:
2323
- dms_variants==1.5.0

scripts/build_docs.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
f"[Notebook summarizing QC drops]({os.path.basename(copied_files[snakemake.input.qc_drops_html])})",
4747
]
4848

49+
for heading, heading_d in snakemake.params.add_htmls_to_docs.items():
50+
md_text += ["", f"## {heading}"]
51+
for name, fname in heading_d.items():
52+
md_text.append(f"[{name}]({os.path.basename(copied_files[fname])})")
53+
4954
md_text = "\n".join(md_text)
5055

5156
print(f"Rendering the following markdown text:\n\n{md_text}\n\n")

seqneut-pipeline.smk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ if "miscellaneous_plates" in config:
4848
else:
4949
miscellaneous_plates = {}
5050

51+
# define `add_htmls_to_docs` if not already defined.
52+
try:
53+
add_htmls_to_docs
54+
except NameError: # if not defined
55+
add_htmls_to_docs = {}
56+
5157

5258
# --- Snakemake rules -------------------------------------------------------------------
5359

@@ -228,6 +234,7 @@ rule notebook_to_html:
228234
rule build_docs:
229235
"""Build the HTML documentation."""
230236
input:
237+
lambda wc: [f for d in add_htmls_to_docs.values() for f in d.values()],
231238
titers_chart=rules.aggregate_titers.output.titers_chart,
232239
serum_titers_htmls=lambda wc: expand(
233240
"results/sera/{serum}/{serum}_titers.html",
@@ -244,6 +251,10 @@ rule build_docs:
244251
description=config["description"],
245252
sera=lambda wc: list(sera_plates()),
246253
plates=list(plates),
254+
add_htmls_to_docs=lambda wc: {
255+
key: {key2: str(val2) for (key2, val2) in val.items()}
256+
for (key, val) in add_htmls_to_docs.items()
257+
},
247258
conda:
248259
"environment.yml"
249260
log:

test_example/Snakefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Top-level ``snakemake`` file that runs analysis."""
22

33
import os
4+
import textwrap
45

56

67
configfile: "config.yml"
@@ -12,3 +13,33 @@ include: os.path.join(config["seqneut-pipeline"], "seqneut-pipeline.smk")
1213
rule all:
1314
input:
1415
seqneut_pipeline_outputs,
16+
17+
18+
rule make_extra_html_for_docs:
19+
"""Write example HTML for docs."""
20+
output:
21+
html="results/extra_htmls/example_html.html",
22+
log:
23+
"results/logs/make_extra_html_for_docs.txt",
24+
run:
25+
with open(output.html, "w") as f:
26+
f.write(
27+
textwrap.dedent(
28+
"""\
29+
<!DOCTYPE html>
30+
<html lang="en">
31+
<body>
32+
Example HTML file
33+
</body>
34+
</html>
35+
"""
36+
)
37+
)
38+
39+
40+
# add extra HTML to docs
41+
add_htmls_to_docs = {
42+
"Additional files": {
43+
"Example HTML file": "results/extra_htmls/example_html.html",
44+
},
45+
}

0 commit comments

Comments
 (0)