Skip to content

Commit 6f9e424

Browse files
committed
fix for manually colored genes
1 parent 3c5b562 commit 6f9e424

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

‎anvio/data/interactive/js/charts.js‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,7 @@ function loadAll() {
425425
}
426426
});
427427

428-
$('#gene_color_order').on('focus', function() {
429-
Object.keys(state['highlight-genes']).forEach(gene_id => {
430-
state['highlight-genes'][gene_id] = $('#picker_' + gene_id).attr('color');
431-
});
432-
433-
}).change(function() {
428+
$('#gene_color_order').change(function() {
434429
state['gene-fn-db'] = $(this).val();
435430
resetFunctionColors(state[$(this).val().toLowerCase() + '-colors']);
436431
redrawArrows();
@@ -680,7 +675,7 @@ function generateFunctionColorTable(fn_colors, fn_type, highlight_genes=null, fi
680675
$(el).css('background-color', '#' + hex);
681676
$(el).attr('color', '#' + hex);
682677
let category = el.id.substring(7).replaceAll('_', ' ');
683-
state[$('#gene_color_order').val().toLowerCase() + '-colors'][category] = '#' + hex;
678+
state['highlight-genes'][category] = '#' + hex;
684679
if (!bySetColor) $(el).val(hex);
685680
}
686681
}).keyup(function() {
@@ -749,8 +744,8 @@ function addGeneIDColor(gene_id, color="#FF0000") {
749744
onChange: function(hsb, hex, rgb, el, bySetColor) {
750745
$(el).css('background-color', '#' + hex);
751746
$(el).attr('color', '#' + hex);
752-
753-
state['highlight-genes'][el.id.substring(7)] = '#' + hex;
747+
let category = el.id.substring(7).replaceAll('_', ' ');
748+
state['highlight-genes'][category] = '#' + hex;
754749
if (!bySetColor) $(el).val(hex);
755750
}
756751
}).keyup(function() {
@@ -795,8 +790,14 @@ function defineArrowMarkers(fn_type, cags=null, noneMarker=true) {
795790
if(category.indexOf(',') != -1) category = category.substr(0,category.indexOf(','));
796791
if(category.indexOf(';') != -1) category = category.substr(0,category.indexOf(';'));
797792
if(category.indexOf('!!!') != -1) category = category.substr(0,category.indexOf('!!!'));
798-
let prop = fn_type.toLowerCase() + '-colors';
799-
let color = state[prop][category] ? state[prop][category] : "#808080";
793+
let color;
794+
if(fn_type) {
795+
let prop = fn_type.toLowerCase() + '-colors';
796+
color = state[prop][category] ? state[prop][category] : "#808080";
797+
} else {
798+
// highlighted gene id
799+
color = state['highlight-genes'][category];
800+
}
800801
contextSvg.select('#contextSvgDefs').append('svg:marker')
801802
.attr('id', 'arrow_' + getCleanCagCode(category) )
802803
.attr('markerHeight', 2)

‎anvio/data/interactive/js/inspectionutils.js‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,14 @@ function drawArrows(_start, _stop, colortype, gene_offset_y, color_genes=null) {
324324
}
325325

326326
// M10 15 l20 0
327-
let prop = colortype.toLowerCase() + '-colors';
328-
let color = state[prop][category] ? state[prop][category] : "#808080";
327+
let color;
328+
if(category == gene.gene_callers_id) {
329+
// highlighted gene id
330+
color = state['highlight-genes'][category];
331+
} else {
332+
let prop = colortype.toLowerCase() + '-colors';
333+
color = state[prop][category] ? state[prop][category] : "#808080";
334+
}
329335
path = paths.append('svg:path')
330336
.attr('id', 'gene_' + gene.gene_callers_id)
331337
.attr('d', 'M' + start +' '+ y +' l'+ stop +' 0')

0 commit comments

Comments
 (0)