From 85f518d103bcc07db253e6e1e90b7417f5cf2047 Mon Sep 17 00:00:00 2001 From: Ali Khan Date: Tue, 27 Aug 2024 00:58:56 -0400 Subject: [PATCH] forgot to add new script (#45) patch fix for #44 --- workflow/scripts/generate_aggregate_qc.py | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 workflow/scripts/generate_aggregate_qc.py diff --git a/workflow/scripts/generate_aggregate_qc.py b/workflow/scripts/generate_aggregate_qc.py new file mode 100644 index 0000000..d35189b --- /dev/null +++ b/workflow/scripts/generate_aggregate_qc.py @@ -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\tsub-{subject}_sample-{sample}_acq-{acq}
\n' + + output+=subj_link + +with open(total_html, 'w') as f: + f.write(output)