Commit 5a33ea59 authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-c/2632-ordre-des-locus-mieux-qu-alphabetique' into 'dev'

Resolve "Ordre des locus mieux qu'alphabétique"

Closes #2632

See merge request !393
parents c8e14cca 422df321
Pipeline #60803 passed with stages
in 5 minutes and 11 seconds
...@@ -332,7 +332,7 @@ Info.prototype = { ...@@ -332,7 +332,7 @@ Info.prototype = {
var keys = 0; var keys = 0;
var key_list = this.m.system_available; var key_list = this.m.system_available;
key_list.sort();
var last_key = ""; var last_key = "";
......
...@@ -325,6 +325,8 @@ Model_loader.prototype = { ...@@ -325,6 +325,8 @@ Model_loader.prototype = {
self.system_available.push(system) self.system_available.push(system)
} }
} }
self.system_available.sort(locus_cmp)
for (var sa in self.system_available){ for (var sa in self.system_available){
system = this.system_available[sa] system = this.system_available[sa]
self.system_selected.push(system) self.system_selected.push(system)
......
...@@ -4,7 +4,7 @@ var INS="insertion"; ...@@ -4,7 +4,7 @@ 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 "; var END_CODON_NOT_FIRST = "end-codon-not-first ";
var LOCUS_ORDER = [ "TRA", "TRB", "TRB+", "TRG", "TRD", "TRA+D", "TRD+", "IGH", "IGH+", "IGK", "IGK+", "IGL"]
/** /**
* Get codons from two aligned sequences * Get codons from two aligned sequences
* @pre both sequences are aligned together ref.length == seq.length * @pre both sequences are aligned together ref.length == seq.length
...@@ -648,3 +648,34 @@ function pearsonCoeff(l1, l2) { ...@@ -648,3 +648,34 @@ function pearsonCoeff(l1, l2) {
} }
function logadd1(x) { return Math.log(x + 1) ; } function logadd1(x) { return Math.log(x + 1) ; }
/**
* Compare two locus to sort them.
* The list is ordered on a preordered list of locus (LOCUS_ORDER).
* By this way, locus that are not in this list will be added at the end of it.
* @param {String} valA One locus value
* @param {String} valB Another locus value to compare
* @return {Number} A number -1 if A before B, else 1
*/
function locus_cmp(valA, valB){
// Ordered list of all generic locus
var index_A = LOCUS_ORDER.indexOf(valA)
var index_B = LOCUS_ORDER.indexOf(valB)
if (index_A == -1 && index_B == -1){
// Neither A or B are present in LOCUS_ORDER
return valA.localeCompare(valB)
} else if (index_A != -1 && index_B == -1){
// Only A is present in LOCUS_ORDER
return -1
} else if (index_A == -1 && index_B != -1){
// Only B is present in LOCUS_ORDER
return 1
} else if (index_A != -1 && index_B != -1){
// A & B are present in LOCUS_ORDER
return index_A - index_B
}
return 0
}
...@@ -49,8 +49,8 @@ QUnit.test("read details", function(assert) { ...@@ -49,8 +49,8 @@ QUnit.test("read details", function(assert) {
m.keep_one_active_system('IGH') m.keep_one_active_system('IGH')
var sbnm = document.getElementsByClassName('systemBoxNameMenu') var sbnm = document.getElementsByClassName('systemBoxNameMenu')
assert.includes(sbnm[0].outerHTML, '<span class="systemBoxNameMenu IGH">', 'system box IGH is still active') assert.includes(sbnm[0].outerHTML, '<span class="systemBoxNameMenu inactive TRG">', 'system box TRG is inactive')
assert.includes(sbnm[1].outerHTML, '<span class="systemBoxNameMenu inactive TRG">', 'system box TRG is inactive') assert.includes(sbnm[1].outerHTML, '<span class="systemBoxNameMenu IGH">', 'system box IGH is still active')
var reads = document.getElementsByClassName('reads_details')[0] var reads = document.getElementsByClassName('reads_details')[0]
assert.includes(reads.outerHTML, 'analyzed reads</span><span>200 (100.00%)', 'read details: analyzed reads (same than before)') assert.includes(reads.outerHTML, 'analyzed reads</span><span>200 (100.00%)', 'read details: analyzed reads (same than before)')
......
...@@ -393,3 +393,19 @@ QUnit.test("Pearson coefficient", function(assert) { ...@@ -393,3 +393,19 @@ QUnit.test("Pearson coefficient", function(assert) {
assert.equal(pearsonCoeff([3, 2, 1], [10, 20, 30]), -1) assert.equal(pearsonCoeff([3, 2, 1], [10, 20, 30]), -1)
} }
); );
QUnit.test("Sort list locus", function(assert) {
list_test_1 = [ "TRA", "TRB", "TRG", "TRD", "testlocus", "IGH", "IGK", "IGL"]
wait_test_1 = [ "TRA", "TRB", "TRG", "TRD", "IGH", "IGK", "IGL", "testlocus"]
list_test_2 = [ "IGH", "IGH+", "unknow_locus", "IGK+", "IGL", "testlocus", "TRA", "TRB", "TRB+", "TRG", "TRD"]
wait_test_2 = [ "TRA", "TRB", "TRB+", "TRG", "TRD", "IGH", "IGH+", "IGK+", "IGL", "testlocus", "unknow_locus"]
list_test_1.sort(locus_cmp)
list_test_2.sort(locus_cmp)
assert.deepEqual(list_test_1, wait_test_1, "list2 is correctly sorted")
assert.deepEqual(list_test_2, wait_test_2, "list2 is correctly sorted")
}
);
...@@ -31,7 +31,7 @@ class TestMultilocus < BrowserTest ...@@ -31,7 +31,7 @@ class TestMultilocus < BrowserTest
end end
def test_00_germline def test_00_germline
assert ($b.div(:id => 'info').span(:class => 'systemBoxNameMenu', :index => 2).text.include? 'TRA'), 'missing system TRA' assert ($b.div(:id => 'info').span(:class => 'systemBoxNameMenu', :index => 0).text.include? 'TRA'), 'missing system TRA'
end end
def test_00_legend_scatterplot def test_00_legend_scatterplot
......
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