Commit 3cbec1d1 authored by flothoni's avatar flothoni

model.js; create new function to get the sample name

If vidjil file is loaded from server, correct names are set in model.samples.names.
This is not the case if loaded from local file.
Create a function to alwaysget correct value
Link to #4422
parent eb1da1b3
Pipeline #168602 passed with stages
in 12 minutes and 20 seconds
......@@ -1518,7 +1518,7 @@ changeAlleleNotation: function(alleleNotation) {
var overlap = this.overlaps[key_overlap]
html += "<tr><td class='header'></td>" // header with samples names
for (var posSample = 0; posSample < overlap.length; posSample++) {
html += "<td class='header'>"+this.samples.names[posSample]+"</td>"
html += "<td class='header'>"+this.getSampleName(posSample)+"</td>"
}
html += '</tr>'
for (posSample = 0; posSample < overlap.length; posSample++) {
......@@ -1527,7 +1527,7 @@ changeAlleleNotation: function(alleleNotation) {
} else {
html += "<tr>"
}
html += "<td class='header'>"+this.samples.names[posSample]+"</td>"
html += "<td class='header'>"+this.getSampleName(posSample)+"</td>"
values = overlap[posSample]
for (var i = 0; i < (overlap[posSample].length); i++) {
value = overlap[posSample][i]
......@@ -3465,5 +3465,18 @@ changeAlleleNotation: function(alleleNotation) {
return
},
/**
* Get the name of a samples.
* If getted from the server, the correct name to send come from original_names field
* Else return value from samples.names
*/
getSampleName: function(posSample){
var name_server = this.samples.original_names[posSample]
var name_file = this.samples.names[posSample]
if (name_file == ""){
return name_server
}
return name_file
},
}; //end prototype Model
......@@ -659,5 +659,20 @@ QUnit.test("getSampleWithSelectedClones", function(assert) {
m.select(2)
assert.deepEqual( m.getSampleWithSelectedClones(), [0,1,2], "clone 1 and 2, should return samples 1 and 2 and 3")
});
QUnit.test("getSampleName", function(assert) {
var m = new Model();
m.parseJsonData(json_data, 100)
m.initClones()
assert.equal( m.getSampleName(0), "Diag.fa", "Correct name getted as no values for m.samples.names (values from server)")
// Simulate data from server opening
m.samples.names = ["f0", "f1", "f2", "f3"]
assert.equal( m.getSampleName(0), "f0", "Correct name getted if values from server")
});
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