Commit 0e46514e authored by Thonier Florian's avatar Thonier Florian Committed by Mathieu Giraud

tests: add & update various tests

Add clone attributes to clones in unit tests
Allow to test various behavior of major refactoring
Add a specific functionnal test script to allow testing new behavior of clones

Link to #3902, #3945
parent e99a796d
......@@ -7,7 +7,7 @@ headless:
HEADLESS=1 $(MAKE) functional
HEADLESS=1 $(MAKE) external
functional: ../../doc/analysis-example1.vidjil
functional: ../../doc/analysis-example1.vidjil ../../tools/tests/data/fused_multiple.vidjil
sh launch_functional_tests $(BROWSERS) functional/test_*rb
external: ../../doc/analysis-example1.vidjil
......
......@@ -127,12 +127,12 @@ QUnit.test("name, informations, getHtmlInfo", function(assert) {
assert.equal(json_clone1.seg.junction.start, 10, "Start junction is 10 in JSON for clone 1");
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
assert.equal(c1.seg.junction.start, 9, "Start junction is now 9 for clone 1 as positions start at 0 in the code");
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)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
var c3 = new Clone(json_clone3, m, 2, c_attributes)
var c4 = new Clone(json_clone4, m, 3, c_attributes)
var c5 = new Clone(json_clone5, m, 4, c_attributes)
m.initClones()
assert.equal(c1.getSequenceName(), "hello", "get name clone1 : hello");
......@@ -261,9 +261,9 @@ QUnit.test("name, informations, getHtmlInfo", function(assert) {
QUnit.test('clone: get info from seg', function(assert) {
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
var c2 = new Clone(json_clone2, m, 1)
var c3 = new Clone(json_clone3, m, 2)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
var c3 = new Clone(json_clone3, m, 2, c_attributes)
m.initClones()
assert.ok(c1.hasSeg('cdr3'), "clone1 has CDR3")
......@@ -304,9 +304,9 @@ QUnit.test('clone: get info from seg', function(assert) {
QUnit.test("clone : feature defined by a nucleotide sequence", function(assert) {
var m = new Model()
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
var c2 = new Clone(json_clone2, m, 1)
var c3 = new Clone(json_clone3, m, 2)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
var c3 = new Clone(json_clone3, m, 2, c_attributes)
m.initClones()
assert.deepEqual(c3.getSegStartStop('somefeature'), null, "start/stop positions are not present")
......@@ -318,9 +318,9 @@ QUnit.test("clone : feature defined by a nucleotide sequence", function(assert)
QUnit.test("getSequence/RevComp", function(assert) {
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
var c2 = new Clone(json_clone2, m, 1)
var c3 = new Clone(json_clone3, m, 2)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
var c3 = new Clone(json_clone3, m, 2, c_attributes)
m.initClones()
//fix test sequence et revcomp
......@@ -335,9 +335,9 @@ QUnit.test("size", function(assert) {
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
var c2 = new Clone(json_clone2, m, 1)
var c3 = new Clone(json_clone3, m, 2)
c1 = new Clone(json_clone1, m, 0, c_attributes)
c2 = new Clone(json_clone2, m, 1, c_attributes)
c3 = new Clone(json_clone3, m, 2, c_attributes)
m.initClones()
assert.equal(c1.getSystemSize(), "0.1", "clone c1 system size : 0.1");
......@@ -368,7 +368,7 @@ QUnit.test("system", function(assert) {
var m = new Model();
m.parseJsonData(json_data)
var c3 = new Clone(json_clone3, m, 0)
var c3 = new Clone(json_clone3, m, 0, c_attributes)
m.initClones()
......@@ -387,7 +387,7 @@ QUnit.test("tag / color", function(assert) {
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
m.initClones()
assert.equal(c1.getTag(), 8, "getTag() >> default tag : 8");
......@@ -408,8 +408,8 @@ QUnit.test("tag / color", function(assert) {
QUnit.test("color by CDR3", function(assert) {
var m = new Model();
m.parseJsonData(json_data);
var c1 = new Clone(json_clone1, m, 0);
var c2 = new Clone(json_clone2, m, 0);
var c1 = new Clone(json_clone1, m, 0, c_attributes);
var c2 = new Clone(json_clone2, m, 0, c_attributes);
m.initClones();
var color = c1.getCDR3Color();
c1.seg.junction.aa = "AZERTY";
......@@ -426,8 +426,8 @@ QUnit.test("export", function(assert) {
var m = new Model();
m.parseJsonData(json_data)
var c3 = new Clone(json_clone3, m, 0)
var c4 = new Clone(json_clone4, m, 1)
var c3 = new Clone(json_clone3, m, 0, c_attributes)
var c4 = new Clone(json_clone4, m, 1, c_attributes)
m.initClones()
assert.equal(c3.getPrintableSegSequence(), "aaaaaa\naaaattttt\ntttt", "c3.getPrintableSegSequence() : Ok");
......@@ -478,9 +478,9 @@ QUnit.test("changeLocus/Segment", function(assert) {
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
var c2 = new Clone(json_clone2, m, 1)
var c3 = new Clone(json_clone3, m, 2)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
var c3 = new Clone(json_clone3, m, 2, c_attributes)
m.initClones()
// Test after germline manual changement
......@@ -505,9 +505,9 @@ QUnit.test("changeLocus/Segment", function(assert) {
QUnit.test("changeNameNotation", function(assert) {
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
var c2 = new Clone(json_clone2, m, 1)
var c3 = new Clone(json_clone3, m, 2)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
var c3 = new Clone(json_clone3, m, 2, c_attributes)
m.initClones()
m.changeCloneNotation('short_sequence')
assert.equal(c2.getShortName(), "IGHV3-23 6/ACGTG/4 D1-1 5/12/4 J5*02", "clone2, .getShortName()");
......@@ -523,10 +523,10 @@ QUnit.test("getLengthDoubleFeature", function(assert) {
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
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 c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
var c3 = new Clone(json_clone3, m, 2, c_attributes)
var c4 = new Clone(json_clone4, m, 3, c_attributes)
m.initClones()
assert.equal(c2.getSegLengthDoubleFeature('primer5','primer3'), "undefined", "C2 getSegLengthDoubleFeature('primer5','primer3')");
......@@ -537,9 +537,9 @@ QUnit.test("getLengthDoubleFeature", function(assert) {
QUnit.test("changealleleNotation", function(assert) {
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
var c2 = new Clone(json_clone2, m, 1)
var c3 = new Clone(json_clone3, m, 2)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
var c3 = new Clone(json_clone3, m, 2, c_attributes)
m.initClones()
m.changeAlleleNotation('always')
......@@ -554,9 +554,9 @@ QUnit.test("changealleleNotation", function(assert) {
QUnit.test("productivity", function(assert) {
var m = new Model();
m.parseJsonData(json_data);
var c1 = new Clone(json_clone1, m, 0);
var c2 = new Clone(json_clone2, m, 1);
var c3 = new Clone(json_clone3, m, 2);
var c1 = new Clone(json_clone1, m, 0, c_attributes);
var c2 = new Clone(json_clone2, m, 1, c_attributes);
var c3 = new Clone(json_clone3, m, 2, c_attributes);
m.initClones();
assert.equal(c1.getProductivityName(), "productive", "clone 1 should be productive");
......@@ -579,3 +579,32 @@ QUnit.test("productivity", function(assert) {
assert.equal(c3.getPhase(), 'undefined', "No phase for clone 3");
});
QUnit.test("attributes", function(assert) {
var m = new Model();
m.parseJsonData(json_data);
var c1 = new Clone(json_clone1, m, 0, c_attributes);
var c2 = new Clone(json_clone2, m, 1, c_attributes);
var c3 = new Clone(json_clone3, m, 2, c_attributes);
m.initClones();
var clone;
clone = new Clone(json_clone1, m, 0, C_INTERACTABLE)
assert.equal(clone.isInteractable(), true, "clone should be seen as isInteractable");
assert.equal(clone.hasSizeOther(), false, "clone should NOT be seen as hasSizeOther");
clone = new Clone(json_clone1, m, 0, C_SIZE_OTHER)
assert.equal(clone.isInteractable(), false, "clone should NOT be seen as isInteractable");
assert.equal(clone.hasSizeOther(), true, "clone should be seen as hasSizeOther");
clone = new Clone(json_clone1, m, 0, C_INTERACTABLE | C_SIZE_OTHER)
assert.equal(clone.isInteractable(), true, "clone should NOT be seen as isInteractable");
assert.equal(clone.hasSizeOther(), true, "clone should be seen as hasSizeOther");
});
......@@ -108,6 +108,15 @@ QUnit.test("time control", function(assert) {
});
QUnit.test("top clones", function(assert) {
function count_active() {
var nb_active = 0
for (i = 0; i < m.clones.length; i++)
if (m.clones[i].isActive())
nb_active += 1
return nb_active
}
var m = new Model();
m.parseJsonData(json_data,100)
m.initClones()
......@@ -120,16 +129,13 @@ QUnit.test("top clones", function(assert) {
assert.equal(m.top, m.countRealClones() * 2 + 10, "Model top can be greater than the number of real clones")
assert.equal(m.current_top, m.countRealClones(), "Current Top cannot be greater than the number of real clones")
c = m
assert.equal(m.clones.length, 7, "m.clones.length")
assert.equal(count_active(), 5, "Without top modification, there should be one active clone")
// 0-4; clone reel; 5-6, clone virtuel
m.displayTop(1)
function count_active() {
var nb_active = 0
for (i = 0; i < m.clones.length; i++)
if (m.clones[i].isActive())
nb_active += 1
return nb_active
}
assert.equal(count_active(), 1, "With top 1, there should be one active clone")
m.changeTime(2)
assert.equal(count_active(), 1, "With top 1, there should be one active clone")
......@@ -362,12 +368,12 @@ QUnit.test("model: primer detection", function(assert) {
QUnit.test("normalization", function(assert) {
var m = new Model();
m.parseJsonData(json_data, 100)
var c1 = new Clone(json_clone1, m, 0)
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)
var c6 = new Clone(json_clone6, m, 4)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
var c3 = new Clone(json_clone3, m, 2, c_attributes)
var c4 = new Clone(json_clone4, m, 3, c_attributes)
var c5 = new Clone(json_clone5, m, 5, c_attributes)
var c6 = new Clone(json_clone6, m, 6, c_attributes)
m.initClones()
m.set_normalization(m.NORM_FALSE)
assert.equal(c2.getSize(),0.05,"clone3 size")
......@@ -406,20 +412,20 @@ QUnit.test("normalization", function(assert) {
// Test detection of external normalization inside clones
var m = new Model();
m.parseJsonData(json_data, 100)
var c1 = new Clone(json_clone1, m, 0)
var c2 = new Clone(json_clone2, m, 1)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
m.initClones()
assert.equal(m.have_external_normalization, false, "Model don't show clone with normalized_reads")
var c1 = new Clone(json_clone1, m, 0)
var c2 = new Clone(json_clone2, m, 1)
var c6 = new Clone(json_clone6, m, 4)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
var c6 = new Clone(json_clone6, m, 4, c_attributes)
m.initClones()
assert.equal(m.have_external_normalization, true, "model have detected normalized_reads of clones")
m.parseJsonData(json_data, 100)
var c1 = new Clone(json_clone1, m, 0)
var c2 = new Clone(json_clone2, m, 1)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
m.initClones()
assert.equal(m.have_external_normalization, false, "Model have_external_normalization is correctly resetted")
......@@ -458,12 +464,12 @@ QUnit.test("findGermlineFromGene", function(assert) {
QUnit.test("getFasta", function(assert) {
var m = new Model();
m.parseJsonData(json_data, 100)
var c1 = new Clone(json_clone1, m, 0)
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)
var c6 = new Clone(json_clone6, m, 4)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
var c3 = new Clone(json_clone3, m, 2, c_attributes)
var c4 = new Clone(json_clone4, m, 3, c_attributes)
var c5 = new Clone(json_clone5, m, 4, c_attributes)
var c6 = new Clone(json_clone6, m, 4, c_attributes)
m.initClones()
......@@ -484,12 +490,12 @@ QUnit.test("tag / color", function(assert) {
var m = new Model();
m.parseJsonData(json_data)
var c1 = new Clone(json_clone1, m, 0)
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)
var c6 = new Clone(json_clone6, m, 4)
var c1 = new Clone(json_clone1, m, 0, c_attributes)
var c2 = new Clone(json_clone2, m, 1, c_attributes)
var c3 = new Clone(json_clone3, m, 2, c_attributes)
var c4 = new Clone(json_clone4, m, 3, c_attributes)
var c5 = new Clone(json_clone5, m, 4, c_attributes)
var c6 = new Clone(json_clone6, m, 5, c_attributes)
m.initClones()
assert.equal(m.getColorSelectedClone(), false, "Color of selected clones (empty selection) is correct")
......
......@@ -96,6 +96,10 @@
});
};
var c_attributes = C_CLUSTERIZABLE
| C_INTERACTABLE
| C_IN_SCATTERPLOT
| C_SIZE_CONSTANT
</script>
<script src="./testFiles/dbscan_test.js"></script>
<script src="./testFiles/model_test.js"></script>
......
This diff is collapsed.
......@@ -282,10 +282,22 @@ class TestMultilocus < BrowserTest
end
def test_16_select_unsegmented
clone_id = '10'
$b.clone_in_scatterplot(clone_id).click
clone_list = ["1", "32", "24", "68"]
# clone with seg & sequence (1)
$b.clone_in_scatterplot(clone_list[0]).click
assert ($b.clone_in_segmenter(clone_list[0]).present?), "Clone %s (seg+/seq+) is in segmenter" % clone_list[0]
# clone with seg & not sequence (32)
$b.clone_in_scatterplot(clone_list[1]).click
assert (not $b.clone_in_segmenter(clone_list[1]).present?), "Clone %s (seg+/seq-) is NOT in segmenter" % clone_list[1]
# clone without seg & sequence (24)
$b.clone_in_scatterplot(clone_list[2]).click
assert (not $b.clone_in_segmenter(clone_list[2]).present?), "Clone %s (seg-/seq-) is NOT in segmenter" % clone_list[2]
assert ($b.clone_in_segmenter(clone_id).exists?), "Clone %s is not in segmenter" % clone_id
# clone without seg & sequence (68)
$b.clone_in_scatterplot(clone_list[3]).click
assert ($b.clone_in_segmenter(clone_list[3]).present?), "Clone %s (seg-/seq+) is in segmenter" % clone_list[3]
end
def test_17_select_clustered
......
......@@ -13,7 +13,7 @@ CGTCTTCTGTACTATGACGTCTCCAACTCAAAGGATGTGTTGGAATCAGGACTCAGTCCAGGAAAGTATTATACTCATAC
GGGGGAGGCTTGGTACAGCCTGGGGGGTCCCTGAGACTCTCCTGTGCAGCCTCTGGATTCACCTTCAGTAGCTACGACATGCACTGGGTCCGCCAAGCTACAGGAAAAGGTCTGGAGTGGGTCTCAGCTATTGGTACTGCTGGTGACACATACTATCCAGGCTCCGTGAAGGGCCGATTCACCATCTCCAGAGAAAATGCCAAGAACTCCTTGTATCTTCAAATGAACAGCCTGAGAGCCGGGGACACGGCTGTGTATTACTGTGCAAGAGTGAGGCGGAGAGATCGGGGGATTGTAGTGGTGGTAGCTGCTACTCAACGGTAAGTTGGTTCGACCCCTGGGGCCAGGGAACCCTGGTCACCGTCTCCTCAGGT"
assert (not $b.element(:class => 'segmenter').present?), "Segmenter should not be present yet"
assert (not $b.element(:class => 'scatterplot').present?), "Segmenter should not be present yet"
assert (not $b.element(:class => 'scatterplot').present?), "Scatterplot should not be present yet"
$b.button(:id => 'form_submit').click
......@@ -21,7 +21,7 @@ GGGGGAGGCTTGGTACAGCCTGGGGGGTCCCTGAGACTCTCCTGTGCAGCCTCTGGATTCACCTTCAGTAGCTACGACAT
$b.clone_in_scatterplot('0').wait_until(&:present?)
assert ($b.element(:class => 'segmenter').present?), "Segmenter should be present"
assert ($b.element(:class => 'scatterplot').present?), "Segmenter should be present"
assert ($b.element(:class => 'scatterplot').present?), "Scatterplot should be present"
end
def test_01_segmenter
......
......@@ -98,6 +98,14 @@ class VidjilBrowser < Watir::Browser
return element(extra.merge(:id => 'seq'+id))
end
def clear_filter
return span(:id => "clear_filter")
end
def filter_area
return text_field(:id => "filter_input")
end
# Change the coloration
def color_by(dimension)
menu_color.select_list.select dimension
......
......@@ -616,7 +616,6 @@
{
"germline": "TRB",
"name": "TRBV26*01 -4/0/-4 TRBD1*01 -5/5/-0 TRBJ1-4*02",
"sequence": "CCTTGYGCCYYAATYAGYCYTYGGYGYYCYAGYCTGYCCYTGTGCYGYGYAYTTYYACYAAYTYTTTTYGGYATGYACYAGCTGYTGYCTGYGYYTYYAATGTYCYYCCYAG",
"top": 5,
"seg": {
"5end": 66,
......@@ -1220,7 +1219,8 @@
"reads": [
450
],
"id": "GYCTYTGTGCYGYGCYYAYYYAGYTYTTT"
"id": "GYCTYTGTGCYGYGCYYAYYYAGYTYTTT",
"sequence": "une sequence de test devraitapparaitre dans le segmenter"
},
{
"germline": "TRB",
......
!LAUNCH: python ../../vidjil-to-fasta.py -o vidjil-to-fasta-with-sequences.fasta ../../../doc/analysis-example.vidjil > /dev/null; cat vidjil-to-fasta-with-sequences.fasta
$ 19 sequences with a seg field should be found
19:^>
$ 18 sequences with a seg field should be found
18:^>
$ Affectation for sequence YYGGGYYACGYAYAGCGGYGYTTYYCCTYTYTGYTYTGCYAAAYAACYYYYTGTGYCTYTGTGCYGYGTTYCCCGGYYYAAACYCYCYYCCTYGGCYAGGYCYGGCTTTTGGYAYYGYYTYYAATGTYCYYCCC
1:VDJ 1 95 100 105 107 134
......
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