From 8b7e3fc4eb8f942c2e70543fa42594f5c094c925 Mon Sep 17 00:00:00 2001 From: Gopi Gugan Date: Tue, 11 Oct 2022 12:49:16 -0400 Subject: [PATCH 1/2] Restore search, display recombinants during search --- js/covizu.js | 5 +++-- js/drawtree.js | 2 +- js/search.js | 5 +++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/js/covizu.js b/js/covizu.js index 68b4129..6784c89 100644 --- a/js/covizu.js +++ b/js/covizu.js @@ -195,8 +195,9 @@ req.done(async function() { curr_date.setFullYear(curr_date.getFullYear() - 1); // Maps id to a cidx - for (i in tips) { - id_to_cidx[i] = 'cidx-' + tips[i].cluster_idx + var all_tips = [...recombinant_tips, ...tips] + for (i in all_tips) { + id_to_cidx[i] = 'cidx-' + all_tips[i].cluster_idx } // Maps cidx to an id diff --git a/js/drawtree.js b/js/drawtree.js index 19fa696..64d5d24 100644 --- a/js/drawtree.js +++ b/js/drawtree.js @@ -319,7 +319,7 @@ function draw_clusters(tips, recombinant_tips, redraw=false) { .attr("height", 10) .attr("class", "default recombinant") .attr("cidx", function(d) { return "cidx-" + d.cluster_idx; }) - .attr("id", function(d, i) { return "id-" + i; }) + .attr("id", function(d, i) { return "id-" + map_cidx_to_id['cidx-' + d.cluster_idx]; }) .on('mouseover', mouseover) .on("mouseout", function() { d3.select(this) diff --git a/js/search.js b/js/search.js index 0bb080b..1f62cbc 100644 --- a/js/search.js +++ b/js/search.js @@ -73,6 +73,11 @@ async function wrap_search() { return; } + // Display recombinants when doing a search + $('#display-option').attr('checked', 'checked'); + $(".recombinant-tree-content").show() + $(".recombtitle").show() + var start_date, end_date; if (start_date_text === "") { start_date = utcDate("2020-01-01"); From 80a16f788cee0d0b36c38d6e9d761c0e60fad25d Mon Sep 17 00:00:00 2001 From: bonnielu Date: Tue, 11 Oct 2022 14:29:57 -0400 Subject: [PATCH 2/2] fix for #428 --- js/drawtree.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/drawtree.js b/js/drawtree.js index 64d5d24..1c38172 100644 --- a/js/drawtree.js +++ b/js/drawtree.js @@ -106,7 +106,7 @@ function draw_cluster_box(rect) { * Draw time-scaled tree in SVG * @param {Array} df: data frame */ -function drawtree(df, redraw=true) { +function drawtree(df, org_df, redraw=true) { // Sets margin top to align vertical scrollbar with the time-scaled tree $('#tree-vscroll').css('margin-top', document.getElementById("tree-title").clientHeight + document.getElementById("svg-timetreeaxis").clientHeight + $('#inner-hscroll').height() + 5); @@ -123,8 +123,8 @@ function drawtree(df, redraw=true) { // adjust d3 scales to data frame if(!redraw) { xScale.domain([ - d3.min(df, xValue)-0.05, - date_to_xaxis(d3.max(df, function(d) {return d.last_date})) + d3.min(org_df, xValue)-0.05, + date_to_xaxis(d3.max(org_df, function(d) {return d.last_date})) ]); } @@ -885,7 +885,7 @@ async function redraw_tree(cutoff_date, redraw=true) { document.querySelector("#svg-timetree > svg").innerHTML = ''; document.querySelector("#svg-recombinants > svg").innerHTML = ''; - drawtree(final_df, redraw=redraw); + drawtree(final_df, df_copy, redraw=redraw); draw_clusters(filtered_tips, filtered_recomb_tips, redraw); if(redraw) {