Commit 58fea312 authored by marc's avatar marc Committed by Mathieu Giraud
Browse files

browser : add custom highlight method to display quality information

parent 2523c922
......@@ -36,7 +36,7 @@ function Clone(data, model, index, virtual) {
this.segEdited = false
this.virtual = typeof virtual !== 'undefined' ? virtual : false
var key = Object.keys(data)
for (var i=0; i<key.length; i++ ){
this[key[i]]=data[key[i]]
}
......
......@@ -331,6 +331,8 @@ Model_loader.prototype = {
for (var i=0 ; i<this.reads.segmented.length; i++){
this.reads.segmented_all[i] = this.reads.segmented[i]
}
this.compute_average_quality();
//extract germline
......@@ -700,6 +702,29 @@ Model_loader.prototype = {
newSeg = seg[key+bound];
}
return newSeg;
},
compute_average_quality: function() {
this.min_quality = 255;
this.max_quality = 0;
this.average_quality = 0;
var count = 0;
for (var i in this.clones){
if (typeof this.clones[i].seg != "undefined" && typeof this.clones[i].seg.quality != "undefined"){
var s = this.clones[i].seg.quality.seq;
for (var j in s){
if (s[j] != "!"){
var c = s[j].charCodeAt(0);
if (c < this.min_quality) this.min_quality=c;
if (c > this.max_quality) this.max_quality=c;
this.average_quality += c;
count++;
}
}
}
}
this.average_quality = this.average_quality/count;
}
};
......@@ -1134,7 +1134,7 @@ Sequence.prototype = {
highlightSpan.dataset.tooltip = h.tooltip;
highlightSpan.dataset.tooltip_position = "right";
}
highlightSpan.appendChild(document.createTextNode(h.seq));
highlightSpan.innerHTML = h.seq;
var highlightWrapper = document.createElement("span");
highlightWrapper.appendChild(highlightSpan);
......@@ -1273,6 +1273,16 @@ Sequence.prototype = {
if (this.seq[k] != '-') {
var cc = raw_seq[j++]
if ((cc != '_') && (cc != ' ')) c = cc ;
if (field == "quality") {
var percent = (cc.charCodeAt(0)-this.m.min_quality)/(this.m.max_quality-this.m.min_quality)
var color_hue = (percent * 100);
var color = colorGenerator(color_hue);
c = "<span style='height:"+(50+(percent*50))+"%;"
c += "top:"+(100-(50+(percent*50)))+"%;"
c += "position:relative;"
c += "background-color:"+color+";"
c += "'>\u00A0</span>"
}
}
h.seq += c
}
......
Supports Markdown
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