Commit 6c00655d authored by flothoni's avatar flothoni Committed by Mathieu Giraud

model & clone; refactor the function that allow to add primer feature

Use now a better search function that work with alignment.
This allow to find primer even without perfect match on sequence
parent 69760f07
......@@ -247,17 +247,10 @@ Clone.prototype = {
/**
* Add a new feature from a nucleotide sequence
*/
addSegFeatureFromSeq: function(field_name, sequence)
{
this.computeSegFeatureFromSeq(field_name, sequence);
},
/**
* 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, sequence, extend)
addSegFeatureFromSeq: function(field_name, sequence, extend)
{
positions = this.getSegStartStop(field_name)
......
......@@ -3140,20 +3140,30 @@ changeAlleleNotation: function(alleleNotation, update, save) {
/*
* Generic function to add a feature based on sequence for each clones
* Sequence can be an array of sequence. In this case, the function will search for best matching sequence in the array before adding feature
*/
addSegFeatureFromSeq : function (feature, sequence) {
if (this.clones.length > 100 ) {
numberToProcess = 100
} else {
numberToProcess = this.clones.length
}
numberToProcess = this.clones.length
var best_sequence;
for (var i = 0; i < numberToProcess; i++) {
if ( this.clones[i].hasSequence() ) {
var clone = this.clones[i]
if ( clone.seg[feature] == undefined && clone.hasSequence() ) {
// filter to extend only in one direction; depending of feature naming
var extend = ([5, 3].indexOf(feature.substr(feature.length - 1)) != -1) ? feature.substr(feature.length - 1) : undefined
// TODO : sequence 0 ou undefined ? bypass la fct ?
if (this.clones[i].sequence.indexOf(sequence) != -1) {
this.clones[i].addSegFeatureFromSeq(feature, sequence)
if (Array.isArray(sequence)){
var values = clone.getBestMatchingSequence(sequence, extend)
best_sequence = values[0]
extend = values[1]
if (best_sequence == undefined){
continue
}
} else {
best_sequence = sequence
}
clone.addSegFeatureFromSeq(feature, best_sequence, extend)
}
}
},
......@@ -3188,15 +3198,12 @@ changeAlleleNotation: function(alleleNotation, update, save) {
this.cleanPreviousFeature("primer3")
for (var i = 0; i < this.system_available.length; i++) {
var germline = this.system_available[i].replace("+", "")
if (this.primersSetData[this.primerSetCurrent][germline] != undefined){
primer5 = this.primersSetData[this.primerSetCurrent][germline].primer5
primer3 = this.primersSetData[this.primerSetCurrent][germline].primer3
primer5 = this.primersSetData[this.primerSetCurrent][germline].primer5
primer3 = this.primersSetData[this.primerSetCurrent][germline].primer3
for (var p = 0; p < primer5.length; p++) {
this.addSegFeatureFromSeq("primer5", primer5[p])
}
for (var q = 0; q < primer3.length; q++) {
this.addSegFeatureFromSeq("primer3", primer3[q])
this.addSegFeatureFromSeq("primer5", primer5)
this.addSegFeatureFromSeq("primer3", primer3)
}
}
},
......
......@@ -784,6 +784,13 @@ QUnit.test("primer detection align", function(assert) {
assert.deepEqual( clone.getBestMatchingSequence(primer3_ecngs_igh, []), [undefined, false],"seq full; primer3, no extend")
assert.deepEqual( clone.getBestMatchingSequence(primer3_ecngs_igh, [5]), ["GGTCACCGTCTCCTCAGGTAAG", true],"seq full; primer3, extend 5" )
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.equal( clone.getSegLengthDoubleFeature('primer5', 'primer3'), 249, "Correct length for genescan ecngs" ) // ~245
delete clone.seg["primer5"]
delete clone.seg["primer3"]
// Sequence with 5' and 3' deletion
......@@ -797,7 +804,14 @@ QUnit.test("primer detection align", function(assert) {
assert.deepEqual( clone.getBestMatchingSequence(primer3_ecngs_igh, []), [undefined, false], "seq short; primer3, no extend")
assert.deepEqual( clone.getBestMatchingSequence(primer3_ecngs_igh, [5]), ["GGTCACCGTCTCCTCAGGTAAG", true], "seq short; primer3, extend 5" )
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"]
});
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