-
Notifications
You must be signed in to change notification settings - Fork 4
/
search.html
437 lines (367 loc) · 15.6 KB
/
search.html
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
<!DOCTYPE html>
<html lang="en" style="height: 100vh;">
<head>
<!-- Global site tag (gtag.js) - Google Analytics - Personal -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-176192306-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-176192306-1');
</script>
<!-- Global site tag (gtag.js) - Google Analytics - SBRG -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-176090948-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-176090948-2');
</script>
<title>iModulonDB: Search</title>
<!-- Metadata -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<!-- Bootstrap CDN -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<!-- Jquery -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<!-- Font -->
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700&display=swap" rel="stylesheet">
<!-- CSS -->
<style>
* {
font-family: 'Roboto', 'Helvetica', 'Segoe UI', sans-serif;
}
#search_box {
background-color: #A8D0E6;
color: black;
}
#searchBtn {
background-color: #5D5C61;
color: white;
}
.result {
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1), 0 2px 7px 0 rgba(0, 0, 0, 0.09);
list-style-type: none;
border-radius: 8px;
padding: 8px;
margin: 8px 40px;
color: #5D5C61;
font-weight: 300;
}
.name-result {
background-color: #E0EDF5;
border: 1px solid gray;
}
.desc-result {
border: 1px solid #BBBBBB;
}
.result-title {
color: #007bff;
font-weight: 400;
}
.result-link:hover .result {
background-color: #D6D6D6;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 3px 10px 0 rgba(0, 0, 0, 0.19);
text-decoration: none;
}
#results {
padding: unset;
}
.no-results {
list-style-type: none;
margin: 8px 40px;
}
.searchHeader {
list-style-type: none;
color: white;
font-weight: bold;
border-radius: 8px;
margin: 2.5rem 40px 0.5rem;
padding-top: 8px;
padding-bottom: 8px;
text-align: center;
}
.header {
background-color: #5D5C61;
color: white;
margin-bottom: 0;
padding: 0.4rem 0.4rem 0.4rem 0.7rem;
}
.header a {
color: white;
}
.header a:hover {
color: #A8D0E6;
}
#left_col {
background-color: #A8D0E6;
padding: 1rem 1rem 4.5rem;
height: unset;
min-height: 100vh;
}
#left_col_content {
position: sticky;
top: 4.5rem;
}
.card {
background-color: #5D5C61;
}
.im_head_meta_cat {
margin-bottom: 0;
font-size: 12px;
font-weight: bold;
color: white;
}
.im_head_meta_val {
color: white;
}
.im_head_meta_val a {
color: #A8D0E6;
}
.align-right {
display: flex;
align-items: center;
justify-content: flex-end;
}
.bd-lead {
overflow-wrap: break-word;
word-wrap: break-word;
-webkit-hyphens: auto;
-ms-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
.description {
margin: unset;
font-weight: 300;
}
</style>
</head>
<body style="height: 100vh;">
<!-- Page Content -->
<div class="container-fluid" style="min-width: 650px; max-width: 1600px">
<!-- Navbar -->
<div class="header row navbar-dark sticky-top">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">
<img src="images/modulytics_logo.png" width="30" height="30" class="d-inline-block align-top" alt=""
loading="lazy">
iModulonDB
</a>
</div>
<ul class="nav navbar-dark">
<li class="nav-item">
<a id="dataset_link" class="nav-link navbar-dark" href="dataset.html?organism=e_coli&dataset=precise1">Dataset
Page</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About</a>
</li>
</ul>
</div>
<div class="row">
<!-- Left column: Header -->
<div id="left_col" class="col-md-3">
<div id="left_col_content">
<h1 id="title" class="bd-title bd-lead"></h1>
<div class="card p-2 bd-lead" id="header"></div>
</div>
</div>
<!-- Main body -->
<div class="col-md-9 p-3">
<!-- Search -->
<div class="row mx-auto justify-content-center">
<div id="search_box" class="card p-3" style="width: 100%">
<p class="card-body text-center" style="font-size: xx-large; font-weight: 400; padding: 0.5rem">
Search for an iModulon or Gene
</p>
<div class="row">
<div class="col-6 align-right">
<input type="checkbox" checked="true" id="im_checkbox"><span
class="option"> Search iModulons </span>
</div>
<div class="col-6">
<input type="checkbox" checked="true" id="gene_checkbox"><span
class="option"> Search Genes </span>
</div>
</div>
<div class="input-group mx-auto pt-2 px-5">
<input type="text" class="form-control" placeholder="" id="searchText">
<div class="input-group-append">
<button class="btn btn-dark" id="searchBtn" onclick="search()">
Search
</button>
</div>
</div>
<p class="description pt-4 px-5">
<i> Genes: Search by gene name, locus tag, or gene product </i>
</p>
<p class="description px-5">
<i> iModulons: Search by iModulon name, associated regulator(s), or iModulon function </i>
</p>
</div>
</div>
<div>
<ul id="results"></ul>
</div>
<div class="tall-row"></div>
<hr>
<!-- Footer -->
<footer>
<div class="container">
<div class="row">
<div class="col-sm-3">
<a href="http://systemsbiology.ucsd.edu/">
<img class="img-fluid" src="images/sbrg-logo.png">
</a>
</div>
<div class="col-sm-9 m-auto">
<p class="copyright text-muted small">
iModulonDB is maintained by the Systems Biology Research Group at the University of
California, San Diego. <br/>
</p>
</div>
</div>
</div>
</footer>
</div>
</div>
</div>
<!-- Required CDNs: URLSearchParams, Papa Parse -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/url-search-params/1.1.0/url-search-params.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.1.0/papaparse.min.js"></script>
<!-- Populate page -->
<script>
// parse url
const params = new URLSearchParams(window.location.search);
const org_folder = 'organisms/' + params.get('organism') + '/' + params.get('dataset') + '/';
const link_suffix = "?organism=" + params.get('organism') + "&dataset=" + params.get('dataset');
// Update iModulon dataset page link
document.getElementById("dataset_link").setAttribute('href', 'dataset.html' + link_suffix);
// populate the dataset info
$.get(org_folder + 'dataset_meta.csv', function (meta) {
const metadata = Papa.parse(meta).data;
// dataset title
var title = metadata[1][1]
document.title = 'iModulonDB: ' + title.replace(/(<([^>]+)>)/ig, '');
if (title.slice(-8) != ' Dataset') {
title = title + ' Dataset';
}
$('#title').append(title);
// header text
for (i = 1; i < metadata.length - 1; i++) {
$('#header').append('<p class="im_head_meta_cat">' + metadata[i][0].toUpperCase() + '</p>')
$('#header').append('<p class="im_head_meta_val">' + metadata[i][1] + '</p>');
}
});
// fetch json file
let gene_list = [];
let im_list = [];
async function run() {
const response_gene = await fetch(org_folder + "gene_page_files/gene_list.json");
const response_im = await fetch(org_folder + "iModulon_files/im_list.json");
gene_list = await response_gene.json();
im_list = await response_im.json();
}
run();
// Search functionality below
// generate list items
//genes
const geneNameResultItem = ({gene_name, gene_id, gene_product}, searchTerm) => {
const re = new RegExp(searchTerm, "gi");
const formatted = `<span class="result-title">${gene_name} : ${gene_id}</span> (<i>gene product: ${gene_product}</i>)`.replace(re, (match) => `<u><b>${match}</b></u>`)
return `<a class="result-link" style="text-decoration: none;" href="gene.html${link_suffix}&gene_id=${gene_id}"><li class="result name-result">${formatted} </li></a>`
};
const geneDescResultItem = ({gene_name, gene_id, gene_product}, searchTerm) => {
const re = new RegExp(searchTerm, "gi");
const formatted = `<span class="result-title">${gene_name} : ${gene_id}</span> (<i>gene product: ${gene_product}</i>)`.replace(re, (match) => `<u><b>${match}</b></u>`)
return `<a class="result-link" style="text-decoration: none; " href="gene.html${link_suffix}&gene_id=${gene_id}"><li class="result desc-result">${formatted}</li></a>`
};
// iModulons
const imNameResultItem = ({component, name, regulator, Function}, searchTerm) => {
const re = new RegExp(searchTerm, "gi");
const formatted = `<span class="result-title">${name}</span> (<i>associated regulator(s): ${regulator}; Function: ${Function}</i>)`.replace(re, (match) => `<u><b>${match}</b></u>`)
return `<a class="result-link" style="text-decoration: none;" href="iModulon.html${link_suffix}&k=${component}"><li class="result name-result">${formatted}</li></a>`
};
const imDescResultItem = ({component, name, regulator, Function}, searchTerm) => {
const re = new RegExp(searchTerm, "gi");
const formatted = `<span class="result-title">${name}</span> (<i>associated regulator(s): ${regulator}; Function: ${Function}</i>)`.replace(re, (match) => `<u><b>${match}</b></u>`)
return `<a class="result-link" style="text-decoration: none;" href="iModulon.html${link_suffix}&k=${component}"><li class="result desc-result">${formatted}</li></a>`
};
// Headers for different sections
const geneHeader = `<li class="searchHeader card"> Gene Search Results </li>`;
const imHeader = `<li class="searchHeader card"> iModulon Search Results </li>`;
const noResults = `<li class="no-results"> No results found - please try again. To see a list of all available data, empty the input field and click the "Search" button. </li>`
async function search() {
// clear previous results
$('#results').empty();
// checkbox info
const showGenes = $('#gene_checkbox').prop('checked');
const showIMs = $('#im_checkbox').prop('checked');
// search input
const searchTerm = $('#searchText').val().toLowerCase();
// gene & iM filter by input
const geneNameResults = !showGenes ? [] : gene_list.filter(gene =>
gene.gene_name.toLowerCase().includes(searchTerm));
const geneDescResults = !showGenes ? [] : gene_list.filter(gene =>
(gene.gene_id.toLowerCase().includes(searchTerm) || gene.gene_product.toLowerCase().includes(searchTerm)) &&
!gene.gene_name.toLowerCase().includes(searchTerm));
const imNameResults = !showIMs ? [] : im_list.filter(im =>
im.name.toLowerCase().includes(searchTerm));
const imDescResults = !showIMs ? [] : im_list.filter(im =>
(im.regulator.toLowerCase().includes(searchTerm) || im.Function.toLowerCase().includes(searchTerm)) &&
!im.name.toLowerCase().includes(searchTerm));
// mapping
const geneNameListItems = geneNameResults.map(result => geneNameResultItem(result, searchTerm));
const geneDescListItems = geneDescResults.map(result => geneDescResultItem(result, searchTerm));
const imNameListItems = imNameResults.map(result => imNameResultItem(result, searchTerm));
const imDescListItems = imDescResults.map(result => imDescResultItem(result, searchTerm));
// add headers or no results based on checkbox and search results
if (showGenes) {
geneNameListItems.unshift(geneHeader)
if ((geneNameListItems.length + geneDescListItems.length) == 1) {
geneDescListItems.push(noResults)
}
}
;
if (showIMs) {
imNameListItems.unshift(imHeader)
if ((imNameListItems.length + imDescListItems.length) == 1) {
imDescListItems.push(noResults)
}
}
;
// add all search items
const allResultItems = imNameListItems.concat(imDescListItems, geneNameListItems, geneDescListItems)
allResultItems.forEach((r) => {
$('#results').append(r);
});
// Show 'no results found' message when there are no elements
if (!$('#results').children().length) {
$('#results').append('<div class="no-results">No results found. Please select at least one dataset to search' +
' by clicking the checkboxes above. </div>')
}
};
// search on 'Enter'
const input = document.getElementById("searchText");
input.addEventListener(
"keyup", function (event) {
if (event.keyCode == 13) {
event.preventDefault();
document.getElementById("searchBtn").click();
}
}
)
// Bolding of matching text
content=document.getElementById("results");
content.innerHTML=content.innerHTML.replace(/#searchText/gi,"<b>$&</b>");
</script>
</body>
</html>