Commit aba08aca authored by Mathieu Giraud's avatar Mathieu Giraud

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= {
* @param {char} other
* @return {string}
* */
spanify_mutation: function (self, other, mutation) {
if (mutation != undefined) {
spanify_mutation: function (self, other, mutation, i_am_first_clone) {
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');
span.className = mutation
span.setAttribute('other', other + '-' + this.segmenter.first_clone);
......@@ -1298,6 +1301,8 @@ genSeq.prototype= {
if (this.segmenter.aligned) {
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 m in highlights){
......@@ -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);
var marge = ""
......
......@@ -2,7 +2,8 @@ var SILENT="silent";
var SUBST="substitution";
var INS="insertion";
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
......@@ -127,7 +128,7 @@ function get_mutations(ref, seq, frame) {
}
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;
}
......
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