This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualization.psp
355 lines (292 loc) · 9.54 KB
/
visualization.psp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<!DOCTYPE HTML>
<!--
Dopetrope 2.5 by HTML5 UP
html5up.net | @n33co
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
<head>
<title>Visualization</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,900,300italic" rel="stylesheet" />
<script src="js/jquery.min.js"></script>
<script src="js/jquery.dropotron.min.js"></script>
<script src="js/config.js"></script>
<script src="js/skel.min.js"></script>
<script src="js/skel-panels.min.js"></script>
<script type="text/javascript" src="json2.min.js"></script>
<script type="text/javascript" src="/control/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/vis.js"></script>
<script type="text/javascript" src="js/graphData.js"></script>
<link type="text/css" rel="stylesheet" href="vis.css">
<link rel="icon" type="image/vnd.microsoft.icon"
href="images\logo.jpg" />
<style>
table,th,td
{
border:1px solid black;
border-collapse:collapse;
}
th,td
{
padding:5px;
}
th
{
text-align:center;
}
</style>
<style type="text/css">
html,
body {
font: 10pt arial;
}
#mygraph {
width: 1000px;
height: 500px;
border: 1px solid lightgray;
}
</style>
<noscript>
<link rel="stylesheet" href="css/skel-noscript.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/style-desktop.css" />
</noscript>
<%import sys
sys.path.append('/home/bi2_pg6/public_html/Inficio Raptum/Python')
import mysql.connector
a=""
title=''
pubid=''
abstract=''
pub_date=""
conn = mysql.connector.Connect(host='localhost',user='bi2_pg6',
password='blaat1234',database='InfiRap')
c = conn.cursor()
c.execute ("""select * from Article""")
for row in c:
title+=row[2]+"++"
pubid+=row[0]+"++"
abstract+=row[3]+"++"
pub_date+= str(row[1])+"++"
c.close()
# end
zoekTerm = form["search"]
import searchOrgComTest
searchOrgComTest.index(zoekTerm)
%>
<script>
var lijst = '<%=title%>';
var titles = lijst.split("++");
titles.pop();
var lijst = '<%=pubid%>';
var pubids = lijst.split("++");
pubids.pop();
var lijst = '<%=abstract%>';
var abstracts = lijst.split("++");
var lijst = '<%=pub_date%>';
var pub_dates = lijst.split("++");
abstracts.pop();
</script>
<script type="text/javascript">
//declaratie variabelen
var nodes = [];
var orgimg = "images/organism.jpg";
var compimg = "images/compound.jpg";
var edges = [];
var graph = null;
var pathOfFileToRead = null;
var array = [];
var dict = {};
var values = null;
var id1 = null;
var id2 = null;
var val = null;
var counter = 0;
var DIR = 'img/graph/';
var nod= [];
var edg= [];
var nodefile = null;
var edgefile = null;
var searchCheck= '<%=zoekTerm%>';
var notConnected=[];
function createNodes() { //Functie voor het aanmaken van de nodes
nodefile = "Python/nodesSearch.3j";
edgefile = "Python/edgesSearch.3j";
var pathOfFileToRead = nodefile; //bestand in .3j opmaak
var contentsOfFileAsString = FileHelper.readStringFromFileAtPath(pathOfFileToRead); //call aan de filehelper function voor het uilezen van .3j
var mainlist = contentsOfFileAsString.split(":");
var compoundlist = mainlist[0].split(">");
compoundlist.shift();
for (var i = 1; i <= compoundlist.length; i += 1) {
counter += 1;
var ids = i //id voor de nodes is gelijk aan het aantal waardes in de array
var labels = mainlist[0].split("*")[i].split("#")[0]; //labels voor de nodes worden uit het bestand gehaald
var values = mainlist[0].split("#")[i].split("@")[0]; // waardes/aantal voorkomens voor nodes worden uit het bestand gehaald
var title = mainlist[0].split("@")[i].split("+")[0]; // titel voor de nodes worden uit het bestand gehald
nodes.push({ // functie die de voorgaande variabelen in een dictionary voegt en deze toevoegd aan de nodes arraylist met de .push methode
id: ids,
value: parseInt(values),
label: labels,
title: title,
shape: 'dot'
});
}
var organismlist = mainlist[1].split(">");
organismlist.shift();
for (var i = 1; i <= organismlist.length; i += 1) {
var ids = counter + i //id voor de nodes is gelijk aan het aantal waardes in de array
var labels = mainlist[1].split("*")[i].split("#")[0]; //labels voor de nodes worden uit het bestand gehaald;
var values = mainlist[1].split("#")[i].split("@")[0]; // waardes/aantal voorkomens voor nodes worden uit het bestand gehaald
var title = mainlist[1].split("@")[i].split("+")[0]; // titel voor de nodes worden uit het bestand gehald
nodes.push({ // functie die de voorgaande variabelen in een dictionary voegt en deze toevoegd aan de nodes arraylist met de .push methode
id: ids,
value: parseInt(values),
label: labels,
title: title,
shape: 'triangle'
});
}
createEdges();
}
function createEdges() { //functie voor het aanmaken van de edges
var pathOfFileToRead1 = edgefile; //bestand in .3j opmaak
var contentsOfFileAsString1 = FileHelper.readStringFromFileAtPath(pathOfFileToRead1);
var array2 = contentsOfFileAsString1.split(">");
var waarde = null;
var a = null;
array2.shift();
for (var i = 1; i <= array2.length; i += 1) {
id1 = contentsOfFileAsString1.split(">")[i].split("*")[0];
id2 = contentsOfFileAsString1.split("*")[i].split("#")[0];
waarde = contentsOfFileAsString1.split("@")[i].split("%")[0];
parseInt(waarde);
if (waarde == 0) {
a = 1;
} else {
edges.push({
from: parseInt(id1),
to: parseInt(id2),
value: parseInt(waarde)
});
}
}
drawGraph();
}
function FileHelper() {} { //voor het uitlezn van het bestand
FileHelper.readStringFromFileAtPath = function (pathOfFileToReadFrom) {
var request = new XMLHttpRequest();
request.open("GET", pathOfFileToReadFrom, false);
request.send(null);
var returnValue = request.responseText;
return returnValue;
}
}
function drawGraph() {
// Instantiate our graph object.
var container = document.getElementById('mygraph');
var data = {
nodes: nodes,
edges: edges
};
var options = {
width: '1000px',
height: '500px',
edges: {
color: '#97C2FC'
},
//dataManipulation: true,
// clustering: true,
initiallyVisible: true
};
graph = new vis.Graph(container, data, options);
graph.on('doubleClick', function (properties) {//Double click event on nodes
document.getElementById("tabbeldiv").innerHTML = '\
<table id="itemList">\
<thead>\
<tr>\
<td><b>Title</b></td>\
<td><b>Publication date</b></td>\
<td><b>Pubmed_ID</b></td>\
<td><b>Abstract</b></td>\
</tr>\
</thead>\
<tbody>\
</tbody>\
</table>';
var id = properties.nodes;
var selected = nodes[id - 1]["title"].split(",");
selected.pop();
var rows = "";
var items = [];
for (var i = 0; i <= titles.length; i += 1) {
if(pubids[i]!=undefined){
var pubid = pubids[i].replace(" ","");
//var pubid = pubid[i].replace(",","");
var url = "http://www.ncbi.nlm.nih.gov/pubmed/"+pubid
if(selected.indexOf(pubid)>=0){
var date = pub_dates[i];
var tit = titles[i];
var abst = abstracts[i];
items.push({Title: tit, Pub_date: date, Pubmed_ID: url, Abstract: abst, ID_los: pubid});
}
else{}
}
}
$.each(items, function(){
rows += "<tr><td>" + this.Title + "</td><td>" + this.Pub_date + "</td><td>" + "<a href=" +this.Pubmed_ID+" target='_blank'>" +this.ID_los+ "</a>" + "</td><td>" + this.Abstract + "</td></tr>";
}
);
$( rows ).appendTo( "#itemList tbody" );
});
}
</script>
<!--[if lte IE 8]><script src="js/html5shiv.js"></script><link rel="stylesheet" href="css/ie8.css" /><![endif]-->
</head>
<body onload="createNodes();">
<!-- Header Wrapper -->
<div id="header-wrapper">
<div class="container">
<div class="row">
<div class="12u">
<!-- Header -->
<section id="header">
<!-- Logo -->
<h1><a href="index.html"><img src="images\logo.jpg" alt="logo" width="196" height="176"></a> </h1>
<!-- Nav -->
<nav id="nav">
<ul>
<li><a href="index.html">Home</a>
</li>
<li><a href="graphNew.psp">Visualization</a>
</li>
<li class="current_page_item"><a href="http://cytosine.nl/~bi2_pg6/Inficio%20Raptum/visualization.psp?search=">Specific Visualization</a>
</li>
<li>
<a href="http://cytosine.nl/~bi2_pg6/Inficio%20Raptum/Search_New.psp?Substance=&Organism=">Search</a>
</li>
<li><a href="get-started.html">Get started</a>
</li>
<li><a href="about-us.html">About us</a>
</li>
</ul>
</nav>
</section>
Search for an specific organism or compound:
<form name="zoekTerm" method="get">
<input type="text" id ='zoekbalk' name="search" value="">
<input id="clickMe" class= "button" type="submit" value="Search"/>
</form>
<div id="mygraph"></div>
<div id="abstract"></div>
<div id="test"></div>
<div id="tabbeldiv"></div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>