Commit 73166dc9 authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-c/3483-productive-phase-refactor' into 'dev'

Resolve "Extraire/tester isProductive/referencePhase dans clone.js"

Closes #3483

See merge request !295
parents 942645fa bed21668
Pipeline #41363 failed with stages
in 2 minutes and 38 seconds
......@@ -22,7 +22,10 @@
*/
/**
* Clone object, store clone information and provide useful access function
* Clone object, store clone information and provide useful access function.
*
* BEWARE! Positions inside the seg field start at 0
*
* @constructor Clone
* @param {object} data - json style object, come directly from .vidjil file
* @param {Model} model
......@@ -920,6 +923,20 @@ Clone.prototype = {
return "unknown"
},
/**
* @return the phase for the sequence.
* The phase is computed according to the CDR3. For the phase to be returned
* we need to have isProductive() (otherwise we return "undefined").
* The returned phase is an integer between 0 and 2. 0 meaning that
* the first codon should start at the first nucleotide of the sequence.
*/
getPhase: function() {
if (this.isProductive()) {
return this.seg.junction.start % 3;
}
return 'undefined';
},
getVIdentityIMGT: function () {
if (typeof this.seg.imgt !== 'undefined' &&
this.seg.imgt !== null) {
......@@ -932,6 +949,16 @@ Clone.prototype = {
}
return "unknown"
},
/**
* @return true iff the clone is productive, false otherwise.
* Thus the function doesn't differentiate between a non-productive
* clone and a clone for which we don't know. For more information
* see getProductivityName() function.
*/
isProductive: function() {
return this.getProductivityName() == "productive";
},
/* compute clone color
*
......
......@@ -1280,10 +1280,10 @@ genSeq.prototype= {
result = document.createElement('span');
currentSpan = document.createElement('span');
var isProductive = (! this.segmenter.amino &&
this.m.clones.hasOwnProperty(this.segmenter.first_clone) &&
this.m.clones[this.segmenter.first_clone].getProductivityName() == "productive"); // TODO : isProductive method
var reference_phase = (isProductive) ? (this.m.clones[this.segmenter.first_clone].seg.junction.start - 1) % 3 : undefined;
var canDisplaySynMutations = (! this.segmenter.amino &&
this.m.clones.hasOwnProperty(this.segmenter.first_clone) &&
this.m.clones[this.segmenter.first_clone].isProductive());
var reference_phase = (canDisplaySynMutations) ? (this.m.clones[this.segmenter.first_clone].getPhase()) : undefined;
var mutations = {};
var ref = '';
......
......@@ -116,9 +116,11 @@ var json_clone5 = {
QUnit.test("name, informations, getHtmlInfo", function(assert) {
assert.equal(json_clone1.seg.junction.start, 10, "Start junction is 10 in JSON for clone 1");
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
assert.equal(c1.seg.junction.start, 9, "Start junction is now 9 for clone 1 as positions start at 0 in the code");
var c2 = new Clone(json_clone2, m, 1)
var c3 = new Clone(json_clone3, m, 2)
var c4 = new Clone(json_clone4, m, 3)
......@@ -514,3 +516,32 @@ QUnit.test("changealleleNotation", function(assert) {
m.changeAlleleNotation('never')
assert.equal(c2.getShortName(), "IGHV3-23 6/ACGTG/4 D1-1 5/12/4 J5", "clone2, .getShortName()");
});
QUnit.test("productivity", 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, 1);
var c3 = new Clone(json_clone3, m, 2);
m.initClones();
assert.equal(c1.getProductivityName(), "productive", "clone 1 should be productive");
assert.equal(c1.isProductive(), true, "clone 1 should be productive");
assert.equal(c1.getPhase(), 0, "Phase of clone 1 should be 0");
c1.seg.junction.start = 8;
assert.equal(c1.getPhase(), 2, "Phase of modified clone 1 should be 2");
c1.seg.junction.start = 7;
assert.equal(c1.getPhase(), 1, "Phase of modified clone 1 should be 1");
c1.seg.junction.start = 6;
assert.equal(c1.getPhase(), 0, "Phase of modified clone 1 should be 0");
assert.equal(c2.getProductivityName(), "no CDR3 detected", "clone 2 doesn't have information about productivity");
assert.equal(c2.isProductive(), false, "clone 2 doesn't have information about productivity");
assert.equal(c2.getPhase(), 'undefined', "No phase for clone 2");
assert.equal(c3.getProductivityName(), "not productive", "clone 3 should not be productive");
assert.equal(c3.isProductive(), false, "clone 3 should not be productive");
assert.equal(c3.getPhase(), 'undefined', "No phase for clone 3");
});
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