Commit 97f344a3 authored by Carlos GO's avatar Carlos GO
Browse files

pick motif id

parent d5b5603b
......@@ -21,10 +21,12 @@ import numpy as np
app = Flask(__name__)
motifs_id = "motifs_bb"
MOTIF_PATH = os.path.join("static", motifs_id)
def get_parents(this_motif):
this_motif = ms.Multiset(map(int,this_motif.split("-")))
motif_ids = os.listdir("static/motifs")
motif_ids = os.listdir(MOTIF_PATH)
parents = []
for motif in motif_ids:
that_motif = ms.Multiset(map(int, motif.split("-")))
......@@ -36,10 +38,10 @@ def get_parents(this_motif):
@app.route("/")
def home():
motif_ids = os.listdir("static/motifs")
motif_ids = os.listdir(MOTIF_PATH)
motif_dict = defaultdict(list)
for mot in motif_ids:
if len(os.listdir(f"static/motifs/{mot}")) < 1:
if len(os.listdir(f"{MOTIF_PATH}/{mot}")) < 1:
continue
size = len(mot.split("-"))
motif_dict[size].append(mot)
......@@ -47,7 +49,7 @@ def home():
for size in sorted(motif_dict.keys()):
sorted_dict[size] = motif_dict[size]
return render_template("home.html", motif_dict=sorted_dict)
return render_template("home.html", motifs_id=motifs_id, motif_dict=sorted_dict)
@app.route("/hmp")
def hmp():
......@@ -63,11 +65,12 @@ def motif_json(motif_id):
@app.route('/motif_page/<motif_id>')
def motif_page(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)]
motif_path = os.path.join(MOTIF_PATH, motif_id)
instance_paths = [os.path.join(motifs_id, motif_id, inst) for inst in os.listdir(motif_path)]
return render_template("motif_page.html",
instance_paths=instance_paths,
parents=parents)
parents=parents,
motifs_id=motifs_id)
@app.route('/graphlets')
def graphlets():
......
......@@ -29,7 +29,7 @@ Click on a motif drawing to see other instances.
<tr>
<td>
<a href="{{url_for('motif_page', motif_id='{}'.format(m)) }}">
<img src="{{ url_for('static', filename='motifs/{}/0.png'.format(m)) }}" width="450px" id="border">
<img src="{{ url_for('static', filename='{motifs_id}/{}/0.png'.format(motifs_id, m)) }}" width="450px" id="border">
</a></td>
</tr>
......
......@@ -25,7 +25,7 @@ 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">
<img src="{{ url_for('static', filename='{}/{}/0.png'.format(motifs_id, 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