Commit 59f3e19d authored by Marc Duez's avatar Marc Duez

qunit test

parent 5370c5c2
......@@ -48,6 +48,7 @@ function Model() {
this[f] = Model_loader.prototype[f]
}
this.reset();
this.view = [];
this.checkBrowser();
this.germlineList = new GermlineList()
......@@ -211,6 +212,7 @@ Model.prototype = {
for (var i = 0; i < this.clones.length; i++) {
var clone = this.clone(i)
clone.colorN = colorGenerator((((clone.getNlength() / n_max) - 1) * (-250)));
clone.tag = this.default_tag;
}
this.applyAnalysis(this.analysis);
......@@ -323,7 +325,7 @@ Model.prototype = {
if (new_cluster.length != 0){
var l = new_cluster[0]
for (var j=0; j<new_cluster.length;j++){
if (m.clone(new_cluster[j]).top < m.clone(l).top) l = new_cluster[j]
if (this.clone(new_cluster[j]).top < this.clone(l).top) l = new_cluster[j]
}
this.clusters[l] = new_cluster;
}
......@@ -344,19 +346,6 @@ Model.prototype = {
return -1
},
/**
* erase all changes made by user or from the .analysis file
* */
resetAnalysis: function () {
console.log("resetAnalysis()");
this.analysis = {
clones: [],
cluster: [],
date: []
};
this.initClones();
},
/**
* return the given time index if exist, or the one currently used as default
* @return {integer} time - time index
......@@ -384,6 +373,7 @@ Model.prototype = {
* @return {string} timestamp - sample date
* */
getSampleTime: function(time) {
var time = typeof time !== 'undefined' ? time : this.t
var value = ""
if (typeof this.samples.timestamp != 'undefined'){
if (typeof this.samples.timestamp[time] != 'undefined'){
......@@ -398,9 +388,10 @@ Model.prototype = {
* @return {string} soft - name of the software used
* */
getSoftVersionTime: function(time) {
var time = typeof time !== 'undefined' ? time : this.t
var soft_version = ""
if (typeof m.samples.producer != 'undefined')
soft_version = m.samples.producer[time]
if (typeof this.samples.producer != 'undefined')
soft_version = this.samples.producer[time]
return soft_version;
},
......@@ -409,9 +400,10 @@ Model.prototype = {
* @return {string} command - sample command
* */
getCommandTime: function(time) {
var time = typeof time !== 'undefined' ? time : this.t
var command = ""
if (typeof m.samples.commandline != 'undefined')
command = m.samples.commandline[time]
if (typeof this.samples.commandline != 'undefined')
command = this.samples.commandline[time]
return command;
},
......@@ -420,9 +412,10 @@ Model.prototype = {
* @return {string} command - sample command
* */
getTimestampTime: function(time) {
var time = typeof time !== 'undefined' ? time : this.t
var timestamp = ""
if (typeof m.samples.run_timestamp != 'undefined')
timestamp = m.samples.run_timestamp[time]
if (typeof this.samples.run_timestamp != 'undefined')
timestamp = this.samples.run_timestamp[time]
return timestamp
},
......@@ -586,7 +579,7 @@ Model.prototype = {
* clones sizes can change depending the parameters so it's neccesary to recompute normalization from time to time
* */
update_normalization: function () {
if (this.normalization.B != 0 && this.normalization.type=="clone") {
if ((this.normalization.B != 0 && this.normalization.type=="clone" )) {
this.compute_normalization( this.normalization.id, this.normalization.B);
}
},
......
......@@ -185,19 +185,19 @@ Model_loader.prototype = {
var url_split = url.split('/')
$.ajax({
type: "POST",
type: "GET",
timeout: 5000,
crossDomain: true,
url: url,
success: function (result) {
self.parseJsonData(result, 100)
self.loadGermline();
self.initClones()
.loadGermline()
.initClones();
self.dataFileName = url_split[url_split.length-1]
callback()
},
error: function (request, status, error) {
console.log({"type": "flash", "msg": "error : can't reach " + url + "file", "priority": 2 });
console.log({"type": "flash", "msg": "error : can't reach " + url + " file", "priority": 2 });
}
});
......@@ -216,7 +216,7 @@ Model_loader.prototype = {
var url_split = url2.split('/')
$.ajax({
type: "POST",
type: "GET",
timeout: 5000,
crossDomain: true,
url: url2,
......@@ -451,6 +451,21 @@ Model_loader.prototype = {
saveAs(textFileAsBlob, filename + ".analysis");
self.m.analysisHasChanged = false
}, //end saveAnalysis
/**
* erase all changes made by user or from the .analysis file
* */
resetAnalysis: function () {
console.log("resetAnalysis()");
this.analysis = {
clones: [],
cluster: [],
date: []
};
this.initClones();
},
/**
* create a json string with analysis currently applied
......
......@@ -5,7 +5,7 @@ page.onConsoleMessage = function(msg) { console.log(msg); };
var curdir = phantom.args[0] || fs.workingDirectory;
page.open(curdir+"/test_Qunit.html", function() {
page.open("http://localhost/browser/test/QUnit/test_Qunit.html", function() {
setTimeout(function(){
var tap = page.evaluate(function() {
......
......@@ -74,7 +74,6 @@ test("Axis : ", function() {
//Nlength
axis.custom(function(cloneID) {
m.clone(cloneID).getNlength()
return m.clone(cloneID).getNlength();
},
0,25)
......@@ -97,4 +96,10 @@ test("Axis : ", function() {
equal(axis.pos(1).toPrecision(3), 0.992, "custom (percent+log) : clone 1 (gc = 17/18) position -> 0.992")
deepEqual(axis.labels[0].text, "100%", "custom (percent+log) : check label 100%")
deepEqual(axis.labels[1].text, "10%", "custom (percent+log) : check label 10%")
//output string
axis.custom(function(cloneID) {
return m.clone(cloneID).getName();
}, undefined, undefined, 'string')
equal(axis.pos(0).toPrecision(3), 0.100, "custom (name : clone 0 ")
});
var json_clone1 = {
"sequence" : "abcdefghijklmnopqrstuvwxyz",
"sequence" : "aaaaaaaaaattttttttt",
"name" : "hello",
"id" : "id1",
"reads" : [10,10,15,15] ,
......@@ -50,6 +50,7 @@ test("clone : name", function() {
equal(c3.getCode(), "id3", "get code clone3 : id3");
c3.changeName("plop")
equal(c3.getName(), "plop", "changename clone3 : plop");
equal(c3.getSequenceName(), "plop", "changename clone3 : plop");
m.select(0)
......@@ -63,8 +64,8 @@ test("clone : name", function() {
equal(c1.get('reads'), 10, "clone c1 reads : 10");
equal(c1.getSequenceSize(), "0.05", "clone c1 size : 0.05");
console.log(m.samples.order)
equal(c1.getHtmlInfo(), "<h2>Cluster info : hello</h2><div id='info_window'><table><tr><th></th><td>Diag</td><td>Fu-1</td><td>Fu-2</td><td>Fu-3</td></tr><tr><td class='header' colspan='5'> clone </td></tr><tr><td> clone name </td><td colspan='4'>hello</td></tr><tr><td> clone size (n-reads (total reads) )</td><td>20 (200)</td><td>20 (100)</td><td>30 (200)</td><td>30 (100)</td></tr><tr><td> clone size (%)</td><td>10.000 % </td><td>20.000 % </td><td>15.000 % </td><td>30.000 % </td><tr><td class='header' colspan='5'> representative sequence</td></tr><tr><td> sequence name </td><td colspan='4'>hello</td></tr><tr><td> code </td><td colspan='4'>hello</td></tr><tr><td> length </td><td colspan='4'>26</td></tr><tr><td> size (n-reads (total reads) )</td><td>10 (200)</td><td>10 (100)</td><td>15 (200)</td><td>15 (100)</td></tr><tr><td> size (%)</td><td>5.000 % </td><td>10.000 % </td><td>7.500 % </td><td>15.000 % </td></tr><tr><td class='header' colspan='5'> segmentation</td></tr><tr><td> sequence </td><td colspan='4'>abcdefghijklmnopqrstuvwxyz</td></tr><tr><td> id </td><td colspan='4'>id1</td></tr><tr><td> 5 </td><td colspan='4'>undefined V</td></tr><tr><td> 4 </td><td colspan='4'>IGHD2*03</td></tr><tr><td> 3 </td><td colspan='4'>IGHV4*01</td></tr><tr><td class='header' colspan='5'> &nbsp; </td></tr></table></div>",
"getHtmlInfo");
equal(c1.getHtmlInfo(), "<h2>Cluster info : hello</h2><div id='info_window'><table><tr><th></th><td>Diag</td><td>Fu-1</td><td>Fu-2</td><td>Fu-3</td></tr><tr><td class='header' colspan='5'> clone </td></tr><tr><td> clone name </td><td colspan='4'>hello</td></tr><tr><td> clone size (n-reads (total reads) )</td><td>20 (200)</td><td>20 (100)</td><td>30 (200)</td><td>30 (100)</td></tr><tr><td> clone size (%)</td><td>10.000 % </td><td>20.000 % </td><td>15.000 % </td><td>30.000 % </td><tr><td class='header' colspan='5'> representative sequence</td></tr><tr><td> sequence name </td><td colspan='4'>hello</td></tr><tr><td> code </td><td colspan='4'>hello</td></tr><tr><td> length </td><td colspan='4'>19</td></tr><tr><td> size (n-reads (total reads) )</td><td>10 (200)</td><td>10 (100)</td><td>15 (200)</td><td>15 (100)</td></tr><tr><td> size (%)</td><td>5.000 % </td><td>10.000 % </td><td>7.500 % </td><td>15.000 % </td></tr><tr><td class='header' colspan='5'> segmentation</td></tr><tr><td> sequence </td><td colspan='4'>aaaaaaaaaattttttttt</td></tr><tr><td> id </td><td colspan='4'>id1</td></tr><tr><td> 5 </td><td colspan='4'>undefined V</td></tr><tr><td> 4 </td><td colspan='4'>IGHD2*03</td></tr><tr><td> 3 </td><td colspan='4'>IGHV4*01</td></tr><tr><td class='header' colspan='5'> &nbsp; </td></tr></table></div>",
"getHtmlInfo");
});
......@@ -78,6 +79,8 @@ test("clone : size", function() {
var c3 = new Clone(json_clone3, m, 2)
m.initClones()
equal(c1.getSystemSize(), "0.1", "clone c1 system size : 0.1");
equal(c1.getStrSystemSize(), "10.000%", "clone c1 system size : 10%");
m.select(0)
m.select(1)
m.merge()
......@@ -89,6 +92,7 @@ test("clone : size", function() {
equal(c1.get('reads'), 10, "clone c1 reads : 10");
equal(c1.getSequenceSize(), "0.05", "clone c1 size : 0.05");
});
test("clone : system", function() {
......@@ -98,6 +102,7 @@ test("clone : system", function() {
var c1 = new Clone(json_clone1, m, 0)
m.initClones()
equal(c1.get('germline'), "TRG", "getSystem() >> clone system : TRG");
equal(c1.getGene('5'), "undefined V", "getV() >> V : undefined");
equal(c1.getGene('4'), "IGHD2*03", "getD() >> D (+allele): IGHD2*03");
......@@ -131,3 +136,17 @@ test("clone : tag / color", function() {
equal(c1.getColor(), "rgb(183,36,36)", "getColor() >> abundance color : ");
});
test("clone : export", function() {
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
m.initClones()
equal(c1.getPrintableSegSequence(), "aaaaa\naaaaatttt\nttttt", "getPrintableSegSequence() : Ok");
console.log(c1.getFasta())
equal(c1.getFasta(), ">hello 200 reads (100.00%)\naaaaa\naaaaatttt\nttttt\n", "getFasta() : Ok");
});
test("console : ", function() {
console = new Com(console)
stop()
console.log({msg: 'plop', type: 'flash', priority: 3})
setTimeout( function() {
start()
var box = document.getElementsByClassName("flash_container")[0]
notEqual(box.innerHTML.indexOf("plop"), -1, "console flash : Ok")
}, 100)
stop()
console.log({msg: 'plup', type: 'popup', priority: 3})
setTimeout( function() {
start()
var box = document.getElementsByClassName("popup_container")[0]
notEqual(box.innerHTML.indexOf("plup"), -1, "console popup : Ok")
console.closePopupMsg()
equal(box.innerHTML.indexOf("plup"), -1, "console close popup : Ok")
}, 100)
stop()
console.log({msg: 'plip', type: 'big-popup', priority: 3})
setTimeout( function() {
start()
var box = document.getElementsByClassName("data-container")[0]
notEqual(box.innerHTML.indexOf("plip"), -1, "console data : Ok")
console.closeDataBox()
equal(box.innerHTML.indexOf("plip"), -1, "console close data : Ok")
}, 100)
stop()
console.log({msg: 'plap', type: 'log', priority: 3})
setTimeout( function() {
start()
var box = document.getElementsByClassName("log_container")[0]
notEqual(box.innerHTML.indexOf("plap"), -1, "console log : Ok")
}, 100)
});
......@@ -28,7 +28,9 @@ json_data = {
" ==> segmented 407095 reads (56.5%)\n ==> found 35801 40-windows in 396776 segments (55.1%) inside 720531 sequences\n ",
" ==> segmented 419506 reads (46.2%)\n ==> found 19567 40-windows in 400435 segments (44.1%) inside 908909 sequences\n ",
" ==> segmented 448435 reads (48.2%)\n ==> found 43444 40-windows in 418595 segments (45%) inside 929901 sequences\n "
]
],
"producer": ["ha","hi","ho","hu"],
"run_timestamp": ["2015-10-20 13:59:02", "2015-10-25 14:00:32", "2015-11-20 14:03:13", "2015-12-20 14:04:48"]
},
"data": {
"dataTest1" : [45,60,52,60],
......
......@@ -4,14 +4,48 @@ test("model : load", function() {
var m = new Model();
m.parseJsonData(json_data)
equal(m.samples.number, 4, "timepoint : number==4");
equal(m.samples.number, m.samples.original_names.length, "timepoint : check if array have the expected length");
equal(m.samples.number, 4, "parse_json > timepoint : number==4");
equal(m.samples.number, m.samples.original_names.length, "parse_json > timepoint : check if array have the expected length");
stop()
m.loadDataUrl("http://localhost/browser/test/QUnit/testFiles/test.vidjil")
setTimeout( function() {
start()
equal(m.samples.number, 3, "loadDataUrl > timepoint : number==3")
}, 100)
stop()
m.loadAnalysisUrl("http://localhost/browser/test/QUnit/testFiles/test.analysis")
setTimeout( function() {
start()
equal(m.clone(0).tag, 0, "loadAnalysisUrl() : OK")
equal(m.getPrintableAnalysisName() , "test", "getPrintableAnalysisName : Ok")
deepEqual(jQuery.parseJSON(m.strAnalysis()).producer, "browser" , "strAnalysis() : OK")
m.resetAnalysis();
equal(m.clone(0).tag, 8, "resetAnalysis() : OK")
}, 100)
});
test("model : time control", function() {
var m = new Model();
m.parseJsonData(json_data)
equal(m.getSampleTime(), "2014-10-20 13:59:02", "getSampleTime : Ok")
equal(m.getSampleTime(2), "2014-11-20 14:03:13", "getSampleTime : Ok")
equal(m.getSoftVersionTime(), "ha", "getSoftVersionTime : Ok")
equal(m.getSoftVersionTime(2), "ho", "getSoftVersionTime : Ok")
equal(m.getCommandTime(), "./vidjil -c clones -g germline/ -r 1 -o ./out0 -z 200 -n 5 Diag.fa ", "getCommandTime : Ok")
equal(m.getCommandTime(2), "./vidjil -c clones -g germline/ -r 1 -o ./out2 -z 200 -n 5 Fu-2.fa ", "getCommandTime : Ok")
equal(m.getTimestampTime(), "2015-10-20 13:59:02", "getTimestampTime : Ok")
equal(m.getTimestampTime(2), "2015-11-20 14:03:13", "getTimestampTime : Ok")
equal(m.t, 0, "default timepoint = 0"); // [0,1,2,3] => 0
deepEqual(m.samples.order, [0,1,2,3], "default order = [0,1,2,3]")
......@@ -59,6 +93,8 @@ test("model : select/focus", function() {
m.multiSelect([0,2,3])
deepEqual(m.getSelected(), [0,2,3], "multi-select");
m.unselectAll()
equal(m.findWindow("aaaaaaaaaaaid1aaaaaaa"), 0, "findWindow : Ok")
equal(m.findWindow("aaaaaaaaaaaplopaaaaaaa"), -1, "findWindow : Ok")
m.focusIn(0)
});
......@@ -96,6 +132,12 @@ test("model : cluster", function() {
m.resetClusters()
deepEqual(m.clusters, [[0],[1],[2],[3]], "resetClusters");
var m = new Model();
m.parseJsonData(json_data,100)
m.loadCluster([["id1", "id2"]])
deepEqual(m.clusters[0], [0,1], "loadCluster() : Ok");
});
test("model: system selection", function() {
......
......@@ -5,6 +5,11 @@
<title>QUnit - The Vidjil Project</title>
<link rel="stylesheet" href="../../css/qunit-1.15.0.css">
<style>
.flash_container, .log_container, .popup_container, .data-container{
display:none !important;
}
</style>
<script type="text/javascript" src='../../js/lib/d3.v3.js'></script>
<script type="text/javascript" src="../../js/lib/jquery-2.1.1.min.js"></script>
......@@ -20,28 +25,28 @@
<script type="text/javascript" src='../../js/lib/file.js'></script>
<script type="text/javascript" src='../../js/lib/jquery.zclip.js'></script>
<script type="text/javascript" src='../../js/view.js'></script>
<script type="text/javascript" src='../../js/view.js' data-cover></script>
<script type="text/javascript" src='../../js/compare.js' data-cover></script>
<script type="text/javascript" src='../../js/menu.js'></script>
<script type="text/javascript" src='../../js/dbscan.js'></script>
<script type="text/javascript" src='../../js/germline.js'></script>
<script type="text/javascript" src='../../../germline/germlines.data'></script>
<script type="text/javascript" src='../../js/germline_builder.js'></script>
<script type="text/javascript" src='../../js/segmenter.js'></script>
<script type="text/javascript" src='../../js/menu.js' data-cover></script>
<script type="text/javascript" src='../../js/dbscan.js' data-cover></script>
<script type="text/javascript" src='../../js/germline.js' ></script>
<script type="text/javascript" src='../../../germline/germlines.data' ></script>
<script type="text/javascript" src='../../js/germline_builder.js' data-cover></script>
<script type="text/javascript" src='../../js/segmenter.js' data-cover></script>
<script type="text/javascript" src='../../js/model_loader.js' data-cover></script>
<script type="text/javascript" src='../../js/model.js' data-cover></script>
<script type="text/javascript" src='../../js/clone.js' data-cover></script>
<script type="text/javascript" src='../../js/list.js'></script>
<script type="text/javascript" src='../../js/list.js' data-cover></script>
<script type="text/javascript" src="../../js/axis.js" data-cover> </script>
<script type="text/javascript" src="../../js/graph.js" data-cover> </script>
<script type="text/javascript" src="../../js/scatterPlot.js" data-cover> </script>
<script type="text/javascript" src='../../js/builder.js'></script>
<script type="text/javascript" src='../../js/com.js'></script>
<script type="text/javascript" src='../../js/vidjil-style.js'></script>
<script type="text/javascript" src='../../js/crossDomain.js'></script>
<script type="text/javascript" src='../../js/builder.js' data-cover></script>
<script type="text/javascript" src='../../js/com.js' data-cover></script>
<script type="text/javascript" src='../../js/vidjil-style.js' data-cover></script>
<script type="text/javascript" src='../../js/crossDomain.js' data-cover></script>
<script type="text/javascript" src='../../js/pdf.js'></script>
<script type="text/javascript" src='../../js/database.js'></script>
<script type="text/javascript" src='../../js/stats.js'></script>
<script type="text/javascript" src='../../js/database.js' data-cover></script>
<script type="text/javascript" src='../../js/stats.js' data-cover></script>
<script type="text/javascript" src="./testFiles/data_test.js"></script>
</head>
......@@ -82,5 +87,6 @@
<script src="./testFiles/scatterPlot_test.js"></script>
<script src="./testFiles/axis_test.js"></script>
<script src="./testFiles/graph_test.js"></script>
<script src="./testFiles/com_test.js"></script>
</body>
</html>
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