Commit 5faab27c authored by flothoni's avatar flothoni Committed by Mathieu Giraud

model and clone; after loading, clone value is 0based

Update test
parent 0c52e1d7
......@@ -273,8 +273,8 @@ Clone.prototype = {
// perfect match exist
this.seg[field_name] = {};
this.seg[field_name].seq = sequence;
this.seg[field_name].start = pos +1 // seq is 1-based
this.seg[field_name].stop = pos + sequence.length
this.seg[field_name].start = pos // seq is 0-based
this.seg[field_name].stop = pos + sequence.length -1
return
} else if (extend == true || extend == undefined) {
// No perfect match; try extension with germline sequence
......@@ -286,18 +286,18 @@ 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] // -1 to be 0-based
var germpos = rst[1] -1 //to be 0-based
var nb_match = bsa_cigar2match(rst[2]) // Get number of match
if (nb_match > (sequence.length/2) ){
if (gene_way == 5){
computed_pos = this.seg["5"].stop + germpos - germseq.length + this.seg["5"].delRight
computed_pos = this.seg["5"].stop + germpos - germseq.length + this.seg["5"].delRight +1
} else if (gene_way == 3){
computed_pos = this.seg["3"].start - this.seg["3"].delLeft + germpos -1
computed_pos = this.seg["3"].start - this.seg["3"].delLeft + germpos
}
this.seg[field_name] = {};
this.seg[field_name].seq = sequence;
this.seg[field_name].start = computed_pos + 1
this.seg[field_name].stop = computed_pos + sequence.length// + end_adding
this.seg[field_name].stop = computed_pos + sequence.length
break
}
}
......@@ -404,7 +404,7 @@ Clone.prototype = {
positions = this.getSegStartStop(field_name)
if (positions !== null) {
// return this.sequence.substr(positions.start-1, (positions.stop+1) - positions.start)
return this.sequence.substr(positions.start-1, this.getSegLength(field_name))
return this.sequence.substr(positions.start, this.getSegLength(field_name))
}
return '';
},
......
......@@ -3157,12 +3157,13 @@ changeAlleleNotation: function(alleleNotation, update, save) {
var values = clone.getBestMatchingSequence(sequence, extend)
best_sequence = values[0]
extend = values[1]
if (best_sequence == undefined){
continue
}
} else {
best_sequence = sequence
}
if (best_sequence == undefined){
continue
}
clone.addSegFeatureFromSeq(feature, best_sequence, extend)
}
}
......@@ -3192,7 +3193,6 @@ changeAlleleNotation: function(alleleNotation, update, save) {
console.log("Primer set unknow")
return -1
}
primersSet = this.primerSetCurrent
this.cleanPreviousFeature("primer5")
this.cleanPreviousFeature("primer3")
......@@ -3228,7 +3228,6 @@ changeAlleleNotation: function(alleleNotation, update, save) {
this.update();
return 0
}
this.update();
},
......
......@@ -734,7 +734,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.addSegFeatureFromSeq('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");
assert.equal(c3.getSegNtSequence('somefeature'), "aaaattt" , "Seq of the feature");
......@@ -780,8 +780,8 @@ QUnit.test("clone : feature defined by a nucleotide sequence", function(assert)
//"IGHV1-2*01 // IGHJ1*01",
// var igh_V1_2_J1_full
clone.sequence = m.germline.IGH.IGH5seg + m.germline.IGH.IGH3seg
clone.seg[5].stop = 100
clone.seg[3].start = 101
clone.seg[5].stop = 99
clone.seg[3].start = 100
assert.deepEqual( clone.getBestMatchingSequence(primer5_fictif, false), [primer5_fictif[0], false], "seq full; BestMatching; primer5, no extend" )
assert.deepEqual( clone.getBestMatchingSequence(primer5_fictif, [5]), [primer5_fictif[0], false], "seq full; BestMatching; primer5, extend 5" )
......@@ -791,47 +791,47 @@ QUnit.test("clone : feature defined by a nucleotide sequence", function(assert)
assert.deepEqual( clone.getBestMatchingSequence(primer3_fictif, [3]), [primer3_fictif[0], true],"seq full; BestMatching; primer3, extend 3" )
clone.addSegFeatureFromSeq("primer5", primer5_fictif[0], true)
clone.addSegFeatureFromSeq("primer3", primer3_fictif[0], true)
assert.deepEqual( clone.seg["primer5"], {"seq":primer5_fictif[0], "start":1, "stop":15}, "addSegFeatureFromSeq; Primer5 value")
assert.deepEqual( clone.seg["primer3"], {"seq":primer3_fictif[0], "start":126, "stop":140}, "addSegFeatureFromSeq; Primer3 value")
assert.equal( clone.getSegLengthDoubleFeature('primer5', 'primer3'), 140, "Correct length for genescan ecngs" ) // ~245
assert.deepEqual( clone.seg["primer5"], {"seq":primer5_fictif[0], "start":0, "stop":14}, "seq full; addSegFeatureFromSeq; Primer5 value")
assert.deepEqual( clone.seg["primer3"], {"seq":primer3_fictif[0], "start":125, "stop":139}, "seq full; addSegFeatureFromSeq; Primer3 value")
assert.equal( clone.getSegLengthDoubleFeature('primer5', 'primer3'), 140, "seq full; Correct length for genescan ecngs" ) // ~245
delete clone.seg["primer5"] // delete for next addSegFeatureFromSeq call
delete clone.seg["primer3"]
// Sequence with 5' and 3' deletion
clone.sequence = m.germline.IGH.IGH5seg.substr(20, 80) + m.germline.IGH.IGH3seg.substr(0, 25)
clone.seg[5].stop = 80
clone.seg[3].start = 81
clone.seg[5].stop = 79
clone.seg[3].start = 80
assert.deepEqual( clone.getBestMatchingSequence(primer5_fictif, false), [undefined, false], "seq short; primer5, no extend" )
assert.deepEqual( clone.getBestMatchingSequence(primer5_fictif, [5]), [primer5_fictif[0], true], "seq short; primer5, extend 5" )
// not full match, but if extend, have bas_align call
assert.deepEqual( clone.getBestMatchingSequence(primer3_fictif, []), [undefined, false], "seq short; primer3, no extend")
assert.deepEqual( clone.getBestMatchingSequence(primer3_fictif, []), [undefined, false], "seq short; primer3, no extend")
assert.deepEqual( clone.getBestMatchingSequence(primer3_fictif, [5]), [undefined, false], "seq short; primer3, extend 5" )
assert.deepEqual( clone.getBestMatchingSequence(primer3_fictif, [3]), [primer3_fictif[0], true], "seq short; primer3, extend 3" )
clone.addSegFeatureFromSeq("primer5", primer5_fictif[0], true)
clone.addSegFeatureFromSeq("primer3", primer3_fictif[0], true)
assert.deepEqual( clone.seg["primer5"], {"seq":primer5_fictif[0], "start":-19, "stop":-5}, "addSegFeatureFromSeq; Primer5 value")
assert.deepEqual( clone.seg["primer3"], {"seq":primer3_fictif[0], "start":106, "stop":120}, "addSegFeatureFromSeq; Primer3 value")
assert.equal( clone.getSegLengthDoubleFeature('primer5', 'primer3'), 140, "Correct length for genescan ecngs" )
assert.deepEqual( clone.seg["primer5"], {"seq":primer5_fictif[0], "start":-20, "stop":-6}, "seq short; addSegFeatureFromSeq; Primer5 value")
assert.deepEqual( clone.seg["primer3"], {"seq":primer3_fictif[0], "start":105, "stop":119}, "seq short; addSegFeatureFromSeq; Primer3 value")
assert.equal( clone.getSegLengthDoubleFeature('primer5', 'primer3'), 140, "seq short; Correct length for genescan ecngs" )
delete clone.seg["primer5"]
delete clone.seg["primer3"]
// Sequence with 5'(-10) and 3'(-5) deletion, and D insertion (20nt)
clone.sequence = m.germline.IGH.IGH5seg.substr(20, 70) + m.germline.IGH.IGH4seg + m.germline.IGH.IGH3seg.substr(5, 25)
clone.seg[5].stop = 70
clone.seg[3].start = 91
clone.seg[5].stop = 69
clone.seg[3].start = 90
clone.seg[5].delRight = 10
clone.seg[3].delLeft = 5
clone.seg[4] = {"delLeft": 0, "delRight": 0, "name": "IGH4seg", "start": 71, "stop": 90 }
clone.seg[4] = {"delLeft": 0, "delRight": 0, "name": "IGH4seg", "start": 70, "stop": 89 }
clone.addSegFeatureFromSeq("primer5", primer5_fictif[0], true)
clone.addSegFeatureFromSeq("primer3", primer3_fictif[0], true)
assert.deepEqual( clone.seg["primer5"], {"seq":primer5_fictif[0], "start":-19, "stop":-5}, "Seq with D; Primer5 value")
assert.deepEqual( clone.seg["primer3"], {"seq":primer3_fictif[0], "start":111, "stop":125}, "Seq with D; Primer3 value")
assert.deepEqual( clone.seg["primer5"], {"seq":primer5_fictif[0], "start":-20, "stop":-6}, "Seq with D; Primer5 value")
assert.deepEqual( clone.seg["primer3"], {"seq":primer3_fictif[0], "start":110, "stop":124}, "Seq with D; Primer3 value")
assert.equal( clone.getSegLengthDoubleFeature('primer5', 'primer3'), 145, "Seq with D; Correct length for genescan ecngs (-10+20-5)" ) // ~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