Commit 0d486d1c authored by Mikaël Salson's avatar Mikaël Salson

Merge branch 'feature-c/3127-warn-levels' into 'dev'

Feature c/3127 warn levels

See merge request !177
parents d926e405 d6d56623
Pipeline #21446 failed with stages
in 47 seconds
......@@ -1171,15 +1171,21 @@ span.info {
text.info {
color: blue;
}
span.warn,
span.warning {
color: orange;
}
text.warn,
text.warning {
fill: orange;
}
span.error,
span.fatal,
span.alert {
color: red;
}
text.error,
text.fatal,
text.alert {
fill: red;
}
......
......@@ -1171,15 +1171,21 @@ span.info {
text.info {
color: blue;
}
span.warn,
span.warning {
color: orange;
}
text.warn,
text.warning {
fill: orange;
}
span.error,
span.fatal,
span.alert {
color: red;
}
text.error,
text.fatal,
text.alert {
fill: red;
}
......
......@@ -1171,15 +1171,21 @@ span.info {
text.info {
color: blue;
}
span.warn,
span.warning {
color: orange;
}
text.warn,
text.warning {
fill: orange;
}
span.error,
span.fatal,
span.alert {
color: red;
}
text.error,
text.fatal,
text.alert {
fill: red;
}
......
......@@ -1170,15 +1170,21 @@ span.info {
text.info {
color: blue;
}
span.warn,
span.warning {
color: orange;
}
text.warn,
text.warning {
fill: orange;
}
span.error,
span.fatal,
span.alert {
color: red;
}
text.error,
text.fatal,
text.alert {
fill: red;
}
......
......@@ -1349,10 +1349,10 @@ span.ok { color: green; }
text.ok { color: green; }
span.info { color: blue; }
text.info { color: blue; }
span.warning { color: orange; }
text.warning { fill: orange; }
span.alert { color: red; }
text.alert { fill: red; }
span.warn, span.warning { color: orange; }
text.warn, text.warning { fill: orange; }
span.error, span.fatal, span.alert { color: red; }
text.error, text.fatal, text.alert { fill: red; }
span.warningReads {
margin-left: .5em;
......
......@@ -54,7 +54,7 @@ function Clone(data, model, index, virtual) {
this.warn = []
if (typeof this.warn === 'string')
this.warn = [ this.warn ]
this.warn = [ {'code': '', 'level': warnLevels[WARN], 'msg': this.warn } ]
// .shortName
if (typeof (this.getSequence()) != 'undefined' && typeof (this.name) != 'undefined') {
......@@ -88,8 +88,10 @@ Clone.prototype = {
/**
* @return {string} a warning class is set on this clone
*/
if (this.warn.length) {
return 'warning'
var wL = this.warnLevel()
if (wL >= WARN) {
return warnTextOf(wL)
}
if (this.hasSeg('clonedb')) {
......@@ -104,18 +106,25 @@ Clone.prototype = {
computeWarnings: function() {
console.log(this.coverage)
if (this.coverage < this.COVERAGE_WARN)
this.warn.push({'code': 'W51', 'msg': 'Low coverage (' + this.coverage.toFixed(3) + ')'}) ;
this.warn.push({'code': 'W51', 'level': warnLevels[WARN], 'msg': 'Low coverage (' + this.coverage.toFixed(3) + ')'}) ;
if (typeof(this.eValue) != 'undefined' && this.eValue > this.EVALUE_WARN)
this.warn.push({'code': 'Wxx', 'msg': 'Bad e-value (' + this.eValue + ')' });
this.warn.push({'code': 'Wxx', 'level': warnLevels[WARN], 'msg': 'Bad e-value (' + this.eValue + ')' });
},
warnLevel: function () {
var level = 0
for (var i = 0; i < this.warn.length; i++) {
level = Math.max(level, warnLevelOf(this.warn[i].level))
}
return level
},
warnText: function () {
items = []
var items = []
for (var i = 0; i < this.warn.length; i++) {
items.push(this.warn[i].code + ': ' + this.warn[i].msg)
......
......@@ -366,3 +366,35 @@ function remove_all_children(node)
Node.prototype.removeAllChildren = function removeAllChildren() {
remove_all_children(this);
}
FATAL = 50
ERROR = 40
WARN = 30
INFO = 20
DEBUG = 10
warnLevels = {
'fatal': FATAL,
'error': ERROR,
'warn': WARN,
'info': INFO,
'debug': DEBUG
}
warnTexts = { }
for (var key in warnLevels) {
warnTexts[warnLevels[key]] = key ;
}
function warnLevelOf(key)
{
return (key in warnLevels) ? warnLevels[key] : WARN
}
function warnTextOf(key)
{
return (key in warnTexts) ? warnTexts[key] : '?'
}
......@@ -36,7 +36,11 @@ QUnit.module("Clone", {
"reads" : [10,10,30,0] ,
"top" : 2,
"germline" : "TRG",
"warn": [{
"code": "Wxx",
"msg": "a warning that is only an information",
"level": "info"
}],
"seg" : {
"5" : {'start': 2, 'stop': 6, 'delRight': 18}, // 1-based (current format)
}
......@@ -50,7 +54,7 @@ QUnit.module("Clone", {
"reads" : [10,10,15,15] ,
"top" : 3,
"germline" : "TRG",
"warn": "a warning",
"warn": "a warning, old style",
"seg" : {
"3" : "IGHV4*01",
"4" : "IGHD2*03",
......@@ -77,6 +81,15 @@ QUnit.module("Clone", {
"reads" : [10,10,15,15] ,
"top" : 4,
"germline" : "TRG",
"warn": [{
"code": "Wyy",
"msg": "a normal warning",
"level": "warn"
},{
"code": "Wzz",
"msg": "a severe warning",
"level": "error"
}],
"seg" : {
"3" : "IGHV4*01",
"4" : "IGHD2*03",
......@@ -123,9 +136,12 @@ QUnit.test("name, informations, getHtmlInfo", function(assert) {
assert.equal(c2.getCode(), some_name, "clone2, .getCode()");
assert.equal(c2.getName(), some_name, "clone2, .getName()");
assert.equal(c2.getShortName(), "IGHV3-23 6/ACGTG/4 D1-1 5/12/4 J5*02", "clone2, .getShortName()");
assert.equal(c2.isWarned(), false, "clone2 is not warned")
assert.equal(c3.isWarned(), 'warning', "clone3 is warned")
assert.equal(c1.isWarned(), 'warn', "clone1 is warned (client, bad e-value)")
assert.equal(c2.isWarned(), false, "clone2 is not warned (only 'info')")
assert.equal(c3.isWarned(), 'warn', "clone3 is warned with 'warn'")
assert.equal(c4.isWarned(), 'error', "clone4 is warned with 'error'")
assert.equal(c5.isWarned(), false, "clone5 is not warned")
assert.equal(c3.getSequenceName(), "custom name", "get name clone3 : custom name");
assert.equal(c3.getCode(), "id3", "get code clone3 : id3");
......
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