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

browser : replace windows with clones object

parent 8d9c9b2b
......@@ -139,7 +139,7 @@ Axis.prototype = {
var n_min = 0;
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;
}
......
......@@ -112,7 +112,7 @@ Builder.prototype = {
normalize_list.appendChild(document.createTextNode("none"))
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"){
var input = document.createElement("input")
var text = document.createTextNode(self.m.clone(i).getName() + " => " +self.m.clone(i).expected)
......@@ -357,7 +357,7 @@ Builder.prototype = {
//init slider
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)
max_top = this.m.clone(i).top
}
......@@ -410,7 +410,7 @@ Builder.prototype = {
var clusterSelector = document.getElementById("clusterby_button")
clusterSelector.innerHTML = "";
if (self.m.windows[0]._target){
if (self.m.clones[0]._target){
var target = document.createElement('a');
target.className = "buttonSelector"
......@@ -437,7 +437,7 @@ Builder.prototype = {
clusterSelector.appendChild(clonotype)
}
if (self.m.windows[0].system){
if (self.m.clones[0].system){
var system = document.createElement('a');
system.className = "buttonSelector"
......
......@@ -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)
* */
getSize: function (time) {
......@@ -107,7 +107,7 @@ Clone.prototype = {
}, //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)
* */
getReads: function (time) {
......
......@@ -50,7 +50,7 @@ Germline.prototype = {
//reduce germline size (keep only detected genes)
//and add undetected genes
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"
&& typeof this.m.clone(i)[type][0] != "undefined"){
var gene=this.m.clone(i)[type][0];
......
......@@ -136,7 +136,7 @@ Graph.prototype = {
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] = {
id: i,
name: "line" + i,
......@@ -153,13 +153,13 @@ Graph.prototype = {
}
this.data_res.push({
id: this.m.n_windows,
id: this.m.n_clones,
name: "resolution1",
path: this.constructPathR(this.resolution1)
});
this.data_res.push({
id: this.m.n_windows + 1,
id: this.m.n_clones + 1,
name: "resolution5",
path: this.constructPathR(this.resolution5)
});
......@@ -398,12 +398,12 @@ Graph.prototype = {
this.data_res[0].path = this.constructPathR(this.resolution1);
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++) {
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
for (var j = 0; j < this.m.clusters[cloneID].length; j++) {
var seqID = this.m.clusters[cloneID][j]
......@@ -892,11 +892,11 @@ Stack.prototype = {
this.total_size = [];
for (j=0; j<this.m.samples.number; j++){
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
}
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 = {
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.max[i] = []
//active clones
......@@ -929,9 +929,9 @@ Stack.prototype = {
//other
for (j=0; j<this.m.samples.number; j++){
this.min[this.m.windows.length-1][j] = this.sum[j]
this.sum[this.m.windows.length-1] += this.m.clone(this.m.windows.length-1).getSize(j)
this.max[this.m.windows.length-1][j] = this.sum[j]
this.min[this.m.clones.length-1][j] = this.sum[j]
this.sum[this.m.clones.length-1] += this.m.clone(this.m.clones.length-1).getSize(j)
this.max[this.m.clones.length-1][j] = this.sum[j]
}
},
......
......@@ -60,7 +60,7 @@ List.prototype = {
var div_list_clones = document.createElement('div')
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');
div.className = "list";
div.id = i;
......@@ -158,7 +158,7 @@ List.prototype = {
var startTime = new Date()
.getTime();
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]);
}
elapsedTime = new Date()
......@@ -472,7 +472,7 @@ List.prototype = {
},
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)
c.isFiltered=bool
}
......@@ -480,7 +480,7 @@ List.prototype = {
filter: function (str) {
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)
if (c.getName().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 = {
this.precision = 1;
this.isPlaying = false;
this.clusters = [];
this.windows = [];
this.clones = [];
this.germline = {}
this.germlineV = new Germline(this)
this.germlineD = new Germline(this)
......@@ -228,44 +228,44 @@ Model.prototype = {
parseJsonData: function (data, limit) {
self = this;
self.windows = [];
self.clones = [];
self.links = [];
self.mapID = {}
self.dataCluster = []
var min_sizes = [];
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;
}
var hash = 0
//keep best top value
for (var i = 0; i < data.windows.length; i++) {
if (data.windows[i].top <= limit) {
for (var i = 0; i < data.clones.length; i++) {
if (data.clones[i].top <= limit) {
//search for min_size
for (var k = 0; k < data.windows[i].size.length; k++) {
var size = (data.windows[i].size[k] / data.reads.segmented[k])
for (var k = 0; k < data.clones[i].size.length; 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;
}
data.windows[i].Nlength = 0;
if ((typeof (data.windows[i].Jstart) != 'undefined') &&
(typeof (data.windows[i].Vend) != 'undefined') ) {
data.windows[i].Nlength = data.windows[i].Jstart - data.windows[i].Vend
data.clones[i].Nlength = 0;
if ((typeof (data.clones[i].Jstart) != 'undefined') &&
(typeof (data.clones[i].Vend) != 'undefined') ) {
data.clones[i].Nlength = data.clones[i].Jstart - data.clones[i].Vend
}
//search for n_max
if ((typeof (data.windows[i].sequence) != 'undefined') &&
(typeof (data.windows[i].Nlength) != 'undefined') &&
(data.windows[i].Nlength > n_max)) {
n_max = data.windows[i].Nlength;
if ((typeof (data.clones[i].sequence) != 'undefined') &&
(typeof (data.clones[i].Nlength) != 'undefined') &&
(data.clones[i].Nlength > n_max)) {
n_max = data.clones[i].Nlength;
}
var clone = new Clone(data.windows[i], self, hash)
self.windows.push(clone);
var clone = new Clone(data.clones[i], self, hash)
self.clones.push(clone);
hash++
}
}
......@@ -282,7 +282,7 @@ Model.prototype = {
"size": []
}
var clone = new Clone(other, self, hash)
self.windows.push(clone);
self.clones.push(clone);
// default samples
if (typeof self.samples.number == 'string'){
......@@ -297,7 +297,7 @@ Model.prototype = {
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.n_max = n_max;
self.system_selected = [];
......@@ -326,8 +326,8 @@ Model.prototype = {
self.system = germline_list[0];
}
for (var i = 0; i < self.n_windows; i++) {
self.mapID[self.windows[i].window] = i;
for (var i = 0; i < self.n_clones; i++) {
self.mapID[self.clones[i].window] = i;
}
return this
......@@ -431,7 +431,7 @@ Model.prototype = {
}
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)
if (clone.getSystem() == system) {
if (clone[gene] && clone[gene][0]){
......@@ -441,7 +441,7 @@ Model.prototype = {
}
}else{
for (var i=0; i<this.n_windows; i++){
for (var i=0; i<this.n_clones; i++){
var clone = this.clone(i)
if (clone[gene] && clone[gene][0]){
list[clone[gene][0]]=0
......@@ -500,7 +500,7 @@ Model.prototype = {
this.clusters = [];
// NSIZE
for (var i = 0; i < this.n_windows; i++) {
for (var i = 0; i < this.n_clones; i++) {
var clone = this.clone(i)
if (typeof (clone.getSequence()) != 'undefined') {
......@@ -518,7 +518,7 @@ Model.prototype = {
}
// 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)
clone.colorN = colorGenerator((((clone.Nlength / maxNlength) - 1) * (-250)), color_s, color_v);
}
......@@ -526,7 +526,7 @@ Model.prototype = {
this.computeColor()
// SHORTNAME
for (var i = 0; i < this.n_windows; i++) {
for (var i = 0; i < this.n_clones; i++) {
var clone = this.clone(i)
if (typeof (clone.getSequence()) != 'undefined' && typeof (clone.name) != 'undefined') {
clone.shortName = clone.name.replace(new RegExp('IGHV', 'g'), "VH");
......@@ -543,7 +543,7 @@ Model.prototype = {
computeColor: function(){
// 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)
if (typeof (clone.V) != 'undefined' && this.germlineV.allele[clone.V[0]]) {
......@@ -555,7 +555,7 @@ Model.prototype = {
}
// 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)
if (typeof (clone.J) != 'undefined' && this.germlineJ.allele[clone.J[0]]) {
......@@ -615,7 +615,7 @@ Model.prototype = {
max.id = id
}
}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{
if (typeof (c[i].tag) != "undefined") {
......@@ -651,7 +651,7 @@ Model.prototype = {
*/
findWindow: function (sequence) {
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
}
}
......@@ -692,7 +692,7 @@ Model.prototype = {
tags : {}
}
for (var i = 0; i < this.n_windows; i++) {
for (var i = 0; i < this.n_clones; i++) {
var clone = this.clone(i)
//tag, custom name, expected_value
......@@ -1027,7 +1027,7 @@ Model.prototype = {
* */
getSelected: function () {
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()) {
result.push(i);
}
......@@ -1065,7 +1065,7 @@ Model.prototype = {
select: function (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()) {
return;
......@@ -1143,7 +1143,7 @@ Model.prototype = {
nlist.splice(index, 1);
//le clone retrouve sa liste de windows -1
//le clone retrouve sa liste de clones -1
this.clusters[cloneID] = nlist;
//la window forme son propre clone a part
this.clusters[windowID] = [windowID];
......@@ -1188,15 +1188,15 @@ Model.prototype = {
// unactive clones from unselected system
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) {
this.windows[i].active = false;
this.clones[i].active = false;
}
}
}
//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) {
this.clone(i).active = false;
}
......@@ -1204,7 +1204,7 @@ Model.prototype = {
this.computeOtherSize();
for (var i = 0; i < this.n_windows; i++) {
for (var i = 0; i < this.n_clones; i++) {
this.clone(i).updateColor()
}
......@@ -1266,7 +1266,7 @@ Model.prototype = {
updateStyle: function () {
var list = []
for (var i=0; i<this.n_windows; i++) list[i]=i
for (var i=0; i<this.n_clones; i++) list[i]=i
for (var i = 0; i < this.view.length; i++) {
this.view[i].updateElemStyle(list);
}
......@@ -1283,7 +1283,7 @@ Model.prototype = {
this.displayTop();
var count = 0;
for (var i = 0; i < this.n_windows; i++) {
for (var i = 0; i < this.n_clones; i++) {
if (this.clone(i).isActive()) count++
}
......@@ -1310,7 +1310,7 @@ Model.prototype = {
var html_label = document.getElementById('top_label');
if (html_label != null) {
var count = 0;
for (var i=0; i<this.n_windows; i++){
for (var i=0; i<this.n_clones; i++){
if (this.clone(i).top <= top) count++;
}
html_label.innerHTML = count + ' clones (top ' + top + ')' ;
......@@ -1329,18 +1329,18 @@ Model.prototype = {
other[j] = this.reads.segmented[j]
}
for (var i = 0; i < this.n_windows - 1; i++) {
for (var i = 0; i < this.n_clones - 1; i++) {
for (var j = 0; j < this.reads.segmented.length; j++) {
if (this.clone(i).isActive()) {
for (var k = 0; k < this.clusters[i].length; k++) {
if (this.clusters[i][k] != this.n_windows - 1)
if (this.clusters[i][k] != this.n_clones - 1)
other[j] -= this.clone(this.clusters[i][k]).size[j];
}
}
}
}
this.clone(this.n_windows - 1).size = other;
this.clone(this.n_clones - 1).size = other;
},
......@@ -1374,7 +1374,7 @@ Model.prototype = {
}
var tmp = {}
for (var i = 0; i < this.n_windows - 1; i++) {
for (var i = 0; i < this.n_clones - 1; i++) {
//detect key value
var key = "undefined"
......@@ -1391,7 +1391,7 @@ Model.prototype = {
}
}
//store windows with same key together
//store clones with same key together
if (key == "") key = "undefined"
if (tmp[key]) {
tmp[key].push(i)
......@@ -1401,14 +1401,14 @@ Model.prototype = {
}
//order windows with same key
//order clones with same key
var keys = Object.keys(tmp)
for (var i in tmp) {
tmp[i].sort()
}
//reset cluster
for (var i = 0; i < this.windows.length; i++) {
for (var i = 0; i < this.clones.length; i++) {
this.clusters[i] = []
}
......@@ -1433,7 +1433,7 @@ Model.prototype = {
//reset cluster
this.cluster_key = ""
for (var i = 0; i < this.windows.length; i++) {
for (var i = 0; i < this.clones.length; i++) {
this.clusters[i] = []
}
......@@ -1606,7 +1606,7 @@ Model.prototype = {
clone: function(hash) {
return this.windows[hash]
return this.clones[hash]
},
......@@ -1631,11 +1631,11 @@ Model.prototype = {
loadRandomTab: function() {
this.tabRandomColor = [];
/*Initialisation du tableau de couleurs*/
for (var i = 0; i < this.n_windows; i++) {
for (var i = 0; i < this.n_clones; i++) {
this.tabRandomColor.push(i);
}
/*Fisher yates algorithm to shuffle the array*/
for (var i = this.n_windows - 1; i >= 1; i--) {
for (var i = this.n_clones - 1; i >= 1; i--) {
var j = Math.floor(Math.random() * i) + 1;
var abs = this.tabRandomColor[i];
this.tabRandomColor[i] = this.tabRandomColor[j];
......@@ -1652,7 +1652,7 @@ Model.prototype = {
this.dbscan.runAlgorithm();
for (var i = 0; i < this.dbscan.clusters.length; i++)
for (var j = 0; j < this.dbscan.clusters[i].length; j++)
this.windows[this.dbscan.clusters[i][j]].cluster = i;
this.clones[this.dbscan.clusters[i][j]].cluster = i;
//Color DBSCAN
if (typeof(this.tabRandomColor) == "undefined") this.loadRandomTab();
this.colorNodesDBSCAN();
......@@ -1667,7 +1667,7 @@ Model.prototype = {
/*Adding color by specific cluster*/
/*-> Solution provisoire quant à la couleur noire non voulue est d' "effacer" le nombre max de clusters, mais de le prendre par défaut (100), soit un intervalle de 2.7 à chaque fois*/
var maxCluster = this.dbscan.clusters.length;
for (var i = 0; i < this.n_windows; i++) {
for (var i = 0; i < this.n_clones; i++) {
if (typeof(this.clone(i)) != 'undefined') {
this.clone(i).colorDBSCAN = colorGenerator( ( (270 / maxCluster) * (this.tabRandomColor[this.clone(i)] + 1) ), color_s, color_v);
}
......@@ -1679,7 +1679,7 @@ Model.prototype = {
/* Fonction permettant d'ajouter un tab concernant un node - s'il est au coeur d'un cluster, à l'extérieur ou appartenant à...
*/
addTagCluster: function() {
for (var i = 0; i < this.n_windows; i++)
for (var i = 0; i < this.n_clones; i++)
if (typeof(this.clone(i)) != 'undefined')
switch (this.dbscan.visitedTab[i].mark) {
case -1:
......
......@@ -41,7 +41,7 @@ PDF.prototype = {
if (this.list.length == 0) {
var flag = 5;
for (var i = 0; i < this.m.n_windows; i++) {
for (var i = 0; i < this.m.n_clones; i++) {
if (this.m.clusters[i].length != 0 && flag != 0) {
this.list.push(i);
flag--;
......@@ -182,7 +182,7 @@ PDF.prototype = {
opt2.y_offset = opt.y;
//clones style
for (var i = 0; i < this.m.n_windows; i++) {
for (var i = 0; i < this.m.n_clones; i++) {
var polyline = elem.querySelectorAll('[id="polyline'+i+'"]')[0]
var color = tagColor[this.m.clone(i).getTag()]
......@@ -194,7 +194,7 @@ PDF.prototype = {
polyline.setAttribute("stroke", color);
}
if (m.windows[i].window == "other" || !m.windows[i].active) {
if (m.clone(i).window == "other" || !m.clone(i).isActive()) {
polyline.parentNode.removeChild(polyline);
}
}
......@@ -378,9 +378,9 @@ PDF.prototype = {
this.doc.setFont('courier', 'normal');
this.doc.setTextColor(0, 0, 0)
if (typeof (m.windows[cloneID].sequence) != 'number') {
if (m.clone(cloneID).getSequence() != "0") {
var seq = m.windows[cloneID].sequence;
var seq = m.clone(cloneID).getSequence()
var seqV = seq.substring(0, this.m.clone(cloneID).Vend + 1)
var seqN = seq.substring(this.m.clone(cloneID).Vend + 1, this.m.clone(cloneID).Jstart)
var seqJ = seq.substring(this.m.clone(cloneID).Jstart)
......@@ -426,7 +426,7 @@ PDF.prototype = {
}
} else {
this.doc.text(this.marge + 20, this.y, "segment fail :" + m.windows[cloneID].window);
this.doc.text(this.marge + 20, this.y, "segment fail :" + m.clone(cloneID).window);
}
this.y += 5;
......@@ -462,7 +462,7 @@ PDF.prototype = {
icon: function (cloneID, x, y, w, h) {
var color = tagColor[m.windows[cloneID].tag]
var color = tagColor[m.clone(cloneID).tag]
var polyline = document.getElementById("polyline" + cloneID)
.cloneNode(true);
......
......@@ -215,9 +215,9 @@ ScatterPlot.prototype = {
this.grpLinks = this.plot_container.append('svg:g').attr('class', 'grpLinks');