comparison script.js @ 0:ed6885c85660 draft

Uploaded
author davidvanzessen
date Wed, 31 Aug 2016 05:31:47 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:ed6885c85660
1 function tsvToTable(data){
2 var lines = data.split("\n");
3 var tbl = document.createElement('table');
4 tbl.className = "result_table";
5 tbl.border="1"
6 var thead = document.createElement('thead');
7 var tr = document.createElement('tr');
8 tr.className = "evenrowcolor";
9 var cells = lines[0].split("\t");
10 var cdr3column = [];
11 for(var a = 0;a < cells.length;++a){
12 if(cells[a] == "CDR3 Sequence" || cells[a] == "CDR3_Sense_Sequence" || cells[a] == "Clone Sequence"){
13 cdr3column.push(a);
14 }
15 var td = document.createElement('td');
16 td.appendChild(document.createTextNode(cells[a]));
17 tr.appendChild(td);
18 }
19 thead.appendChild(tr);
20 tbl.appendChild(thead);
21 var tbdy = document.createElement('tbody');
22
23 for(var a = 1;a < lines.length;++a){
24 tr = document.createElement('tr');
25 var cells = lines[a].split("\t");
26 if(cells.length == 1){
27 continue;
28 }
29 for(var b = 0;b < cells.length;++b){
30 td = document.createElement('td');
31 td.appendChild(document.createTextNode(cells[b]));
32 if(cdr3column.indexOf(b) != -1){
33 td.className = td.className + " cdr3sequence"
34 }
35 tr.appendChild(td)
36 }
37
38 if(a % 2 == 0){
39 tr.className = "evenrowcolor";
40 } else {
41 tr.className = "oddrowcolor";
42 }
43
44 tbdy.appendChild(tr);
45 }
46 tbl.appendChild(tbdy);
47 return tbl;
48 }
49
50 function loadfile(file, patient, type){
51 patient = patient.replace(".", "\\.");
52 $('#hidden_div').load(file, function(){
53 $('#result_div_' + patient + '_' + type).html(tsvToTable($('#hidden_div').html()));
54 $('#result_div_' + patient + '_' + type + ' tr').hover(function() {
55 $(this).addClass('hover');
56 }, function() {
57 $(this).removeClass('hover');
58 });
59 $('#result_div_' + patient + '_' + type + ' table').addClass('result_table');
60 //$('#result_div_' + patient + ' tr:odd').addClass("oddrowcolor");
61 //$('#result_div_' + patient + ' tr:even').addClass("evenrowcolor");
62 $('#result_div_' + patient + '_' + type + ' table').before( "<a href='" + file + "'>Download " + file.replace(".txt", "") + "</a>" );
63 });
64 }
65
66 var currentTD = new Array();
67
68 $( document ).ready(function() {
69 $('.summary_table tr').hover(function() {
70 $(this).addClass('hover');
71 }, function() {
72 $(this).removeClass('hover');
73 });
74
75 $('.summary_table tr:odd').addClass("oddrowcolor");
76 $('.summary_table tr:even').addClass("evenrowcolor");
77
78 $('.summary_table td[data-patient]').click(function() {
79 var tmp = $(this);
80 if(currentTD[tmp.attr("data-patient")] != null){
81 currentTD[tmp.attr("data-patient")].removeClass("clicked_summary");
82 }
83 currentTD[tmp.attr("data-patient")] = tmp;
84 currentTD[tmp.attr("data-patient")].addClass("clicked_summary");
85 });
86 });