Commit fecd609e authored by Jerome Mariette's avatar Jerome Mariette
Browse files

make phylogenie browsing a tree

parent af5e02e5
...@@ -63,6 +63,9 @@ class tx_nG6_pi1 extends tslib_pibase { ...@@ -63,6 +63,9 @@ class tx_nG6_pi1 extends tslib_pibase {
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] = ' $GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] = '
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.js"></script> <script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.core.min.js"></script> <script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.cookie.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.hotkeys.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.jstree.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.dialog.min.js"></script> <script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.dialog.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.draggable.min.js"></script> <script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.draggable.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.resizable.min.js"></script> <script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.resizable.min.js"></script>
......
...@@ -334,7 +334,7 @@ ...@@ -334,7 +334,7 @@
<label index="MothurClassifyAnalyse_click_to_return">Click to return to first graph</label> <label index="MothurClassifyAnalyse_click_to_return">Click to return to first graph</label>
<label index="MothurClassifyAnalyse_bar_title">Taxonomic affiliation against ###DB_NAME### database.</label> <label index="MothurClassifyAnalyse_bar_title">Taxonomic affiliation against ###DB_NAME### database.</label>
<label index="MothurClassifyAnalyse_navigation_txt">Display sequences distribution for </label> <label index="MothurClassifyAnalyse_navigation_txt">Display sequences distribution for </label>
<label index="MothurClassifyAnalyse_all">all</label> <label index="MothurClassifyAnalyse_all">All</label>
</languageKey> </languageKey>
<languageKey index="fr" type="array"> <languageKey index="fr" type="array">
...@@ -665,7 +665,7 @@ ...@@ -665,7 +665,7 @@
<label index="MothurClassifyAnalyse_click_to_return">Cliquez pour revenir au premier graphique</label> <label index="MothurClassifyAnalyse_click_to_return">Cliquez pour revenir au premier graphique</label>
<label index="MothurClassifyAnalyse_bar_title">Affiliation taxonomic contre la banque ###DB_NAME###.</label> <label index="MothurClassifyAnalyse_bar_title">Affiliation taxonomic contre la banque ###DB_NAME###.</label>
<label index="MothurClassifyAnalyse_navigation_txt">Afficher la distribution des séquences pour </label> <label index="MothurClassifyAnalyse_navigation_txt">Afficher la distribution des séquences pour </label>
<label index="MothurClassifyAnalyse_all">tout</label> <label index="MothurClassifyAnalyse_all">Tout</label>
</languageKey> </languageKey>
</data> </data>
......
...@@ -99,7 +99,12 @@ html:not([lang*=""]) button.btn { ...@@ -99,7 +99,12 @@ html:not([lang*=""]) button.btn {
border-top:1px solid #bbb; border-top:1px solid #bbb;
border-bottom:1px solid #aaa; border-bottom:1px solid #aaa;
} }
#navigation_container {
float: left; width: 280px;
}
#highcharts_container{
width: 900px;
}
/* pill classes only needed if using pill style buttons ( LEFT | CENTER | RIGHT ) */ /* pill classes only needed if using pill style buttons ( LEFT | CENTER | RIGHT ) */
button.pill-l span { button.pill-l span {
border-right-width:0; border-right-width:0;
......
...@@ -384,101 +384,70 @@ $(function () { ...@@ -384,101 +384,70 @@ $(function () {
}); });
} }
function updateNavigation(rankid) {
var ajax = new Array();
var samples = new Array();
$(":checked[id^=chk_sample_]").each(function(){
var index = $(this).attr("id").split("_")[2];
ajax.push($.ajax($("#phylogeny_file_"+index).val()));
samples.push($("#phylogeny_file_"+index).val());
});
$.when.apply($, ajax).done(function(){
// for each taxonomy files
var tax_table = new Array();
var tax_values = new Array();
var taxlevel = rankid.split(".");
for (var i=1; i<taxlevel.length;i++) {
var val = "";
for (j=0; j<=i; j++){
if (j!=i) {
val += taxlevel[j] + ".";
} else {
val += taxlevel[j];
}
}
tax_values.push(val);
tax_table[val] = new Array();
}
tax_table["all"] = new Array();
for( var i = 0; i < arguments.length; i++ ) {
var lines = arguments[i][0].split("\n");
var found = false;
var rank = "";
for (j=0; j<lines.length; j++) {
if (lines[j] != "") {
parts = lines[j].split("\t");
var tax_value = parts[1].split(".");
for (k=0; k<tax_values.length; k++) {
var tax_start = tax_values[k].split(".").slice(0,-1).join(".") + ".";
if (parts[1].indexOf(tax_start) === 0 && tax_value.length == tax_values[k].split(".").length) {
if (!(parts[1] in tax_table[tax_values[k]])) {
tax_table[tax_values[k]][parts[1]] = parts[2];
}
}
}
// Find the child to make the all list child
if (found) {
if (parseInt(rank)+1 == parseInt(parts[0])) {
tax_table["all"][parts[1]] = parts[2];
} else if (parseInt(rank) == parseInt(parts[0])) {
found = false;
}
}
if (parts[1] == rankid){
rank = parts[0];
found = true;
}
}
}
}
var html_val = $("#navigation_txt").val();
for (tax_val in tax_table) {
if (tax_val != "all") {
html_val += "<select class='taxonomy_select'>";
var parent_tax_val = tax_val.split(".").slice(0,-1).join(".");
html_val += '<option value="'+parent_tax_val+'">'+$("#all_value").val()+'</option>';
for (option_val in tax_table[tax_val]) {
if (tax_val == option_val) {
html_val += '<option selected value="'+option_val+'">'+tax_table[tax_val][option_val].replace(/"/g, '')+'</option>';
} else {
html_val += '<option value="'+option_val+'">'+tax_table[tax_val][option_val].replace(/"/g, '')+'</option>';
}
}
html_val += "</select>";
}
}
html_val += "<select class='taxonomy_select'>";
html_val += '<option selected value="'+rankid+'">'+$("#all_value").val()+'</option>';
for (option_val in tax_table["all"]) {
html_val += '<option value="'+option_val+'">'+tax_table[tax_val][option_val].replace(/"/g, '')+'</option>';
}
html_val += "</select>";
$("#navigation_container").html(html_val);
$(".taxonomy_select").change(function(){
if ($(this).val().split(".").length < 9) {
updateNavigation($(this).val());
}
updateChart($(this).val());
});
});
}
$("#img_dialog").dialog("option", "title", "nG6 - " + $("#analyse_name").val()); $("#img_dialog").dialog("option", "title", "nG6 - " + $("#analyse_name").val());
$("#img_dialog").dialog("option", "width", 1200);
$("#img_dialog").html('<div id="navigation_container"></div><div id="highcharts_container"></div>').dialog("open"); $("#img_dialog").html('<div id="navigation_container"></div><div id="highcharts_container"></div>').dialog("open");
var ajax = new Array();
var samples = new Array();
$(":checked[id^=chk_sample_]").each(function(){
var index = $(this).attr("id").split("_")[2];
ajax.push($.ajax($("#phylogeny_file_"+index).val()));
samples.push($("#phylogeny_file_"+index).val());
});
// Init the navigation
$.when.apply($, ajax).done(function(){
$("#navigation_container").html('<p>'+$("#navigation_txt").val() + ':</p><div class="underline"> </div><br /><div id="jstree_navigation"></div>');
var html_data = "";
var current_level = -1;
for( var i = 0; i < arguments.length-1; i++ ) {
var lines = arguments[i][0].split("\n");
for (j=0; j<lines.length; j++) {
if (lines[j] != "") {
parts = lines[j].split("\t");
if (parts[0] != "taxlevel") {
if (current_level < parseInt(parts[0])) {
html_data += '<ul>';
html_data += '<li><a class="taxonomy_click" id="'+parts[1]+'" href="#">' + parts[2].replace("Root", $("#all_value").val()) +"</a>";
} else if(current_level == parseInt(parts[0])) {
html_data += '</li><li><a class="taxonomy_click" id="'+parts[1]+'" href="#">' + parts[2] + '</a></li>';
} else if (current_level > parseInt(parts[0])) {
for (var t=0; t<current_level-parseInt(parts[0]); t++){
html_data += '</ul></li>';
}
html_data += '<li><a class="taxonomy_click" id="'+parts[1]+'" href="#">' + parts[2] + '</a>';
}
current_level = parseInt(parts[0]);
}
}
}
}
for (var t=0; t<current_level; t++){
html_data += '</li></ul>';
}
$("#jstree_navigation").jstree({
"themes" : {
"theme" : "default",
"icons" : false
},
"ui" : {
"select_limit" : 1,
"selected_parent_close" : "select_parent",
"initially_select" : [ "0" ]
},
"html_data" : {
"data" : html_data
},
"plugins" : [ "themes", "html_data", "ui" ]
});
$("a.taxonomy_click").click(function(){
updateChart($(this).attr("id"));
});
});
// Init the chart
updateChart("0"); updateChart("0");
updateNavigation("0");
} }
}); });
function get_categories(lines, depth) { function get_categories(lines, depth) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment