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

clone.js: hasSeg()

this.seg was always defined (to an empty object) therefore testing
whether its type is undefined was useless.
Instead we rely on a method in Clone to know whether the seg field is defined.
parent 07f5a7a9
......@@ -99,7 +99,7 @@ Axis.prototype = {
//clone position
this.pos = function(cloneID) {
var clone = self.m.clone(cloneID)
if (typeof clone.seg != "undefined"
if (clone.hasSeg()
&& typeof clone.seg[type2] != "undefined"
&& typeof clone.seg[type2]["name"] != 'undefined'
&& typeof gene_list[clone.seg[type2]["name"].split("*")[0]] != "undefined")
......
......@@ -142,7 +142,7 @@ Clone.prototype = {
* Get the amino-acid sequence of the provided field (in the seg part)
*/
getSegAASequence: function(field_name) {
if (typeof this.seg != 'undefined'
if (this.hasSeg()
&& typeof this.seg[field_name] != 'undefined'
&& typeof this.seg[field_name].aa != 'undefined') {
return this.seg[field_name].aa;
......@@ -180,7 +180,7 @@ Clone.prototype = {
* If it does not exist return null
*/
getSegStartStop: function(field_name) {
if (typeof this.seg != 'undefined'
if (this.hasSeg()
&& typeof this.seg[field_name] != 'undefined'
&& typeof this.seg[field_name].start != 'undefined'
&& typeof this.seg[field_name].stop != 'undefined') {
......@@ -501,6 +501,10 @@ Clone.prototype = {
}, //end getSize
hasSeg: function() {
return typeof(this.seg) != 'undefined' && ! $.isEmptyObject(this.seg)
},
computeEValue: function () {
var e = this.seg['evalue'];
if (typeof(e) != 'undefined')
......@@ -511,7 +515,7 @@ Clone.prototype = {
getGene: function (type, withAllele) {
withAllele = typeof withAllele !== 'undefined' ? withAllele : true;
if (typeof (this.seg) != 'undefined' && typeof (this.seg[type]) != 'undefined' && typeof this.seg[type]["name"] != 'undefined') {
if (this.hasSeg() && typeof (this.seg[type]) != 'undefined' && typeof this.seg[type]["name"] != 'undefined') {
if (withAllele) {
return this.seg[type]["name"];
}else{
......@@ -530,7 +534,7 @@ Clone.prototype = {
},
getNlength: function () {
if (typeof this.seg != 'undefined' && typeof this.seg['3'] != 'undefined' && typeof this.seg['5'] != 'undefined'){
if (this.hasSeg() && typeof this.seg['3'] != 'undefined' && typeof this.seg['5'] != 'undefined'){
return this.seg['3']['start']-this.seg['5']['stop']-1
}else{
return 'undefined'
......@@ -566,7 +570,7 @@ Clone.prototype = {
},
getPrintableSegSequence: function () {
if (typeof this.seg == 'undefined' || typeof this.seg['5'] == 'undefined' || typeof this.seg['3'] == 'undefined') {
if (! this.hasSeg() || typeof this.seg['5'] == 'undefined' || typeof this.seg['3'] == 'undefined') {
return this.getSequence()
}
......@@ -696,7 +700,7 @@ Clone.prototype = {
}else if (this.m.colorMethod == "system") {
this.color = this.m.germlineList.getColor(this.germline)
} else if (this.m.colorMethod == 'productive') {
if (typeof this.seg != 'undefined'
if (this.hasSeg()
&& typeof this.seg.junction != 'undefined'
&& typeof this.seg.junction.productive != 'undefined') {
this.color = colorProductivity(this.seg.junction.productive)
......
......@@ -710,7 +710,7 @@ Report.prototype = {
//colorized clone sequence
var sequence = $('<div/>', {'class': 'sequence'}).appendTo(clone);
if (typeof this.m.clone(cloneID).seg != 'undefined'){
if (typeof this.m.clone(cloneID).hasSeg()){
var seg = this.m.clone(cloneID).seg
var seq = this.m.clone(cloneID).getSequence()
var seqV = seq.substring(0, seg['5']['stop'] + 1)
......
......@@ -178,7 +178,7 @@ Germline.prototype = {
//and add undetected genes (missing from germline)
var g = {}
for (var i=0; i<this.m.clones.length; i++){
if (typeof this.m.clone(i).seg != "undefined" &&
if (typeof this.m.clone(i).hasSeg() != "undefined" &&
typeof this.m.clone(i).seg[type2] != "undefined" &&
typeof this.m.clone(i).seg[type2]["name"] != "undefined"
){
......
......@@ -712,7 +712,7 @@ Model_loader.prototype = {
var count = 0;
for (var i in this.clones){
if (typeof this.clones[i].seg != "undefined" && typeof this.clones[i].seg.quality != "undefined"){
if (typeof this.clones[i].hasSeg() && typeof this.clones[i].seg.quality != "undefined"){
var s = this.clones[i].seg.quality.seq;
for (var j in s){
if (s[j] != "!"){
......
......@@ -874,7 +874,7 @@ Segment.prototype = {
}
// In the .seg element, What looks like DNA sequence or what is a Pos field
if (typeof clone.seg != 'undefined'){
if (clone.hasSeg()){
for (var i in clone.seg) {
if (! forbidden_fields.includes(i) &&(this.isDNA(clone.seg[i]) || this.isPos(clone.seg[i])) ){
if (result.indexOf(i) == -1) result.push(i);
......@@ -1044,7 +1044,7 @@ Sequence.prototype = {
var stop = -1;
var clone = this.m.clone(this.id);
if (typeof clone.seg != "undefined" && typeof clone.seg["cdr3"] != "undefined"){
if (clone.hasSeg() && typeof clone.seg["cdr3"] != "undefined"){
if (typeof clone.seg["cdr3"].start != "undefined") {
start = this.pos[clone.seg["cdr3"].start];
stop = this.pos[clone.seg["cdr3"].stop];
......@@ -1112,7 +1112,7 @@ Sequence.prototype = {
if (typeof clone.sequence != 'undefined' && clone.sequence != 0) {
//find V, D, J position
if (typeof clone.seg != 'undefined'){
if (clone.hasSeg()){
var vdjArray = this.getVdjStartEnd(clone);
var vdjArrayRev = {};
......@@ -1139,7 +1139,7 @@ Sequence.prototype = {
}
var window_start = this.pos[clone.sequence.indexOf(clone.id)];
if (typeof clone.seg != "undefined" && typeof clone.seg["cdr3"] != "undefined"){
if (clone.hasSeg() && typeof clone.seg["cdr3"] != "undefined"){
if (clone.seg["cdr3"].start != "undefined"){
window_start = this.pos[clone.seg["cdr3"].start];
}else if (clone.seg["cdr3"].constructor === String){
......@@ -1260,7 +1260,7 @@ Sequence.prototype = {
// Find the good object p
if (typeof clone[field] != 'undefined'){
p = clone[field]; //check clone meta-data
}else if (typeof clone.seg != 'undefined' && typeof clone.seg[field] != 'undefined'){
}else if (clone.hasSeg() && typeof clone.seg[field] != 'undefined'){
p = clone.seg[field]; //check clone seg data
}else if (typeof this.m[field] != 'undefined'){
p = this.m[field]; //check 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