Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit 6d796962 authored by Mikaël Salson's avatar Mikaël Salson

clone: More generic access to seg fields

Several methods are defined to acces the seg fields.
Hence the getCDR3length is useless now as the same can be achieved by
calling getSegLength('cdr3').
parent 398e7898
......@@ -127,6 +127,58 @@ Clone.prototype = {
return short_name_items.join(' ')
},
/**
* Get the amino-acid sequence of the provided field (in the seg part)
*/
getSegAASequence: function(field_name) {
if (typeof this.seg != 'undefined'
&& typeof this.seg[field_name] != 'undefined'
&& typeof this.seg[field_name].aa != 'undefined') {
return this.seg[field_name].aa;
}
return '';
},
/**
* Get the nucleotide sequence (extracted from the start and stop fields)
*/
getSegNtSequence: function(field_name) {
positions = this.getSegStartStop(field_name)
if (positions != null) {
return this.sequence.substr(positions['start'], positions['stop'] - positions['start']+1)
}
return '';
},
/**
* Return the length of the given field_name in seg
* (difference between the stop and the start).
* If no start and stop are given, return 0
*/
getSegLength: function(field_name) {
positions = this.getSegStartStop(field_name)
if (positions != null) {
return positions['stop'] - positions['start'] + 1
} else {
return 0;
}
},
/**
* Get the start and stop position of a given field (e.g. cdr3)
* If it does not exist return null
*/
getSegStartStop: function(field_name) {
if (typeof this.seg != 'undefined'
&& typeof this.seg[field_name] != 'undefined'
&& typeof this.seg[field_name].start != 'undefined'
&& typeof this.seg[field_name].stop != 'undefined') {
return {'start': this.seg[field_name].start,
'stop': this.seg[field_name].stop}
}
return null;
},
/**
* return clone's most important name <br>
* cluster name > custom_name > segmentation name > window
......@@ -173,19 +225,7 @@ Clone.prototype = {
return this.id;
}
}, //end getCode
getCDR3length: function() {
if (typeof(this.seg) != 'undefined'
&& typeof (this.seg['cdr3']) != 'undefined'
&& typeof (this.seg['cdr3'].start) != 'undefined'
&& typeof (this.seg['cdr3'].stop) != 'undefined') {
return this.seg["cdr3"].stop - this.seg["cdr3"].start + 1
} else {
return 0;
}
},
/**
* change/add custom name
* @param {string} name
......
......@@ -140,7 +140,7 @@ function ScatterPlot(id, model) {
},
"lengthCDR3": {
label: "CDR3 length",
fct: function(cloneID) {return self.m.clone(cloneID).getCDR3length()}
fct: function(cloneID) {return self.m.clone(cloneID).getSegLength('cdr3')}
},
"coverage": {
label: "clone consensus coverage",
......
......@@ -10,7 +10,17 @@
"3" : "IGHV4*01",
"4" : "IGHD2*03",
"3start" : 15,
"5end" : 5
"5end" : 5,
"cdr3": {
"start": 10,
"stop": 15,
"aa": "ABCDE"
},
"junction": {
"start": 9,
"stop": 11,
"productive": true
}
}
}
......@@ -37,7 +47,12 @@
"3" : "IGHV4*01",
"4" : "IGHD2*03",
"3start" : 15,
"5end" : 5
"5end" : 5,
"junction": {
"start": 2,
"stop": 13,
"productive": false
}
}
}
......@@ -152,6 +167,33 @@ test("clone : name, informations, getHtmlInfo", function() {
});
test('clone: get info from seg', function() {
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
var c2 = new Clone(json_clone2, m, 1)
var c3 = new Clone(json_clone3, m, 2)
m.initClones()
equal(c1.getSegLength('cdr3'), 6, "CDR3 length");
equal(c2.getSegLength('cdr3'), 0, "no cdr3 in c2");
var pos_cdr3 = c1.getSegStartStop('cdr3')
equal(pos_cdr3['start'], 10, "CDR3 length")
equal(pos_cdr3['stop'], 15, "CDR3 length")
equal(c1.getSegStartStop('toto'), null, "no toto record")
var pos_junction = c3.getSegStartStop('junction')
equal(pos_junction['start'], 2, "junction of c3")
equal(pos_junction['stop'], 13, "junction of c3")
pos_junction = c1.getSegStartStop('junction')
equal(pos_junction['start'], 9, "start junction of c1")
equal(pos_junction['stop'], 11, "stop junction of c1")
equal(c1.getSegNtSequence('junction'), 'aat', 'junction c1')
equal(c1.getSegAASequence('junction'), '', 'no AA junction for c1')
equal(c1.getSegAASequence('cdr3'), 'ABCDE', 'AA CDR3 for c1')
});
test("clone : getSequence/RevComp", function() {
var m = new Model();
......
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