Commit 0bb84e40 authored by Mikaël Salson's avatar Mikaël Salson

browser/js: Provide a color by CDR3 method to better see identical CDR3s with same genes

parent d140068b
Pipeline #43176 passed with stages
in 6 minutes and 12 seconds
......@@ -166,6 +166,7 @@
<div class="div-menu-selector"><select class="menu-selector" onchange="m.changeColorMethod(this.value)">
<option value="Tag">tag</option>
<option value="clone">clone</option>
<option value="cdr3">CDR3</option>
<option value="V">V/5'</option>
<option value="J">J/3'</option>
<option value="N">N</option>
......
......@@ -977,6 +977,8 @@ Clone.prototype = {
}
} else if (this.m.colorMethod == 'clone') {
this.color = colorGeneratorIndex(this.index)
} else if (this.m.colorMethod == 'cdr3') {
this.color = this.getCDR3Color();
}else if (this.m.colorMethod == "Tag"){
this.color = this.m.tag[this.getTag()].color;
}else if (this.m.colorMethod == "dbscan"){
......@@ -1509,6 +1511,22 @@ Clone.prototype = {
}
},
/**
* Deterministically return a color associated with the CDR3 (if any)
*/
getCDR3Color: function() {
var junction = this.getSegAASequence('junction');
if (junction.length == 0)
return '';
// Convert CDR3 to int
var intcdr3 = 0;
junction = junction.toUpperCase();
for (var i = 0; i < junction.length; i++) {
intcdr3 += (junction.charCodeAt(i)-65) * (Math.pow(26, i));
}
return colorGeneratorIndex(intcdr3);
},
/**
* Get the number of occurrences of the clone in cloneDB
* @return {int} res - the number of occurrences, undefined if cloneDB wasn't called
......
......@@ -388,6 +388,23 @@ QUnit.test("tag / color", function(assert) {
});
QUnit.test("color by CDR3", function(assert) {
var m = new Model();
m.parseJsonData(json_data);
var c1 = new Clone(json_clone1, m, 0);
var c2 = new Clone(json_clone2, m, 0);
m.initClones();
var color = c1.getCDR3Color();
c1.seg.junction.aa = "AZERTY";
var color2 = c1.getCDR3Color();
// Actually it could happen that some different CDR3s have the same colours
assert.equal(color != color2, true, "two CDR3 should have different"
+ " colors");
assert.equal(c2.getCDR3Color(), '');
});
QUnit.test("export", function(assert) {
var m = new Model();
......
Markdown is supported
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