Skip to content

Commit 3e83ce7

Browse files
committed
Fix beadplot not shown when clicking a cluster after an accn search PoonLab#134
1 parent 4e51cdf commit 3e83ce7

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

js/drawtree.js

+13
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ function create_clusterH(obj, obj_2) {
5252
.raise();
5353
}
5454

55+
/**
56+
* Returns true if the string is an accession number
57+
*/
58+
function is_accn(string) {
59+
const accn_pat = /^EPI_ISL_[0-9]+$/i; // case-insensitive
60+
return accn_pat.test(string);
61+
}
62+
5563
/**
5664
* Rectangular layout of tree, update nodes in place with x,y coordinates
5765
* @param {object} root
@@ -275,6 +283,11 @@ function draw_clusters(tips) {
275283
d3.selectAll("rect.clickedH").remove();
276284

277285
beadplot(d.cluster_idx);
286+
287+
if (is_accn($('#search-input').val())) {
288+
$('#search-input').val('');
289+
}
290+
278291
search(beaddata);
279292

280293
// reset all rectangles to high transparency

js/search.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function select_bead_by_accession(accn, reset_clusters_tree = true) {
151151
if (reset_clusters_tree === true) {
152152
d3.selectAll("#svg-timetree > svg > g > rect:not(.clickedH)").attr("class", "not_SelectedCluster");
153153
}
154-
154+
155155
var rect = d3.selectAll("#svg-timetree > svg > g > rect:not(.clickedH)")
156156
.filter(function(d) { return(d.cluster_idx === cid); })
157157
.attr("class", "clicked");
@@ -237,12 +237,12 @@ function get_autocomplete_source_fn(accn_to_cid) {
237237

238238
function search(beaddata) {
239239
var query = $('#search-input').val();
240-
const accn_pat = /^EPI_ISL_[0-9]+$/i; // case-insensitive
240+
241241
// FIX ME: Accn search returning 0 beads
242242
const points = find_beads_points(beaddata)
243243
.filter(point => point.labels.some(label => label.includes(query)));
244244
// TODO: Make select_bead_by_* use find_beads_points result
245-
accn_pat.test(query) ? select_bead_by_accession(query) : select_beads_by_substring(query);
245+
is_accn(query) ? select_bead_by_accession(query) : select_beads_by_substring(query);
246246
const stats = search_stats.update({
247247
query,
248248
current_point: 1,

0 commit comments

Comments
 (0)