1/*eslint complexity: ["error", 8]*/ 2/*global ClearSelection, CheckSelection, AddToSelection, superposition, copyToClipboard, showAlert*/ 3 4function structurebrowser() { 5 6 var oTable2 = $("#structures_scrollable").DataTable({ 7 scrollY: "65vh", 8 scrollX: true, 9 scrollCollapse: true, 10 scroller: true, 11 paging: true, 12 pageLength: 100, 13 aaSorting: [], 14 autoWidth: false, 15 order: [[29, "desc"],[1,"asc"]], 16 columnDefs: [{ "targets": "no-sort", "orderable": false }], 17 columns: [ 18 null, 19 null, 20 null, 21 null, 22 null, 23 null, 24 null, 25 null, 26 null, 27 null, 28 null, 29 null, 30 null, 31 null, 32 null, 33 null, 34 null, 35 null, 36 null, 37 null, 38 {"width": "20%"}, 39 null, 40 null, 41 null, 42 null, 43 null, 44 null, 45 null, 46 null, 47 null, 48 null 49 ], 50 bInfo: true, 51 }); 52 53 var prev_ids = Array(); 54 var current_align_ids = Array(); 55 56 //Uncheck every row when using back button on browser 57 $(".alt_selected").prop("checked",false); 58 $(".alt").prop("checked",false); 59 $(".select-all").prop("checked",false); 60 61 const validPrefixes = ["#keepselection"]; 62 63 if (validPrefixes.some(prefix => window.location.hash.startsWith(prefix))) {} 64 else { 65 ClearSelection('targets'); 66 ClearSelection('reference'); 67 } 68 69 $("#loading_div").hide(); 70 71 yadcf.init(oTable2, 72 [ 73 { 74 column_number : 1, 75 filter_type: "multi_select", 76 select_type: "select2", 77 column_data_type: "html", 78 html_data_type: "text", 79 filter_default_label: "UniProt", 80 filter_match_mode : "exact", 81 filter_reset_button_text: false, 82 select_type_options: { 83 width: "60px", 84 } 85 }, 86 { 87 column_number : 2, 88 filter_type: "multi_select", 89 select_type: "select2", 90 column_data_type: "html", 91 html_data_type: "text", 92 filter_default_label: "IUPHAR", 93 filter_match_mode : "exact", 94 filter_reset_button_text: false, 95 select_type_options: { 96 width: "60px", 97 } 98 }, 99 { 100 column_number : 3, 101 filter_type: "multi_select", 102 select_type: "select2", 103 column_data_type: "html", 104 html_data_type: "text", 105 filter_default_label: "Select", 106 filter_match_mode : "exact", 107 filter_reset_button_text: false, 108 select_type_options: { 109 width: "80px", 110 } 111 }, 112 { 113 column_number: 4, 114 filter_type: "multi_select", 115 select_type: "select2", 116 filter_default_label: "", 117 filter_reset_button_text: false, 118 select_type_options: { 119 width: "35px", 120 } 121 }, 122 { 123 column_number: 5, 124 filter_type: "multi_select", 125 select_type: "select2", 126 filter_default_label: "Species", 127 filter_reset_button_text: false, 128 select_type_options: { 129 width: "60px", 130 } 131 }, 132 { 133 column_number : 6, 134 filter_type: "multi_select", 135 select_type: "select2", 136 filter_default_label: "Method", 137 filter_reset_button_text: false, 138 select_type_options: { 139 width: "60px", 140 } 141 }, 142 { 143 column_number : 7, 144 filter_type: "multi_select", 145 select_type: "select2", 146 column_data_type: "html", 147 filter_default_label: "Select", 148 filter_reset_button_text: false, 149 select_type_options: { 150 width: "50px", 151 } 152 }, 153 { 154 column_number : 8, 155 filter_type: "multi_select", 156 select_type: "select2", 157 filter_default_label: "Select", 158 column_data_type: "html", 159 filter_reset_button_text: false, 160 select_type_options: { 161 width: "50px", 162 } 163 }, 164 { 165 column_number : 9, 166 filter_type: "range_number", 167 filter_reset_button_text: false, 168 filter_default_label: ["Min", "Max"], 169 }, 170 { 171 column_number : 10, 172 filter_type: "multi_select", 173 select_type: "select2", 174 filter_default_label: "", 175 filter_reset_button_text: false, 176 select_type_options: { 177 width: "30px", 178 } 179 }, 180 { 181 column_number : 11, 182 filter_type: "multi_select", 183 select_type: "select2", 184 filter_default_label: "State", 185 filter_reset_button_text: false, 186 filter_match_mode : "exact", 187 select_type_options: { 188 width: "70px", 189 } 190 }, 191 { 192 column_number : 12, 193 filter_type: "range_number", 194 filter_reset_button_text: false, 195 filter_default_label: ["Min", "Max"], 196 }, 197 { 198 column_number : 13, 199 filter_type: "range_number", 200 filter_reset_button_text: false, 201 filter_default_label: ["Min", "Max"], 202 select_type_options: { 203 width: "50px", 204 } 205 }, 206 { 207 column_number : 14, 208 filter_type: "multi_select", 209 select_type: "select2", 210 filter_default_label: "Family", 211 filter_match_mode : "exact", 212 filter_reset_button_text: false, 213 select_type_options: { 214 width: "50px", 215 } 216 }, 217 { 218 column_number : 15, 219 filter_type: "multi_select", 220 select_type: "select2", 221 filter_default_label: "Subtype", 222 filter_match_mode : "exact", 223 filter_reset_button_text: false, 224 select_type_options: { 225 width: "55px", 226 } 227 }, 228 { 229 column_number : 16, 230 filter_type: "text", 231 select_type: "select2", 232 filter_default_label: "Note", 233 filter_match_mode : "exact", 234 filter_reset_button_text: false, 235 select_type_options: { 236 width: "80px", 237 } 238 }, 239 { 240 column_number : 17, 241 filter_type: "range_number", 242 filter_reset_button_text: false, 243 filter_default_label: ["Min", "Max"], 244 select_type_options: { 245 width: "50px", 246 } 247 }, 248 { 249 column_number : 18, 250 filter_type: "text", 251 select_type: "select2", 252 filter_default_label: "Fusion", 253 filter_reset_button_text: false, 254 select_type_options: { 255 width: "100px", 256 } 257 }, 258 { 259 column_number : 19, 260 filter_type: "text", 261 select_type: "select2", 262 filter_default_label: "Antibodies", 263 filter_reset_button_text: false, 264 select_type_options: { 265 width: "100px", 266 } 267 }, 268 { 269 column_number : 20, 270 filter_type: "text", 271 select_type: "select2", 272 html_data_type: "text", 273 filter_default_label: "Ligand name", 274 filter_reset_button_text: false, 275 select_type_options: { 276 width: "100px", 277 } 278 }, 279 { 280 column_number : 21, 281 filter_type: "multi_select", 282 select_type: "select2", 283 html_data_type: "text", 284 filter_default_label: "Ligand type", 285 filter_reset_button_text: false, 286 text_data_delimiter: "<br>", 287 select_type_options: { 288 width: "100px", 289 } 290 }, 291 { 292 column_number : 22, 293 filter_type: "multi_select", 294 select_type: "select2", 295 filter_default_label: "Modality", 296 filter_match_mode : "exact", 297 filter_reset_button_text: false, 298 text_data_delimiter: "<br>", 299 select_type_options: { 300 width: "100px", 301 } 302 }, 303 { 304 column_number : 23, 305 filter_type: "text", 306 select_type: "select2", 307 filter_default_label: "Ligand name", 308 filter_reset_button_text: false, 309 select_type_options: { 310 width: "100px", 311 } 312 }, 313 { 314 column_number : 24, 315 filter_type: "multi_select", 316 select_type: "select2", 317 filter_default_label: "Ligand type", 318 filter_reset_button_text: false, 319 select_type_options: { 320 width: "80px", 321 } 322 }, 323 { 324 column_number : 25, 325 filter_type: "multi_select", 326 select_type: "select2", 327 filter_default_label: "", 328 filter_reset_button_text: false, 329 select_type_options: { 330 width: "40px", 331 } 332 }, 333 { 334 column_number : 26, 335 filter_type: "multi_select", 336 select_type: "select2", 337 filter_default_label: "", 338 filter_reset_button_text: false, 339 select_type_options: { 340 width: "40px", 341 } 342 }, 343 { 344 column_number : 27, 345 filter_type: "text", 346 select_type: "select2", 347 filter_default_label: "Authors", 348 filter_reset_button_text: false, 349 select_type_options: { 350 width: "100px", 351 } 352 }, 353 { 354 column_number : 28, 355 filter_type: "multi_select", 356 select_type: "select2", 357 filter_default_label: "Reference", 358 filter_reset_button_text: false, 359 select_type_options: { 360 width: "140px", 361 } 362 }, 363 { 364 column_number : 29, 365 filter_type: "range_date", 366 filter_reset_button_text: false, 367 date_format: "yyyy-mm-dd", 368 select_type: "select2", 369 filter_default_label: ["Min", "Max"], 370 // filter_reset_button_text: false, 371 }, 372 { 373 column_number : 30, 374 filter_type: "multi_select", 375 select_type: "select2", 376 filter_default_label: "Select", 377 filter_reset_button_text: false, 378 select_type_options: { 379 width: "80px", 380 } 381 } 382 ], 383 { 384 cumulative_filtering: false 385 } 386 ); 387 388 // NOTE: getting the columns correct with DT/YADCF 389 //yadcf.exResetAllFilters(oTable2); // Slowest option 390 //oTable2.draw(); // Bit faster but still slow 391 oTable2.columns.adjust() // Quick and clean 392 393 $("#structures_scrollable > tbody > tr").click(function(event) { 394 if (event.target.type !== "checkbox") { 395 $(":checkbox", this).trigger("click"); 396 $(this).eq(0).toggleClass("alt_selected"); 397 $(this).find("td").toggleClass("highlight"); 398 } 399 $(this).eq(0).toggleClass("alt_selected"); 400 $(this).find("td").toggleClass("highlight"); 401 }); 402 403 $(".select-all").click(function() { 404 $(":checkbox", this).trigger("click"); 405 if ($(this).prop("checked")===true) { 406 $(".alt").prop("checked", true); 407 $(".alt").parent().parent().addClass("alt_selected"); 408 $(".alt").parent().parent().find("td").addClass("highlight"); 409 } 410 if ($(this).prop("checked")===false) { 411 $(".alt").prop("checked", false); 412 $(".alt").parent().parent().removeClass("alt_selected"); 413 $(".alt").parent().parent().find("td").removeClass("highlight"); 414 } 415 }); 416 417 $(".hide_columns").click(function(evt) { 418 var columns = $(this).attr("columns").split(","); 419 columns.forEach(function(column) { 420 var column = oTable2.column( column ); 421 try { 422 column.visible( false, false ); 423 } 424 catch(err) { 425 column.visible( false, false ); 426 } 427 }); 428 oTable2.draw(); 429 } ); 430 431 var toggle_enabled = true; 432 $("#toggle_fixed_btn").click(function() { 433 if (toggle_enabled) { 434 toggle_enabled = false;
435 $("#overlay").hide(); 436 $("#toggle_fixed_btn").attr("value","Enable fixed columns"); 437 $("#toggle_fixed_btn").addClass("clicked_button"); 438 } else { 439 toggle_enabled = true; 440 $(".dataTables_scrollBody").scroll(); 441 $("#toggle_fixed_btn").attr("value","Disable fixed columns"); 442 $("#toggle_fixed_btn").removeClass("clicked_button"); 443 } 444 }); 445 446 $("#toggle_columns_btn").click(function() { 447 var columns = Array.from(new Array(24), (x,i) => i + 6); 448 columns.forEach(function(column) { 449 var column = oTable2.column( column ); 450 try { 451 column.visible( true, false ); 452 } 453 catch(err) { 454 column.visible( true, false ); 455 } 456 }); 457 oTable2.draw(); 458 }); 459 460 $("#representative_btn").click(function () { 461 $(this).toggleClass("toggled"); 462 if ($(this).hasClass("toggled")) { 463 $("#representative_btn").addClass("clicked_button"); 464 $("#representative_btn").attr("value","All structures"); 465 } 466 else { 467 $("#representative_btn").removeClass("clicked_button"); 468 $("#representative_btn").attr("value","Representative structures (state & receptor)"); 469 } 470 oTable2.draw(); 471 }); 472 473 $.fn.dataTable.ext.search.push( 474 function (settings, data, dataIndex) { 475 if ($("#representative_btn").hasClass("toggled")) { 476 if ($(oTable2.row(dataIndex).node()).hasClass("repr-st") && $(oTable2.row(dataIndex).node()).hasClass("repr-st")) { 477 return true; 478 } 479 return false; 480 } 481 else { 482 return true; 483 } 484 }); 485 486 $("#align_btn").click(function () { 487 var checked_data = oTable2.rows(".alt_selected").data(); 488 ClearSelection("targets"); 489 if (checked_data.length === 0) { 490 showAlert("No entries selected for sequence alignment", "danger"); 491 return 0; 492 } 493 for (var i = 0; i < checked_data.length; i++) { 494 var div = document.createElement("div"); 495 div.innerHTML = checked_data[i][7]; 496 if (typeof div.innerText !== "undefined") { 497 AddToSelection("targets", "structure", div.innerText.replace(/\s+/g, "")); 498 } else { 499 AddToSelection("targets", "structure", div.textContent.replace(/\s+/g, "")); 500 } 501 } 502 window.location.href = "/structure/selection_convert"; 503 }); 504 505 $("#superpose_btn").click(function() { 506 superposition(oTable2, [7,1,2,3,4,5,11,29], "structure_browser", "gpcr", 7); 507 }); 508 509 $('#superpose_template_btn').click(function () { 510 direct_superposition(oTable2, "gpcr", 7, "structure"); 511 }); 512 513 $("#download_btn").click(function () { 514 ClearSelection("targets"); 515 var checked_data = oTable2.rows(".alt_selected").data(); 516 if (checked_data.length === 0) { 517 showAlert("No structures selected for download", "danger"); 518 return 0; 519 } 520 else if (checked_data.length > 100) { 521 showAlert("Maximum number of selected entries is 100", "warning"); 522 return 0; 523 } 524 var selected_ids = []; 525 for (var i = 0; i < checked_data.length; i++) { 526 var div = document.createElement("div"); 527 div.innerHTML = checked_data[i][7]; 528 if (typeof div.innerText !== "undefined") { 529 selected_ids.push(div.innerText.replace(/\s+/g, "")); 530 } else { 531 selected_ids.push(div.textContent.replace(/\s+/g, "")); 532 } 533 } 534 AddToSelection("targets", "structure_many", selected_ids.join(",")); 535 536 window.location.href = "/structure/pdb_download"; 537 }); 538 539 $(".uniprot-export").data("powertipjq", $([ 540 "<p>Export UniProt IDs</p>" 541 ].join("\n"))); 542 $(".pdb-export").data("powertipjq", $([ 543 "<p>Export PDB IDs</p>" 544 ].join("\n"))); 545 $(".glyphicon-export").powerTip({ 546 placement: "n", 547 smartPlacement: true 548 }); 549 $("#uniprot_copy").click(function () { 550 copyToClipboard($(".alt_selected > .uniprot > a"), "\n", "UniProt IDs", $(".uniprot-export")); 551 }); 552 $("#pdb_copy").click(function () { 553 copyToClipboard($(".alt_selected > .pdb > a"), "\n", "PDB IDs", $(".pdb-export")); 554 }); 555 556 $("#reset_filters_btn").click(function () {
557 window.location.href = "/structure/"; 558 }); 559 560 $(".dataTables_scrollBody").append("<div id=overlay><table id='overlay_table' class='row-border text-center compact dataTable no-footer text-nowrap'><tbody></tbody></table></div>"); 561 562 function create_overlay() { 563 // This function fires upon filtering, to update what rows to show as an overlay 564 $("#overlay_table tbody tr").remove(); 565 var $target = $("#overlay_table tbody"); 566 $("#structures_scrollable tbody tr").each(function() { 567 var $tds = $(this).children(), 568 $row = $("<tr></tr>"); 569 // $row.append($tds.eq(0).clone()).append($tds.eq(1).clone()).appendTo($target); 570 $row.append($tds.eq(1).clone()).append($tds.eq(2).clone()).appendTo($target); 571 $row.height($(this).height()); 572 }); 573 $("#overlay_table .border-right").removeClass("border-right"); 574 } 575 576 // Function that detects filtering events 577 $("#structures_scrollable").on( "draw.dt", function (e,oSettings) { 578 create_overlay(); 579 }); 580 581 create_overlay(); 582 $("#overlay").hide(); 583 584 var left = 0; 585 var old_left = 0; 586 $(".dataTables_scrollBody").scroll(function(){ 587 // If user scrolls and it"s >100px from left, then attach fixed columns overlay 588 left = $(".dataTables_scrollBody").scrollLeft(); 589 if (left !== old_left) { 590 $("#overlay").hide(); 591 } 592 old_left = left; 593 594 if (left>100 && toggle_enabled) { 595 $("#overlay").css({ left: left+"px" }); 596 if ($("#overlay").is(":hidden")) { 597 $("#overlay").show(); 598 } 599 } 600 }); 601}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.