-
Notifications
You must be signed in to change notification settings - Fork 50
/
test_trajectory.js
465 lines (419 loc) · 24.1 KB
/
test_trajectory.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
/**
*
* @author Yoshiki Vazquez Baeza
* @copyright Copyright 2013, The Emperor Project
* @credits Yoshiki Vazquez Baeza
* @license BSD
* @version 0.9.5
* @maintainer Yoshiki Vazquez Baeza
* @email yoshiki89@gmail.com
* @status Release
*
*/
$(document).ready(function() {
// these variables are reused throughout this test suite
var mappingFileHeaders, mappingFileData, coordinatesData;
var sampleNames, gradientPoints, coordinates;
// these are expected results needed for multiple tests
var crunchedDataTwoCategories, crunchedDataOneCategory;
module("Trajectory", {
setup: function(){
// setup function
mappingFileHeaders = ['SampleID','LinkerPrimerSequence','Treatment','DOB'];
mappingFileData = { 'PC.481': ['PC.481','YATGCTGCCTCCCGTAGGAGT','Control','20070314'],'PC.607': ['PC.607','YATGCTGCCTCCCGTAGGAGT','Fast','20071112'],'PC.634': ['PC.634','YATGCTGCCTCCCGTAGGAGT','Fast','20080116'],'PC.635': ['PC.635','YATGCTGCCTCCCGTAGGAGT','Fast','20080116'],'PC.593': ['PC.593','YATGCTGCCTCCCGTAGGAGT','Control','20071210'],'PC.636': ['PC.636','YATGCTGCCTCCCGTAGGAGT','Fast','20080116'],'PC.355': ['PC.355','YATGCTGCCTCCCGTAGGAGT','Control','20061218'],'PC.354': ['PC.354','YATGCTGCCTCCCGTAGGAGT','Control','20061218'],'PC.356': ['PC.356','YATGCTGCCTCCCGTAGGAGT','Control','20061126'] };
coordinatesData = new Array();
coordinatesData['PC.636'] = { 'name': 'PC.636', 'color': 0, 'x': -0.276542, 'y': -0.144964, 'z': 0.066647, 'P1': -0.276542, 'P2': -0.144964, 'P3': 0.066647, 'P4': -0.067711, 'P5': 0.176070, 'P6': 0.072969, 'P7': -0.229889, 'P8': -0.046599 };
coordinatesData['PC.635'] = { 'name': 'PC.635', 'color': 0, 'x': -0.237661, 'y': 0.046053, 'z': -0.138136, 'P1': -0.237661, 'P2': 0.046053, 'P3': -0.138136, 'P4': 0.159061, 'P5': -0.247485, 'P6': -0.115211, 'P7': -0.112864, 'P8': 0.064794 };
coordinatesData['PC.356'] = { 'name': 'PC.356', 'color': 0, 'x': 0.228820, 'y': -0.130142, 'z': -0.287149, 'P1': 0.228820, 'P2': -0.130142, 'P3': -0.287149, 'P4': 0.086450, 'P5': 0.044295, 'P6': 0.206043, 'P7': 0.031000, 'P8': 0.071992 };
coordinatesData['PC.481'] = { 'name': 'PC.481', 'color': 0, 'x': 0.042263, 'y': -0.013968, 'z': 0.063531, 'P1': 0.042263, 'P2': -0.013968, 'P3': 0.063531, 'P4': -0.346121, 'P5': -0.127814, 'P6': 0.013935, 'P7': 0.030021, 'P8': 0.140148 };
coordinatesData['PC.354'] = { 'name': 'PC.354', 'color': 0, 'x': 0.280399, 'y': -0.006013, 'z': 0.023485, 'P1': 0.280399, 'P2': -0.006013, 'P3': 0.023485, 'P4': -0.046811, 'P5': -0.146624, 'P6': 0.005670, 'P7': -0.035430, 'P8': -0.255786 };
coordinatesData['PC.593'] = { 'name': 'PC.593', 'color': 0, 'x': 0.232873, 'y': 0.139788, 'z': 0.322871, 'P1': 0.232873, 'P2': 0.139788, 'P3': 0.322871, 'P4': 0.183347, 'P5': 0.020466, 'P6': 0.054059, 'P7': -0.036625, 'P8': 0.099824 };
coordinatesData['PC.355'] = { 'name': 'PC.355', 'color': 0, 'x': 0.170518, 'y': -0.194113, 'z': -0.030897, 'P1': 0.170518, 'P2': -0.194113, 'P3': -0.030897, 'P4': 0.019809, 'P5': 0.155100, 'P6': -0.279924, 'P7': 0.057609, 'P8': 0.024248 };
coordinatesData['PC.607'] = { 'name': 'PC.607', 'color': 0, 'x': -0.091330, 'y': 0.424147, 'z': -0.135627, 'P1': -0.091330, 'P2': 0.424147, 'P3': -0.135627, 'P4': -0.057519, 'P5': 0.151363, 'P6': -0.025394, 'P7': 0.051731, 'P8': -0.038738 };
coordinatesData['PC.634'] = { 'name': 'PC.634', 'color': 0, 'x': -0.349339, 'y': -0.120788, 'z': 0.115275, 'P1': -0.349339, 'P2': -0.120788, 'P3': 0.115275, 'P4': 0.069495, 'P5': -0.025372, 'P6': 0.067853, 'P7': 0.244448, 'P8': -0.059883 };
sampleNames = ['PC.636', 'PC.635', 'PC.356', 'PC.481', 'PC.354'];
gradientPoints = [1, 4, 6, 8, 11];
coordinates = [{'x':0, 'y':0, 'z':0}, {'x':1, 'y':1, 'z':1},
{'x':-9, 'y':-9, 'z':-9}, {'x':3, 'y':3, 'z':3},
{'x':8, 'y':8, 'z':8}];
crunchedDataOneCategory = {"YATGCTGCCTCCCGTAGGAGT": [
{ "name": "PC.356", "value": "20061126", "x": 0.22882, "y": -0.130142, "z": -0.287149},
{ "name": "PC.355", "value": "20061218", "x": 0.170518, "y": -0.194113, "z": -0.030897},
{ "name": "PC.354", "value": "20061218", "x": 0.280399, "y": -0.006013, "z": 0.023485},
{ "name": "PC.481", "value": "20070314", "x": 0.042263, "y": -0.013968, "z": 0.063531},
{ "name": "PC.607", "value": "20071112", "x": -0.09133, "y": 0.424147, "z": -0.135627},
{ "name": "PC.593", "value": "20071210", "x": 0.232873, "y": 0.139788, "z": 0.322871},
{ "name": "PC.634", "value": "20080116", "x": -0.349339, "y": -0.120788, "z": 0.115275},
{ "name": "PC.635", "value": "20080116", "x": -0.237661, "y": 0.046053, "z": -0.138136},
{ "name": "PC.636", "value": "20080116", "x": -0.276542, "y": -0.144964, "z": 0.066647}
]
};
crunchedDataTwoCategories = expectedResult = {"Control": [
{"name": "PC.356", "value": "20061126", "x": 0.22882, "y": -0.130142, "z": -0.287149},
{"name": "PC.355", "value": "20061218", "x": 0.170518, "y": -0.194113, "z": -0.030897},
{"name": "PC.354", "value": "20061218", "x": 0.280399, "y": -0.006013, "z": 0.023485},
{"name": "PC.481", "value": "20070314", "x": 0.042263, "y": -0.013968, "z": 0.063531},
{"name": "PC.593", "value": "20071210", "x": 0.232873, "y": 0.139788, "z": 0.322871}
],
"Fast": [
{"name": "PC.607", "value": "20071112", "x": -0.09133, "y": 0.424147, "z": -0.135627},
{"name": "PC.634", "value": "20080116", "x": -0.349339, "y": -0.120788, "z": 0.115275},
{"name": "PC.635", "value": "20080116", "x": -0.237661, "y": 0.046053, "z": -0.138136},
{"name": "PC.636", "value": "20080116", "x": -0.276542, "y": -0.144964, "z": 0.066647}
]
};
},
teardown: function(){
// teardown function
mappingFileHeaders = null;
mappingFileData = null;
coordinatesData = null;
sampleNames = null;
gradientPoints = null;
coordinates = null;
}
});
/**
*
* Test that the trajectory object can be constructed without any problems
* and check that the attributes are set correctly.
*
*/
test("Test constructor", function() {
var trajectory;
trajectory = new TrajectoryOfSamples(sampleNames, 'Treatment',
gradientPoints, coordinates, 2,
10);
deepEqual(trajectory.sampleNames, ['PC.636', 'PC.635', 'PC.356',
'PC.481', 'PC.354'], 'Sample names are set correctly');
equal(trajectory.metadataCategoryName, 'Treatment', 'Metadata '+
'category name is set correctly');
deepEqual(trajectory.gradientPoints, [1, 4, 6, 8, 11], 'Gradient '+
'point values are set correctly');
deepEqual(trajectory.coordinates, [{'x':0, 'y':0, 'z':0},
{'x':1, 'y':1, 'z':1}, {'x':-9, 'y':-9, 'z':-9},
{'x':3, 'y':3, 'z':3}, {'x':8, 'y':8, 'z':8}], "Coordinates"+
" values are set correctly");
equal(trajectory.minimumDelta, 2, "Minimum delta is set correctly");
equal(trajectory.suppliedN, 10, 'Value of N is set correctly');
trajectory = new TrajectoryOfSamples(sampleNames, 'Treatment',
gradientPoints,
coordinates, 2);
deepEqual(trajectory.sampleNames, ['PC.636', 'PC.635', 'PC.356',
'PC.481', 'PC.354'], 'Sample names are set correctly');
equal(trajectory.metadataCategoryName, 'Treatment', 'Metadata '+
'category name is set correctly');
deepEqual(trajectory.gradientPoints, [1, 4, 6, 8, 11], 'Gradient'+
' point values are set correctly');
deepEqual(trajectory.coordinates, [{'x':0, 'y':0, 'z':0},
{'x':1, 'y':1, 'z':1}, {'x':-9, 'y':-9, 'z':-9},
{'x':3, 'y':3, 'z':3}, {'x':8, 'y':8, 'z':8}], "Coordinates"+
" values are set correctly");
equal(trajectory.minimumDelta, 2, "Minimum delta is set correctly");
equal(trajectory.suppliedN, 5, "Default value of N is set to 5");
});
/**
*
* Test the trajectory object raises the appropriate errors when
* constructing with bad arguments.
*
*/
test("Test constructor exceptions", function(){
var result;
// check this happens for all the properties
throws(
function (){
result = new TrajectoryOfSamples(sampleNames, 'foo', [1, 2, 3],
coordinates);
},
Error,
'An error is raised if the number of coordinates does not '+
'correspond to the number of gradient points'
);
});
/**
*
* Test the trajectory object computes the interpolated coordinates
* correctly
*
*/
test("Test _generateInterpolatedCoordinates", function(){
var trajectory;
var expectedInterpolatedCoordinates = [{ "x": 0, "y": 0, "z": 0},
{ "x": 0.1, "y": 0.1, "z": 0.1},
{ "x": 0.2, "y": 0.2, "z": 0.2},
{ "x": 0.30000000000000004, "y": 0.30000000000000004, "z": 0.30000000000000004},
{ "x": 0.4, "y": 0.4, "z": 0.4},
{ "x": 0.5, "y": 0.5, "z": 0.5},
{ "x": 0.6000000000000001, "y": 0.6000000000000001, "z": 0.6000000000000001},
{ "x": 0.7000000000000001, "y": 0.7000000000000001, "z": 0.7000000000000001},
{ "x": 0.8, "y": 0.8, "z": 0.8},
{ "x": 0.9, "y": 0.9, "z": 0.9},
{ "x": 1, "y": 1, "z": 1},
{ "x": 0, "y": 0, "z": 0},
{ "x": -1, "y": -1, "z": -1},
{ "x": -2, "y": -2, "z": -2},
{ "x": -3, "y": -3, "z": -3},
{ "x": -4, "y": -4, "z": -4},
{ "x": -5, "y": -5, "z": -5},
{ "x": -6, "y": -6, "z": -6},
{ "x": -7, "y": -7, "z": -7},
{ "x": -8, "y": -8, "z": -8},
{ "x": -9, "y": -9, "z": -9},
{ "x": -7.8, "y": -7.8, "z": -7.8},
{ "x": -6.6, "y": -6.6, "z": -6.6},
{ "x": -5.4, "y": -5.4, "z": -5.4},
{ "x": -4.2, "y": -4.2, "z": -4.2},
{ "x": -3, "y": -3, "z": -3},
{ "x": -1.8000000000000007, "y": -1.8000000000000007, "z": -1.8000000000000007},
{ "x": -0.5999999999999996, "y": -0.5999999999999996, "z": -0.5999999999999996},
{ "x": 0.5999999999999996, "y": 0.5999999999999996, "z": 0.5999999999999996},
{ "x": 1.799999999999999, "y": 1.799999999999999, "z": 1.799999999999999},
{ "x": 3, "y": 3, "z": 3},
{ "x": 3.5, "y": 3.5, "z": 3.5},
{ "x": 4, "y": 4, "z": 4},
{ "x": 4.5, "y": 4.5, "z": 4.5},
{ "x": 5, "y": 5, "z": 5},
{ "x": 5.5, "y": 5.5, "z": 5.5},
{ "x": 6, "y": 6, "z": 6},
{ "x": 6.5, "y": 6.5, "z": 6.5},
{ "x": 7, "y": 7, "z": 7},
{ "x": 7.5, "y": 7.5, "z": 7.5},
{ "x": 8, "y": 8, "z": 8}];
trajectory = new TrajectoryOfSamples(sampleNames, 'Treatment',
gradientPoints, coordinates, 2,
10);
// test the interpolated values and the interval values
deepEqual(trajectory.interpolatedCoordinates,
expectedInterpolatedCoordinates,
'Check the interpolated coordinates are computed correctly');
deepEqual(trajectory._intervalValues, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3] , 'Check the intervals array is '+
'created properyl');
expectedInterpolatedCoordinates = [{"x": 0, "y": 0, "z": 0},
{"x": 0.25, "y": 0.25, "z": 0.25},
{"x": 0.5, "y": 0.5, "z": 0.5},
{"x": 0.75, "y": 0.75, "z": 0.75},
{"x": 1, "y": 1, "z": 1},
{"x": -2.3333333333333335, "y": -2.3333333333333335, "z": -2.3333333333333335},
{"x": -5.666666666666667, "y": -5.666666666666667, "z": -5.666666666666667},
{"x": -9, "y": -9, "z": -9},
{"x": -5, "y": -5, "z": -5},
{"x": -1, "y": -1, "z": -1},
{"x": 3, "y": 3, "z": 3},
{"x": 4.25, "y": 4.25, "z": 4.25},
{"x": 5.5, "y": 5.5, "z": 5.5},
{"x": 6.75, "y": 6.75, "z": 6.75},
{"x": 8, "y": 8, "z": 8 }];
trajectory = new TrajectoryOfSamples(sampleNames, 'Treatment',
gradientPoints, coordinates, 2,
3);
deepEqual(trajectory.interpolatedCoordinates,
expectedInterpolatedCoordinates,
'Check the interpolated coordinates are computed correctly');
deepEqual(trajectory._intervalValues,
[0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3] ,
'Check the interpolated coordinates are computed correctly');
});
/**
*
* Test the trajectory object retrieves only the needed points for a given
* index (edge cases).
*
*/
test('Test representativeCoordinatesAtIndex edge cases', function(){
trajectory = new TrajectoryOfSamples(sampleNames, 'Treatment',
gradientPoints, coordinates, 2,
3);
deepEqual(trajectory.representativeCoordinatesAtIndex(0),
[{'x':0, 'y':0, 'z':0}],
'Returns an empty array for index 0');
var expectedCoordinates = [{'x':0, 'y':0, 'z':0},
{'x':1, 'y':1, 'z':1},
{'x':-9, 'y':-9, 'z':-9},
{'x':3, 'y':3, 'z':3},
{'x':8, 'y':8, 'z':8}];
// the interpolated array is 18 samples long
deepEqual(trajectory.representativeCoordinatesAtIndex(18),
expectedCoordinates, 'Returns an array with only the '+
'original coordinates');
deepEqual(trajectory.representativeCoordinatesAtIndex(100),
expectedCoordinates, 'Returns an array with only the '+
'original coordinates');
});
/**
*
* Test the trajectory object retrieves only the needed points for a given
* index.
*
*/
test('Test representativeCoordinatesAtIndex', function(){
trajectory = new TrajectoryOfSamples(sampleNames, 'Treatment',
gradientPoints, coordinates, 2,
3);
var expectedCoordinates = [{'x':0, 'y':0, 'z':0},
{'x':1, 'y':1, 'z':1},
{'x':-9, 'y':-9, 'z':-9},
{'x':3, 'y':3, 'z':3},
{'x':8, 'y':8, 'z':8}];
var expectedInterpolatedCoordinates = [{'x': 0, 'y': 0, 'z': 0},
{'x': 0.25, 'y': 0.25, 'z': 0.25},
{'x': 0.5, 'y': 0.5, 'z': 0.5},
{'x': 0.75, 'y': 0.75, 'z': 0.75},
{'x': 1, 'y': 1, 'z': 1},
{'x': -2.3333333333333335, 'y': -2.3333333333333335, 'z': -2.3333333333333335},
{'x': -5.666666666666667, 'y': -5.666666666666667, 'z': -5.666666666666667},
{'x': -9, 'y': -9, 'z': -9},
{'x': -5, 'y': -5, 'z': -5},
{'x': -1, 'y': -1, 'z': -1},
{'x': 3, 'y': 3, 'z': 3},
{'x': 4.25, 'y': 4.25, 'z': 4.25},
{'x': 5.5, 'y': 5.5, 'z': 5.5},
{'x': 6.75, 'y': 6.75, 'z': 6.75},
{'x': 8, 'y': 8, 'z': 8}]
deepEqual(trajectory.representativeCoordinatesAtIndex(3),
[{"x": 0, "y": 0, "z": 0},
{"x": 0.75, "y": 0.75, "z": 0.75}],
'Coordinates are retrieved correctly at index 3');
deepEqual(trajectory.representativeCoordinatesAtIndex(11),
[{'x':0, 'y':0, 'z':0}, {'x':1, 'y':1, 'z':1},
{'x':-9, 'y':-9, 'z':-9}, {'x':3, 'y':3, 'z':3},
{'x': 4.25, 'y': 4.25, 'z': 4.25}],
'Coordinates are retrieved correctly at index 11');
});
/**
*
* Test the trajectory object computes the number of points for a given
* delta correctly.
*
*/
test('Test calculateNumberOfPointsForDelta', function(){
var trajectory;
trajectory = new TrajectoryOfSamples(sampleNames, 'Treatment',
gradientPoints, coordinates, 2,
10);
equal(trajectory.calculateNumberOfPointsForDelta(3), 15, 'Number of '+
'points for delta is calculated correctly');
equal(trajectory.calculateNumberOfPointsForDelta(8), 40, 'Number of '+
'points for delta is calculated correctly');
equal(trajectory.calculateNumberOfPointsForDelta(7), 35, 'Number of '+
'points for delta is calculated correctly');
equal(trajectory.calculateNumberOfPointsForDelta(11), 55, 'Number of '+
'points for delta is calculated correctly');
equal(trajectory.calculateNumberOfPointsForDelta(1), 5, 'Number of '+
'points for delta is calculated correctly');
});
/**
*
* Test linearInterpolation function.
*
*/
test('Test linearInterpolation', function(){
var result;
result = linearInterpolation(0, 0, 0, 1, 1, 1, 5);
expectedResult = [{ "x": 0, "y": 0, "z": 0},
{"x": 0.2, "y": 0.2, "z": 0.2},
{ "x": 0.4, "y": 0.4, "z": 0.4 },
{ "x": 0.6000000000000001, "y": 0.6000000000000001,
"z": 0.6000000000000001 },
{ "x": 0.8, "y": 0.8, "z": 0.8 },
{ "x": 1, "y": 1, "z": 1}];
deepEqual(result, expectedResult, 'Linear interpolation is computed '+
'correctly')
result = linearInterpolation(0, 0, 0, -1, -1, -1, 5);
expectedResult = [{ "x": 0, "y": 0, "z": 0},
{"x": -0.2, "y": -0.2, "z": -0.2},
{ "x": -0.4, "y": -0.4, "z": -0.4 },
{ "x": -0.6000000000000001, "y": -0.6000000000000001,
"z": -0.6000000000000001 },
{ "x": -0.8, "y": -0.8, "z": -0.8 },
{ "x": -1, "y": -1, "z": -1}];
deepEqual(result, expectedResult, 'Linear interpolation is computed '+
'correctly')
});
/**
*
* Test distanceBetweenPoints function.
*
*/
test('Test distanceBetweenPoints', function(){
var result;
result = distanceBetweenPoints(0, 0, 0, 1, 1, 1);
equal(result, Math.sqrt(3),'Distance between points is computed'+
'correctly');
result = distanceBetweenPoints(-4, -3, -2, 84, 2, 11);
equal(result, 89.09545442950498, 'Distance between points is computed '+
'correctly');
result = distanceBetweenPoints(0, 0, 0, 0, 0, 0);
equal(result, 0, 'Distance between points is computed correctly');
result = distanceBetweenPoints(-3, 17, -8888, 11, 0, 1);
equal(result, 8889.027280867125, 'Distance between points is computed '+
'correctly');
});
/**
*
* Test getSampleNamesAndDataForSortedTrajectories function.
*
*/
test('Test getSampleNamesAndDataForSortedTrajectories', function(){
var result, expectedResult;
result = getSampleNamesAndDataForSortedTrajectories(mappingFileHeaders,
mappingFileData,
coordinatesData,
'Treatment',
'DOB');
deepEqual(result, crunchedDataTwoCategories, 'The data is computed '+
'correctly for two trajectories');
result = getSampleNamesAndDataForSortedTrajectories(mappingFileHeaders,
mappingFileData,
coordinatesData,
'LinkerPrimerSequence',
'DOB');
deepEqual(result, crunchedDataOneCategory, 'The data is computed '+
'correctly for a single trajectory');
});
/**
*
* Test getSampleNamesAndDataForSortedTrajectories function raises the
* appropriate errors.
*
*/
test('Test getSampleNamesAndDataForSortedTrajectories exceptions', function(){
throws(function(){
result = getSampleNamesAndDataForSortedTrajectories(mappingFileHeaders,
mappingFileData,
coordinatesData,
'DOB',
'BAZ');
}, Error, 'Error is thrown when a category is not found');
throws(function(){
result = getSampleNamesAndDataForSortedTrajectories(mappingFileHeaders,
mappingFileData,
coordinatesData,
'SPAM',
'DOB');
}, Error, 'Error is thrown when a category is not found');
throws(function(){
result = getSampleNamesAndDataForSortedTrajectories(mappingFileHeaders,
mappingFileData,
coordinatesData,
'FOO',
'BAR');
}, Error, 'Error is thrown when a category is not found');
});
/**
*
* Test getMinimumDelta function computes data correctly.
*
*/
test('Test getMinimumDelta function', function(){
var result;
result = getMinimumDelta(crunchedDataOneCategory);
equal(result, 92, 'The minimum delta is computed correctly for one '+
'category');
result = getMinimumDelta(crunchedDataTwoCategories);
equal(result, 92, 'The minimum delta is computed correctly for one '+
'category');
});
});