This repository has been archived by the owner on May 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fsearch.js
303 lines (256 loc) · 9.51 KB
/
fsearch.js
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
// these functions execute our search via an AJAX call
function gene_search( term ) {
// hide and clear the previous results, if any
$('#results').hide();
$('tbody').empty();
// transforms all the form parameters into a string we can send to the server
var frmStr = $('#search_term').serialize();
$.ajax({
url: './gene_search.cgi',
dataType: 'json',
data: frmStr,
success: function(data, textStatus, jqXHR) {
processJSON(data);
},
error: function(jqXHR, textStatus, errorThrown){
alert("Failed to perform gene search! textStatus: (" + textStatus +
") and errorThrown: (" + errorThrown + ")");
}
});
}
function dn_search( term ) {
// hide and clear the previous results, if any
$('#results').hide();
$('tbody').empty();
// transforms all the form parameters into a string we can send to the server
var frmStr = $('#search_term').serialize();
$.ajax({
url: './dn_search.cgi',
dataType: 'json',
data: frmStr,
success: function(data, textStatus, jqXHR) {
processJSON(data);
},
error: function(jqXHR, textStatus, errorThrown){
alert("Failed to perform gene search! textStatus: (" + textStatus +
") and errorThrown: (" + errorThrown + ")");
}
});
}
function rs_search( term ) {
// hide and clear the previous results, if any
$('#results').hide();
$('tbody').empty();
// transforms all the form parameters into a string we can send to the server
var frmStr = $('#rs_term').serialize();
$.ajax({
url: './rs_search.cgi',
dataType: 'json',
data: frmStr,
success: function(data, textStatus, jqXHR) {
processJSON(data);
},
error: function(jqXHR, textStatus, errorThrown){
alert("Failed to perform gene search! textStatus: (" + textStatus +
") and errorThrown: (" + errorThrown + ")");
}
});
}
function sig_search( term ) {
// hide and clear the previous results, if any
$('#results').hide();
$('tbody').empty();
// transforms all the form parameters into a string we can send to the server
var frmStr = $('#search_term').serialize();
$.ajax({
url: './sig_search.cgi',
dataType: 'json',
data: frmStr,
success: function(data, textStatus, jqXHR) {
processJSON(data);
},
error: function(jqXHR, textStatus, errorThrown){
alert("Failed to perform gene search! textStatus: (" + textStatus +
") and errorThrown: (" + errorThrown + ")");
}
});
}
function anpred_search( term ) {
// hide and clear the previous results, if any
$('#results').hide();
$('tbody').empty();
// transforms all the form parameters into a string we can send to the server
var frmStr = $('#search_term').serialize();
$.ajax({
url: './anpred_search.cgi',
dataType: 'json',
data: frmStr,
success: function(data, textStatus, jqXHR) {
processJSON(data);
},
error: function(jqXHR, textStatus, errorThrown){
alert("Failed to perform gene search! textStatus: (" + textStatus +
") and errorThrown: (" + errorThrown + ")");
}
});
}
function sepred_search( term ) {
// hide and clear the previous results, if any
$('#results').hide();
$('tbody').empty();
// transforms all the form parameters into a string we can send to the server
var frmStr = $('#search_term').serialize();
$.ajax({
url: './sepred_search.cgi',
dataType: 'json',
data: frmStr,
success: function(data, textStatus, jqXHR) {
processJSON(data);
},
error: function(jqXHR, textStatus, errorThrown){
alert("Failed to perform gene search! textStatus: (" + textStatus +
") and errorThrown: (" + errorThrown + ")");
}
});
}
// this processes a passed JSON structure representing gene matches and draws it
// to the result table
function processJSON( data ) {
// set the span that lists the match count
$('#match_count').text( data.match_count );
// this will be used to keep track of row identifiers
var next_row_num = 1;
// iterate over each match and add a row to the result table for each
$.each( data.matches, function(i, item) {
var this_row_id = 'result_row_' + next_row_num++;
// create a row and append it to the body of the table
$('<tr/>', { "id" : this_row_id } ).appendTo('tbody');
// add the loc column
$('<td/>', { "text" : item.loc } ).appendTo('#' + this_row_id);
// add the gene column
$('<td/>', { "text" : item.gene } ).appendTo('#' + this_row_id);
// add the gt column
$('<td/>', { "text" : item.gt } ).appendTo('#' + this_row_id);
// add the dn column
$('<td/>', { "text" : item.dn } ).appendTo('#' + this_row_id);
// add the rs column
$('<td/>', { "text" : item.rs } ).appendTo('#' + this_row_id);
// add the sig column
$('<td/>', { "text" : item.sig } ).appendTo('#' + this_row_id);
// add the clinvartype column
$('<td/>', { "text" : item.clinvartype } ).appendTo('#' + this_row_id);
// add the sepred column
$('<td/>', { "text" : item.sepred } ).appendTo('#' + this_row_id);
// add the sevartype column
$('<td/>', { "text" : item.sevartype } ).appendTo('#' + this_row_id);
// add the anpred column
$('<td/>', { "text" : item.anpred } ).appendTo('#' + this_row_id);
// add the anvartype column
$('<td/>', { "text" : item.anvartype } ).appendTo('#' + this_row_id);
});
$.each($('td'), function () {
if($(this).html() == 'HIGH' || $(this).html() == 'Automatic_disease_causing' || $(this).html() == 'Pathogenic' || $(this).html() == 'Pathogenic/Likely_pathogenic'|| $(this).html() == 'Likely_pathogenic') {
$(this).css('background-color', 'FireBrick');
}
if($(this).html() == 'MODERATE' || $(this).html() == 'Disease_causing' || $(this).html() == 'Conflicting_interpretations_of_pathogenicity' || $(this).html() == 'Pathogenic,_risk_factor') {
$(this).css('background-color', 'LightCoral');
}
if($(this).html() == 'drug_response' || $(this).html() == 'LOW' ||$(this).html() == 'Uncertain_significance') {
$(this).css('background-color', 'MistyRose');
}
if($(this).html() == 'CHT' || $(this).html() == 'HM') {
$(this).css('background-color', 'LightGrey');
}
if($(this).html() == 'Automatic_polymorphism' || $(this).html() == 'Polymorphism' || $(this).html() == 'Benign' || $(this).html() == 'Likely_benign' || $(this).html() == 'Benign/Likely_benign') {
$(this).css('background-color', 'LightGreen');
}
if($(this).html() == 'null') {
$(this).html('.');
}
});
// now show the result section that was previously hidden
$('#results').show();
}
// run our javascript once the page is ready
$(document).ready( function() {
$('#search').hide();
$('#rs_search').hide();
$('#choose').click( function() {
var search_type = $('input:radio[name=choice]:checked').val()
if (search_type == 'gene'){
$('#search').show();
$('#rs_search').hide();
$('#search_term').autocomplete({
minLength:3,
source:"./gene_auto.cgi"
});
// define what should happen when a user clicks submit
$('#submit').click( function() {
gene_search();
return false;// prevents 'normal' form submission
});
} if (search_type == 'dn'){
$('#search').show();
$('#rs_search').hide();
//add autocomplete
$('#search_term').autocomplete({
minLength:4,
source:"./dn_auto.cgi"
});
// define what should happen when a user clicks submit
$('#submit').click( function() {
dn_search();
return false;// prevents 'normal' form submission
});
} if (search_type == 'rs'){
$('#rs_search').show();
$('#search').hide();
// define what should happen when a user clicks submit no atuocomplete for rs
$('#rs_submit').click( function() {
rs_search();
return false;// prevents 'normal' form submission
});
} if (search_type == 'sig'){
$('#search').show();
$('#rs_search').hide();
//add autocomplete
$('#search_term').autocomplete({
minLength:1,
source:"./sig_auto.cgi"
});
// define what should happen when a user clicks submit
$('#submit').click( function() {
sig_search();
return false;// prevents 'normal' form submission
});
} if (search_type == 'anpred'){
$('#search').show();
$('#rs_search').hide();
//add autocomplete
$('#search_term').autocomplete({
minLength:0,
source:"./anpred_auto.cgi"
});
$('#search_term').autocomplete("search", "");
// define what should happen when a user clicks submit
$('#submit').click( function() {
anpred_search();
return false;// prevents 'normal' form submission
});
} if (search_type == 'sepred'){
$('#search').show();
$('#rs_search').hide();
//add autocomplete
$('#search_term').autocomplete({
minLength:0,
source:"./sepred_auto.cgi"
});
$('#search_term').autocomplete("search", "");
// define what should happen when a user clicks submit
$('#submit').click( function() {
sepred_search();
return false;// prevents 'normal' form submission
});
}
});
});