Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Carlos GO
vernal_server
Commits
d2cbe670
Commit
d2cbe670
authored
Aug 14, 2020
by
Carlos GO
Browse files
show parent motifs
parent
359e6d09
Changes
4
Hide whitespace changes
Inline
Side-by-side
app.py
View file @
d2cbe670
...
...
@@ -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
):
p
rint
(
motif_id
)
p
arents
=
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
():
...
...
static/css/style.css
View file @
d2cbe670
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
;
}
...
...
templates/default.html
View file @
d2cbe670
...
...
@@ -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>
...
...
templates/motif_page.html
View file @
d2cbe670
<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 %}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment