Commit 8057f332 authored by Marc Duez's avatar Marc Duez

browser : replace windows with clones object

parent 8d9c9b2b
...@@ -139,7 +139,7 @@ Axis.prototype = { ...@@ -139,7 +139,7 @@ Axis.prototype = {
var n_min = 0; var n_min = 0;
var n_max = 1; var n_max = 1;
for (var i=0; i<this.m.n_windows; i++){ for (var i=0; i<this.m.n_clones; i++){
if (this.m.clone(i).Nlength > n_max) n_max = this.m.clone(i).Nlength; if (this.m.clone(i).Nlength > n_max) n_max = this.m.clone(i).Nlength;
} }
......
...@@ -112,7 +112,7 @@ Builder.prototype = { ...@@ -112,7 +112,7 @@ Builder.prototype = {
normalize_list.appendChild(document.createTextNode("none")) normalize_list.appendChild(document.createTextNode("none"))
normalize_list.appendChild(document.createElement("br")) normalize_list.appendChild(document.createElement("br"))
for (var i=0; i<self.m.n_windows; i++){ for (var i=0; i<self.m.n_clones; i++){
if (typeof self.m.clone(i).expected != "undefined"){ if (typeof self.m.clone(i).expected != "undefined"){
var input = document.createElement("input") var input = document.createElement("input")
var text = document.createTextNode(self.m.clone(i).getName() + " => " +self.m.clone(i).expected) var text = document.createTextNode(self.m.clone(i).getName() + " => " +self.m.clone(i).expected)
...@@ -357,7 +357,7 @@ Builder.prototype = { ...@@ -357,7 +357,7 @@ Builder.prototype = {
//init slider //init slider
var max_top = 0; var max_top = 0;
for (var i = 0; i < this.m.n_windows; i++) { for (var i = 0; i < this.m.n_clones; i++) {
if (this.m.clone(i).top > max_top) if (this.m.clone(i).top > max_top)
max_top = this.m.clone(i).top max_top = this.m.clone(i).top
} }
...@@ -410,7 +410,7 @@ Builder.prototype = { ...@@ -410,7 +410,7 @@ Builder.prototype = {
var clusterSelector = document.getElementById("clusterby_button") var clusterSelector = document.getElementById("clusterby_button")
clusterSelector.innerHTML = ""; clusterSelector.innerHTML = "";
if (self.m.windows[0]._target){ if (self.m.clones[0]._target){
var target = document.createElement('a'); var target = document.createElement('a');
target.className = "buttonSelector" target.className = "buttonSelector"
...@@ -437,7 +437,7 @@ Builder.prototype = { ...@@ -437,7 +437,7 @@ Builder.prototype = {
clusterSelector.appendChild(clonotype) clusterSelector.appendChild(clonotype)
} }
if (self.m.windows[0].system){ if (self.m.clones[0].system){
var system = document.createElement('a'); var system = document.createElement('a');
system.className = "buttonSelector" system.className = "buttonSelector"
......
...@@ -64,7 +64,7 @@ Clone.prototype = { ...@@ -64,7 +64,7 @@ Clone.prototype = {
} }
}, },
/* compute the clone size ( sum of all windows clustered ) /* compute the clone size ( sum of all clones clustered )
* @t : tracking point (default value : current tracking point) * @t : tracking point (default value : current tracking point)
* */ * */
getSize: function (time) { getSize: function (time) {
...@@ -107,7 +107,7 @@ Clone.prototype = { ...@@ -107,7 +107,7 @@ Clone.prototype = {
}, //end getSequenceSize }, //end getSequenceSize
/* compute the clone reads number ( sum of all reads of windows clustered ) /* compute the clone reads number ( sum of all reads of clones clustered )
* @t : tracking point (default value : current tracking point) * @t : tracking point (default value : current tracking point)
* */ * */
getReads: function (time) { getReads: function (time) {
......
...@@ -50,7 +50,7 @@ Germline.prototype = { ...@@ -50,7 +50,7 @@ Germline.prototype = {
//reduce germline size (keep only detected genes) //reduce germline size (keep only detected genes)
//and add undetected genes //and add undetected genes
var g = {} var g = {}
for (var i=0; i<this.m.n_windows; i++){ for (var i=0; i<this.m.n_clones; i++){
if (typeof this.m.clone(i)[type] != "undefined" if (typeof this.m.clone(i)[type] != "undefined"
&& typeof this.m.clone(i)[type][0] != "undefined"){ && typeof this.m.clone(i)[type][0] != "undefined"){
var gene=this.m.clone(i)[type][0]; var gene=this.m.clone(i)[type][0];
......
...@@ -136,7 +136,7 @@ Graph.prototype = { ...@@ -136,7 +136,7 @@ Graph.prototype = {
this.initAxis(); this.initAxis();
for (var i = 0; i < this.m.n_windows; i++) { for (var i = 0; i < this.m.n_clones; i++) {
this.data_graph[i] = { this.data_graph[i] = {
id: i, id: i,
name: "line" + i, name: "line" + i,
...@@ -153,13 +153,13 @@ Graph.prototype = { ...@@ -153,13 +153,13 @@ Graph.prototype = {
} }
this.data_res.push({ this.data_res.push({
id: this.m.n_windows, id: this.m.n_clones,
name: "resolution1", name: "resolution1",
path: this.constructPathR(this.resolution1) path: this.constructPathR(this.resolution1)
}); });
this.data_res.push({ this.data_res.push({
id: this.m.n_windows + 1, id: this.m.n_clones + 1,
name: "resolution5", name: "resolution5",
path: this.constructPathR(this.resolution5) path: this.constructPathR(this.resolution5)
}); });
...@@ -398,12 +398,12 @@ Graph.prototype = { ...@@ -398,12 +398,12 @@ Graph.prototype = {
this.data_res[0].path = this.constructPathR(this.resolution1); this.data_res[0].path = this.constructPathR(this.resolution1);
this.data_res[1].path = this.constructPathR(this.resolution5); this.data_res[1].path = this.constructPathR(this.resolution5);
for (var i = 0; i < this.m.n_windows; i++) { for (var i = 0; i < this.m.n_clones; i++) {
for (var j = 0; j < this.m.clusters[i].length; j++) { for (var j = 0; j < this.m.clusters[i].length; j++) {
this.data_graph[this.m.clusters[i][j]].path = this.constructPath(i, false); this.data_graph[this.m.clusters[i][j]].path = this.constructPath(i, false);
} }
} }
for (var i = 0; i < this.m.n_windows; i++) { for (var i = 0; i < this.m.n_clones; i++) {
var cloneID = i var cloneID = i
for (var j = 0; j < this.m.clusters[cloneID].length; j++) { for (var j = 0; j < this.m.clusters[cloneID].length; j++) {
var seqID = this.m.clusters[cloneID][j] var seqID = this.m.clusters[cloneID][j]
...@@ -892,11 +892,11 @@ Stack.prototype = { ...@@ -892,11 +892,11 @@ Stack.prototype = {
this.total_size = []; this.total_size = [];
for (j=0; j<this.m.samples.number; j++){ for (j=0; j<this.m.samples.number; j++){
this.total_size[j]=0 this.total_size[j]=0
for (i=0; i<this.m.n_windows; i++){ for (i=0; i<this.m.n_clones; i++){
if (this.m.clone(i).isActive()) this.total_size[j] += this.m.clone(i).getSize(j); //active clones if (this.m.clone(i).isActive()) this.total_size[j] += this.m.clone(i).getSize(j); //active clones
} }
this.total_size[j] += this.m.clone(this.m.windows.length-1).getSize(j);//other clones this.total_size[j] += this.m.clone(this.m.clones.length-1).getSize(j);//other clones
} }
}, },
...@@ -909,7 +909,7 @@ Stack.prototype = { ...@@ -909,7 +909,7 @@ Stack.prototype = {
this.sum[j]=1 this.sum[j]=1
} }
for (i=0; i<this.m.n_windows; i++){ for (i=0; i<this.m.n_clones; i++){
this.min[i] = [] this.min[i] = []
this.max[i] = [] this.max[i] = []
//active clones //active clones
...@@ -929,9 +929,9 @@ Stack.prototype = { ...@@ -929,9 +929,9 @@ Stack.prototype = {
//other //other
for (j=0; j<this.m.samples.number; j++){ for (j=0; j<this.m.samples.number; j++){
this.min[this.m.windows.length-1][j] = this.sum[j] this.min[this.m.clones.length-1][j] = this.sum[j]
this.sum[this.m.windows.length-1] += this.m.clone(this.m.windows.length-1).getSize(j) this.sum[this.m.clones.length-1] += this.m.clone(this.m.clones.length-1).getSize(j)
this.max[this.m.windows.length-1][j] = this.sum[j] this.max[this.m.clones.length-1][j] = this.sum[j]
} }
}, },
......
...@@ -60,7 +60,7 @@ List.prototype = { ...@@ -60,7 +60,7 @@ List.prototype = {
var div_list_clones = document.createElement('div') var div_list_clones = document.createElement('div')
div_list_clones.id = "list_clones" div_list_clones.id = "list_clones"
for (var i = 0; i < this.m.n_windows; i++) { for (var i = 0; i < this.m.n_clones; i++) {
var div = document.createElement('li'); var div = document.createElement('li');
div.className = "list"; div.className = "list";
div.id = i; div.id = i;
...@@ -158,7 +158,7 @@ List.prototype = { ...@@ -158,7 +158,7 @@ List.prototype = {
var startTime = new Date() var startTime = new Date()
.getTime(); .getTime();
var elapsedTime = 0; var elapsedTime = 0;
for (var i = 0; i < this.m.n_windows; i++) { for (var i = 0; i < this.m.n_clones; i++) {
this.updateElem([i]); this.updateElem([i]);
} }
elapsedTime = new Date() elapsedTime = new Date()
...@@ -472,7 +472,7 @@ List.prototype = { ...@@ -472,7 +472,7 @@ List.prototype = {
}, },
reset_filter: function (bool) { reset_filter: function (bool) {
for (var i=0; i<this.m.n_windows; i++){ for (var i=0; i<this.m.n_clones; i++){
var c = this.m.clone(i) var c = this.m.clone(i)
c.isFiltered=bool c.isFiltered=bool
} }
...@@ -480,7 +480,7 @@ List.prototype = { ...@@ -480,7 +480,7 @@ List.prototype = {
filter: function (str) { filter: function (str) {
this.reset_filter(true) this.reset_filter(true)
for (var i=0; i<this.m.n_windows; i++){ for (var i=0; i<this.m.n_clones; i++){
var c = this.m.clone(i) var c = this.m.clone(i)
if (c.getName().toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false if (c.getName().toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false
if (c.getSequence().toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false if (c.getSequence().toUpperCase().indexOf(str.toUpperCase())!=-1 ) c.isFiltered = false
......
...@@ -78,7 +78,7 @@ Model.prototype = { ...@@ -78,7 +78,7 @@ Model.prototype = {
this.precision = 1; this.precision = 1;
this.isPlaying = false; this.isPlaying = false;
this.clusters = []; this.clusters = [];
this.windows = []; this.clones = [];
this.germline = {} this.germline = {}
this.germlineV = new Germline(this) this.germlineV = new Germline(this)
this.germlineD = new Germline(this) this.germlineD = new Germline(this)
...@@ -228,44 +228,44 @@ Model.prototype = { ...@@ -228,44 +228,44 @@ Model.prototype = {
parseJsonData: function (data, limit) { parseJsonData: function (data, limit) {
self = this; self = this;
self.windows = []; self.clones = [];
self.links = []; self.links = [];
self.mapID = {} self.mapID = {}
self.dataCluster = [] self.dataCluster = []
var min_sizes = []; var min_sizes = [];
var n_max = 0; var n_max = 0;
for (var k = 0; k < data.windows[0].size.length; k++) { for (var k = 0; k < data.clones[0].size.length; k++) {
min_sizes[k] = 0.01; min_sizes[k] = 0.01;
} }
var hash = 0 var hash = 0
//keep best top value //keep best top value
for (var i = 0; i < data.windows.length; i++) { for (var i = 0; i < data.clones.length; i++) {
if (data.windows[i].top <= limit) { if (data.clones[i].top <= limit) {
//search for min_size //search for min_size
for (var k = 0; k < data.windows[i].size.length; k++) { for (var k = 0; k < data.clones[i].size.length; k++) {
var size = (data.windows[i].size[k] / data.reads.segmented[k]) var size = (data.clones[i].size[k] / data.reads.segmented[k])
if (min_sizes[k] > size && data.windows[i].size[k] != 0) if (min_sizes[k] > size && data.clones[i].size[k] != 0)
min_sizes[k] = size; min_sizes[k] = size;
} }
data.windows[i].Nlength = 0; data.clones[i].Nlength = 0;
if ((typeof (data.windows[i].Jstart) != 'undefined') && if ((typeof (data.clones[i].Jstart) != 'undefined') &&
(typeof (data.windows[i].Vend) != 'undefined') ) { (typeof (data.clones[i].Vend) != 'undefined') ) {
data.windows[i].Nlength = data.windows[i].Jstart - data.windows[i].Vend data.clones[i].Nlength = data.clones[i].Jstart - data.clones[i].Vend
} }
//search for n_max //search for n_max
if ((typeof (data.windows[i].sequence) != 'undefined') && if ((typeof (data.clones[i].sequence) != 'undefined') &&
(typeof (data.windows[i].Nlength) != 'undefined') && (typeof (data.clones[i].Nlength) != 'undefined') &&
(data.windows[i].Nlength > n_max)) { (data.clones[i].Nlength > n_max)) {
n_max = data.windows[i].Nlength; n_max = data.clones[i].Nlength;
} }
var clone = new Clone(data.windows[i], self, hash) var clone = new Clone(data.clones[i], self, hash)
self.windows.push(clone); self.clones.push(clone);
hash++ hash++
} }
} }
...@@ -282,7 +282,7 @@ Model.prototype = { ...@@ -282,7 +282,7 @@ Model.prototype = {
"size": [] "size": []
} }
var clone = new Clone(other, self, hash) var clone = new Clone(other, self, hash)
self.windows.push(clone); self.clones.push(clone);
// default samples // default samples
if (typeof self.samples.number == 'string'){ if (typeof self.samples.number == 'string'){
...@@ -297,7 +297,7 @@ Model.prototype = { ...@@ -297,7 +297,7 @@ Model.prototype = {
for (var i = 0; i < self.samples.number; i++) self.samples.names.push(""); for (var i = 0; i < self.samples.number; i++) self.samples.names.push("");
} }
self.n_windows = self.windows.length; self.n_clones = self.clones.length;
self.min_sizes = min_sizes; self.min_sizes = min_sizes;
self.n_max = n_max; self.n_max = n_max;
self.system_selected = []; self.system_selected = [];
...@@ -326,8 +326,8 @@ Model.prototype = { ...@@ -326,8 +326,8 @@ Model.prototype = {
self.system = germline_list[0]; self.system = germline_list[0];
} }
for (var i = 0; i < self.n_windows; i++) { for (var i = 0; i < self.n_clones; i++) {
self.mapID[self.windows[i].window] = i; self.mapID[self.clones[i].window] = i;
} }
return this return this
...@@ -431,7 +431,7 @@ Model.prototype = { ...@@ -431,7 +431,7 @@ Model.prototype = {
} }
if (this.system == "multi"){ if (this.system == "multi"){
for ( var i=0; i<this.n_windows; i++){ for ( var i=0; i<this.n_clones; i++){
var clone = this.clone(i) var clone = this.clone(i)
if (clone.getSystem() == system) { if (clone.getSystem() == system) {
if (clone[gene] && clone[gene][0]){ if (clone[gene] && clone[gene][0]){
...@@ -441,7 +441,7 @@ Model.prototype = { ...@@ -441,7 +441,7 @@ Model.prototype = {
} }
}else{ }else{
for (var i=0; i<this.n_windows; i++){ for (var i=0; i<this.n_clones; i++){
var clone = this.clone(i) var clone = this.clone(i)
if (clone[gene] && clone[gene][0]){ if (clone[gene] && clone[gene][0]){
list[clone[gene][0]]=0 list[clone[gene][0]]=0
...@@ -500,7 +500,7 @@ Model.prototype = { ...@@ -500,7 +500,7 @@ Model.prototype = {
this.clusters = []; this.clusters = [];
// NSIZE // NSIZE
for (var i = 0; i < this.n_windows; i++) { for (var i = 0; i < this.n_clones; i++) {
var clone = this.clone(i) var clone = this.clone(i)
if (typeof (clone.getSequence()) != 'undefined') { if (typeof (clone.getSequence()) != 'undefined') {
...@@ -518,7 +518,7 @@ Model.prototype = { ...@@ -518,7 +518,7 @@ Model.prototype = {
} }
// COLOR_N // COLOR_N
for (var i = 0; i < this.n_windows; i++) { for (var i = 0; i < this.n_clones; i++) {
var clone = this.clone(i) var clone = this.clone(i)
clone.colorN = colorGenerator((((clone.Nlength / maxNlength) - 1) * (-250)), color_s, color_v); clone.colorN = colorGenerator((((clone.Nlength / maxNlength) - 1) * (-250)), color_s, color_v);
} }
...@@ -526,7 +526,7 @@ Model.prototype = { ...@@ -526,7 +526,7 @@ Model.prototype = {
this.computeColor() this.computeColor()
// SHORTNAME // SHORTNAME
for (var i = 0; i < this.n_windows; i++) { for (var i = 0; i < this.n_clones; i++) {
var clone = this.clone(i) var clone = this.clone(i)
if (typeof (clone.getSequence()) != 'undefined' && typeof (clone.name) != 'undefined') { if (typeof (clone.getSequence()) != 'undefined' && typeof (clone.name) != 'undefined') {
clone.shortName = clone.name.replace(new RegExp('IGHV', 'g'), "VH"); clone.shortName = clone.name.replace(new RegExp('IGHV', 'g'), "VH");
...@@ -543,7 +543,7 @@ Model.prototype = { ...@@ -543,7 +543,7 @@ Model.prototype = {
computeColor: function(){ computeColor: function(){
// COLOR_V // COLOR_V
for (var i = 0; i < this.n_windows; i++) { for (var i = 0; i < this.n_clones; i++) {
var clone = this.clone(i) var clone = this.clone(i)
if (typeof (clone.V) != 'undefined' && this.germlineV.allele[clone.V[0]]) { if (typeof (clone.V) != 'undefined' && this.germlineV.allele[clone.V[0]]) {
...@@ -555,7 +555,7 @@ Model.prototype = { ...@@ -555,7 +555,7 @@ Model.prototype = {
} }
// COLOR_J // COLOR_J
for (var i = 0; i < this.n_windows; i++) { for (var i = 0; i < this.n_clones; i++) {
var clone = this.clone(i) var clone = this.clone(i)
if (typeof (clone.J) != 'undefined' && this.germlineJ.allele[clone.J[0]]) { if (typeof (clone.J) != 'undefined' && this.germlineJ.allele[clone.J[0]]) {
...@@ -615,7 +615,7 @@ Model.prototype = { ...@@ -615,7 +615,7 @@ Model.prototype = {
max.id = id max.id = id
} }
}else{ }else{
myConsole.log(" apply analysis : windows "+ c[i].window + " > incorrect expected value", 0) myConsole.log(" apply analysis : clones "+ c[i].window + " > incorrect expected value", 0)
} }
}else{ }else{
if (typeof (c[i].tag) != "undefined") { if (typeof (c[i].tag) != "undefined") {
...@@ -651,7 +651,7 @@ Model.prototype = { ...@@ -651,7 +651,7 @@ Model.prototype = {
*/ */
findWindow: function (sequence) { findWindow: function (sequence) {
if (sequence != 0){ if (sequence != 0){
for ( var i=0; i<this.n_windows; i++ ){ for ( var i=0; i<this.n_clones; i++ ){
if ( sequence.indexOf(this.clone(i).window) != -1 ) return i if ( sequence.indexOf(this.clone(i).window) != -1 ) return i
} }
} }
...@@ -692,7 +692,7 @@ Model.prototype = { ...@@ -692,7 +692,7 @@ Model.prototype = {
tags : {} tags : {}
} }
for (var i = 0; i < this.n_windows; i++) { for (var i = 0; i < this.n_clones; i++) {
var clone = this.clone(i) var clone = this.clone(i)
//tag, custom name, expected_value //tag, custom name, expected_value
...@@ -1027,7 +1027,7 @@ Model.prototype = { ...@@ -1027,7 +1027,7 @@ Model.prototype = {
* */ * */
getSelected: function () { getSelected: function () {
var result = [] var result = []
for (var i = 0; i < this.n_windows; i++) { for (var i = 0; i < this.n_clones; i++) {
if (this.clone(i).isSelected()) { if (this.clone(i).isSelected()) {
result.push(i); result.push(i);
} }
...@@ -1065,7 +1065,7 @@ Model.prototype = { ...@@ -1065,7 +1065,7 @@ Model.prototype = {
select: function (cloneID) { select: function (cloneID) {
myConsole.log("select() (clone " + cloneID + ")"); myConsole.log("select() (clone " + cloneID + ")");
if (cloneID == (this.n_windows - 1)) return 0 if (cloneID == (this.n_clones - 1)) return 0
if (this.clone(cloneID).isSelected()) { if (this.clone(cloneID).isSelected()) {
return; return;
...@@ -1143,7 +1143,7 @@ Model.prototype = { ...@@ -1143,7 +1143,7 @@ Model.prototype = {
nlist.splice(index, 1); nlist.splice(index, 1);
//le clone retrouve sa liste de windows -1 //le clone retrouve sa liste de clones -1
this.clusters[cloneID] = nlist; this.clusters[cloneID] = nlist;
//la window forme son propre clone a part //la window forme son propre clone a part
this.clusters[windowID] = [windowID]; this.clusters[windowID] = [windowID];
...@@ -1188,15 +1188,15 @@ Model.prototype = { ...@@ -1188,15 +1188,15 @@ Model.prototype = {
// unactive clones from unselected system // unactive clones from unselected system
if (this.system == "multi" && this.system_selected.length != 0) { if (this.system == "multi" && this.system_selected.length != 0) {
for (var i = 0; i < this.n_windows; i++) { for (var i = 0; i < this.n_clones; i++) {
if (this.system_selected.indexOf(this.clone(i).getSystem()) == -1) { if (this.system_selected.indexOf(this.clone(i).getSystem()) == -1) {
this.windows[i].active = false; this.clones[i].active = false;
} }
} }
} }
//unactive filtered clone //unactive filtered clone
for (var i = 0; i < this.n_windows; i++) { for (var i = 0; i < this.n_clones; i++) {
if (this.clone(i).isFiltered) { if (this.clone(i).isFiltered) {
this.clone(i).active = false; this.clone(i).active = false;