Lukas Adam (Talk | contribs) |
Lukas Adam (Talk | contribs) |
||
Line 59: | Line 59: | ||
} | } | ||
− | if (functionality_safety[j] | + | if (functionality_safety[j] && k == 3) { |
td_body.style.backgroundColor = 'red'; | td_body.style.backgroundColor = 'red'; | ||
− | } else if (functionality_safety[j] | + | } else if (!functionality_safety[j] && k == 3) { |
td_body.style.backgroundColor = 'green'; | td_body.style.backgroundColor = 'green'; | ||
} else { | } else { | ||
Line 94: | Line 94: | ||
for (idx = 0; idx < nhits; ++idx) { | for (idx = 0; idx < nhits; ++idx) { | ||
console.log("ORGANISMS: ", result.organisms[idx][1]); | console.log("ORGANISMS: ", result.organisms[idx][1]); | ||
− | name.push(result. | + | name.push(result.hits[idx].name); |
organism.push(result.matches[idx]); | organism.push(result.matches[idx]); | ||
organism_safety.push(result.organisms[idx][1]); | organism_safety.push(result.organisms[idx][1]); | ||
functionality.push(result.functions[idx]); | functionality.push(result.functions[idx]); | ||
− | functionality_safety.push(result. | + | functionality_safety.push(result.functionality_safety[idx]); |
id.push(result.hits[idx].id); | id.push(result.hits[idx].id); | ||
identity.push(result.hits[idx].identity); | identity.push(result.hits[idx].identity); | ||
Line 124: | Line 124: | ||
for (idx = 0; idx < nhits; ++idx) { | for (idx = 0; idx < nhits; ++idx) { | ||
console.log("ORGANISMS: ", result.organisms[idx][1]); | console.log("ORGANISMS: ", result.organisms[idx][1]); | ||
− | name.push(result. | + | name.push(result.hits[idx].name); |
organism.push(result.matches[idx]); | organism.push(result.matches[idx]); | ||
organism_safety.push(result.organisms[idx][1]); | organism_safety.push(result.organisms[idx][1]); | ||
functionality.push(result.functions[idx]); | functionality.push(result.functions[idx]); | ||
− | functionality_safety.push(result. | + | functionality_safety.push(result.functionality_safety[idx]); |
id.push(result.hits[idx].id); | id.push(result.hits[idx].id); | ||
identity.push(result.hits[idx].identity); | identity.push(result.hits[idx].identity); | ||
Line 139: | Line 139: | ||
}); | }); | ||
} | } | ||
+ | |||
+ | register_handlers(); |
Revision as of 06:27, 1 November 2017
function createTable(name, organism, organism_safety, functionality,
functionality_safety, id, identity, e_value, onkogenes) {
var table_head = [ 'Name', 'Organism', 'Group', 'Functionality', 'ID', 'Identity', 'E-Value', 'Onkogenicity' ];
var div = document.getElementById('safety_table'); var table = document.createElement('table'); var thead = document.createElement('thead'); var tbody = document.createElement('tbody');
var tr_head = document.createElement('tr'); for (var i = 0; i < 8; i++) { var td_head = document.createElement('th'); td_head.append(document.createTextNode(table_head[i])); tr_head.appendChild(td_head); } thead.appendChild(tr_head);
for (var j = 0; j < organism.length; j++) { var table_body = [];
table_body[0] = name[j]; table_body[1] = organism[j]; table_body[2] = "S" + organism_safety[j].toString(); table_body[3] = functionality[j];
table_body[4] = id[j]; table_body[5] = identity[j]; table_body[6] = e_value[j]; table_body[7] = onkogenes[j];
var tr_body = document.createElement('tr'); for (var k = 0; k < 8; k++) { var td_body = document.createElement('td');
if (k == 3) {
var inner_func = table_body[k].split(','); for (var w = 0; w < functionality[j].split(',').length; w++) { var tr_inner = document.createElement('tr'); var td_inner = document.createElement('td'); td_inner.append(document.createTextNode(inner_func[w])); tr_inner.appendChild(td_inner); td_body.appendChild(tr_inner); }
} else { td_body.append(document.createTextNode(table_body[k])); if (organism_safety[j] > 1 && k == 2) { td_body.style.backgroundColor = 'red'; } else if (organism_safety[j] <= 1 && k == 2) { td_body.style.backgroundColor = 'green'; } else { // Nothing } }
if (functionality_safety[j] && k == 3) { td_body.style.backgroundColor = 'red'; } else if (!functionality_safety[j] && k == 3) { td_body.style.backgroundColor = 'green'; } else { // Nothing } tr_body.appendChild(td_body); } tbody.appendChild(tr_body); }
table.appendChild(thead); table.appendChild(tbody); table.className = "table table-bordered mdl-shadow--4dp"; div.appendChild(table);
}
function register_handlers() {
$("#hyperreference1").one("click", function() { sequence = $("#push_sequence")[0].value; doSafetyQuery(sequence).then(function(result) { console.log(result); let nhits = result.hits.length; var name = []; var organism = []; var organism_safety = []; var functionality = []; var functionality_safety = []; var id = []; var identity = []; var e_value = []; var onkogenes = []; for (idx = 0; idx < nhits; ++idx) { console.log("ORGANISMS: ", result.organisms[idx][1]); name.push(result.hits[idx].name); organism.push(result.matches[idx]); organism_safety.push(result.organisms[idx][1]); functionality.push(result.functions[idx]); functionality_safety.push(result.functionality_safety[idx]); id.push(result.hits[idx].id); identity.push(result.hits[idx].identity); e_value.push(result.hits[idx].evalue); onkogenes.push(result.onkogenes[idx]); } createTable(name, organism, organism_safety, functionality, functionality_safety, id, identity, e_value, onkogenes); }); }); $("#hyperreference2").one("click", function() { rid = $("#get_sequence")[0].value; doSafetyQueryWithRID(rid).then(function(result) { console.log(result); let nhits = result.hits.length; var name = []; var organism = []; var organism_safety = []; var functionality = []; var functionality_safety = []; var id = []; var identity = []; var e_value = []; var onkogenes = []; for (idx = 0; idx < nhits; ++idx) { console.log("ORGANISMS: ", result.organisms[idx][1]); name.push(result.hits[idx].name); organism.push(result.matches[idx]); organism_safety.push(result.organisms[idx][1]); functionality.push(result.functions[idx]); functionality_safety.push(result.functionality_safety[idx]); id.push(result.hits[idx].id); identity.push(result.hits[idx].identity); e_value.push(result.hits[idx].evalue); onkogenes.push(result.onkogenes[idx]); } createTable(name, organism, organism_safety, functionality, functionality_safety, id, identity, e_value, onkogenes); }); });
}
register_handlers();