Commit 5ac26e1b authored by Mikaël Salson's avatar Mikaël Salson
Browse files

Clone.js: 'end' keys are changed to 'stop' in the seg field

parent 4ab8f18c
......@@ -602,6 +602,9 @@ Model_loader.prototype = {
} else {
newSeg[key] = seg[key];
}
if (typeof newSeg[key] == 'object') {
newSeg[key] = this.getConvertedSegNames(newSeg[key])
}
}
return newSeg;
},
......@@ -620,6 +623,23 @@ Model_loader.prototype = {
return newSeg;
},
/**
* Convert fields from old names to new names.
* For instance some fields were called 'end', they now must be 'stop' (see bc32af9)
* We convert all of them.
*/
getConvertedSegNames: function(seg) {
var renameFields = {'end': 'stop'}
for (field in renameFields) {
if (typeof seg[field] != 'undefined'
&& typeof seg[renameFields[field]] == 'undefined') {
seg[renameFields[field]] = seg[field]
delete seg[field]
}
}
return seg
},
getConvertedBoundary: function(seg, key, bound) {
var newSeg;
if (typeof seg[key+bound] != 'undefined') {
......
......@@ -11,10 +11,10 @@
"4" : "IGHD2*03",
'_evalue': 1e-2,
"3start" : 15,
"5end" : 5,
"5" : {'start': 1, 'end': 5},
"cdr3": {
"start": 10,
"stop": 15,
"end": 15,
"aa": "ABCDE"
},
"junction": {
......
......@@ -9,10 +9,11 @@ test("model: convert", function () {
"3": "J",
"4": "D",
"5": {"name": "V", "stop": 0},
"cdr3": {"start": 0, "stop": 3}
"cdr3": {"start": 0, "end": 3}
};
equal(m.getConvertedBoundary(json_clone3.seg, "5", "end"), 5, "getConvertedBoundary existant: Ok");
equal(typeof m.getConvertedBoundary(json_clone3.seg, "5", "start"), 'undefined', "getConvertedBoundary non existant: Ok");
deepEqual(m.getConvertedSegNames(seg['cdr3']), {"start": 0, "stop": 3}, "getConvertedSegNames: ok")
deepEqual(m.getConvertedSeg(seg, "3"), {"name": "J", "start": 3}, "getConvertedSeg: Ok");
......
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