annotate script.js @ 5:bcf1469e8feb draft

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