Commit f5f8f3bc authored by flothoni's avatar flothoni Committed by Mathieu Giraud

clone.js; update position for feature as 1based

parent 6cdc15a2
......@@ -272,8 +272,8 @@ Clone.prototype = {
// perfect match exist
this.seg[field_name] = {};
this.seg[field_name].seq = sequence;
this.seg[field_name].start = pos
this.seg[field_name].stop = pos + sequence.length -1
this.seg[field_name].start = pos +1 // seq is 1-based
this.seg[field_name].stop = pos + sequence.length
} else if (extend == true || extend == undefined) {
// No perfect match; try extension with germline sequence
// Warning; predictive approach can't be perfect
......@@ -284,17 +284,21 @@ Clone.prototype = {
germseq = this.getExtendedSequence(gene_way)
if (germseq != undefined){
var rst = bsa_align(true, germseq, sequence, [1, -2], [-2, -1]) // return [score, start pos, ~cigar]
var germpos = rst[1]
var germpos = rst[1] // -1 to be 0-based
if (rst[0] > (sequence.length/2) ){
if (gene_way == 5){
computed_pos = this.seg["5"].stop + germpos - germseq.length - this.seg["5"].delRight //-sequence.length // start n'existe pas si extention; (this.seg["5"].start != undefined ? this.seg["5"].start : 0)
computed_pos = this.seg["5"].stop + germpos - germseq.length //-sequence.length // start n'existe pas si extention; (this.seg["5"].start != undefined ? this.seg["5"].start : 0)
console.log( "(5) computed_pos = germpos; germseq.length; sequence.length; this.seg['5'].delRight; this.seg['5'].stop; (this.seg['5'].start != undefined ? this.seg['5'].start : 0)")
console.log( computed_pos+" = "+germpos+"; "+germseq.length+"; "+sequence.length+"; "+this.seg["5"].delRight+"; "+this.seg["5"].stop+"; "+(this.seg["5"].start != undefined ? this.seg["5"].start : 0))
} else if (gene_way == 3){
computed_pos = germpos + this.seg["3"].start - this.seg["3"].delLeft
computed_pos = this.seg["3"].start + (germpos - this.seg["3"].delLeft)
console.log( "computed_pos = this.seg[3].start; germpos; this.seg[3].delLeft; sequence.length")
console.log( computed_pos+" = "+this.seg["3"].start+"; "+germpos+"; "+this.seg["3"].delLeft+"; "+sequence.length)
}
this.seg[field_name] = {};
this.seg[field_name].seq = sequence;
this.seg[field_name].start = computed_pos
this.seg[field_name].stop = computed_pos + sequence.length -1
this.seg[field_name].stop = computed_pos + sequence.length
break
}
}
......@@ -399,7 +403,8 @@ Clone.prototype = {
getSegNtSequence: function(field_name) {
positions = this.getSegStartStop(field_name)
if (positions !== null) {
return this.sequence.substr(positions.start, positions.stop - positions.start+1)
// return this.sequence.substr(positions.start-1, (positions.stop+1) - positions.start)
return this.sequence.substr(positions.start-1, (positions.stop - positions.start-1))
}
return '';
},
......@@ -412,7 +417,7 @@ Clone.prototype = {
getSegLength: function(field_name) {
positions = this.getSegStartStop(field_name)
if (positions !== null) {
return positions.stop - positions.start + 1
return (positions.stop+1) - positions.start
} else {
return 'undefined';
}
......@@ -429,7 +434,7 @@ Clone.prototype = {
var positions2 = this.getSegStartStop(field_name2)
if (positions1 !== null && positions2 !== null) {
return positions2.stop - positions1.start +1
return positions2.stop - (positions1.start - 1)
} else {
return 'undefined';
}
......
......@@ -729,15 +729,15 @@ QUnit.test("clone : feature defined by a nucleotide sequence", function(assert)
// Test with sequence already in a feature inside clone
var m = new Model()
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
var c3 = new Clone(json_clone3, m, 2, c_attributes)
var c3 = new Clone(json_clone3, m, 0, c_attributes)
m.initClones()
assert.deepEqual(c3.getSegStartStop('somefeature'), null, "start/stop positions are not present")
c3.addSegFeatureFromSeq('somefeature')
assert.deepEqual(c3.getSegStartStop('somefeature'), {"start": 6, "stop": 12}, "start/stop positions, computed from sequence")
assert.deepEqual(c3.getSegStartStop('somefeature'), {"start": 7, "stop": 13}, "start/stop positions, computed from sequence")
assert.equal(c3.getSegLength('somefeature'), 7, "length of the feature");
assert.equal(c3.getSegNtSequence('somefeature'), "aaaattt" , "Seq of the feature");
// Test with given sequence for new feature
var m = new Model();
......@@ -759,7 +759,8 @@ QUnit.test("clone : feature defined by a nucleotide sequence", function(assert)
"5": {
"delRight": 0,
"name": "IGHV1-2*01",
"stop": 296
"stop": 296,
"start": 0
}
},
"sequence": "init",
......@@ -775,6 +776,7 @@ QUnit.test("clone : feature defined by a nucleotide sequence", function(assert)
primer5_ecngs_trd = m.primersSetData.ecngs.TRD.primer5
primer3_ecngs_trd = m.primersSetData.ecngs.TRD.primer3
//"IGHV1-2*01 // IGHJ1*01",
// var igh_V1_2_J1_full
clone.sequence = "CAGGTGCAGCTGGTGCAGTCTGGGGCTGAGGTGAAGAAGCCTGGGGCCTCAGTGAAGGTCTCCTGCAAGGCTTCTGGATACACCTTCACCGGCTACTATATGCACTGGGTGCGACAGGCCCCTGGACAAGGGCTTGAGTGGATGGGACGGATCAACCCTAACAGTGGTGGCACAAACTATGCACAGAAGTTTCAGGGCAGGGTCACCAGTACCAGGGACACGTCCATCAGCACAGCCTACATGGAGCTGAGCAGGCTGAGATCTGACGACACGGTCGTGTATTACTGTGCGAGAGAGCTGAATACTTCCAGCACTGGGGCCAGGGCACCCTGGTCACCGTCTCCTCAG"
......@@ -787,8 +789,9 @@ QUnit.test("clone : feature defined by a nucleotide sequence", function(assert)
assert.deepEqual( clone.getBestMatchingSequence(primer3_ecngs_igh, [3]), ["GGTCACCGTCTCCTCAGGTAAG", true],"seq full; primer3, extend 3" )
clone.addSegFeatureFromSeq("primer5", "CTGGGTGCGACAGGCCCCT", true)
clone.addSegFeatureFromSeq("primer3", "GGTCACCGTCTCCTCAGGTAAG", true)
assert.deepEqual( clone.seg["primer5"], {"seq":"CTGGGTGCGACAGGCCCCT", "start":104, "stop":122}, "Primer5 value")
assert.deepEqual( clone.seg["primer3"], {"seq":"GGTCACCGTCTCCTCAGGTAAG", "start":331, "stop":352}, "Primer3 value")
assert.deepEqual( clone.seg["primer5"], {"seq":"CTGGGTGCGACAGGCCCCT", "start":105, "stop":123}, "Primer5 value")
assert.deepEqual( clone.seg["primer3"], {"seq":"GGTCACCGTCTCCTCAGGTAAG", "start":331, "stop":353}, "Primer3 value")
console.log( clone.seg )
assert.equal( clone.getSegLengthDoubleFeature('primer5', 'primer3'), 249, "Correct length for genescan ecngs" ) // ~245
delete clone.seg["primer5"]
delete clone.seg["primer3"]
......@@ -807,12 +810,31 @@ QUnit.test("clone : feature defined by a nucleotide sequence", function(assert)
assert.deepEqual( clone.getBestMatchingSequence(primer3_ecngs_igh, [3]), ["GGTCACCGTCTCCTCAGGTAAG", true], "seq short; primer3, extend 3" )
clone.addSegFeatureFromSeq("primer5", "CTGGGTGCGACAGGCCCCT", true)
clone.addSegFeatureFromSeq("primer3", "GGTCACCGTCTCCTCAGGTAAG", true)
assert.deepEqual( clone.seg["primer5"], {"seq":"CTGGGTGCGACAGGCCCCT", "start":-16, "stop":2}, "Primer5 value")
assert.deepEqual( clone.seg["primer3"], {"seq":"GGTCACCGTCTCCTCAGGTAAG", "start":212, "stop":233}, "Primer3 value")
assert.equal( clone.getSegLengthDoubleFeature('primer5', 'primer3'), 249, "Correct length for genescan ecngs" ) // ~245
delete clone.seg["primer5"]
delete clone.seg["primer3"]
assert.deepEqual( clone.seg["primer5"], {"seq":"CTGGGTGCGACAGGCCCCT", "start":-16, "stop":3}, "seq short; Primer5 value")
assert.deepEqual( clone.seg["primer3"], {"seq":"GGTCACCGTCTCCTCAGGTAAG", "start":212, "stop":234}, "seq short; Primer3 value")
console.log( clone.seg )
assert.equal( clone.getSegLengthDoubleFeature('primer5', 'primer3'), 249, "seq short; Correct length for genescan ecngs" ) // ~245
// delete clone.seg["primer5"]
// delete clone.seg["primer3"]
// // Sequence with 5'(-10) and 3'(-5) deletion, and D insertion (20nt)
// clone.seg[5].stop = 166
// clone.seg[3].start = 187
// clone.seg[3].delRight = 10
// clone.seg[3].delLeft = 5
// clone.seg[4] = {"delLeft": 2, "delRight": 0, "name": "IGHD1-26*01", "start": 169, "stop": 186 }
// clone.sequence = "CCTGGACAAGGGCTTGAGTGGATGGGACGGATCAACCCTAACAGTGGTGGCACAAACTATGCACAGAAGTTTCAGGGCAGGGTCACCAGTACCAGGGACACGTCCATCAGCACAGCCTACATGGAGCTGAGCAGGCTGAGATCTGACGACACGGTCGTGTATTACTggtatagtgggagctactacGCTGAATACTTCCAGCACTGGGGC"
// clone.addSegFeatureFromSeq("primer5", "CTGGGTGCGACAGGCCCCT", true)
// clone.addSegFeatureFromSeq("primer3", "GGTCACCGTCTCCTCAGGTAAG", true)
// assert.deepEqual( clone.seg["primer5"], {"seq":"CTGGGTGCGACAGGCCCCT", "start":-16, "stop":2}, "Seq with D; Primer5 value")
// assert.deepEqual( clone.seg["primer3"], {"seq":"GGTCACCGTCTCCTCAGGTAAG", "start":221, "stop":243}, "Seq with D; Primer3 value")
// console.log( clone.seg )
// assert.equal( clone.getSegLengthDoubleFeature('primer5', 'primer3'), 258, "Seq with D; Correct length for genescan ecngs" ) // ~245
// // delete clone.seg["primer5"]
// // delete clone.seg["primer3"]
});
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