File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ from jinja2 import Environment , FileSystemLoader
2+ from pathlib import Path
3+
4+ datasets = snakemake .params .datasets
5+ total_html = snakemake .output .total_html
6+ subj_htmls = snakemake .input .subj_htmls
7+
8+ # load jinja template
9+ file_loader = FileSystemLoader ("." )
10+ env = Environment (loader = file_loader )
11+ template = env .get_template (snakemake .input .report_html )
12+
13+ output = template .render ()
14+
15+ for i ,subj_html in enumerate (subj_htmls ):
16+ subject = datasets .loc [i ,'subject' ]
17+ sample = datasets .loc [i ,'sample' ]
18+ acq = datasets .loc [i ,'acq' ]
19+
20+ relative_path = Path (subj_html ).relative_to (Path (total_html ).parent )
21+ # Create line to add link to subject into final qc report combining all subjects
22+ subj_link = f'\n \t \t <a href="{ relative_path } ">sub-{ subject } _sample-{ sample } _acq-{ acq } </a><br>\n '
23+
24+ output += subj_link
25+
26+ with open (total_html , 'w' ) as f :
27+ f .write (output )
You can’t perform that action at this time.
0 commit comments