From 858a7517d24caee7e3333594477d9aa0dad56ac4 Mon Sep 17 00:00:00 2001 From: Samuel Nichols Date: Wed, 6 Jul 2022 11:27:46 -0400 Subject: [PATCH] fig_reports and replacement --- CRISPRessoReport.py | 3 +- templates/pooledReport.html | 6 +- templates/report.html | 428 +++++++------------ templates/shared/partials/fig_reports.html | 23 + templates/shared/partials/fig_summaries.html | 11 + 5 files changed, 183 insertions(+), 288 deletions(-) create mode 100644 templates/shared/partials/fig_reports.html create mode 100644 templates/shared/partials/fig_summaries.html diff --git a/CRISPRessoReport.py b/CRISPRessoReport.py index 83d94ed6..2880d7f4 100644 --- a/CRISPRessoReport.py +++ b/CRISPRessoReport.py @@ -101,7 +101,7 @@ def assemble_figs(run_data, crispresso_folder): amplicons = [] for amplicon_name in run_data['results']['ref_names']: amplicons.append(amplicon_name) - amplicon_figures = {'names': [], 'locs': {}, 'titles': {}, 'captions': {}, 'datas': {}} + amplicon_figures = {'names': [], 'locs': {}, 'titles': {}, 'captions': {}, 'datas': {}, 'htmls': {}} for fig in ['2a', '3a', '3b', '4a', '4b', '4c', '4d', '4e', '4f', '4g', '5', '6', '7', '8', '10a', '10b', '10c', '11a']: @@ -133,6 +133,7 @@ def assemble_figs(run_data, crispresso_folder): figures['titles'][amplicon_name] = amplicon_figures['titles'] figures['captions'][amplicon_name] = amplicon_figures['captions'] figures['datas'][amplicon_name] = amplicon_figures['datas'] + figures['htmls'][amplicon_name] = amplicon_figures['htmls'] data = {'amplicons': amplicons, 'figures': figures} return data diff --git a/templates/pooledReport.html b/templates/pooledReport.html index aa31ba15..bf29ed9b 100644 --- a/templates/pooledReport.html +++ b/templates/pooledReport.html @@ -73,11 +73,7 @@
{{report_name}}
{{summary_plot_titles[plot_name]}}
- - - {% for (data_label,data_path) in summary_plot_datas[plot_name] %} -

Data: {{data_label}}

- {% endfor %} + {{ render_partials('shared/partials/fig_summaries.html', plot_name=plot_name, summary_plot_htmls=summary_plot_htmls, crispresso_data_path=crispresso_data_path, summary_plot_labels=summary_plot_labels, summary_plot_datas=summary_plot_datas) }}
{% endfor %} diff --git a/templates/report.html b/templates/report.html index b85fe2ea..84c849e9 100644 --- a/templates/report.html +++ b/templates/report.html @@ -75,11 +75,7 @@
CRISPResso2 run information
- {{report_data['figures']['htmls']['plot_1a']|safe}} - - {% for (data_label,data_path) in report_data['figures']['datas']['plot_1a'] %} -

Data: {{data_label}}

- {% endfor %} + {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_1a')}}
{{ render_partial('shared/partials/log_params.html', report_data=report_data) }}
@@ -105,156 +101,116 @@
Allele assignments
-
- - - {% for (data_label,data_path) in report_data['figures']['datas']['plot_1b'] %} -

Data: {{data_label}}

- {% endfor %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_1b')}}
-
- - - {% for (data_label,data_path) in report_data['figures']['datas']['plot_1c'] %} -

Data: {{data_label}}

- {% endfor %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_1c')}}
{% if report_data['figures']['locs']['plot_1d'] %}
- - - {% for (data_label,data_path) in report_data['figures']['datas']['plot_1d'] %} -

Data: {{data_label}}

- {% endfor %} -
- {% endif %} + {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_1d')}} +
+ {% endif %}
{# end card #} {# start global coding sequence report #} - {% if report_data['figures']['locs']['plot_5a'] %} -
-
-
Global frameshift analysis
-
-
- - - {% for (data_label,data_path) in report_data['figures']['datas']['plot_5a'] %} -

Data: {{data_label}}

- {% endfor %} -
-
- {% endif %} + {% if report_data['figures']['locs']['plot_5a'] %} +
+
+
Global frameshift analysis
+
+
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_5a')}} +
+
+ {% endif %} - {% if report_data['figures']['locs']['plot_6a'] %} -
-
-
Global frameshift mutagenesis profiles
-
-
- - - {% for (data_label,data_path) in report_data['figures']['datas']['plot_6a'] %} -

Data: {{data_label}}

- {% endfor %} -
-
- {% endif %} + {% if report_data['figures']['locs']['plot_6a'] %} +
+
+
Global frameshift mutagenesis profiles
+
+
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_6a')}} +
+
+ {% endif %} - {% if report_data['figures']['locs']['plot_8a'] %} -
-
-
Global splicing analysis
-
-
- - - {% for (data_label,data_path) in report_data['figures']['datas']['plot_8a'] %} -

Data: {{data_label}}

- {% endfor %} -
-
- {% endif %} - {# end of global coding sequence analysis #} + {% if report_data['figures']['locs']['plot_8a'] %} +
+
+
Global splicing analysis
+
+
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_8a')}} +
+
+ {% endif %} + {# end of global coding sequence analysis #} {# start hdr summary #} - {% if report_data['figures']['locs'][report_data.amplicons[0]]['plot_4g'] %} -
-
- {% if report_data.amplicons|length == 1 %} {# if only one amplicon #} -
HDR summary plot
- {% else %} -
HDR summary report (all reads aligned to {{report_data.amplicons[0]}})
- {% endif %} -
-
- - - {% for (data_label,data_path) in report_data['figures']['datas'][report_data.amplicons[0]]['plot_4g'] %} -

Data: {{data_label}}

- {% endfor %} -
-
+ {% if report_data['figures']['locs'][report_data.amplicons[0]]['plot_4g'] %} +
+
+ {% if report_data.amplicons|length == 1 %} {# if only one amplicon #} +
HDR summary plot
+ {% else %} +
HDR summary report (all reads aligned to {{report_data.amplicons[0]}})
{% endif %} +
+
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_4g', amplicon_name=report_data.amplicons[0])}} +
+
+ {% endif %} {# end HDR summary #} {# start prime editing report #} - {% if report_data['figures']['locs'][report_data.amplicons[0]]['plot_11a'] %} -
-
+ {% if report_data['figures']['locs'][report_data.amplicons[0]]['plot_11a'] %} +
+
{% if report_data.amplicons|length == 1 %} {# if only one amplicon #} -
Prime editing report
+
Prime editing report
{% else %} -
Prime editing report (all reads aligned to {{report_data.amplicons[0]}})
+
Prime editing report (all reads aligned to {{report_data.amplicons[0]}})
{% endif %} -
-
- - - {% for (data_label,data_path) in report_data['figures']['datas'][report_data.amplicons[0]]['plot_11a'] %} -

Data: {{data_label}}

- {% endfor %} -
- {% endif %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_11a', amplicon_name=report_data.amplicons[0])}} +
+
+ {% endif %} {% if report_data['figures']['sgRNA_based_names'][report_data.amplicons[0]] and report_data['figures']['sgRNA_based_names'][report_data.amplicons[0]]['11b']%} -
-
+
+
{% if report_data.amplicons|length == 1 %} {# if only one amplicon #} -
Prime editing summary plots at analysis positions
+
Prime editing summary plots at analysis positions
{% else %} -
Prime editing summary plots at analysis positions (aligned to {{report_data.amplicons[0]}})
+
Prime editing summary plots at analysis positions (aligned to {{report_data.amplicons[0]}})
{% endif %} -
-
- {% for fig_name in report_data['figures']['sgRNA_based_names'][report_data.amplicons[0]]['11b'] %} -
- - - {% for (data_label,data_path) in report_data['figures']['datas'][report_data.amplicons[0]][fig_name] %} -

Data: {{data_label}}

- {% endfor %} -
+
+
+ {% for fig_name in report_data['figures']['sgRNA_based_names'][report_data.amplicons[0]]['11b'] %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name=fig_name, amplicon_name=report_data.amplicons[0])}} +
{% endfor %}
{% endif %} {# end plot 11b for prime editing #} - {% if report_data['figures']['locs']['plot_11c'] %} -
-
-
Scaffold insertions
-
-
- - - {% for (data_label,data_path) in report_data['figures']['datas']['plot_11c'] %} -

Data: {{data_label}}

- {% endfor %} + {% if report_data['figures']['locs']['plot_11c'] %} +
+
+
Scaffold insertions
+
+
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_11c')}}
{% endif %} @@ -339,11 +295,7 @@
Nucleotide composition for {{amplicon_name}}
{% if report_data['figures']['sgRNA_based_names'][amplicon_name] and report_data['figures']['sgRNA_based_names'][amplicon_name]['2b']%}
{% for fig_name in report_data['figures']['sgRNA_based_names'][amplicon_name]['2b'] %} - - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name][fig_name] %} -

Data: {{data_label}}

- {% endfor %} + {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name=fig_name, amplicon_name=amplicon_name)}} {% endfor %}
{% endif %} @@ -374,22 +326,14 @@
Modification lengths for {{amplicon_name}}
{% if report_data['figures']['locs'][amplicon_name]['plot_3a'] %}
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_3a'] %} -

Data: {{data_label}}

- {% endfor %} -
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_3a', amplicon_name=amplicon_name)}} +
{% endif %} {% if report_data['figures']['locs'][amplicon_name]['plot_3b'] %}
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_3b'] %} -

Data: {{data_label}}

- {% endfor %} -
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_3b', amplicon_name=amplicon_name)}} +
{% endif %}
{# end card_body #} @@ -438,61 +382,36 @@
Indel characterization for {{amplicon_name}}
{% if report_data['figures']['locs'][amplicon_name]['plot_4a'] %} -
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_4a'] %} -

Data: {{data_label}}

- {% endfor %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_4a', amplicon_name=amplicon_name)}}
{% endif %} {% if report_data['figures']['locs'][amplicon_name]['plot_4b'] %} -
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_4b'] %} -

Data: {{data_label}}

- {% endfor %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_4b', amplicon_name=amplicon_name)}}
{% endif %} {% if report_data['figures']['locs'][amplicon_name]['plot_4c'] %} -
- - - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_4c'] %} -

Data: {{data_label}}

- {% endfor %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_4c', amplicon_name=amplicon_name)}}
{% endif %} {% if report_data['figures']['locs'][amplicon_name]['plot_4d'] %} -
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_4d'] %} -

Data: {{data_label}}

- {% endfor %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_4d', amplicon_name=amplicon_name)}}
{% endif %} {% if report_data['figures']['locs'][amplicon_name]['plot_4e'] %} -
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_4e'] %} -

Data: {{data_label}}

- {% endfor %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_4e', amplicon_name=amplicon_name)}}
{% endif %} {% if report_data['figures']['locs'][amplicon_name]['plot_4f'] %} -
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_4f'] %} -

Data: {{data_label}}

- {% endfor %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_4f', amplicon_name=amplicon_name)}}
{% endif %}
@@ -510,11 +429,7 @@
Frameshift analysis for {{amplicon_name}}
{% endif %}
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_5'] %} -

Data: {{data_label}}

- {% endfor %} + {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_5', amplicon_name=amplicon_name)}}
{% endif %} @@ -529,11 +444,7 @@
Frameshift mutagenesis profiles for {{amplicon_name}}
{% endif %}
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_6'] %} -

Data: {{data_label}}

- {% endfor %} + {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_6', amplicon_name=amplicon_name)}}
{% endif %} @@ -548,11 +459,7 @@
Coding mutations for {{amplicon_name}}
{% endif %}
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_7'] %} -

Data: {{data_label}}

- {% endfor %} + {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_7', amplicon_name=amplicon_name)}}
{% endif %} @@ -567,11 +474,7 @@
Splicing for {{amplicon_name}}
{% endif %}
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_8'] %} -

Data: {{data_label}}

- {% endfor %} + {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_8', amplicon_name=amplicon_name)}}
{% endif %} @@ -588,13 +491,9 @@
Allele plots for {{amplicon_name}}
{% for fig_name in report_data['figures']['sgRNA_based_names'][amplicon_name]['9'] %} -
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name][fig_name] %} -

Data: {{data_label}}

- {% endfor %} -
+
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name=fig_name, amplicon_name=amplicon_name)}} +
{% endfor %}
@@ -630,96 +529,61 @@
Base editing for {{amplicon_name}}
{% endif %} - -
-
+
+
+
{% if report_data['figures']['locs'][amplicon_name]['plot_10c'] %} -
-
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_10a'] %} -

Data: {{data_label}}

- {% endfor %} -
-
- - +
+
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_10a', amplicon_name=amplicon_name)}} +
+
- {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_10b'] %} -

Data: {{data_label}}

- {% endfor %} - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_10c'] %} -

Data: {{data_label}}

- {% endfor %} -
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_10b', amplicon_name=amplicon_name)}} + {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_10c', amplicon_name=amplicon_name)}}
+
{% else %} -
-
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_10a'] %} -

Data: {{data_label}}

- {% endfor %} -
-
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name]['plot_10b'] %} -

Data: {{data_label}}

- {% endfor %} -
+
+
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_10a', amplicon_name=amplicon_name)}} +
+
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_10b', amplicon_name=amplicon_name)}} +
{% endif %} {% if report_data['figures']['sgRNA_based_names'][amplicon_name] and report_data['figures']['sgRNA_based_names'][amplicon_name]['10d']%} -
- {% for fig_name in report_data['figures']['sgRNA_based_names'][amplicon_name]['10d'] %} -
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name][fig_name] %} -

Data: {{data_label}}

- {% endfor %} -
- {% endfor %} -
+
+ {% for fig_name in report_data['figures']['sgRNA_based_names'][amplicon_name]['10d'] %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name=fig_name, amplicon_name=amplicon_name)}} +
+ {% endfor %} +
{% endif %} {% if report_data['figures']['sgRNA_based_names'][amplicon_name] and report_data['figures']['sgRNA_based_names'][amplicon_name]['10e']%} -
- {% for fig_name in report_data['figures']['sgRNA_based_names'][amplicon_name]['10e'] %} -
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name][fig_name] %} -

Data: {{data_label}}

- {% endfor %} -
- {% endfor %} -
+
+ {% for fig_name in report_data['figures']['sgRNA_based_names'][amplicon_name]['10e'] %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name=fig_name, amplicon_name=amplicon_name)}} +
+ {% endfor %} +
{% endif %} {% if report_data['figures']['sgRNA_based_names'][amplicon_name] and report_data['figures']['sgRNA_based_names'][amplicon_name]['10f']%} -
- {% for fig_name in report_data['figures']['sgRNA_based_names'][amplicon_name]['10f'] %} -
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name][fig_name] %} -

Data: {{data_label}}

- {% endfor %} -
- {% endfor %} - - {% for fig_name in report_data['figures']['sgRNA_based_names'][amplicon_name]['10g'] %} -
- - - {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name][fig_name] %} -

Data: {{data_label}}

- {% endfor %} -
- {% endfor %} +
+ {% for fig_name in report_data['figures']['sgRNA_based_names'][amplicon_name]['10f'] %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_10f', amplicon_name=amplicon_name)}} +
+ {% endfor %} + {% for fig_name in report_data['figures']['sgRNA_based_names'][amplicon_name]['10g'] %} +
+ {{ render_partial('shared/partials/fig_reports.html', report_data=report_data, fig_name='plot_10g', amplicon_name=amplicon_name)}} +
+ {% endfor %}
{% endif %} diff --git a/templates/shared/partials/fig_reports.html b/templates/shared/partials/fig_reports.html new file mode 100644 index 00000000..4ee65aa2 --- /dev/null +++ b/templates/shared/partials/fig_reports.html @@ -0,0 +1,23 @@ +
+ {% if amplicon_name %} + {% if report_data['figures']['htmls'][amplicon_name][fig_name] %} + {{report_data['figures']['htmls'][amplicon_name][fig_name]|safe}} + {% else %} + + {% endif %} + + {% for (data_label,data_path) in report_data['figures']['datas'][amplicon_name][fig_name] %} +

Data: {{data_label}}

+ {% endfor %} + {% else %} + {% if report_data['figures']['htmls'][fig_name] %} + {{report_data['figures']['htmls'][fig_name]|safe}} + {% else %} + + {% endif %} + + {% for (data_label,data_path) in report_data['figures']['datas'][fig_name] %} +

Data: {{data_label}}

+ {% endfor %} + {% endif %} +
\ No newline at end of file diff --git a/templates/shared/partials/fig_summaries.html b/templates/shared/partials/fig_summaries.html new file mode 100644 index 00000000..404e8a26 --- /dev/null +++ b/templates/shared/partials/fig_summaries.html @@ -0,0 +1,11 @@ +
+ {% if summary_plot_htmls[plot_name] %} + {{summary_plot_htmls[plot_name]|safe}} + {% else %} + + {% endif %} + + {% for (data_label,data_path) in summary_plot_datas[plot_name] %} +

Data: {{data_label}}

+ {% endfor %} +
\ No newline at end of file