Commit aba08aca authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

js/segmenter.js, js/tools.js: display codons only on the first clone

See #3325.
Could be improved, there are string manipulations here.
parent 5af2c366
...@@ -1235,8 +1235,11 @@ genSeq.prototype= { ...@@ -1235,8 +1235,11 @@ genSeq.prototype= {
* @param {char} other * @param {char} other
* @return {string} * @return {string}
* */ * */
spanify_mutation: function (self, other, mutation) { spanify_mutation: function (self, other, mutation, i_am_first_clone) {
if (mutation != undefined) { if (mutation != undefined && !i_am_first_clone) {
mutation = mutation.replace(END_CODON, END_CODON_NOT_FIRST)
}
if (mutation != undefined && mutation) {
var span = document.createElement('span'); var span = document.createElement('span');
span.className = mutation span.className = mutation
span.setAttribute('other', other + '-' + this.segmenter.first_clone); span.setAttribute('other', other + '-' + this.segmenter.first_clone);
...@@ -1299,6 +1302,8 @@ genSeq.prototype= { ...@@ -1299,6 +1302,8 @@ genSeq.prototype= {
mutations = get_mutations(ref, seq, reference_phase); mutations = get_mutations(ref, seq, reference_phase);
} }
var i_am_first_clone = (this.id == this.segmenter.first_clone)
for (var i = 0; i < this.seq.length; i++) { for (var i = 0; i < this.seq.length; i++) {
for (var m in highlights){ for (var m in highlights){
var h = highlights[m]; var h = highlights[m];
...@@ -1335,7 +1340,7 @@ genSeq.prototype= { ...@@ -1335,7 +1340,7 @@ genSeq.prototype= {
} }
} }
currentSpan.appendChild(this.spanify_mutation(seq[i], ref[i], mutations.hasOwnProperty(i) ? mutations[i] : undefined)) currentSpan.appendChild(this.spanify_mutation(seq[i], ref[i], mutations.hasOwnProperty(i) ? mutations[i] : undefined, i_am_first_clone))
} }
result.appendChild(currentSpan); result.appendChild(currentSpan);
var marge = "" var marge = ""
......
...@@ -2,7 +2,8 @@ var SILENT="silent"; ...@@ -2,7 +2,8 @@ var SILENT="silent";
var SUBST="substitution"; var SUBST="substitution";
var INS="insertion"; var INS="insertion";
var DEL="deletion"; var DEL="deletion";
var END_CODON = "end-codon"; var END_CODON = "end-codon ";
var END_CODON_NOT_FIRST = "end-codon-not-first ";
/** /**
* Get codons from two aligned sequences * Get codons from two aligned sequences
...@@ -127,7 +128,7 @@ function get_mutations(ref, seq, frame) { ...@@ -127,7 +128,7 @@ function get_mutations(ref, seq, frame) {
} }
nb_pos++; nb_pos++;
} }
mutations[nb_pos-1] = (typeof mutations[nb_pos-1] === 'undefined' ? '' : mutations[nb_pos-1] + ' ') + END_CODON; mutations[nb_pos-1] = END_CODON + (typeof mutations[nb_pos-1] === 'undefined' ? '' : mutations[nb_pos-1])
} }
return mutations; return mutations;
} }
......
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