-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""Curation app for INDRA CoGEx.""" | ||
|
||
import logging | ||
import time | ||
|
||
import flask | ||
from flask import render_template | ||
|
||
|
||
from .proxies import client | ||
|
||
__all__ = [ | ||
"entity_blueprint", | ||
] | ||
|
||
logger = logging.getLogger(__name__) | ||
entity_blueprint = flask.Blueprint("entity", __name__, url_prefix="/explore") | ||
|
||
|
||
@entity_blueprint.route("/entity/<prefix>:<identifier>", methods=["GET"]) | ||
def entity(prefix: str, identifier: str): | ||
"""Get all statements about the given entity.""" | ||
curie = f"{prefix}:{identifier}" | ||
print(f"querying for {curie}") | ||
start= time.time() | ||
node = client.get_node_by_curie(curie) | ||
print(f"done querying for {curie} in {time.time() - start:.2f} seconds") | ||
results = {} | ||
for rel in ["indra_rel", "associated_with", "mutated_in"]: | ||
query = f"""\ | ||
MATCH (n:BioEntity {{id: '{curie}'}})-[r:{rel}]-(v) | ||
RETURN r, v | ||
LIMIT 5 | ||
""" | ||
start = time.time() | ||
results[rel] = list(client.query_tx(query)) | ||
end = time.time() - start | ||
print(f"finished query for {rel} in {end} seconds.") | ||
return render_template("entity.html", node=node, results=results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block container %} | ||
<div class="card"> | ||
<div class="card-header"> | ||
<h4 class="my-0 font-weight-normal"> | ||
{{ node.name }} <span class="badge badge-light">{{ node.id }}</span> | ||
</h4> | ||
</div> | ||
<div class="card-body"> | ||
{{ node }} | ||
</div> | ||
{% for key, records in results.items() %} | ||
{% if records|length > 0 %} | ||
<div class="card-body"> | ||
<h5>{{ key }}</h5> | ||
</div> | ||
<ul class="list-group"> | ||
{% for r, v in records %} | ||
<li class="list-group-item"> | ||
{{ r }} - {{ v }} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
{% endfor %} | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters