Skip to content

Commit 6299f58

Browse files
author
Corentin M
committedMay 5, 2021
Simple Stat page for histo features
1 parent a4a2166 commit 6299f58

File tree

2 files changed

+90
-8
lines changed

2 files changed

+90
-8
lines changed
 

‎app/histostats/routes.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
import json
2+
import os
23
from flask_login import current_user, login_required
3-
from flask import render_template, request, flash, redirect, url_for
4-
from app import db
4+
from flask import render_template, current_app
55
from app.histostats import bp
66

77

88
@bp.route("/histostats", methods=["GET", "POST"])
99
def statsindex():
1010
"""Page for histo statistics page."""
11-
return render_template("histostats_index.html")
11+
stat_per_gene_file = open(
12+
os.path.join(current_app.config["CONFIG_FOLDER"], "stat_per_gene.json")
13+
)
14+
stat_per_gene = json.load(stat_per_gene_file)
15+
stat_per_diag_file = open(
16+
os.path.join(current_app.config["CONFIG_FOLDER"], "stat_per_diag.json")
17+
)
18+
stat_per_diag = json.load(stat_per_diag_file)
19+
stat_per_gene = sorted(stat_per_gene.items())
20+
stat_per_diag = sorted(stat_per_diag.items())
21+
return render_template(
22+
"histostats_index.html",
23+
stat_per_gene=stat_per_gene,
24+
stat_per_diag=stat_per_diag,
25+
)
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,76 @@
1-
{% extends "base.html"%}
2-
{% block content %}
1+
{% extends "base.html"%} {% block content %}
32
<div class="row">
4-
<div class="col-xl">
5-
Test !
3+
<div class="col-xl-6">
4+
<h1>Traits Histologiques par Gène</h1>
5+
<div class="accordion" id="accordionGENE">
6+
{% for gene in stat_per_gene %}
7+
<div class="accordion-item">
8+
<h2 class="accordion-header" id="headingGene{{gene[0]}}">
9+
<button
10+
class="accordion-button collapsed"
11+
type="button"
12+
data-bs-toggle="collapse"
13+
data-bs-target="#collapseGene{{gene[0]}}"
14+
aria-expanded="true"
15+
aria-controls="collapseGene{{gene[0]}}"
16+
>
17+
{{gene[0]}} (n={{gene[1].n}})
18+
</button>
19+
</h2>
20+
<div
21+
id="collapseGene{{gene[0]}}"
22+
class="accordion-collapse collapse"
23+
aria-labelledby="headingGene{{gene[0]}}"
24+
data-bs-parent="#accordionGENE"
25+
>
26+
<div class="accordion-body">
27+
<ul>
28+
{% for key,value in gene[1].feature.items()%}
29+
<li>{{value}}% - {{key}}</li>
30+
{% endfor %}
31+
</ul>
32+
</div>
33+
</div>
34+
</div>
35+
{% endfor %}
636
</div>
37+
</div>
38+
39+
<div class="col-xl-6">
40+
<h1>Traits Histologiques par Classe de Myopathie</h1>
41+
<div class="accordion" id="accordionDIAG">
42+
{% for diag in stat_per_diag %}
43+
<div class="accordion-item">
44+
<h2 class="accordion-header" id="headingDiag{{diag[0]}}">
45+
<button
46+
class="accordion-button collapsed"
47+
type="button"
48+
data-bs-toggle="collapse"
49+
data-bs-target="#collapseDiag{{diag[0]}}"
50+
aria-expanded="true"
51+
aria-controls="collapseDiag{{diag[0]}}"
52+
>
53+
{{diag[0]}} (n={{diag[1].n}})
54+
</button>
55+
</h2>
56+
<div
57+
id="collapseDiag{{diag[0]}}"
58+
class="accordion-collapse collapse"
59+
aria-labelledby="headingDiag{{diag[0]}}"
60+
data-bs-parent="#accordionDIAG"
61+
>
62+
<div class="accordion-body">
63+
<ul>
64+
{% for key,value in diag[1].feature.items()%}
65+
<li>{{value}}% - {{key}}</li>
66+
{% endfor %}
67+
</ul>
68+
</div>
69+
</div>
70+
</div>
71+
{% endfor %}
72+
</div>
73+
</div>
774
</div>
8-
{% endblock %}
75+
76+
{% endblock %}

0 commit comments

Comments
 (0)
Please sign in to comment.