comparison t/golm_ws_LibrarySearch_test.t @ 0:e3d43b8c987b draft

Init repository with last tool-bank-golm-lib_search master version
author fgiacomoni
date Mon, 05 Dec 2016 08:32:04 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e3d43b8c987b
1 #! perl
2 use diagnostics;
3 use warnings;
4 no warnings qw/void/;
5 use strict;
6 no strict "refs" ;
7 use Test::More qw( no_plan );
8 use FindBin ;
9 use Carp ;
10
11 ## Specific Modules
12 use lib $FindBin::Bin ;
13 my $binPath = $FindBin::Bin ;
14
15
16 use lib::golm_ws_api_test qw( :ALL ) ;
17
18 ## To launch the right sequence : API, MSP...
19 my $sequence = 'MSP' ;
20 my $current_test = 1 ;
21
22
23 #### #### ##### ###### ################################################ ###### ##### ##### ###### ######
24
25 ## START of API SEQUENCE ##
26
27 #### #### ##### ###### ################################################ ###### ##### ##### ###### ######
28
29
30 if ($sequence eq "API") {
31
32 ## testing api module of golm wrapper.
33 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
34 print "\n\t\t\t * * * * * * \n" ;
35 print "\t * * * - - - Test Golm API module - - - * * * \n\n" ;
36
37 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
38
39
40
41 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
42 # ARGS : $ws_url, $ws_proxy
43 # Structure of res : @ret = [ %val1, %val2, ... %valN ]
44 print "\n** Test $current_test test_query_golm with default parameters **\n" ; $current_test++;
45 is_deeply( test_query_golmTest("http://gmd.mpimp-golm.mpg.de", "http://gmd.mpimp-golm.mpg.de/webservices/wsLibrarySearch.asmx"),
46 1,
47 "Method \'test_query_golm\' Test Golm webservice with default spectrum");
48
49 print "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n" ;
50
51
52
53 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
54 # ARGS : $ws_url, $ws_proxy
55 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
56 print "\n** Test $current_test connectWSlibrarySearchGolm with real uri and proxy **\n" ; $current_test++;
57 isa_ok( connectWSlibrarySearchGolmTest("http://gmd.mpimp-golm.mpg.de", "http://gmd.mpimp-golm.mpg.de/webservices/wsLibrarySearch.asmx"), 'SOAP::Lite' );
58
59
60
61 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
62 # ARGS : $ri, $riWindow, $gcColumn, $spectrum, $maxHits, $JaccardDistanceThreshold,
63 # $s12GowerLegendreDistanceThreshold,$DotproductDistanceThreshold,$HammingDistanceThreshold,
64 # $EuclideanDistanceThreshold,$ws_url, $ws_proxy,$default_ri, $default_ri_window, $default_gc_column
65 # Structure of res : @limited_hits = [ %val1, %val2, ... %valN ], @json_res = [ ojson1, ojson2,... ]
66 print "\n** Test $current_test LibrarySearch with a list of mzs, intensities and real search parameters **\n" ; $current_test++;
67 is_deeply(LibrarySearchTest(1898, 5, "VAR5", "70 3 71 3 72 16 73 999 74 87 75 78 76 4 77 5 81 1 82 6 83 13 84 4 85 3 86 4 87 5 88 4 89 52 90 4 91 2 97 2 98 1 99 4 100 12 101 16 102 9 103 116 104 11 105 26 106 2 107 1 111 1 112 1 113 4 114 11 115 7 116 5 117 93 118 9 119 8 126 1 127 3 128 3 129 101 130 19 131 25 132 4 133 60 134 8 135 4 140 1 141 1 142 4 143 13 144 2 145 6 146 1 147 276 148 44 149 27 150 3 151 1 156 1 157 70 158 12 159 5 160 148 161 26 162 7 163 8 164 1 168 1 169 2 170 1 172 3 173 4 174 1 175 4 177 4 186 2 187 1 189 28 190 7 191 13 192 2 193 1 201 5 202 1 203 3 204 23 205 162 206 31 207 16 208 2 210 2 214 1 215 2 216 8 217 88 218 18 219 8 220 1 221 6 222 1 229 23 230 6 231 11 232 3 233 4 234 3 235 1 243 1 244 2 245 1 246 2 247 1 256 1 262 3 263 1 269 2 270 1 274 4 275 1 277 4 278 1 291 7 292 2 293 1 300 1 305 4 306 1 307 4 308 1 318 1 319 122 320 37 321 17 322 3 323 1 343 1 364 2 365 1",
68 2, 0.9, 0.9, 0.5, 500, 0.5,"http://gmd.mpimp-golm.mpg.de", "http://gmd.mpimp-golm.mpg.de/webservices/wsLibrarySearch.asmx",1500, 3000, "VAR5"),
69
70 [
71 {
72 'analyteID' => '0a2b3536-2245-4c0e-bdbc-495766eeec67',
73 'metaboliteID' => '68513255-fc44-4041-bc4b-4fd2fae7541d',
74 'analyteName' => 'Glucose (1MEOX) (5TMS) BP',
75 'spectrumName' => 'Glucose (1MEOX) (5TMS) BP [A191001-ambient-na-23]',
76 'EuclideanDistance' => '0.00648652157',
77 'HammingDistance' => 51,
78 'ri' => '1899.05493',
79 'spectrumID' => 'dd5bb721-ce4f-4cec-99ff-de2cb818304d',
80 's12GowerLegendreDistance' => '0.404159725',
81 'riDiscrepancy' => '1.054953',
82 'DotproductDistance' => '0.00376573764',
83 'JaccardDistance' => '0.2849162'
84 },
85 {
86 'DotproductDistance' => '0.0041610254',
87 'JaccardDistance' => '0.238709673',
88 'ri' => '1897.25439',
89 'spectrumID' => 'd00de57d-6fab-49d0-9aee-25e259da9180',
90 's12GowerLegendreDistance' => '0.367506444',
91 'riDiscrepancy' => '0.745605469',
92 'analyteName' => 'Idose (1MEOX) (5TMS) BP',
93 'spectrumName' => 'Idose (1MEOX) (5TMS) BP [A191005-ambient-na-1]',
94 'EuclideanDistance' => '0.007327365',
95 'HammingDistance' => 37,
96 'analyteID' => '6f4e926f-d7ef-47b6-a52c-91ff88ca567a',
97 'metaboliteID' => 'ab025068-f464-4bc6-9c92-994c29387db2'
98 }
99 ]
100 ,
101 "Method \'LibrarySearch\' returns a list of hits for a spectrum and parameters given in argument");
102
103
104 print "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n" ;
105
106 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
107 # ARGS : $ri, $riWindow, $gcColumn, $spectrum, $maxHits, $JaccardDistanceThreshold,
108 # $s12GowerLegendreDistanceThreshold,$DotproductDistanceThreshold,$HammingDistanceThreshold,
109 # $EuclideanDistanceThreshold,$ws_url, $ws_proxy,$default_ri, $default_ri_window, $default_gc_column
110 # Structure of res : @ret = [ %val1, %val2, ... %valN ]
111 print "\n** Test $current_test BUG LibrarySearch with a list of mzs, intensities and empty spectrum **\n" ; $current_test++;
112 is_deeply(LibrarySearchTest(1898, 5, "VAR5", "", 2, 0.9, 0.9, 0.5, 500, 0.5,"http://gmd.mpimp-golm.mpg.de", "http://gmd.mpimp-golm.mpg.de/webservices/wsLibrarySearch.asmx",1500, 3000, "VAR5"),
113 [],
114 "Method \'LibrarySearch\' returns a list of hits for a spectrum and parameters given in argument");
115
116 print "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n" ;
117
118
119
120
121 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
122 # ARGS : $results,$JaccardDistanceThreshold,$s12GowerLegendreDistanceThreshold,
123 # $DotproductDistanceThreshold,$HammingDistanceThreshold,$EuclideanDistanceThreshold
124 # Structure of res : @ret = [ %val1, %val2, ... %valN ]
125
126 my $results = [
127 {
128 's12GowerLegendreDistance' => '0.404159725',
129 'JaccardDistance' => '0.2849162',
130 'ri' => '1899.05493',
131 'metaboliteID' => '68513255-fc44-4041-bc4b-4fd2fae7541d',
132 'EuclideanDistance' => '0.00648652157',
133 'HammingDistance' => '51',
134 'analyteID' => '0a2b3536-2245-4c0e-bdbc-495766eeec67',
135 'spectrumID' => 'dd5bb721-ce4f-4cec-99ff-de2cb818304d',
136 'DotproductDistance' => '0.00376573671',
137 'riDiscrepancy' => '1.054953',
138 'spectrumName' => 'Glucose (1MEOX) (5TMS) BP [A191001-ambient-na-23]',
139 'analyteName' => 'Glucose (1MEOX) (5TMS) BP'
140 },
141 {
142 'analyteName' => 'Idose (1MEOX) (5TMS) BP',
143 'spectrumName' => 'Idose (1MEOX) (5TMS) BP [A191005-ambient-na-3]',
144 'riDiscrepancy' => '0.745605469',
145 'ri' => '1897.25439',
146 'metaboliteID' => 'ab025068-f464-4bc6-9c92-994c29387db2',
147 'JaccardDistance' => '0.835855663',
148 's12GowerLegendreDistance' => '0.771266937',
149 'DotproductDistance' => '0.0228821356',
150 'HammingDistance' => '718',
151 'EuclideanDistance' => '0.007299051',
152 'analyteID' => '6f4e926f-d7ef-47b6-a52c-91ff88ca567a',
153 'spectrumID' => '274f5578-3087-4c10-8a6c-6ffa6eb4bd6c'
154 }
155 ] ;
156 print "\n** Test $current_test filter_scores_golm_results with results and thresholds **\n" ; $current_test++;
157 is_deeply(filter_scores_golm_resultsTest($results, 0.9, 0.9, 0.5, 500, 0.5),
158 [
159 {
160 's12GowerLegendreDistance' => '0.404159725',
161 'DotproductDistance' => '0.00376573671',
162 'spectrumName' => 'Glucose (1MEOX) (5TMS) BP [A191001-ambient-na-23]',
163 'analyteID' => '0a2b3536-2245-4c0e-bdbc-495766eeec67',
164 'riDiscrepancy' => '1.054953',
165 'ri' => '1899.05493',
166 'analyteName' => 'Glucose (1MEOX) (5TMS) BP',
167 'HammingDistance' => 51,
168 'spectrumID' => 'dd5bb721-ce4f-4cec-99ff-de2cb818304d',
169 'JaccardDistance' => '0.2849162',
170 'metaboliteID' => '68513255-fc44-4041-bc4b-4fd2fae7541d',
171 'EuclideanDistance' => '0.00648652157'
172 }
173 ],
174 "Method \'filter_scores_golm_results\' returns results wich have distance scores under thresholds");
175
176 print "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n" ;
177
178
179
180 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
181 # ARGS : $results,$JaccardDistanceThreshold,$s12GowerLegendreDistanceThreshold,
182 # $DotproductDistanceThreshold,$HammingDistanceThreshold,$EuclideanDistanceThreshold
183 # Structure of res : @ret = [ %val1, %val2, ... %valN ]
184
185 $results = [
186 {
187 's12GowerLegendreDistance' => '0.404159725',
188 'JaccardDistance' => '0.9849162',
189 'ri' => '1899.05493',
190 'metaboliteID' => '68513255-fc44-4041-bc4b-4fd2fae7541d',
191 'EuclideanDistance' => '0.00648652157',
192 'HammingDistance' => '51',
193 'analyteID' => '0a2b3536-2245-4c0e-bdbc-495766eeec67',
194 'spectrumID' => 'dd5bb721-ce4f-4cec-99ff-de2cb818304d',
195 'DotproductDistance' => '0.00376573671',
196 'riDiscrepancy' => '1.054953',
197 'spectrumName' => 'Glucose (1MEOX) (5TMS) BP [A191001-ambient-na-23]',
198 'analyteName' => 'Glucose (1MEOX) (5TMS) BP'
199 },
200 {
201 'analyteName' => 'Idose (1MEOX) (5TMS) BP',
202 'spectrumName' => 'Idose (1MEOX) (5TMS) BP [A191005-ambient-na-3]',
203 'riDiscrepancy' => '0.745605469',
204 'ri' => '1897.25439',
205 'metaboliteID' => 'ab025068-f464-4bc6-9c92-994c29387db2',
206 'JaccardDistance' => '0.835855663',
207 's12GowerLegendreDistance' => '0.771266937',
208 'DotproductDistance' => '0.0228821356',
209 'HammingDistance' => '718',
210 'EuclideanDistance' => '0.007299051',
211 'analyteID' => '6f4e926f-d7ef-47b6-a52c-91ff88ca567a',
212 'spectrumID' => '274f5578-3087-4c10-8a6c-6ffa6eb4bd6c'
213 }
214 ] ;
215
216 print "\n** Test $current_test filter_scores_golm_results with results having too high distance scores **\n" ; $current_test++;
217 is_deeply(filter_scores_golm_resultsTest($results, 0.9, 0.9, 0.5, 500, 0.5),
218 [],
219 "Method \'filter_scores_golm_results\' returns results wich have distance scores under thresholds");
220
221 print "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n" ;
222
223
224
225 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
226 # ARGS : $results
227 # Structure of res : @ret = [ %val1, %val2, ... %valN ]
228
229 $results = [
230 {
231 's12GowerLegendreDistance' => '0.404159725',
232 'JaccardDistance' => '0.9849162',
233 'ri' => '1899.05493',
234 'metaboliteID' => '68513255-fc44-4041-bc4b-4fd2fae7541d',
235 'EuclideanDistance' => '0.00648652157',
236 'HammingDistance' => '51',
237 'analyteID' => '0a2b3536-2245-4c0e-bdbc-495766eeec67',
238 'spectrumID' => 'dd5bb721-ce4f-4cec-99ff-de2cb818304d',
239 'DotproductDistance' => '0.00376573671',
240 'riDiscrepancy' => '1.054953',
241 'spectrumName' => 'Glucose (1MEOX) (5TMS) BP [A191001-ambient-na-23]',
242 'analyteName' => 'Glucose (1MEOX) (5TMS) BP'
243 },
244 {
245 's12GowerLegendreDistance' => '0.404159725',
246 'JaccardDistance' => '0.9849162',
247 'ri' => '1899.05493',
248 'metaboliteID' => '68513255-fc44-4041-bc4b-4fd2fae7541d',
249 'EuclideanDistance' => '0.00648652157',
250 'HammingDistance' => '51',
251 'analyteID' => '0a2b3536-2245-4c0e-bdbc-495766eeec67',
252 'spectrumID' => 'dd5bb721-ce4f-4cec-99ff-de2cb818304d',
253 'DotproductDistance' => '0.07376573671',
254 'riDiscrepancy' => '1.054953',
255 'spectrumName' => 'Glucose (1MEOX) (5TMS) BP [A191001-ambient-na-23]',
256 'analyteName' => 'Glucose (1MEOX) (5TMS) BP'
257 }
258 ] ;
259
260 print "\n** Test $current_test filter_replica_results with real parameters **\n" ; $current_test++;
261 is_deeply(filter_replica_resultsTest($results),
262 [
263 {
264 's12GowerLegendreDistance' => '0.404159725',
265 'JaccardDistance' => '0.9849162',
266 'ri' => '1899.05493',
267 'metaboliteID' => '68513255-fc44-4041-bc4b-4fd2fae7541d',
268 'EuclideanDistance' => '0.00648652157',
269 'HammingDistance' => '51',
270 'analyteID' => '0a2b3536-2245-4c0e-bdbc-495766eeec67',
271 'spectrumID' => 'dd5bb721-ce4f-4cec-99ff-de2cb818304d',
272 'DotproductDistance' => '0.00376573671',
273 'riDiscrepancy' => '1.054953',
274 'spectrumName' => 'Glucose (1MEOX) (5TMS) BP [A191001-ambient-na-23]',
275 'analyteName' => 'Glucose (1MEOX) (5TMS) BP'
276 }
277 ],
278 "Method \'filter_replica_results\' returns results with unique spectra with lowest dotproduct");
279
280 print "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n" ;
281
282
283
284
285 }
286
287
288 #### #### ##### ###### ################################################ ###### ##### ##### ###### ######
289
290 ## START of MSP SEQUENCE ##
291
292 #### #### ##### ###### ################################################ ###### ##### ##### ###### ######
293
294
295 elsif ($sequence eq "MSP") {
296
297 ## testing msp module of golm wrapper.
298 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
299 print "\n\t\t\t * * * * * * \n" ;
300 print "\t * * * - - - Test MSP parsing module - - - * * * \n\n" ;
301
302 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
303
304
305 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
306 # ARGS : $msp_file, $mzRes
307 # Structure of res: [ $arr_ref1 , $arr_ref2 ... $arr_refN ]
308 print "\n** Test $current_test get_mzs from a .msp file normal parameters **\n" ; $current_test++;
309 is_deeply( get_mzsTest('./data/inputSpectra_unit_test.msp',0),
310 [
311 [
312 73,
313 74,
314 75,
315 100,
316 103,
317 116,
318 117,
319 118,
320 128,
321 131,
322 133,
323 147,
324 48,
325 149,
326 190,
327 191,
328 192,
329 207,
330 218
331 ]
332 ],
333 "Method \'get_mzs\' return an array of arrays refs containing mzs of all the spectra from a msp file");
334
335
336
337
338 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
339 # ARGS : $msp_file, $mzRes
340 # Structure of res: [ $arr_ref1 , $arr_ref2 ... $arr_refN ]
341 print "\n** Test $current_test get_mzs from a .msp file: specific mzRes **\n" ; $current_test++;
342 is_deeply( get_mzsTest('./data/inputSpectra_unit_test.msp',2),
343 [
344 [
345 '73.05',
346 '74.05',
347 '75.03',
348 '100.06',
349 '103.02',
350 '116.09',
351 '117.09',
352 '118.09',
353 '128.05',
354 '131.04',
355 '133.04',
356 '147.07',
357 '48.07',
358 '149.06',
359 '190.11',
360 '191.11',
361 '192.10',
362 '207.03',
363 '218.10'
364 ]
365 ],
366 "Method \'get_mzs\' return an array of arrays refs containing mzs of all the spectra from a msp file ");
367
368
369
370
371 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
372 # ARGS : $msp_file, $mzRes
373 # Structure of res: [ $arr_ref1 , $arr_ref2 ... $arr_refN ]
374 print "\n** Test $current_test get_mzs from a .msp file: too big mzRes **\n" ; $current_test++;
375 is_deeply( get_mzsTest('./data/inputSpectra_unit_test.msp',10),
376 [
377 [
378 '73.0465000000',
379 '74.0481000000',
380 '75.0319000000',
381 '100.0573000000',
382 '103.0227000000',
383 '116.0884000000',
384 '117.0905000000',
385 '118.0869000000',
386 '128.0526000000',
387 '131.0359000000',
388 '133.0438000000',
389 '147.0666000000',
390 '48.0660000000',
391 '149.0551000000',
392 '190.1069000000',
393 '191.1063000000',
394 '192.1023000000',
395 '207.0333000000',
396 '218.1028000000'
397 ]
398 ],
399 "Method \'get_mzs\' return an array of arrays refs containing mzs of all the spectra from a msp file ");
400
401
402
403
404
405 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
406 # ARGS : $msp_file
407 # Structure of res: [ $arr_ref1 , $arr_ref2 ... $arr_refN ]
408 print "\n** Test $current_test get_intensities from a .msp file **\n" ; $current_test++;
409 is_deeply(get_intensitiesTest('./data/inputSpectra_unit_test.msp'),
410 [
411 [
412 '826983.38',
413 '70018.08',
414 '69475.73',
415 '37477.24',
416 '43054.28',
417 '1433179.62',
418 '151975.23',
419 '53105.64',
420 '26404.77',
421 '22647.44',
422 '22141.56',
423 '255488.28',
424 '49965.66',
425 '37762.38',
426 '72568.23',
427 '18017.34',
428 '6460.8',
429 '35435.81',
430 '30528.82'
431 ]
432 ],
433 "Method \'get_mzs\' return an array of arrays refs containing mzs of all the spectra from a msp file");
434
435
436
437
438
439 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
440 # ARGS : $inputSpectra,$mzRes
441 # Structure of res: [ $arr_ref1 , $arr_ref2 ... $arr_refN ]
442 print "\n** Test $current_test get_masses_from_stringTest from string of mzs and intensities **\n" ; $current_test++;
443 is_deeply(get_masses_from_stringTest('70 3 71 3 72 16 73 999 74 87 75 78 76 4 77 5 81 1 82 6 83 13 84 4 85 3 86 4 87 5 88 4 89 52 90 4 91 2 97 2 98 1 99 4 100
444 12 101 16 102 9 103 116 104 11 105 26 106 2 107 1 111 1 112 1 113 4 114 11 115 7 116 5 117 93 118 9 119 8 126 1 127 3 128 3 129 101 130 19 131 25 132 4 133 60 134 8 135 4 140
445 1 141 1 142 4 143 13 144 2 145 6 146 1 147 276 148 44 149 27 150 3 151 1 156 1 157 70 158 12 159 5 160 148 161 26 162 7 163 8 164 1 168 1 169 2 170 1 172 3 173 4 174 1 175 4
446 177 4 186 2 187 1 189 28 190 7 191 13 192 2 193 1 201 5 202 1 203 3 204 23 205 162 206 31 207 16 208 2 210 2 214 1 215 2 216 8 217 88 218 18 219 8 220 1 221 6 222 1 229 23
447 230 6 231 11 232 3 233 4 234 3 235 1 243 1 244 2 245 1 246 2 247 1 256 1 262 3 263 1 269 2 270 1 274 4 275 1 277 4 278 1 291 7 292 2 293 1 300 1 305 4 306 1 307 4 308 1 318
448 1 319 122 320 37 321 17 322 3 323 1 343 1 364 2 365 1', 0),
449 [
450 '70', '71', '72', '73', '74', '75', '76', '77', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '97', '98', '99', '100', '101', '102', '103', '104', '105', '106', '107', '111', '112', '113', '114', '115', '116', '117', '118', '119', '126', '127', '128', '129', '130', '131', '132', '133', '134', '135', '140', '141', '142', '143', '144', '145', '146', '147', '148', '149', '150', '151', '156', '157', '158', '159', '160', '161', '162', '163', '164', '168', '169', '170', '172', '173', '174', '175', '177', '186', '187', '189', '190', '191', '192', '193', '201', '202', '203', '204', '205', '206', '207', '208', '210', '214', '215', '216', '217', '218', '219', '220', '221', '222', '229', '230', '231', '232', '233', '234', '235', '243', '244', '245', '246', '247', '256', '262', '263', '269', '270', '274', '275', '277', '278', '291', '292', '293', '300', '305', '306', '307', '308', '318', '319', '320', '321', '322', '323', '343', '364', '365'
451 ],
452 "Method \'get_masses_from_stringTest\' return an array containing all masses from a string");
453
454
455
456
457 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
458 # ARGS : $inputSpectra
459 # Structure of res: [ $arr_ref1 , $arr_ref2 ... $arr_refN ]
460 print "\n** Test $current_test get_intensities_from_stringTest from string of mzs and intensities **\n" ; $current_test++;
461 is_deeply(get_intensities_from_stringTest("70 3 71 3 72 16 73 999 74 87 75 78 76 4 77 5 81 1 82 6 83 13 84 4 85 3 86 4 87 5 88 4 89 52 90 4 91 2 97 2 98 1 99 4 100
462 12 101 16 102 9 103 116 104 11 105 26 106 2 107 1 111 1 112 1 113 4 114 11 115 7 116 5 117 93 118 9 119 8 126 1 127 3 128 3 129 101 130 19 131 25 132 4 133 60 134 8 135 4 140
463 1 141 1 142 4 143 13 144 2 145 6 146 1 147 276 148 44 149 27 150 3 151 1 156 1 157 70 158 12 159 5 160 148 161 26 162 7 163 8 164 1 168 1 169 2 170 1 172 3 173 4 174 1 175 4
464 177 4 186 2 187 1 189 28 190 7 191 13 192 2 193 1 201 5 202 1 203 3 204 23 205 162 206 31 207 16 208 2 210 2 214 1 215 2 216 8 217 88 218 18 219 8 220 1 221 6 222 1 229 23
465 230 6 231 11 232 3 233 4 234 3 235 1 243 1 244 2 245 1 246 2 247 1 256 1 262 3 263 1 269 2 270 1 274 4 275 1 277 4 278 1 291 7 292 2 293 1 300 1 305 4 306 1 307 4 308 1 318
466 1 319 122 320 37 321 17 322 3 323 1 343 1 364 2 365 1"),
467 [
468 '3', '3', '16', '999', '87', '78', '4', '5', '1', '6', '13', '4', '3', '4', '5', '4', '52', '4', '2', '2', '1', '4', '12', '16', '9', '116', '11', '26', '2', '1', '1', '1', '4', '11', '7', '5', '93', '9', '8', '1', '3', '3', '101', '19', '25', '4', '60', '8', '4', '1', '1', '4', '13', '2', '6', '1', '276', '44', '27', '3', '1', '1', '70', '12', '5', '148', '26', '7', '8', '1', '1', '2', '1', '3', '4', '1', '4', '4', '2', '1', '28', '7', '13', '2', '1', '5', '1', '3', '23', '162', '31', '16', '2', '2', '1', '2', '8', '88', '18', '8', '1', '6', '1', '23', '6', '11', '3', '4', '3', '1', '1', '2', '1', '2', '1', '1', '3', '1', '2', '1', '4', '1', '4', '1', '7', '2', '1', '1', '4', '1', '4', '1', '1', '122', '37', '17', '3', '1', '1', '2', '1'
469 ],
470 "Method \'get_intensities_from_stringTest\' return an array containing all intensities from a string");
471
472
473
474
475
476 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
477 # ARGS : $mzs,$intensities
478 # Structure of res: [ $arr_ref1 , $arr_ref2 ... $arr_refN ]
479 print "\n** Test $current_test encode_spectrum_for_query from mzs and intensities arrays **\n" ; $current_test++;
480
481 my $mzs = [
482 [73,147,157,160,205,217,272,319,320],
483 [73,129,147,157,160,205,217,319,320]
484 ] ;
485
486 my $intensities = [
487 [5764652,5244020,3561241,3454586,4437872,3601276,30900.41,5352581,3587208],
488 [5551756,3361335,5231997,3641748,3947240,4374348,3683153,5377373,3621938]
489 ];
490
491 is_deeply(encode_spectrum_for_queryTest($mzs,$intensities),
492 [
493 '73 5764652 147 5244020 157 3561241 160 3454586 205 4437872 217 3601276 272 30900.41 319 5352581 320 3587208 ',
494 '73 5551756 129 3361335 147 5231997 157 3641748 160 3947240 205 4374348 217 3683153 319 5377373 320 3621938 ',
495 ],
496 "Method \'encode_spectrum_for_query\' return an array containing WS formatted spectrum strings");
497
498
499
500
501 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
502 # ARGS : $mzs,$intensities
503 # Structure of res: [ $arr_ref1 , $arr_ref2 ... $arr_refN ]
504 print "\n** Test $current_test encode_spectrum_for_query from empty mzs and intensities arrays **\n" ; $current_test++;
505
506 $mzs = [] ;
507
508 $intensities = [];
509
510 is_deeply(encode_spectrum_for_queryTest($mzs,$intensities),
511 [],
512 "Method \'encode_spectrum_for_query\' return an array containing WS formatted spectrum strings");
513
514
515
516 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
517 # ARGS : $mzs,$intensities
518 # Structure of res: [ $arr_ref1 , $arr_ref2 ... $arr_refN ]
519 print "\n** Test $current_test encode_spectrum_for_query from undef mzs and intensities arrays **\n" ; $current_test++;
520 is_deeply(encode_spectrum_for_queryTest(undef,undef),
521 [],
522 "Method \'encode_spectrum_for_query\' return an array containing WS formatted spectrum strings");
523
524
525
526
527 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
528 # ARGS : $mzs_res_sorted, $maxIons
529 # Structure of res: [ $arr_ref1 , $arr_ref2 ... $arr_refN ]
530 print "\n** Test $current_test keep_only_max_masses from mzs arrays according to a max ions given in argument **\n" ; $current_test++;
531 is_deeply(keep_only_max_massesTest(
532 [
533 '73', '147', '205', '160', '319', '103', '129', '117', '217', '74', '75', '157', '133', '89', '148', '320', '206', '189', '149', '105', '161', '131', '204', '229', '130', '218', '321', '72', '101', '207', '83', '143', '191', '100', '158', '104', '114', '231', '102', '118', '119', '134', '163', '216', '219', '115', '162', '190', '291', '82', '145', '221', '230', '77', '87', '116', '159', '201', '76', '84', '86', '88', '90', '99', '113', '132', '135', '142', '173', '175', '177', '233', '274', '277', '305', '307', '70', '71', '85', '127', '128', '150', '172', '203', '232', '234', '262', '322', '91', '97', '106', '144', '169', '186', '192', '208', '210', '215', '244', '246', '269', '292', '364', '81', '98', '107', '111', '112', '126', '140', '141', '146', '151', '156', '164', '168', '170', '174', '187', '193', '202', '214', '220', '222', '235', '243', '245', '247', '256', '263', '270', '275', '278', '293', '300', '306', '308', '318', '323', '343', '365'
534 ], 2),
535 [
536 '73',
537 '147'
538 ],
539 "Method \'keep_only_max_masses\' return an array containing the number of masses to send to Golm");
540
541
542
543 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
544 # ARGS : $mzs_res_sorted, $maxIons
545 # Structure of res: [ $arr_ref1 , $arr_ref2 ... $arr_refN ]
546 print "\n** Test $current_test keep_only_max_intensities from intensity arrays according to a max ions given in argument **\n" ; $current_test++;
547 is_deeply(keep_only_max_intensitiesTest(
548 [
549 999,276,162,148,122,116,101,93,88,87,78,70,60,52,44,37,31,28,27,26,26,25,23,23,19,18,17,16,16,16,13,13,13,12,12,11,11,11,9,9,8,8,8,8,8,7,7,7,7,6,6,6,6,5,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
550 ], 2),
551 [
552 999,
553 276
554 ],
555 "Method \'keep_only_max_intensities\' return an array containing the number of intensities to send to Golm");
556
557
558
559 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
560 # ARGS : $ref_mzs_res, $ref_ints_res
561 # Structure of res: [ mz1,mz2,... ] , [ int1,int2,... ]
562 print "\n** Test $current_test sorting_descending_intensities sort mzs and intensities arrays by descending intensity values **\n" ; $current_test++;
563 is_deeply(sorting_descending_intensities1Test(
564 [
565 '70','71','72','73','74','75','76','77','81','82','83','84','85','86','87','88','89','90','91','97','98','99','100','101','102','103','104','105','106','107','111','112','113','114','115','116','117','118','119','126','127','128','129','130','131','132','133','134','135','140','141','142','143','144','145','146','147','148','149','150','151','156','157','158','159','160','161','162','163','164','168','169','170','172','173','174','175','177','186','187','189','190','191','192','193','201','202','203','204','205','206','207','208','210','214','215','216','217','218','219','220','221','222','229','230','231','232','233','234','235','243','244','245','246','247','256','262','263','269','270','274','275','277','278','291','292','293','300','305','306','307','308','318','319','320','321','322','323','343','364','365'
566 ],
567 [
568 '3','3','16','999','87','78','4','5','1','6','13','4','3','4','5','4','52','4','2','2','1','4','12','16','9','116','11','26','2','1','1','1','4','11','7','5','93','9','8','1','3','3','101','19','25','4','60','8','4','1','1','4','13','2','6','1','276','44','27','3','1','1','70','12','5','148','26','7','8','1','1','2','1','3','4','1','4','4','2','1','28','7','13','2','1','5','1','3','23','162','31','16','2','2','1','2','8','88','18','8','1','6','1','23','6','11','3','4','3','1','1','2','1','2','1','1','3','1','2','1','4','1','4','1','7','2','1','1','4','1','4','1','1','122','37','17','3','1','1','2','1'
569 ]),
570 [
571 '73','147','205','160','319','103','129','117','217','74','75','157','133','89','148','320','206','189','149','105','161','131','204','229','130','218','321','72','101','207','83','143','191','100','158','104','114','231','102','118','119','134','163','216','219','115','162','190','291','82','145','221','230','77','87','116','159','201','76','84','86','88','90','99','113','132','135','142','173','175','177','233','274','277','305','307','70','71','85','127','128','150','172','203','232','234','262','322','91','97','106','144','169','186','192','208','210','215','244','246','269','292','364','81','98','107','111','112','126','140','141','146','151','156','164','168','170','174','187','193','202','214','220','222','235','243','245','247','256','263','270','275','278','293','300','306','308','318','323','343','365'
572 ],
573 "Method \'sorting_descending_intensities\' return the arrays of mz sorted accordingly to the rearrangment of the ints array");
574
575
576
577
578 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
579 # ARGS : $ref_mzs_res, $ref_ints_res
580 # Structure of res: [ mz1,mz2,... ] , [ int1,int2,... ]
581 print "\n** Test $current_test sorting_descending_intensities sort mzs and intensities arrays by descending intensity values **\n" ; $current_test++;
582 is_deeply(sorting_descending_intensities2Test(
583 [
584 '70','71','72','73','74','75','76','77','81','82','83','84','85','86','87','88','89','90','91','97','98','99','100','101','102','103','104','105','106','107','111','112','113','114','115','116','117','118','119','126','127','128','129','130','131','132','133','134','135','140','141','142','143','144','145','146','147','148','149','150','151','156','157','158','159','160','161','162','163','164','168','169','170','172','173','174','175','177','186','187','189','190','191','192','193','201','202','203','204','205','206','207','208','210','214','215','216','217','218','219','220','221','222','229','230','231','232','233','234','235','243','244','245','246','247','256','262','263','269','270','274','275','277','278','291','292','293','300','305','306','307','308','318','319','320','321','322','323','343','364','365'
585 ],
586 [
587 '3','3','16','999','87','78','4','5','1','6','13','4','3','4','5','4','52','4','2','2','1','4','12','16','9','116','11','26','2','1','1','1','4','11','7','5','93','9','8','1','3','3','101','19','25','4','60','8','4','1','1','4','13','2','6','1','276','44','27','3','1','1','70','12','5','148','26','7','8','1','1','2','1','3','4','1','4','4','2','1','28','7','13','2','1','5','1','3','23','162','31','16','2','2','1','2','8','88','18','8','1','6','1','23','6','11','3','4','3','1','1','2','1','2','1','1','3','1','2','1','4','1','4','1','7','2','1','1','4','1','4','1','1','122','37','17','3','1','1','2','1'
588 ]),
589 [
590 999,276,162,148,122,116,101,93,88,87,78,70,60,52,44,37,31,28,27,26,26,25,23,23,19,18,17,16,16,16,13,13,13,12,12,11,11,11,9,9,8,8,8,8,8,7,7,7,7,6,6,6,6,5,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
591 ],
592 "Method \'sorting_descending_intensities\' return the arrays of ints sorted by descending intensity values");
593
594
595
596 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
597 # ARGS : $ref_mzs_res, $ref_ints_res
598 # Structure of res: [ mz1,mz2,... ] , [ int1,int2,... ]
599 print "\n** Test $current_test sorting_descending_intensities remove redundant masses **\n" ; $current_test++;
600 is_deeply(remove_redundants1Test(
601 [
602 '70','71','71','73'
603 ],
604 [
605 '147','259','276','45'
606 ]),
607 [
608 '70','71','73'
609 ],
610 "Method \'sorting_descending_intensities\' return the arrays of masses of non redundant ions");
611
612
613
614 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
615 # ARGS : $ref_mzs_res, $ref_ints_res
616 # Structure of res: [ mz1,mz2,... ] , [ int1,int2,... ]
617 print "\n** Test $current_test sorting_descending_intensities remove redundant masses **\n" ; $current_test++;
618 is_deeply(remove_redundants2Test(
619 [
620 '70','71','71','73'
621 ],
622 [
623 '147','259','276','45'
624 ]),
625 [
626 '147','276','45'
627 ],
628 "Method \'sorting_descending_intensities\' return the arrays of ints of non redundant ions");
629
630
631
632 ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
633 # ARGS : $uniq_total_intensities
634 # Structure of res: [ [int1,int2,...] , ... ]
635 print "\n** Test $current_test apply_relative_intensity make intensities to relative **\n" ; $current_test++;
636 is_deeply(apply_relative_intensityTest(
637 [
638 [
639 '1433179.62','826983.38','255488.28','151975.23','72568.23','70018.08','69475.73','53105.64','49965.66','43054.28','37762.38','37477.24','35435.81','30528.82','26404.77','22647.44','22141.56','18017.34','6460.8'
640 ]
641 ],
642 ),
643 [
644 [
645 '100','57.7027030289476','17.8266754867753','10.6040602224025','5.063442780466','4.88550625636164','4.84766382597598','3.7054420296599','3.48635016174735','3.00410914299772','2.63486721922546','2.61497159720985','2.47253097277507','2.13014611525107','1.84239083723504','1.58022341958784','1.54492568070428','1.25715854095106','0.450801833199386'
646 ]
647 ],
648 "Method \'apply_relative_intensity\' return the arrays of relativ intensities");
649
650
651
652 }
653 else {
654 croak "Can\'t launch any test : no sequence clearly defined !!!!\n" ;
655 }
656