Commit 3109af79 authored by marc duez's avatar marc duez

screen_mrd.js : regroup screen_mrd functions in an object and extend clone prototype with it

parent 5b372f16
Pipeline #188588 passed with stages
in 19 minutes and 5 seconds
...@@ -84,7 +84,6 @@ function loadAfterConf() { ...@@ -84,7 +84,6 @@ function loadAfterConf() {
"../tips", "../tips",
"../tokeniser", "../tokeniser",
"../indexedDom", "../indexedDom",
"../screen_MRD",
// Speed test // Speed test
"../speed_test", "../speed_test",
"../form_builder", "../form_builder",
...@@ -92,6 +91,7 @@ function loadAfterConf() { ...@@ -92,6 +91,7 @@ function loadAfterConf() {
"../vidjil_vmi", "../vidjil_vmi",
"../../test/QUnit/testFiles/data_test", "../../test/QUnit/testFiles/data_test",
], function(){ ], function(){
if (typeof main == "undefined"){ if (typeof main == "undefined"){
require(["../main"]); require(["../main"]);
}else{ }else{
...@@ -100,6 +100,8 @@ function loadAfterConf() { ...@@ -100,6 +100,8 @@ function loadAfterConf() {
if (typeof config.addons !== "undefined") { if (typeof config.addons !== "undefined") {
require(config.addons); require(config.addons);
} }
require(["../screen_MRD"]);
}) })
}) })
}, },
......
...@@ -36,124 +36,133 @@ UNIVERSAL_FAMILY = "UNI" ...@@ -36,124 +36,133 @@ UNIVERSAL_FAMILY = "UNI"
UNIVERSAL_COEFF = 'UNI_COEFF' UNIVERSAL_COEFF = 'UNI_COEFF'
UNIVERSAL_R2 = 'UNI_R2' UNIVERSAL_R2 = 'UNI_R2'
/**
* @return {string} the family used for fiting at the given time
*/
Clone.prototype.getFittingFamily = function(time) {
if (this.m.mrd.prevalent[time] == 0) {
// diagnostic sample
return "";
} else if (this.mrd != undefined && 'family' in this.mrd) {
return this.mrd.family[time];
} else {
// negative clone: report UNI
return UNIVERSAL_FAMILY;
}
};
function ScreenMRD() {}
/** ScreenMRD.prototype = {
* @return {string} the normalization coefficient at the given time
*/
Clone.prototype.getNormCoeff = function(time) {
if (this.m.mrd.prevalent[time] == 0) {
// diagnostic sample
return "";
} else if (this.mrd != undefined && 'norm_coeff' in this.mrd) {
return this.mrd.norm_coeff[time];
} else if (UNIVERSAL_COEFF in this.m.mrd) {
// negative clone:report UNI
return this.m.mrd.UNI_COEFF[time];
} else {
return "";
}
};
/** /**
* @return {string} the Pearson R2 value for the spike-in fitting at the given time * @return {string} the family used for fiting at the given time
*/ */
Clone.prototype.getR2 = function(time) { getFittingFamily : function(time) {
if (this.m.mrd.prevalent[time] == 0) { if (this.m.mrd.prevalent[time] == 0) {
// diagnostic sample // diagnostic sample
return ""; return "";
} else if (this.mrd != undefined && 'R2' in this.mrd) { } else if (this.mrd != undefined && 'family' in this.mrd) {
return this.mrd.R2[time]//.toString(); return this.mrd.family[time];
} else if (UNIVERSAL_R2 in this.m.mrd) { } else {
// negative clone: report UNI R2 // negative clone: report UNI
return this.m.mrd.UNI_R2[time]; return UNIVERSAL_FAMILY;
} else { }
return ""; },
}
};
/**
* @return {string} the prevalent germline at the given time
*/
Clone.prototype.getPrevalent = function(time) {
if (this.m.mrd.prevalent[time] == 0) {
// diagnostic sample
return "";
} else {
return this.m.mrd.prevalent[time];
}
};
/** /**
* @return {string} the amplification coefficient at the given time * @return {string} the normalization coefficient at the given time
* (ampl. coeff. = total prevalent / total spike) */
*/ getNormCoeff : function(time) {
Clone.prototype.getAmplCoeff = function(time) { if (this.m.mrd.prevalent[time] == 0) {
if (this.m.mrd.prevalent[time] == 0) { // diagnostic sample
// diagnostic sample return "";
} else if (this.mrd != undefined && 'norm_coeff' in this.mrd) {
return this.mrd.norm_coeff[time];
} else if (UNIVERSAL_COEFF in this.m.mrd) {
// negative clone:report UNI
return this.m.mrd.UNI_COEFF[time];
} else {
return "";
}
},
/**
* @return {string} the Pearson R2 value for the spike-in fitting at the given time
*/
getR2 : function(time) {
if (this.m.mrd.prevalent[time] == 0) {
// diagnostic sample
return "";
} else if (this.mrd != undefined && 'R2' in this.mrd) {
return this.mrd.R2[time]//.toString();
} else if (UNIVERSAL_R2 in this.m.mrd) {
// negative clone: report UNI R2
return this.m.mrd.UNI_R2[time];
} else {
return ""; return "";
} else if ('ampl_coeff' in this.m.mrd) { }
return this.m.mrd.ampl_coeff[time]//.toString(); },
} else {
return "Please use version 6 or later of spike-normalization";
} /**
}; * @return {string} the prevalent germline at the given time
*/
getPrevalent : function(time) {
if (this.m.mrd.prevalent[time] == 0) {
// diagnostic sample
return "";
} else {
return this.m.mrd.prevalent[time];
}
},
/** /**
* Return info about a sequence/clone in html * @return {string} the amplification coefficient at the given time
*/ * (ampl. coeff. = total prevalent / total spike)
Clone.prototype.getHtmlInfo_prevalent = function () { */
values = [] getAmplCoeff : function(time) {
if (this.m.mrd.prevalent[time] == 0) {
if ('mrd' in this) { // diagnostic sample
// this .vidjil file is not all-diagnostic: return "";
// show R2, etc, fields for follow-up samples } else if ('ampl_coeff' in this.m.mrd) {
content_fitting_family = [] return this.m.mrd.ampl_coeff[time]//.toString();
content_norm_coeff = [] } else {
content_getR2 = [] return "Please use version 6 or later of spike-normalization";
content_getPrevalent = [] }
content_getAmplCoeff = [] },
for (k = 0; k < this.m.samples.order.length; k++) {
var sample = this.m.samples.order[k]
/**
// Get prevalent value * Return info about a sequence/clone in html
var prevalent = this.getPrevalent(sample) */
if (prevalent != ""){ getHtmlInfo_prevalent : function () {
prevalent = this.m.systemBox(prevalent).outerHTML + prevalent values = []
}
content_getPrevalent.push( prevalent ) if ('mrd' in this) {
// this .vidjil file is not all-diagnostic:
// show R2, etc, fields for follow-up samples
content_fitting_family = []
content_norm_coeff = []
content_getR2 = []
content_getPrevalent = []
content_getAmplCoeff = []
for (k = 0; k < this.m.samples.order.length; k++) {
var sample = this.m.samples.order[k]
// Computed values // Get prevalent value
content_fitting_family.push( this.getFittingFamily(sample) ) var prevalent = this.getPrevalent(sample)
content_norm_coeff.push( this.getNormCoeff(sample)) if (prevalent != ""){
content_getR2.push( this.getR2(sample) ) prevalent = this.m.systemBox(prevalent).outerHTML + prevalent
content_getAmplCoeff.push( this.getAmplCoeff(sample) ) }
content_getPrevalent.push( prevalent )
// Computed values
content_fitting_family.push( this.getFittingFamily(sample) )
content_norm_coeff.push( this.getNormCoeff(sample))
content_getR2.push( this.getR2(sample) )
content_getAmplCoeff.push( this.getAmplCoeff(sample) )
}
// include values into html
// name of col, values to show, and DOM id for cells
values.push(["prevalent germline", content_getPrevalent, "mrd_prevalent"])
values.push(["family used for fitting", content_fitting_family, "mrd_family"])
values.push(["normalization coefficient", content_norm_coeff, "mrd_norm_coeff"])
values.push(["Pearson R2", content_getR2, "mrd_pearson"])
values.push(["total prevalent / total spikes", content_getAmplCoeff, "mrd_prevalent_on_spike"])
} }
// include values into html
// name of col, values to show, and DOM id for cells return values
values.push(["prevalent germline", content_getPrevalent, "mrd_prevalent"])
values.push(["family used for fitting", content_fitting_family, "mrd_family"])
values.push(["normalization coefficient", content_norm_coeff, "mrd_norm_coeff"])
values.push(["Pearson R2", content_getR2, "mrd_pearson"])
values.push(["total prevalent / total spikes", content_getAmplCoeff, "mrd_prevalent_on_spike"])
} }
return values }
};
Clone.prototype = $.extend(Object.create(ScreenMRD.prototype), Clone.prototype);
\ No newline at end of file
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