Commit d2cbe670 authored by Carlos GO's avatar Carlos GO
Browse files

show parent motifs

parent 359e6d09
......@@ -5,6 +5,7 @@ import logging
import uuid
from collections import defaultdict
import multiset as ms
from flask import Flask
from flask import render_template
from flask import request
......@@ -21,11 +22,25 @@ import numpy as np
app = Flask(__name__)
def get_parents(this_motif):
this_motif = ms.Multiset(map(int,this_motif.split("-")))
motif_ids = os.listdir("static/motifs")
parents = []
for motif in motif_ids:
that_motif = ms.Multiset(map(int, motif.split("-")))
if this_motif.issubset(that_motif):
if len(that_motif) == len(this_motif) + 1:
parents.append(motif)
return parents
@app.route("/")
def home():
motif_ids = os.listdir("static/motifs")
motif_dict = defaultdict(list)
for mot in motif_ids:
if len(os.listdir(f"static/motifs/{mot}")) < 1:
continue
size = len(mot.split("-"))
motif_dict[size].append(mot)
sorted_dict = {}
......@@ -40,19 +55,19 @@ def hmp():
@app.route('/motif_json/<motif_id>')
def motif_json(motif_id):
print(motif_id)
motif_path = os.path.join("static", "motifs_json", motif_id)
print(motif_path)
instance_paths = [os.path.join("motifs_json", motif_id, inst) for inst in os.listdir(motif_path)]
return render_template("graph.html", instance_paths=instance_paths)
@app.route('/motif_page/<motif_id>')
def motif_page(motif_id):
print(motif_id)
parents = get_parents(motif_id)
motif_path = os.path.join("static", "motifs", motif_id)
instance_paths = [os.path.join("motifs", motif_id, inst) for inst in os.listdir(motif_path)]
return render_template("motif_page.html", instance_paths=instance_paths)
return render_template("motif_page.html",
instance_paths=instance_paths,
parents=parents)
@app.route('/graphlets')
def graphlets():
......
body{
width: 43%;
width: 60%;
padding 100px;
margin:auto;
font-family: monospace;
......@@ -21,7 +21,6 @@ p{
border-image-source: url(../frame.png);
border-image-slice: 70;
border-image-repeat: stretch;
height : 300px;
border-width: 70px;
border-style: solid;
}
......
......@@ -8,7 +8,7 @@
{% endblock %}
<a href="/">
<img src="{{url_for('static', filename='vernal2.png')}}" style="width:60%" id="border">
<img src="{{url_for('static', filename='vernal2.png')}}" style="width:500px" id="border">
</a>
......
<head>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<body>
{% extends 'default.html' %}
{% block body %}
<div style="width: 100%; overflow: hidden;">
<div style="width: 600px; float: left" id="instances">
Instances <br>
{% for instance_path in instance_paths %}
<img src="{{ url_for('static', filename=instance_path)}}">
<img src="{{ url_for('static', filename=instance_path)}}" style="width:250px">
</body>
</html>
{% endfor %}
</div>
<div style="margin-left: 620px;" id="parents">
Parent Motifs <br>
{% for p in parents %}
<a href="{{url_for('motif_page', motif_id='{}'.format(p)) }}">
<img src="{{ url_for('static', filename='motifs/{}/0.png'.format(p)) }}" style="width:200px">
</a>
{% endfor %}
</div>
</body>
{% endblock %}
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