Commit b08d8ce4 authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

Merge branch 'feature-c/fix-2473' into 'dev'

Prevent error without consensus sequence

Closes #2473

See merge request !44
parents 348e4bfc 44bcb3be
......@@ -770,8 +770,8 @@ Clone.prototype = {
},
computeGCContent: function () {
if (typeof (this.sequence) == 'undefined') {
this.GCContent = '?'
if (this.getSequenceLength() === 0) {
this.GCContent = undefined
return
}
......@@ -784,7 +784,8 @@ Clone.prototype = {
},
getSequenceLength : function () {
if (typeof (this.sequence) != 'undefined' && this.sequence !== 0){
if (typeof (this.sequence) != 'undefined' &&
typeof (this.sequence.length) != 'undefined'){
return this.sequence.length
}else{
return 0;
......
......@@ -92,6 +92,14 @@ QUnit.module("Clone", {
}
}
// Clone with undefined sequence
var json_clone5 = {
"sequence": 0,
"name": "undefined clone",
reads: [1, 5, 2, 0],
"top": 5,
};
QUnit.test("name, informations, getHtmlInfo", function(assert) {
var m = new Model();
......@@ -100,11 +108,16 @@ QUnit.test("name, informations, getHtmlInfo", function(assert) {
var c2 = new Clone(json_clone2, m, 1)
var c3 = new Clone(json_clone3, m, 2)
var c4 = new Clone(json_clone4, m, 3)
var c5 = new Clone(json_clone5, m, 4)
m.initClones()
assert.equal(c1.getSequenceName(), "hello", "get name clone1 : hello");
assert.equal(c1.getCode(), "hello", "get code clone1 : hello");
assert.equal(c1.getSequenceLength(), 19, "clone1 sequence: 19nt");
assert.equal(c2.getSequenceLength(), 11, "clone2 sequence: 11nt");
assert.equal(c5.getSequenceLength(), 0, "clone5 sequence: 0nt");
assert.equal(c2.getSequenceName(), some_name, "clone2, .getSequenceName()");
assert.equal(c2.getCode(), some_name, "clone2, .getCode()");
assert.equal(c2.getName(), some_name, "clone2, .getName()");
......@@ -120,6 +133,10 @@ QUnit.test("name, informations, getHtmlInfo", function(assert) {
assert.equal(c2.getNameAndCode(), some_name, "clone2, .getNameAndCode()");
assert.equal(c3.getNameAndCode(), "plop (id3)", "clone3, .getNameAndCode()");
assert.equal(c1.GCContent, 0, "clone1 0% GC content");
assert.equal(typeof(c5.GCContent), 'undefined', "clone5, no GC content for c5: no consensus sequence");
assert.equal(typeof(c5.coverage), 'undefined', "clone5, no GC content for c5: no consensus sequence");
m.select(0)
m.select(1)
......
Supports Markdown
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