Commit 1fcf5a1c authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch...

Merge branch 'feature-c/2041-l-alignement-multiple-plante-quand-la-premiere-sequence-est-retiree' into 'dev'

Resolve "L'alignement multiple plante quand la première séquence est retirée"

Closes #2041

See merge request !454
parents 3be38c03 5e14efda
Pipeline #72281 passed with stages
in 6 minutes and 44 seconds
...@@ -61,7 +61,7 @@ function Segment(id, model, database) { ...@@ -61,7 +61,7 @@ function Segment(id, model, database) {
this.starPath = "M 0,6.1176482 5.5244193, 5.5368104 8.0000008,0 10.172535,5.5368104 16,6.1176482 11.406183,9.9581144 12.947371,16 8.0000008,12.689863 3.0526285,16 4.4675491,10.033876 z"; this.starPath = "M 0,6.1176482 5.5244193, 5.5368104 8.0000008,0 10.172535,5.5368104 16,6.1176482 11.406183,9.9581144 12.947371,16 8.0000008,12.689863 3.0526285,16 4.4675491,10.033876 z";
this.cgi_address = CGI_ADDRESS this.cgi_address = CGI_ADDRESS
this.m = model this.m = model
this.first_clone = 0 ; // id of sequence at the top of the segmenter this.first_clone = -1 ; // id of sequence at the top of the segmenter
this.memtab = []; this.memtab = [];
this.sequence = {}; this.sequence = {};
this.is_open = false; this.is_open = false;
...@@ -555,6 +555,8 @@ Segment.prototype = { ...@@ -555,6 +555,8 @@ Segment.prototype = {
} }
} }
} }
// Update the first clone if needed
this.update_first_clone()
this.updateAlignmentButton() this.updateAlignmentButton()
//this.updateSegmenterWithHighLighSelection(); //this.updateSegmenterWithHighLighSelection();
...@@ -670,12 +672,8 @@ Segment.prototype = { ...@@ -670,12 +672,8 @@ Segment.prototype = {
this.sequence[cloneID] = new Sequence(cloneID, this.m, this) this.sequence[cloneID] = new Sequence(cloneID, this.m, this)
var divParent = document.getElementById("listSeq"); var divParent = document.getElementById("listSeq");
// Am I the first clone in this segmenter ? this.update_first_clone(cloneID)
var previous_li = divParent.getElementsByTagName("li");
if (previous_li && previous_li.length === 0) {
this.first_clone = cloneID
}
var li = document.createElement('li'); var li = document.createElement('li');
li.id = "seq" + cloneID; li.id = "seq" + cloneID;
...@@ -699,11 +697,51 @@ Segment.prototype = { ...@@ -699,11 +697,51 @@ Segment.prototype = {
}, },
/**
* Set the first_clone of the segmenter.
* This one can be changed when we deselect some clone into the segmenter
**/
set_first_clone : function(cloneID) {
if (isNaN(cloneID)){
console.error( "Nan error")
return
}
this.first_clone = cloneID;
},
/**
* Update the first_clone of the segmenter.
* Look if the current clone is the first of the segmenter div
**/
update_first_clone : function(cloneID) {
var divParent = document.getElementById("listSeq");
if (divParent == undefined) { return }
// Am I the first clone in this segmenter ?
var previous_li = divParent.getElementsByTagName("li");
if (previous_li && previous_li.length === 0 ) {
if (cloneID == undefined){
this.set_first_clone( -1 )
return
}
this.set_first_clone( cloneID )
return
} else if (previous_li.length != 0) {
// get first line from html content
var index_first_clone = Number( previous_li[0].id.substr(3) )
this.set_first_clone( index_first_clone )
}
},
/** /**
* select all the germline of a clone . * select all the germline of a clone .
* add them to the segmenter * add them to the segmenter
**/ **/
add_all_germline_to_segmenter : function() { add_all_germline_to_segmenter : function() {
for (var id in this.sequence) { for (var id in this.sequence) {
if (this.isClone(id)) { if (this.isClone(id)) {
...@@ -1359,6 +1397,8 @@ genSeq.prototype= { ...@@ -1359,6 +1397,8 @@ genSeq.prototype= {
var mutations = {}; var mutations = {};
var ref = ''; var ref = '';
var seq = ''; var seq = '';
if (this.segmenter.amino) { if (this.segmenter.amino) {
seq = this.seqAA; seq = this.seqAA;
ref = this.segmenter.sequence[this.segmenter.first_clone].seqAA; ref = this.segmenter.sequence[this.segmenter.first_clone].seqAA;
......
...@@ -11,6 +11,7 @@ QUnit.test("segmenter", function(assert) { ...@@ -11,6 +11,7 @@ QUnit.test("segmenter", function(assert) {
m.initClones() m.initClones()
var segment = new Segment("segment", m); var segment = new Segment("segment", m);
assert.equal(segment.first_clone, -1, "segment.first_clone is set to -1 at init")
segment.init() segment.init()
//select test //select test
...@@ -21,7 +22,10 @@ QUnit.test("segmenter", function(assert) { ...@@ -21,7 +22,10 @@ QUnit.test("segmenter", function(assert) {
m.select(1) m.select(1)
var div1 = document.getElementById("f1"); var div1 = document.getElementById("f1");
assert.notEqual(div1.innerHTML.indexOf("test2"), -1, "select : Ok") assert.notEqual(div1.innerHTML.indexOf("test2"), -1, "select : Ok")
assert.equal(segment.first_clone, 0, "segment.first_clone still set to 0 if clones 0 and 1 are selected")
m.unselect(0)
assert.equal(segment.first_clone, 1, "segment.first_clone is set to 1 if clones 0 is unselected")
m.select(2) m.select(2)
var div2 = document.getElementById("f2"); var div2 = document.getElementById("f2");
assert.notEqual(div2.innerHTML.indexOf("test3"), -1, "select : Ok") assert.notEqual(div2.innerHTML.indexOf("test3"), -1, "select : Ok")
...@@ -30,6 +34,7 @@ QUnit.test("segmenter", function(assert) { ...@@ -30,6 +34,7 @@ QUnit.test("segmenter", function(assert) {
assert.equal(document.getElementById("f0"), null, "unselect : Ok") assert.equal(document.getElementById("f0"), null, "unselect : Ok")
assert.equal(document.getElementById("f1"), null, "unselect : Ok") assert.equal(document.getElementById("f1"), null, "unselect : Ok")
assert.equal(document.getElementById("f2"), null, "unselect : Ok") assert.equal(document.getElementById("f2"), null, "unselect : Ok")
assert.equal(segment.first_clone, -1, "segment.first_clone is set to -1 when no clones are selected")
m.select(0); m.select(0);
m.select(2); m.select(2);
...@@ -82,6 +87,11 @@ QUnit.test("segmenter", function(assert) { ...@@ -82,6 +87,11 @@ QUnit.test("segmenter", function(assert) {
m.select(2) m.select(2)
m.changeTime(3) m.changeTime(3)
assert.equal(document.getElementsByClassName("stats_content")[0].innerHTML, "1 clone, 3 reads ", "stats (1 clone with few reads) : Ok") assert.equal(document.getElementsByClassName("stats_content")[0].innerHTML, "1 clone, 3 reads ", "stats (1 clone with few reads) : Ok")
m.unselectAll()
m.select(2)
m.select(0)
assert.equal(segment.first_clone, 2, "segment.first_clone is set to 2, even if bigger clone is selected")
}); });
QUnit.test("sequence", function(assert) { QUnit.test("sequence", function(assert) {
...@@ -165,10 +175,10 @@ QUnit.test("segt", function (assert) { ...@@ -165,10 +175,10 @@ QUnit.test("segt", function (assert) {
m.initClones(); m.initClones();
var segment = new Segment("segment",m); var segment = new Segment("segment",m);
segment.init(); segment.init();
m.select(2)
segment.addGermlineToSegmenter("IGHD1-1*01","IGH"); segment.addGermlineToSegmenter("IGHD1-1*01","IGH");
assert.equal(segment.sequence["IGHD1-1*01"].seq.join("").toUpperCase(), "GGGCGCCGGGGCAGATTCTGAACAGCCCCGAGTCACGGTGGGTACAACTGGAACGAC") assert.equal(segment.sequence["IGHD1-1*01"].seq.join("").toUpperCase(), "GGGCGCCGGGGCAGATTCTGAACAGCCCCGAGTCACGGTGGGTACAACTGGAACGAC")
assert.equal(segment.sequence["IGHD1-1*01"].is_clone, false); assert.equal(segment.sequence["IGHD1-1*01"].is_clone, false);
m.select(2)
segment.addToSegmenter(2); segment.addToSegmenter(2);
segment.add_all_germline_to_segmenter(); segment.add_all_germline_to_segmenter();
// segment.updateElem() // segment.updateElem()
......
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