Commit 7245e90e authored by Mikaël Salson's avatar Mikaël Salson
parents e504f7ad 7c3305bb
......@@ -112,7 +112,7 @@ Clone.prototype = {
* @t : tracking point (default value : current tracking point)
* */
getSize: function (time) {
time = typeof time !== 'undefined' ? time : this.m.t;
time = this.m.getTime(time)
if (this.m.reads.segmented[time] == 0 ) return 0
var result = this.getReads(time) / this.m.reads.segmented[time]
......@@ -124,7 +124,7 @@ Clone.prototype = {
//special getSize for scatterplot (ignore constant)
getSize2: function (time) {
time = typeof time !== 'undefined' ? time : this.m.t;
time = this.m.getTime(time)
if (this.m.reads.segmented[time] == 0 ) return 0
var result = this.getReads(time) / this.m.reads.segmented[time]
......@@ -139,13 +139,12 @@ Clone.prototype = {
* use scientific notation if neccesary
* */
getStrSize: function (time) {
time = typeof time !== 'undefined' ? time : this.m.t;
var size = this.getSize(time);
var size = this.getSize(this.m.getTime(time));
return this.m.formatSize(size, true)
},
getSystemSize: function (time) {
time = typeof time !== 'undefined' ? time : this.m.t;
time = this.m.getTime(time)
var system_reads = this.m.reads.segmented[time]
if (this.germline in this.m.reads.germline) system_reads = this.m.reads.germline[this.germline][time]
......@@ -159,16 +158,68 @@ Clone.prototype = {
},
getStrSystemSize: function (time) {
time = typeof time !== 'undefined' ? time : this.m.t;
time = this.m.getTime(time)
var size = this.getSystemSize(time);
return this.m.formatSize(size, true)
},
/* Ratio relative to the system group */
getSystemGroupSize: function (time) {
var group_reads = this.m.systemGroupSize(this.germline, this.m.getTime(time))
if (group_reads == 0 ) return 0 ;
var result = this.getReads(time) / group_reads
if (this.norm) result = this.normalize(result, time)
return result
},
getStrSystemGroupSize: function (time) {
time = this.m.getTime(time)
var size = this.getSystemGroupSize(time)
return this.m.formatSize(size, true)
},
/* return a printable size such as either '26.32%' or '26.32% (33.66% of IGH)' (when there are several systems) */
getPrintableSize: function (time) {
var size = this.getReads(time)
s = size + ' read' + (size > 1 ? 's' : '') + ' '
s += '('
s += this.getStrSize(time)
if (this.m.system_available.length>1) {
systemGroup = this.m.systemGroup(this.germline)
if (systemGroup.indexOf('/') > -1) // if the system group has more than one germline
{
s += ', '
s += this.getStrSystemGroupSize(time) + ' of ' + systemGroup
}
s += ', '
s += this.getStrSystemSize(time) + ' of ' + this.germline
}
s += ')'
return s
},
getFasta: function() {
fasta = ''
fasta += '>' + this.getCode() + ' ' + this.getPrintableSize() + '\n'
fasta += this.getSequence() + '\n'
return fasta
},
/*
*
* */
getSequenceSize: function (time) {
time = typeof time !== 'undefined' ? time : this.m.t;
time = this.m.getTime(time)
if (this.m.reads.segmented[time] == 0 ) return 0
var result = this.getSequenceReads(time) / this.m.reads.segmented[time]
......@@ -186,7 +237,7 @@ Clone.prototype = {
* @t : tracking point (default value : current tracking point)
* */
getReads: function (time) {
time = typeof time !== 'undefined' ? time : this.m.t;
time = this.m.getTime(time)
var result = 0;
var cluster = this.m.clusters[this.hash]
......@@ -202,7 +253,7 @@ Clone.prototype = {
*
* */
getSequenceReads: function (time) {
time = typeof time !== 'undefined' ? time : this.m.t;
time = this.m.getTime(time)
return this.reads[time];
}, //end getSequenceSize
......
......@@ -474,20 +474,10 @@ Report.prototype = {
var reads_stats = $('<span/>', {'class': 'clone_table'}).appendTo(clone);
for (var i=0; i<m.samples.order.length; i++){
var t = m.samples.order[i]
$('<span/>', {'text': m.clone(cloneID).getStrSize(t)+'\u00a0', 'class': 'clone_value'}).appendTo(reads_stats);
}
if (m.system_available.length>1){
var reads_system_stats = $('<span/>', {'class': 'clone_table'}).appendTo(clone);
for (var i=0; i<m.samples.order.length; i++){
var t = m.samples.order[i]
$('<span/>', {'text': m.clone(cloneID).getStrSystemSize(t)+'\u00a0', 'class': 'clone_value'}).appendTo(reads_system_stats);
}
$('<span/>', {'text': m.clone(cloneID).getPrintableSize(t)+'\u00a0', 'class': 'clone_value'}).appendTo(reads_stats);
}
}else{
if (m.system_available.length>1){
$('<span/>', {'text': '('+m.clone(cloneID).getStrSystemSize(time)+' of '+system+')\u00a0', 'class': 'float-right'}).appendTo(head);
}
$('<span/>', {'text': m.clone(cloneID).getStrSize(time)+'\u00a0', 'class': 'float-right'}).appendTo(head);
$('<span/>', {'text': m.clone(cloneID).getPrintableSize(time)+'\u00a0', 'class': 'float-right'}).appendTo(head);
}
//colorized clone sequence
......
......@@ -702,6 +702,10 @@ Model.prototype = {
this.initClones();
},
getTime: function(time) {
return typeof time !== 'undefined' ? time : this.t
},
/**
* return a name that can be displayed gracefully
* (either with a real filename, or a name coming from the database).
......@@ -1802,8 +1806,7 @@ Model.prototype = {
var fasta = '<pre>'
for (var i=0; i<list.length; i++){
fasta += '>' + this.clone(list[i]).getCode() + '\n'
fasta += this.clone(list[i]).getSequence() + '\n'
fasta += this.clone(list[i]).getFasta() + '\n'
}
var result = $('<div/>', {
......@@ -1833,7 +1836,7 @@ Model.prototype = {
},
systemSize: function(system, time) {
time = typeof time !== 'undefined' ? time : this.t;
time = this.getTime(time)
if (typeof this.reads.germline[system] != 'undefined'){
return this.reads.germline[system][time]/this.reads.segmented[time]
}else{
......@@ -1845,6 +1848,45 @@ Model.prototype = {
}
},
/* Two systems are in the same group when then only differs by '+' */
sameSystemGroup: function(system1, system2) {
system1 = system1.replace('+', '')
system2 = system2.replace('+', '')
return (system1 == system2)
},
/* Representation of a system group, such as 'TRD/TRD+' */
systemGroup: function(system) {
list = ''
for (var germline in this.reads.germline) {
if (this.sameSystemGroup(germline, system)) {
if (list) list += '/'
list += germline
}
}
return list
},
/* Returns the number of reads of a given system group at a given time */
systemGroupSize: function(system, time) {
time = this.getTime(time)
reads = 0
for (var germline in this.reads.germline) {
if (this.sameSystemGroup(germline, system)) {
reads += this.reads.germline[germline][time]
}
}
return reads
},
wait: function(text){
document.getElementById("waiting_screen").style.display = "block";
......
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