Commit 56ec2a52 authored by Marc Duez's avatar Marc Duez Committed by Mathieu Giraud
Browse files

js : change method to compute min_size and precision, the min_size depends of...

js : change method to compute min_size and precision, the min_size depends of the normalization, so we need to recompute min_size and precision value after each normalization
parent 4c112b93
......@@ -120,18 +120,6 @@ Graph.prototype = {
this.data_res = [];
this.graph_col = [];
var count = this.m.min_size;
this.precision = 1;
while (count < 1) {
count = count * 10;
this.precision = this.precision * 10;
}
this.scale_x = d3.scale.log()
.domain([1, this.precision])
.range([0, 1]);
this.initAxis();
for (var i = 0; i < this.m.n_windows; i++) {
......@@ -198,7 +186,11 @@ Graph.prototype = {
this.data_axis = [];
this.graph_col = [];
this.scale_x = d3.scale.log()
.domain([1, this.m.precision])
.range([0, 1]);
//abscisse
for (var i = 0; i < this.m.time_order.length; i++) {
this.graph_col[i] = this.marge1 + i * ((1 - (this.marge1 + this.marge2)) / (this.m.time_order.length - 1));
......@@ -237,13 +229,13 @@ Graph.prototype = {
var height = 1;
//ordonnée
while ((height * this.precision) > 0.5) {
while ((height * this.m.precision) > 0.5) {
var d = {};
d.type = "axis_h";
d.text = this.m.formatSize(height, false)
d.orientation = "hori";
d.pos = 1 - this.scale_x(height * this.precision);
d.pos = 1 - this.scale_x(height * this.m.precision);
this.data_axis.push(d);
height = height / 10;
......@@ -597,12 +589,12 @@ Graph.prototype = {
}
}
p.push([0, (1 - this.scale_x(size[0] * this.precision))]);
p.push([0, (1 - this.scale_x(size[0] * this.m.precision))]);
for (var i = 0; i < this.graph_col.length; i++) {
p.push([(this.graph_col[i]), (1 - this.scale_x(size[i] * this.precision))]);
p.push([(this.graph_col[i]), (1 - this.scale_x(size[i] * this.m.precision))]);
}
p.push([1, (1 - this.scale_x(size[this.graph_col.length - 1] * this.precision))]);
p.push([1, (1 - this.scale_x(size[this.graph_col.length - 1] * this.m.precision))]);
p.push([1, 1 + 0.1]);
return p;
......@@ -623,7 +615,7 @@ Graph.prototype = {
}
var x = this.graph_col[0];
var y = this.scale_x(size[0] * this.precision)
var y = this.scale_x(size[0] * this.m.precision)
//cas avec un seul point de suivi
if (this.graph_col.length == 1) {
......@@ -664,7 +656,7 @@ Graph.prototype = {
if (to != 0) {
x = this.graph_col[i];
y = this.scale_x(size[i] * this.precision)
y = this.scale_x(size[i] * this.m.precision)
if (size[i] == 0) {
if (p.length != 0) {
......
......@@ -131,14 +131,12 @@ Model.prototype = {
self.windows = [];
self.mapID = {}
self.dataCluster = []
var min_size = 1;
var min_sizes = [];
var n_max = 0;
var n2_max = 0; //TODO rename
var min_nf = 1;
for (var k = 0; k < data.normalization_factor.length; k++) {
if (min_nf > data.normalization_factor[k])
min_nf = data.normalization_factor[k];
for (var k = 0; k < data.windows[0].size.length; k++) {
min_sizes[k] = 1;
}
//keep best top value
......@@ -147,10 +145,10 @@ Model.prototype = {
//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]) * min_nf;
var size = (data.windows[i].size[k] / data.reads_segmented[k])
if (min_size > size && data.windows[i].size[k] != 0)
min_size = size;
if (min_sizes[k] > size && data.windows[i].size[k] != 0)
min_sizes[k] = size;
}
//search for n_max / n2_max
......@@ -160,15 +158,6 @@ Model.prototype = {
n_max = data.windows[i].Nlength;
}
/*
var n2=0;
if ((typeof(data.windows[i].sequence) != 'undefined') &&
(typeof(data.windows[i].Nlength) != 'undefined')){
n2=data.windows[i].name.split('/')[1];
if (n2>n2_max)n2_max=n2;
}
data.windows[i].n=n2
*/
self.windows.push(data.windows[i]);
}
}
......@@ -181,16 +170,8 @@ Model.prototype = {
}
self.windows.push(other);
var count = min_size;
while (count < 1) {
count = count * 10;
self.precision = self.precision * 10;
}
self.n_windows = self.windows.length;
self.min_size = min_size;
self.min_sizes = min_sizes;
self.n_max = n_max;
self.n2_max = n2_max;
self.normalization_factor = data.normalization_factor;
......@@ -759,6 +740,23 @@ Model.prototype = {
}
},
update_precision: function () {
min_size = 1
for (var i=0; i<this.time_order.length; i++){
var t = this.time_order[i]
var size = this.normalize(this.min_sizes[t], i)
if (size < min_size) min_size = size
}
this.min_size = min_size
this.precision = 1
while (min_size < 1) {
min_size = min_size*10
this.precision=this.precision*10
}
},
/*
*
* */
......@@ -1084,8 +1082,9 @@ Model.prototype = {
.getTime();
var elapsedTime = 0;
this.update_normalization();
this.updateModel();
this.update_normalization()
this.update_precision()
this.updateModel()
for (var i = 0; i < this.view.length; i++) {
this.view[i].update();
......@@ -1104,6 +1103,7 @@ Model.prototype = {
if ( list.indexOf(this.normalization.id) != -1 ){
this.update_normalization()
this.update_precision()
}
this.updateModel()
......
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