Commit 5bf132c9 authored by Mikaël Salson's avatar Mikaël Salson

Merge branch 'feature-c/4057-distributions-le-calcul-de-countrealclones-est-faux' into 'dev'

Resolve "Distributions : le calcul de countRealClones est faux"

Closes #4057

See merge request !549
parents a8edddc8 7358b86a
Pipeline #106471 passed with stages
in 49 minutes and 27 seconds
......@@ -1321,8 +1321,9 @@ changeAlleleNotation: function(alleleNotation) {
this.top = top;
// top show cannot be greater than the number of clones
if (top > this.countRealClones())
top = this.countRealClones()
var max_clones = this.countRealClones();
if (top > max_clones)
top = max_clones;
this.current_top = top
var html_slider = document.getElementById('top_slider');
......@@ -1348,7 +1349,14 @@ changeAlleleNotation: function(alleleNotation) {
* added)
* */
countRealClones: function() {
return this.clones.length - this.system_available.length;
var sum = 0;
for (var i = 0; i < this.clones.length; i++) {
var clone = this.clones[i]
if (clone.hasSizeConstant()){
sum += 1
}
}
return sum
},
/**
......
......@@ -234,3 +234,31 @@ json_data = {
}
]
};
data_distributions = {
"keys": ["clones", "reads"],
"repertoires": {
"Diag.fa": [
{
"axes": ["lenSeqAverage"],
"values": { "18": [1, 20], "20": [11, 125], "21": [11, 46], "241": [1, 5], "?": [1, 4] }
}],
"Fu-1.fa": [
{
"axes": ["lenSeqAverage"],
"values": { "18": [1, 20], "20": [1, 25], "21": [6, 46], "241": [1, 5], "?": [1, 4] }
}],
"Fu-2.fa": [
{
"axes": ["lenSeqAverage"],
"values": { "18": [5, 26], "20": [1, 50], "21": [10, 115], "241": [1, 5], "?": [1, 4] }
}],
"Fu-3.fa": [
{
"axes": ["lenSeqAverage"],
"values": { "18": [1, 10], "20": [1, 3], "21": [7, 27], "241": [1, 50], "?": [1, 20] }
}]
}
}
......@@ -521,4 +521,31 @@ QUnit.test("tag / color", function(assert) {
m.select(2)
assert.equal(m.getColorSelectedClone(), "", "Color of selected clones (mix of clones) is false")
});
\ No newline at end of file
});
QUnit.test("distribution_load", function(assert) {
var m1 = new Model();
m1.parseJsonData(json_data, 100)
m1.initClones()
assert.equal(m1.clones.length, 7, 'Correct number of clones WITHOUT distributions clones')
assert.equal(m1.countRealClones(), 5, 'Correct number of real clones WITHOUT distributions clones')
m1.distributions = data_distributions
m1.loadAllDistribClones()
assert.equal(m1.clones.length, 12, 'Correct number of clones WITH distributions clones')
assert.equal(m1.countRealClones(), 5, 'Correct number of real clones WITH distributions clones')
// Add distrib values directly into json data
var json_data_bis = JSON.parse(JSON.stringify(json_data)) // hard copy
json_data_bis.distributions = data_distributions
var m2 = new Model();
m2.parseJsonData(json_data_bis, 100)
assert.equal(m2.clones.length, 12, 'Correct number of clones WITH distributions clones (directly from json_data)')
assert.equal(m2.countRealClones(), 5, 'Correct number of real clones WITH distributions clones (directly from json_data)')
});
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