diff options
author | Hao Chen | 2019-05-08 01:55:31 -0500 |
---|---|---|
committer | Hao Chen | 2019-05-08 01:55:31 -0500 |
commit | efaf3a4abe2f6ae5b67578182085d18d05f25c5f (patch) | |
tree | 00ee6bb45907e03cc192e469892c06c30e0f2e6b | |
parent | 577515fb8afdf7fa535a3b16d13f261696bb6ce0 (diff) | |
download | genecup-efaf3a4abe2f6ae5b67578182085d18d05f25c5f.tar.gz |
multiple genes allowed
-rw-r--r-- | server.py | 25 | ||||
-rw-r--r-- | templates/index.html | 14 | ||||
-rw-r--r-- | templates/layout.html | 46 | ||||
-rw-r--r-- | templates/network.html | 46 |
4 files changed, 122 insertions, 9 deletions
@@ -19,14 +19,21 @@ def network(): nodes_list=[] if request.method == 'POST': term = request.form - gene=term['query'] - nodes="{ data: { id: '" + gene + "', nodecolor:'#FADBD8'} },\n" + default_nodes - tmp0=gene_addiction(gene) - e0=generate_edges(tmp0) - tmp1=gene_functional(gene) - e1=generate_edges(tmp1) - tmp2=gene_anatomical(gene) - e2=generate_edges(tmp2) - return render_template('network.html', elements=nodes+e0+e1+e2) + genes=term['query'] + genes=genes.replace(",", " ") + genes=genes.replace(";", " ") + genes=genes.split() + nodes=default_nodes + edges=str() + for gene in genes: + nodes+="{ data: { id: '" + gene + "', nodecolor:'#FADBD8', fontweight:700} },\n" + tmp0=gene_addiction(gene) + e0=generate_edges(tmp0) + tmp1=gene_functional(gene) + e1=generate_edges(tmp1) + tmp2=gene_anatomical(gene) + e2=generate_edges(tmp2) + edges+=e0+e1+e2 + return render_template('network.html', elements=nodes+edges) if __name__ == '__main__': app.run(debug=True) diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..c7bafcd --- /dev/null +++ b/templates/index.html @@ -0,0 +1,14 @@ +{% extends "layout.html" %} +{% block content %} + + +<h3> Searching PubMed to find sentences related to addiction</h3> + <form class="form-inline my-2 my-lg-0" action="/network" method="POST"> + <input name="query" class="form-control mr-sm-2" type="search" placeholder="Nrxn1" aria-label="search" value="Nrxn1"> + <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button> + </form> + +{% endblock %} + + + diff --git a/templates/layout.html b/templates/layout.html new file mode 100644 index 0000000..1a81c1a --- /dev/null +++ b/templates/layout.html @@ -0,0 +1,46 @@ +<!doctype html> +<head> +<!-- Required meta tags --> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> + <meta http-equiv="X-UA-Compatible" content="ie=edge"> + + <!-- Bootstrap CSS --> + <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> + <link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}"> + + + <title>GatPub: Gene Addictionness through PubMed</title> +</head> +<body> + +<nav class="navbar navbar-expand-lg navbar-light bg-light"> + <a class="navbar-brand" href="#">GatPub</a> + <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> + <span class="navbar-toggler-icon"></span> + </button> + + <div class="collapse navbar-collapse" id="navbarSupportedContent"> + <ul class="navbar-nav mr-auto"> + <li class="nav-item active"> + <a class="nav-link" href="/home">Home <span class="sr-only">(current)</span></a> + </li> + <li class="nav-item"> + <a class="nav-link" href="/search">Search</a> + </li> + <li class="nav-item"> + <a class="nav-link" href="/result">Result</a> + </li> + </div> +</nav> + + <div class="container"> + {% block content %}{% endblock %} + </div> + +<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> +<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> +<script src="http://d3js.org/d3.v5.min.js"></script> +</body> + + diff --git a/templates/network.html b/templates/network.html new file mode 100644 index 0000000..24c18c1 --- /dev/null +++ b/templates/network.html @@ -0,0 +1,46 @@ +{% extends "layout.html" %} +{% block content %} + +<script type="text/javascript" src="{{ url_for('static', filename='cytoscape.min.js') }}"></script> + + + <div id="cy"></div> + <script> + var cy = cytoscape({ + container: document.getElementById('cy'), + + style: [ + { selector: 'node', + css: { + 'content': 'data(id)', + 'text-valign': 'center', + 'text-halign': 'center', + 'background-color': 'data(nodecolor)', + 'font-weight': 'data(fontweight)' + } + }, + + { selector: 'edge', + css: { + 'content': 'data(sentCnt)', + 'curve-style': 'bezier', + "opacity": "0.4", + } + } + ], + elements:[ {{ elements | safe }} ], + + layout: { + name: 'concentric', + concentric: function( node ){ + return node.degree(); + }, + levelWidth: function( nodes ){ + return 2; + } + }, + + }); + </script> + +{% endblock %} |