Commit 3351a03f authored by Carlos's avatar Carlos
Browse files

instance info page

parent a4490d9e
import os
import json
import shutil
import sys
import logging
......@@ -69,14 +70,46 @@ def motif_json(motif_id):
@app.route('/motif_page/<motif_type>/<motif_id>')
def motif_page(motif_type, motif_id):
parents = get_parents(motif_type, motif_id)
motif_path = os.path.join("static", motif_type, motif_id)
instance_paths = [os.path.join(motif_type, motif_id, inst) for inst in os.listdir(motif_path)]
return render_template("motif_page.html",
instance_paths=instance_paths,
parents=parents,
motif_type=motif_type)
parents = get_parents(motif_type, motif_id)
motif_path = os.path.join("static", motif_type, motif_id, "graphs")
instance_info= []
for inst in os.listdir(motif_path):
info = {
'drawing_path': os.path.join(motif_type, motif_id,\
"graphs", inst),
'motif_id': motif_id,
'instance_id': inst.split(".")[0].strip()
}
instance_info.append(info)
return render_template("motif_page.html",
instance_info=instance_info,
parents=parents,
motif_type=motif_type
)
@app.route('/instance_page/<motif_type>/<motif_id>/<instance>')
def instance_page(motif_type, motif_id, instance):
drawing_path = os.path.join(motif_type,
motif_id,
"graphs",
f"{instance}.png"
)
metadata_path = os.path.join("static",
motif_type,
motif_id,
"metadata",
f"{instance}.json")
with open(os.path.join(metadata_path)) as meta:
instance_metadata = json.load(meta)
return render_template("instance_page.html",
drawing_path=drawing_path,
metadata=instance_metadata,
instance=instance,
motif_type=motif_type,
motif_id=motif_id)
@app.route('/graphlets')
def graphlets():
graphlet_path = os.path.join("static", "graphlets")
......
......@@ -88,7 +88,7 @@ td {
padding: 8px;
}
th{
text-align: center;
text-align: left;
padding: 8px;
}
......
......@@ -29,7 +29,7 @@ Click on a motif drawing to see other instances.
<tr>
<td>
<a href="{{url_for('motif_page', motif_type=motif_type, motif_id='{}'.format(m) ) }}">
<img src="{{ url_for('static', filename='{}/{}/0.png'.format(motif_type, m)) }}" width="450px" id="border">
<img src="{{ url_for('static', filename='{}/{}/graphs/0.png'.format(motif_type, m)) }}" width="450px" id="border">
</a></td>
</tr>
......
......@@ -18,8 +18,7 @@ Select a motif gallery:
<ul>
<li><a href="{{ url_for('gallery', motif_type='motifs_bb') }}">Linear Motifs</a>: Nodes aggregated along a single chain.</li>
<li><a href="{{ url_for('gallery', motif_type='motifs') }}">General Motifs</a>: Nodes aggregated can span multiple chains.</li>
<li><a href="{{ url_for('gallery', motif_type='bioinformatics_1') }}">General Motifs</a>: Nodes aggregated can span multiple chains.</li>
</ul>
<b> Cite </b> <br><br>
......
{% extends 'default.html' %}
<head>
{% block body %}
<div style="width: 100%; overflow: hidden;">
<a href="{{url_for('motif_page', motif_type=motif_type, motif_id=motif_id ) }}">Back</a>
<table>
<tr>
<th> Instance ID </th>
<th> PDBID </th>
<th> Residues </th>
</tr>
<tr>
<td>
{{ instance }}
</td>
<td>
<a href="https://www.rcsb.org/structure/{{metadata.pdbid.upper()}}">{{ metadata.pdbid }}</a>
</td>
<td>
{{ metadata.nodes }}
</td>
</tr>
</table><br><br>
<img src="{{ url_for('static', filename=drawing_path)}}" style="width:250px">
</div>
</body>
{% endblock %}
......@@ -8,9 +8,15 @@
Instances <br>
{% for instance_path in instance_paths %}
{% for instance_info in instance_info %}
<img src="{{ url_for('static', filename=instance_path)}}" style="width:250px">
<a href="{{ url_for('instance_page', motif_type=motif_type,
motif_id=instance_info.motif_id, instance=instance_info.instance_id) }}">
<img src="{{ url_for('static', filename=instance_info.drawing_path)}}"
style="width:250px">
</a>
{% endfor %}
......@@ -25,7 +31,7 @@ Parent Motifs <br>
{% for p in parents %}
<a href="{{url_for('motif_page', motif_type=motif_type, motif_id='{}'.format(p)) }}">
<img src="{{ url_for('static', filename='{}/{}/0.png'.format(motif_type, p)) }}" style="width:200px">
<img src="{{ url_for('static', filename='{}/{}/graphs/0.png'.format(motif_type, p)) }}" style="width:200px">
</a>
{% endfor %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment