-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixed #152 * fixed js test * added check for 'non-unique' column name in metadata files * Removed 'non-unique' * removed redundant line * Apply suggestions from code review removed 'addNonUnique' from _projectObservations' function description and fixed typos/format Co-authored-by: Marcus Fedarko <[email protected]> * added two more tests Co-authored-by: Marcus Fedarko <[email protected]>
- Loading branch information
1 parent
31883f2
commit c672144
Showing
9 changed files
with
277 additions
and
61 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
require(["jquery", "BPTree", "Empress", "util"], function($, BPTree, Empress, util) { | ||
$(document).ready(function() { | ||
// Setup test variables | ||
// Note: This is ran for each test() so tests can modify bpArray without | ||
// effecting other test | ||
module('Empress' , { | ||
setup: function() { | ||
// tree comes from the following newick string | ||
// ((1,(2,3)4)5,6)7; | ||
var tree = new BPTree( | ||
new Uint8Array([1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0])); | ||
var treeData = { | ||
7: { | ||
"color":[1.0, 1.0, 1.0], | ||
"inSample": false | ||
}, | ||
6: { | ||
"color":[1.0, 1.0, 1.0], | ||
"inSample": false | ||
}, | ||
5: { | ||
"color":[1.0, 1.0, 1.0], | ||
"inSample": false | ||
}, | ||
4: { | ||
"color":[1.0, 1.0, 1.0], | ||
"inSample": false | ||
}, | ||
2: { | ||
"color":[1.0, 1.0, 1.0], | ||
"inSample": false | ||
}, | ||
3: { | ||
"color":[1.0, 1.0, 1.0], | ||
"inSample": false | ||
}, | ||
1: { | ||
"color":[1.0, 1.0, 1.0], | ||
"inSample": false | ||
} | ||
|
||
} | ||
this.empress = new Empress(tree, treeData, null, | ||
null, null, null, null, null, null, null); | ||
}, | ||
|
||
teardown: function() { | ||
this.empress = null; | ||
} | ||
}); | ||
|
||
test("Test _projectObservations, all tips in obs", function() { | ||
var obs = { | ||
"g1" : new Set([2, 3]), | ||
"g2" : new Set([1]), | ||
"g3" : new Set([6]) | ||
}; | ||
var expectedResult = { | ||
"g1" : new Set([2,3,4]), | ||
"g2" : new Set([1]), | ||
"g3" : new Set([6]), | ||
}; | ||
var result = this.empress._projectObservations(obs); | ||
|
||
var groups = ["g1", "g2", "g3"]; | ||
for (var i = 0; i < groups.length; i++) { | ||
var group = groups[i]; | ||
var expectedArray = Array.from(expectedResult[group]); | ||
var resultArray = util.naturalSort(Array.from(result[group])); | ||
deepEqual(resultArray, expectedArray); | ||
} | ||
|
||
var columns = Object.keys(result); | ||
deepEqual(columns, groups); | ||
}); | ||
|
||
test("Test _projectObservations, missing tips in obs", function() { | ||
var obs = { | ||
"g1" : new Set([2, 3]), | ||
"g2" : new Set([]), | ||
"g3" : new Set([6]) | ||
}; | ||
var expectedResult = { | ||
"g1" : new Set([2, 3, 4]), | ||
"g2" : new Set([]), | ||
"g3" : new Set([6]) | ||
}; | ||
var result = this.empress._projectObservations(obs); | ||
|
||
var groups = ["g1", "g2", "g3"]; | ||
for (var i = 0; i < groups.length; i++) { | ||
var group = groups[i]; | ||
var expectedArray = Array.from(expectedResult[group]); | ||
var resultArray = util.naturalSort(Array.from(result[group])); | ||
deepEqual(resultArray, expectedArray); | ||
} | ||
|
||
var columns = Object.keys(result); | ||
deepEqual(columns, groups); | ||
}); | ||
|
||
test("Test _projectObservations, all tips are unique to group", function() { | ||
var obs = { | ||
"g1": new Set([1, 2, 3, 6]), | ||
"g2": new Set([]) | ||
}; | ||
var expectedResult = { | ||
"g1": new Set([1, 2, 3, 4, 5, 6, 7]), | ||
"g2": new Set([]) | ||
}; | ||
var result = this.empress._projectObservations(obs); | ||
|
||
var groups = ["g1", "g2"]; | ||
for (var i = 0; i < groups.length; i++) { | ||
var group = groups[i]; | ||
var expectedArray = Array.from(expectedResult[group]); | ||
var resultArray = util.naturalSort(Array.from(result[group])); | ||
deepEqual(resultArray, expectedArray); | ||
} | ||
|
||
var columns = Object.keys(result); | ||
deepEqual(columns, groups); | ||
}); | ||
|
||
test("Test _projectObservations, no tips are present in any group", function() { | ||
var obs = { | ||
"g1": new Set([]), | ||
"g2": new Set([]) | ||
}; | ||
var expectedResult = { | ||
"g1": new Set([]), | ||
"g2": new Set([]) | ||
}; | ||
var result = this.empress._projectObservations(obs); | ||
|
||
var groups = ["g1", "g2"]; | ||
for (var i = 0; i < groups.length; i++) { | ||
var group = groups[i]; | ||
var expectedArray = Array.from(expectedResult[group]); | ||
var resultArray = util.naturalSort(Array.from(result[group])); | ||
deepEqual(resultArray, expectedArray); | ||
} | ||
|
||
var columns = Object.keys(result); | ||
deepEqual(columns, groups); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.