Commit 4968bbed authored by Thonier Florian's avatar Thonier Florian

model_loader; fix error if sample is present twice in analyses order field

Link to #4381
parent e6f1e6c6
Pipeline #153365 passed with stages
in 13 minutes and 26 seconds
......@@ -483,12 +483,16 @@ Model_loader.prototype = {
}
// Fix case of error where same timepoint is present multiple time in order
clone.order = clone.order.filter(function(item, pos) {
return clone.order.indexOf(item) == pos;
})
clone.stock_order = clone.stock_order.filter(function(item, pos) {
return clone.stock_order.indexOf(item) == pos;
})
if (analysis.order != undefined){
analysis.order = analysis.order.filter(function(item, pos) {
return analysis.order.indexOf(item) == pos;
})
}
if (analysis.stock_order != undefined){
analysis.stock_order = analysis.stock_order.filter(function(item, pos) {
return analysis.stock_order.indexOf(item) == pos;
})
}
if ('order' in analysis && 'stock_order' in analysis) {
// Jquery Extend don't work on samples.order.
......
......@@ -76,6 +76,19 @@ QUnit.test("load with new order && stock_order", function(assert) {
// Note, respective clone 0 size: 0.05, 0.1, 0.075, 0.15
assert.equal( m.clones[0].getSize(), m.clones[0].getSize(3), "clone 0 hve size corresponding to timepoint 3 (loading order)")
// Test loading file with duplicate sample present in order field of analysis
var m = new Model();
m.parseJsonData(json_data, 100)
m.initClones()
analysis_data_stock_order_with_error = JSON.parse(JSON.stringify(analysis_data_stock_order))
analysis_data_stock_order_with_error.samples.order = [3, 3, 0, 1]
m.parseJsonAnalysis(analysis_data_stock_order_with_error)
m.initClones()
assert.deepEqual(m.samples.order, [3,0,1], "Correct order after loading analysis with dusplicate sample in order" )
assert.deepEqual(m.samples.stock_order, [2,3,0,1], "Correct stock_order after loading analysis with dusplicate sample in order" )
});
......
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