Skip to content

Commit

Permalink
updated to latest code
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredwilkening committed Jun 5, 2012
1 parent cac7f92 commit 1cb8a99
Show file tree
Hide file tree
Showing 85 changed files with 23,871 additions and 3,772 deletions.
206 changes: 9 additions & 197 deletions src/MGRAST/Analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,6 @@ function abu(t, id, md5columnindex, source) {
}

function generate_krona_data (depth, table_id, func_or_org) {
//var data = '<magnitude attribute="magnitude"><\/magnitude><attributes rank="Rank" score="Avg. log e-value" magnitude="Abundance"><\/attributes><datasets names="'+dataset_name+'"><\/datasets><color valueend="4" valuestart="-157" hueend="0" huestart="120" attribute="score"><\/color>';

var data_index;
for (i=0;i<table_list.length;i++) {
if (table_id == table_list[i]) {
Expand Down Expand Up @@ -525,204 +523,18 @@ function generate_krona_data (depth, table_id, func_or_org) {
}
}

generate_krona(krona_data, hierarchy, 1);
// cut out data below defined depth
depth = parseInt(depth);
hierarchy = hierarchy.slice(0,depth+1);
for (var i=0;i<krona_data.length;i++) {
var beg = krona_data[i].slice(0, depth + 2);
var nums = krona_data[i].slice(krona_data[i].length-2);
krona_data[i] = beg.concat(nums);
}

// var nodes = [];
// var all = [];
// var dataset_names = dataset_name.split(",");
// var dataset_hash = [];
// for (i=0;i<dataset_names.length;i++) {
// dataset_hash[dataset_names[i]] = i;
// all[i] = 0;
// }

// for (i=0; i<table_filtered_data[data_index].length; i++) {
// var curr_abundance = parseFloat(table_filtered_data[data_index][i][10].replace(/<[^>]+>/g, ""));
// var curr_evalue = parseFloat(table_filtered_data[data_index][i][12]);
// var curr_mg = table_filtered_data[data_index][i][0];
// all[dataset_hash[curr_mg]] += curr_abundance;
// krona_recursive(table_filtered_data[data_index][i], nodes, 0, depth + 1, curr_abundance, curr_evalue, curr_mg);
// }

// data += "<node score='1' magnitude='"+all.join(",")+"' name='all'>";
// for (a in nodes) {
// var sc = "";
// var mag = "";
// for (m=0;m<dataset_names.length;m++) {
// if (nodes[a][dataset_names[m]]) {
// sc += nodes[a][dataset_names[m]][1]+",";
// mag += nodes[a][dataset_names[m]][0]+",";
// } else {
// sc += "0,";
// mag += "0,";
// }
// }
// sc = sc.slice(0,sc.length-1);
// mag = mag.slice(0,mag.length-1);
// data += "<node rank='Domain' score='"+sc+"' magnitude='"+mag+"' name='"+a+"'>";
// if (depth > 0) {
// for (b in nodes[a]['children']) {
// sc = "";
// mag = "";
// for (m=0;m<dataset_names.length;m++) {
// if (nodes[a]['children'][b][dataset_names[m]]) {
// sc += nodes[a]['children'][b][dataset_names[m]][1]+",";
// mag += nodes[a]['children'][b][dataset_names[m]][0]+",";
// } else {
// sc += "0,";
// mag += "0,";
// }
// }
// sc = sc.slice(0,sc.length-1);
// mag = mag.slice(0,mag.length-1);
// data += "<node rank='Phylum' score='"+sc+"' magnitude='"+mag+"' name='"+b+"'>";
// if (depth > 1) {
// for (c in nodes[a]['children'][b]['children']) {
// sc = "";
// mag = "";
// for (m=0;m<dataset_names.length;m++) {
// if (nodes[a]['children'][b]['children'][c][dataset_names[m]]) {
// sc += nodes[a]['children'][b]['children'][c][dataset_names[m]][1]+",";
// mag += nodes[a]['children'][b]['children'][c][dataset_names[m]][0]+",";
// } else {
// sc += "0,";
// mag += "0,";
// }
// }
// sc = sc.slice(0,sc.length-1);
// mag = mag.slice(0,mag.length-1);
// data += "<node rank='Class' score='"+sc+"' magnitude='"+mag+"' name='"+c+"'>";
// if (depth > 2) {
// for (d in nodes[a]['children'][b]['children'][c]['children']) {
// sc = "";
// mag = "";
// for (m=0;m<dataset_names.length;m++) {
// if (nodes[a]['children'][b]['children'][c]['children'][d][dataset_names[m]]) {
// sc += nodes[a]['children'][b]['children'][c]['children'][d][dataset_names[m]][1]+",";
// mag += nodes[a]['children'][b]['children'][c]['children'][d][dataset_names[m]][0]+",";
// } else {
// sc += "0,";
// mag += "0,";
// }
// }
// sc = sc.slice(0,sc.length-1);
// mag = mag.slice(0,mag.length-1);
// data += "<node rank='Order' score='"+sc+"' magnitude='"+mag+"' name='"+d+"'>";
// if (depth > 3) {
// for (e in nodes[a]['children'][b]['children'][c]['children'][d]['children']) {
// sc = "";
// mag = "";
// for (m=0;m<dataset_names.length;m++) {
// if (nodes[a]['children'][b]['children'][c]['children'][d]['children'][e][dataset_names[m]]) {
// sc += nodes[a]['children'][b]['children'][c]['children'][d]['children'][e][dataset_names[m]][1]+",";
// mag += nodes[a]['children'][b]['children'][c]['children'][d]['children'][e][dataset_names[m]][0]+",";
// } else {
// sc += "0,";
// mag += "0,";
// }
// }
// sc = sc.slice(0,sc.length-1);
// mag = mag.slice(0,mag.length-1);
// data += "<node rank='Family' score='"+sc+"' magnitude='"+mag+"' name='"+e+"'>";
// if (depth > 4) {
// for (f in nodes[a]['children'][b]['children'][c]['children'][d]['children'][e]['children']) {
// sc = "";
// mag = "";
// for (m=0;m<dataset_names.length;m++) {
// if (nodes[a]['children'][b]['children'][c]['children'][d]['children'][e]['children'][f][dataset_names[m]]) {
// sc += nodes[a]['children'][b]['children'][c]['children'][d]['children'][e]['children'][f][dataset_names[m]][1]+",";
// mag += nodes[a]['children'][b]['children'][c]['children'][d]['children'][e]['children'][f][dataset_names[m]][0]+",";
// } else {
// sc += "0,";
// mag += "0,";
// }
// }
// sc = sc.slice(0,sc.length-1);
// mag = mag.slice(0,mag.length-1);
// data += "<node rank='Genus' score='"+sc+"' magnitude='"+mag+"' name='"+f+"'>";
// if (depth > 5) {
// for (g in nodes[a]['children'][b]['children'][c]['children'][d]['children'][e]['children'][f]['children']) {
// sc = "";
// mag = "";
// for (m=0;m<dataset_names.length;m++) {
// if (nodes[a]['children'][b]['children'][c]['children'][d]['children'][e]['children'][f]['children'][g][dataset_names[m]]) {
// sc += nodes[a]['children'][b]['children'][c]['children'][d]['children'][e]['children'][f]['children'][g][dataset_names[m]][1]+",";
// mag += nodes[a]['children'][b]['children'][c]['children'][d]['children'][e]['children'][f]['children'][g][dataset_names[m]][0]+",";
// } else {
// sc += "0,";
// mag += "0,";
// }
// }
// sc = sc.slice(0,sc.length-1);
// mag = mag.slice(0,mag.length-1);
// data += "<node rank='Species' score='"+sc+"' magnitude='"+mag+"' name='"+g+"'>";
// if (depth > 6) {
// for (h in nodes[a]['children'][b]['children'][c]['children'][d]['children'][e]['children'][f]['children'][g]['children']) {
// sc = "";
// mag = "";
// for (m=0;m<dataset_names.length;m++) {
// if (nodes[a]['children'][b]['children'][c]['children'][d]['children'][e]['children'][f]['children'][g]['children'][h][dataset_names[m]]) {
// sc += nodes[a]['children'][b]['children'][c]['children'][d]['children'][e]['children'][f]['children'][g]['children'][h][dataset_names[m]][1]+",";
// mag += nodes[a]['children'][b]['children'][c]['children'][d]['children'][e]['children'][f]['children'][g]['children'][h][dataset_names[m]][0]+",";
// } else {
// sc += "0,";
// mag += "0,";
// }
// }
// sc = sc.slice(0,sc.length-1);
// mag = mag.slice(0,mag.length-1);
// data += "<node rank='Strain' score='"+sc+"' magnitude='"+mag+"' name='"+h+"'></node>";
// data += "<\/node>";

// }
// }
// data += "<\/node>";
// }
// }
// data += "<\/node>";
// }
// }
// data += "<\/node>";
// }
// }
// data += "<\/node>";
// }
// }
// data += "<\/node>";
// }
// }
// data += "<\/node>";
// }
// }
// data += "<\/node>";
// }
// data += "<\/node>";

// var krona_window = window.open('','krona_window_'+dataset_name);
// krona_window.document.write('<html><head><meta charset="utf-8"\/><style>body { margin:0; }<\/style><title>MG-RAST - Krona view of Metagenome '+dataset_name+'<\/title><link rel="icon" type="image/png" href="./Html/favicon.ico"><\/head><body style="padding:0;position:relative"><a href="?page=Home" style="border: none; background-color:black; position: absolute; bottom: 8px;"><img style="height: 66px; border: none;" src="./Html/MGRAST_logo.png" alt="MG-RAST Metagenomics Analysis Server" \/><\/a><a href="http://sourceforge.net/p/krona/home/krona/" target=_blank style="position: absolute; bottom: 8px; border: none; text-decoration: none; color: black; left: 260px;"><img src="./Html/krona.png" style="border: none;"> powered by Krona<\/a><div id="options" style="position:absolute;left:0;top:100px"><\/div><div id="details" style="position:absolute;top:1px;right:2px;text-align:right;"><\/div><canvas id="canvas" width="100%" height="100%"><\/canvas><img id="hiddenImage" visibility="hide" src="http://krona.sourceforge.net/img/hidden.png"><script name="tree" src="./Html/krona-1.1.js"><\/script><data>'+data+'<\/data><img src="./Html/clear.gif" onload="load()"><\/body><\/html>');
// krona_window.document.close();
generate_krona(krona_data, hierarchy, 1);
}

// function krona_recursive (tdata, parentNode, depth, maxDepth, curr_abundance, curr_evalue, curr_mg) {
// if (! parentNode[tdata[depth + 2]]) {
// parentNode[tdata[depth + 2]] = [];
// parentNode[tdata[depth + 2]]['children'] = [];
// }
// if (! parentNode[tdata[depth + 2]][curr_mg]) {
// parentNode[tdata[depth + 2]][curr_mg] = [ curr_abundance, curr_evalue, 1 ];
// } else {
// parentNode[tdata[depth + 2]][curr_mg][0] += curr_abundance;
// parentNode[tdata[depth + 2]][curr_mg][1] = ((parentNode[tdata[depth + 2]][curr_mg][1] * parentNode[tdata[depth + 2]][curr_mg][2]) + curr_evalue) / (parentNode[tdata[depth + 2]][curr_mg][2] + 1);
// parentNode[tdata[depth + 2]][curr_mg][2]++;
// }
// depth++;
// if (depth < maxDepth) {
// krona_recursive(tdata, parentNode[tdata[depth + 1]]['children'], depth, maxDepth, curr_abundance, curr_evalue, curr_mg);
// }
// depth--;
// return;
// }

function transpose_table (table_id, transpose_column, displayed_columns, data_column, target_div) {
// variable to store the table html in
var table_html = "";
Expand Down
Loading

0 comments on commit 1cb8a99

Please sign in to comment.