Commit bed21668 authored by Mikaël Salson's avatar Mikaël Salson

clone.js, segmenter.js: Define getPhase(), use it and test it

parent d064eb23
Pipeline #41357 passed with stages
in 4 minutes and 40 seconds
......@@ -923,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) {
......
......@@ -1283,7 +1283,7 @@ genSeq.prototype= {
var canDisplaySynMutations = (! this.segmenter.amino &&
this.m.clones.hasOwnProperty(this.segmenter.first_clone) &&
this.m.clones[this.segmenter.first_clone].isProductive());
var reference_phase = (isProductive) ? (this.m.clones[this.segmenter.first_clone].seg.junction.start - 1) % 3 : undefined;
var reference_phase = (canDisplaySynMutations) ? (this.m.clones[this.segmenter.first_clone].getPhase()) : undefined;
var mutations = {};
var ref = '';
......
......@@ -527,11 +527,21 @@ QUnit.test("productivity", function(assert) {
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