Commit 092ddd40 authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-c/4354-analysis_order_loading' into 'dev'

Resolve "Chargement impossible après enregistrement d'une analyse avec un sample caché"

Closes #4354

See merge request !737
parents cc8cd449 ce2aea28
Pipeline #152753 passed with stages
in 60 minutes and 47 seconds
......@@ -416,7 +416,13 @@ Model_loader.prototype = {
return fields;
},
/**
* recalculating the array is sometimes necessary if the analysis and fused_file have diverged.
* @param {Array} arr [description]
* @return {Array} [description]
*/
calculateOrder: function(arr) {
tmp = arr.slice();
res = arr.slice();
previous = -1;
......@@ -473,10 +479,21 @@ Model_loader.prototype = {
for (var key in dict[id]) {
clone[key][idx] = dict[id][key];
}
}
}
if ('order' in analysis) {
if ('order' in analysis && 'stock_order' in analysis) {
// Jquery Extend don't work on samples.order.
clone.order = analysis.order
clone.stock_order = analysis.stock_order
// Check if new sample have been added
if (clone.stock_order.length < this.samples.number){
for (var j = clone.stock_order.length; j < this.samples.number; j++) {
clone.order.push(j)
clone.stock_order.push(j)
}
}
} else if ('order' in analysis && !('stock_order' in analysis)) {
// Keep this behavior to ope old samples/analysis
clone.order = this.calculateOrder(clone.order);
}
return clone;
......@@ -589,6 +606,7 @@ Model_loader.prototype = {
}
}
this.toggle_all_systems(true);
this.t = this.samples.order[0]
}else{
console.log({"type": "flash", "msg": "invalid version for this .analysis file" , "priority": 1});
......
......@@ -311,3 +311,72 @@ data_distributions = {
}]
}
}
analysis_data_stock_order = {
"producer": "browser",
"timestamp": "2017-2-13 10:41:25",
"vidjil_json_version": "2014.09",
"samples": {
"id": [
"Diag.fa",
"Fu-0.fa",
"Fu-1.fa",
"Fu-2.fa"
],
"timestamp": [
"2014-10-20 13:59:02",
"2014-10-22 11:00:32",
"2014-10-22 11:00:32",
"2014-10-25 14:00:32"
],
"commandline": [
"./vidjil -c clones -g germline/ -r 1 -o ./out0 -z 200 -n 5 Diag.fa ",
"./vidjil -c clones -g germline/ -r 1 -o ./out1 -z 200 -n 5 Fu-0.fa ",
"./vidjil -c clones -g germline/ -r 1 -o ./out1 -z 200 -n 5 Fu-0.fa ",
"./vidjil -c clones -g germline/ -r 1 -o ./out2 -z 200 -n 5 Fu-1.fa "
],
"number": 4,
"order": [
3,
0,
1
],
"stock_order": [
2,
3,
0,
1
],
"names": [
"diag",
"fu0",
"fu1",
"fu2"
]
},
"clones": [
],
"clusters": [],
"tags": {
"names": {
"0": "clone 1",
"1": "clone 2",
"2": "clone 3",
"3": "standard",
"4": "standard (noise)",
"5": "custom 1",
"6": "custom 2",
"7": "custom 3",
"8": "-/-"
},
"hide": []
},
"normalization": {
"A": [],
"B": 0,
"id": -1
}
}
......@@ -62,6 +62,23 @@ QUnit.test("load", function(assert) {
});
QUnit.test("load with new order && stock_order", function(assert) {
var m = new Model();
m.parseJsonData(json_data, 100)
m.initClones()
m.parseJsonAnalysis(analysis_data_stock_order)
m.initClones()
assert.deepEqual(m.samples.order, [3,0,1], "Correct order after loading" )
assert.deepEqual(m.samples.stock_order, [2,3,0,1], "Correct stock_order after loading" )
assert.equal(m.t, 3, "Correct time selected after analysis loading")
// 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)")
});
QUnit.test("time control", function(assert) {
var m = new Model();
m.parseJsonData(json_data)
......
......@@ -20,6 +20,10 @@ class TestCluster < BrowserTest
end
def test_00_list_clones
# change current sample to start on sample 0 (second in loaded order)
$b.send_keys :arrow_right
$b.update_icon.wait_while(&:present?)
assert ($b.div(:id => 'cluster1').exists? ), '>> cluster1 exist'
assert (not $b.clone_cluster('1').present?), '>> cluster1 is not display'
end
......
......@@ -20,7 +20,10 @@ class TestList < BrowserTest
end
def test_00_list_clones
# change current sample to start on sample 0 (second in loaded order)
$b.send_keys :arrow_right
$b.update_icon.wait_while(&:present?)
# declare variables
$lock = $b.listLock()
$listClone = $b.list()
......
......@@ -15,6 +15,10 @@ class TestLoadingAnalysis < BrowserTest
end
def test_001_name
# change current sample to start on sample 0 (second in loaded order)
$b.send_keys :arrow_right
$b.update_icon.wait_while(&:present?)
assert ($b.graph_x_legend('0').text == '2019-12-17')
assert ($b.graph_x_legend('1').text == '+10')
......
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