Skip to content

Commit

Permalink
forgot to add new script (#45)
Browse files Browse the repository at this point in the history
patch fix for #44
  • Loading branch information
akhanf authored Aug 27, 2024
1 parent 6c39193 commit 85f518d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions workflow/scripts/generate_aggregate_qc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from jinja2 import Environment, FileSystemLoader
from pathlib import Path

datasets = snakemake.params.datasets
total_html = snakemake.output.total_html
subj_htmls = snakemake.input.subj_htmls

# load jinja template
file_loader = FileSystemLoader(".")
env = Environment(loader=file_loader)
template = env.get_template(snakemake.input.report_html)

output = template.render()

for i,subj_html in enumerate(subj_htmls):
subject=datasets.loc[i,'subject']
sample=datasets.loc[i,'sample']
acq=datasets.loc[i,'acq']

relative_path = Path(subj_html).relative_to(Path(total_html).parent)
# Create line to add link to subject into final qc report combining all subjects
subj_link = f'\n\t\t<a href="{relative_path}">sub-{subject}_sample-{sample}_acq-{acq}</a><br>\n'

output+=subj_link

with open(total_html, 'w') as f:
f.write(output)

0 comments on commit 85f518d

Please sign in to comment.