diff --git a/browser/js/clone.js b/browser/js/clone.js
index e54ce82a78c3bc122830c218823022c5e0a2df7a..aba792994abd1dc2ac8220e785568ad9e274520a 100644
--- a/browser/js/clone.js
+++ b/browser/js/clone.js
@@ -234,6 +234,7 @@ Clone.prototype = {
/**
* Compute feature positions (start/stop) from its sequence, unless they are already present
+ * Computed positions are converted to start from 0 and can be used without manipualtions
*/
computeSegFeatureFromSeq: function(field_name)
{
@@ -251,8 +252,8 @@ Clone.prototype = {
// No feature here
return;
- this.seg[field_name].start = pos + 1
- this.seg[field_name].stop = pos + seq.length
+ this.seg[field_name].start = pos
+ this.seg[field_name].stop = pos + seq.length -1
},
@@ -273,7 +274,7 @@ Clone.prototype = {
getSegNtSequence: function(field_name) {
positions = this.getSegStartStop(field_name)
if (positions !== null) {
- return this.sequence.substr(positions.start-1, positions.stop - positions.start+1)
+ return this.sequence.substr(positions.start, positions.stop - positions.start+1)
}
return '';
},
@@ -311,6 +312,7 @@ Clone.prototype = {
/**
* Get the start and stop position of a given field (e.g. cdr3)
+ * Getted positions are 0 based.
* If it does not exist return null
*/
getSegStartStop: function(field_name) {
diff --git a/browser/test/QUnit/testFiles/clone_test.js b/browser/test/QUnit/testFiles/clone_test.js
index 7f18a98ee940a4a81db7308cac04d4e7efb7f55e..345b1f911d020211c28cc8c697e8bcd835e8939e 100644
--- a/browser/test/QUnit/testFiles/clone_test.js
+++ b/browser/test/QUnit/testFiles/clone_test.js
@@ -15,7 +15,7 @@ QUnit.module("Clone", {
"3start" : 15,
"5" : {'start': 1, 'end': 5}, // 0-based (old format, with 'end')
"cdr3": {
- "start": 11,
+ "start": 8,
"stop": 16,
"aa": "ABCDE"
},
@@ -248,10 +248,10 @@ QUnit.test("name, informations, getHtmlInfo", function(assert) {
"getHtmlInfo: segmentation information (V gene) after changment");
// Test junction in html export
- assert.includes(html, "
junction | aat |
",
+ assert.includes(html, "junction | att |
",
"getHtmlInfo c1: junction info for productive clone");
html = c3.getHtmlInfo();
- assert.includes(html, "junction | aaaaaaaaattt |
",
+ assert.includes(html, "junction | aaaaaaaatttt |
",
"getHtmlInfo c3: junction info for non productive clone");
assert.includes(html, "junction (AA seq) | WKIC |
",
"getHtmlInfo c3: junction (AAseq) info for non productive clone");
@@ -272,10 +272,10 @@ QUnit.test('clone: get info from seg', function(assert) {
assert.notOk(c1.hasSeg('toto'), "clone1 doesn't have toto")
assert.notOk(c1.hasSeg('junction', 'toto'), "clone1 has junction but doesn't have toto")
- assert.equal(c1.getSegLength('cdr3'), 6, "CDR3 length");
+ assert.equal(c1.getSegLength('cdr3'), 9, "CDR3 length");
assert.equal(c2.getSegLength('cdr3'), 'undefined', "no cdr3 in c2");
var pos_cdr3 = c1.getSegStartStop('cdr3')
- assert.equal(pos_cdr3['start'], 10, "CDR3 length")
+ assert.equal(pos_cdr3['start'], 7, "CDR3 length")
assert.equal(pos_cdr3['stop'], 15, "CDR3 length")
assert.equal(c1.getSegStartStop('toto'), null, "no toto record")
var pos_junction = c3.getSegStartStop('junction')
@@ -292,7 +292,8 @@ QUnit.test('clone: get info from seg', function(assert) {
c1.computeEValue()
assert.equal(c1.eValue, 1e-2, 'Recomputing e-value should not change its value')
- assert.equal(c1.getSegNtSequence('junction'), 'aat', 'junction c1')
+ assert.equal(c1.getSegNtSequence('junction'), 'att', 'junction c1')
+ assert.equal(c1.getSegNtSequence('cdr3'), 'aaatttttt', 'sequence cdr3 c1 (by getSegNtSequence)')
assert.equal(c1.getSegAASequence('junction'), '', 'no AA junction for c1')
assert.equal(c1.getSegAASequence('cdr3'), 'ABCDE', 'AA CDR3 for c1')
@@ -310,7 +311,7 @@ QUnit.test("clone : feature defined by a nucleotide sequence", function(assert)
assert.deepEqual(c3.getSegStartStop('somefeature'), null, "start/stop positions are not present")
c3.computeSegFeatureFromSeq('somefeature')
- assert.deepEqual(c3.getSegStartStop('somefeature'), {"start": 7, "stop": 13}, "start/stop positions, computed from sequence")
+ assert.deepEqual(c3.getSegStartStop('somefeature'), {"start": 6, "stop": 12}, "start/stop positions, computed from sequence")
assert.equal(c3.getSegLength('somefeature'), 7, "length of the feature");
});
@@ -439,7 +440,7 @@ QUnit.test("export", function(assert) {
"TRG", "-/-",
"undefined V", "IGHD2*03", "IGHV4*01",
"not productive",
- "aaaaaaaaattt",
+ "aaaaaaaatttt",
"WKIC",
"AAAAAAAAAATTTTTTTTT",
10, 10, 15, 15,
diff --git a/browser/test/QUnit/testFiles/model_test.js b/browser/test/QUnit/testFiles/model_test.js
index dc2fc8824fe06dee3b0357080e93afcc2124922e..6b9f4b743eb1b8292b817b52d94935083321ceaa 100644
--- a/browser/test/QUnit/testFiles/model_test.js
+++ b/browser/test/QUnit/testFiles/model_test.js
@@ -349,8 +349,8 @@ QUnit.test("model: primer detection", function(assert) {
// primer found inside clones
assert.equal(typeof m.clones[2]["seg"]["primer5"], "undefined", "Control neg primer 5 not in sequence")
assert.equal(typeof m.clones[2]["seg"]["primer3"], "undefined", "Control neg primer 3 not in sequence")
- assert.deepEqual(m.clones[3]["seg"]["primer5"], { seq: "GGAAGGCCCCACAGCG", start: 1, stop: 16 }, "Found primer 5")
- assert.deepEqual(m.clones[3]["seg"]["primer3"], { seq: "AACTTCGCCTGGTAA", start: 227, stop: 241 }, "Found primer 3")
+ assert.deepEqual(m.clones[3]["seg"]["primer5"], { seq: "GGAAGGCCCCACAGCG", start: 0, stop: 15 }, "Found primer 5")
+ assert.deepEqual(m.clones[3]["seg"]["primer3"], { seq: "AACTTCGCCTGGTAA", start: 226, stop: 240 }, "Found primer 3")
m.cleanPreviousFeature("primer3")
diff --git a/browser/test/QUnit/testFiles/segmenter_test.js b/browser/test/QUnit/testFiles/segmenter_test.js
index 812a65ab5019309c300b252c7ad7fac41723c375..3a450d1190587acb180a8d01ca820dd977586755 100644
--- a/browser/test/QUnit/testFiles/segmenter_test.js
+++ b/browser/test/QUnit/testFiles/segmenter_test.js
@@ -111,8 +111,8 @@ QUnit.test("sequence", function(assert) {
assert.equal(h.stop, 6, '"f1" feature, stop')
h = seq1.get_positionned_highlight('f2', '')
- assert.equal(h.start, 15, '"f2" feature, start')
- assert.equal(h.stop, 20, '"f2" feature, stop')
+ assert.equal(h.start, 14, '"f2" feature, start')
+ assert.equal(h.stop, 19, '"f2" feature, stop')
segment.updateElemStyle([4]) /* Will remove sequence 4 from the segmenter
* as it is not really selected
@@ -138,11 +138,11 @@ QUnit.test("segt", function (assert) {
assert.equal(m.clone(3).getSequence(),"GGAAGGCCCCACAGCGTCTTCTGTACTATGACGTCTCCACCGCAAGGGATGTGTTGGAATCAGGACTCAGTCCAGGAAAGTATTATACTCATACACCCAGGAGGTGGAGCTGGATATTGAGACTGCAAAATCTAATTGAAAATGATTCTGGGGTCTATTACTGTGCCACCTGGGACAGGCTGAAGGATTGGATCAAGACGTTTGCAAAAGGGACTAGGCTCATAGTAACTTCGCCTGGTAA","sequence")
m.clone(3).addSegFeatureFromSeq('test_feature','CACCCAGGAGGTGGAGCTGGATATTGAGACT');
f1 = segment.sequence[3].get_positionned_highlight('test_feature','');
- assert.equal(f1.start, 94 , "feature start");
- assert.equal(f1.stop, 124, "feature stop");
+ assert.equal(f1.start, 93 , "feature start");
+ assert.equal(f1.stop, 123, "feature stop");
assert.equal(f1.seq,'CACCCAGGAGGTGGAGCTGGATATTGAGACT', "feature sequence");
assert.equal(m.clone(3).getSegNtSequence("test_feature"), "CACCCAGGAGGTGGAGCTGGATATTGAGACT", "feature sequence 3");
- assert.deepEqual(m.clone(3).getSegFeature("test_feature"),{"seq": "CACCCAGGAGGTGGAGCTGGATATTGAGACT", "start": 94, "stop": 124}, "feature sequence 4");
+ assert.deepEqual(m.clone(3).getSegFeature("test_feature"),{"seq": "CACCCAGGAGGTGGAGCTGGATATTGAGACT", "start": 93, "stop": 123}, "feature sequence 4");
// segment.sequence[3].computeAAseq()
// assert.equal(m.clone(3).getSegAASequence("cdr3"),"AKDILKSLKQQLATPNWFDP","feature sequence 2")
@@ -156,7 +156,7 @@ QUnit.test("segt", function (assert) {
var h = segment.sequence[3].get_positionned_highlight('f1','');
assert.equal(h.start,-1, " start feature value");
assert.equal(h.stop, -1, "stop feature value");
- assert.deepEqual(segment.sequence[3].get_positionned_highlight("test_feature",""),{"color": "", "css": "highlight_seq", "seq": "CACCCAGGAGGTGGAGCTGGATATTGAGACT", "start": 94, "stop": 124, "tooltip": ""}, "test feature value")
+ assert.deepEqual(segment.sequence[3].get_positionned_highlight("test_feature",""),{"color": "", "css": "highlight_seq", "seq": "CACCCAGGAGGTGGAGCTGGATATTGAGACT", "start": 93, "stop": 123, "tooltip": ""}, "test feature value")
assert.equal(m.clone(3).getSegLength('test_feature'),31, "feature length");
m.unselectAll();
assert.equal(segment.toFasta(), "");