comparison t/downloader_bank_hmdb.t @ 0:7c9269bded0e draft

Init repository for [downloader_bank_hmdb]
author fgiacomoni
date Tue, 14 Jan 2020 05:21:23 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:7c9269bded0e
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 Test::More tests => 8 ; ## with MAPPER SEQUENCE
9 use FindBin ;
10 use Carp ;
11
12 ## Specific Modules
13 use lib $FindBin::Bin.'/lib' ;
14 my $binPath = $FindBin::Bin ;
15 use utilsTest qw( :ALL ) ;
16 use hmdb_apiTest qw( :ALL ) ;
17
18
19 ## If needed to launch parallele test sequences : SEQ01, SEQ02, SEQ03, ...
20 my $sequence = 'SEQ02' ;
21 my $current_test = 1 ;
22
23 #### #### ##### ###### ################################################ ###### ##### ##### ###### ######
24
25 ## START of SEQ01 SEQUENCE ##
26
27 #### #### ##### ###### ################################################ ###### ##### ##### ###### ######
28
29 if ($sequence eq "SEQ01") {
30
31 print "\n\t\t\t\t * * * * * * \n" ;
32 print "\t * * * - - - Test module utils - - - * * * \n\n" ;
33
34 ## - - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - - -
35 # ARGVTS : $argt1, ...
36 sleep 1 ; print "\n** Test $current_test getHttpFileVersion with a valid url **\n" ; $current_test++ ;
37 is_deeply( getHttpFileVersionTest ( ## input parameters : here only one argt
38 'http://www.hmdb.ca/system/downloads/current/urine_metabolites.zip',
39 ),
40 'v2018Jul09',
41 'Method \'getHttpFileVersion\' works with a valid url and return the attended output');
42
43
44 ## - - - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - -
45 # ARGVTS : $argt1, ...
46 sleep 1 ; print "\n** Test $current_test getHttpFile with a valid url and fileName **\n" ; $current_test++ ;
47 is_deeply( getHttpFileTest ( ## input parameters : here only one argt
48 'http://www.hmdb.ca/system/downloads/current/csf_metabolites.zip',
49 '/tmp/CSF_v2018Jul09/CSF_v2018Jul09.zip'
50 ),
51 1,
52 'Method \'getHttpFile\' works with a valid url and a file name and return the attended output (a file)');
53
54
55 ## - - - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - -
56 # ARGVTS : $argt1, ...
57 sleep 1 ; print "\n** Test $current_test unzipFile with a valid url, a dir and fileName **\n" ; $current_test++ ;
58 is_deeply( unzipFileTest ( ## input parameters : here only one argt
59 '/tmp/CSF_v2018Jul09/CSF_v2018Jul09.zip',
60 '/tmp/CSF_v2018Jul09/csf_metabolites.xml',
61 'csf_metabolites.xml'
62
63 ),
64 1,
65 'Method \'unzipFile\' works with a valid url and a file name and return the attended output (1)');
66
67 #### #### ##### ###### ################################################ ###### ##### ##### ###### ######
68
69 ## END of SEQ01 SEQUENCE ##
70
71 #### #### ##### ###### ################################################ ###### ##### ##### ###### ######
72
73 }
74
75 #### #### ##### ###### ################################################ ###### ##### ##### ###### ######
76
77 ## START of SEQ02 SEQUENCE ##
78
79 #### #### ##### ###### ################################################ ###### ##### ##### ###### ######
80 elsif ($sequence eq "SEQ02") {
81 print "\n\t\t\t\t * * * * * * \n" ;
82 print "\t * * * - - - Test SEQ02 Main script - - - * * * \n\n" ;
83
84 ## - - - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - -
85 # ARGVTS : $argt1, ...
86 # sleep 1 ; print "\n** Test $current_test getMetaboliteFeatures with a valid xml file **\n" ; $current_test++ ;
87 # is_deeply( getMetaboliteFeaturesTest ( ## input parameters : here only one argt
88 # '/Users/fgiacomoni/Inra/labs/perl/downloader-bank-hmdb/banks/CSF_v2018Jul09/csf_metabolites.xml',
89 # ),
90 # 450,
91 # 'Method \'getMetaboliteFeatures\' works with a valid xml and return the attended output (HASH)');
92
93 ## - - - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - -
94 # ARGVTS : $argt1, ...
95 sleep 1 ; print "\n** Test $current_test buildMetabolitesArray with a hash of metabolites **\n" ; $current_test++ ;
96 is_deeply( buildMetabolitesArrayTest ( ## input parameters : here only one argt
97 { 'HMDB0001565' => { 'metabolite_name' => 'Phosphorylcholine',
98 'monisotopic_molecular_weight' => '184.073869485',
99 '[M+H]+' => '185.081145885',
100 '[M-H]-' => '183.066593085',
101 'chemical_formula' => 'C5H15NO4P',
102 'inchikey' => 'YHHSONZFOIEMCP-UHFFFAOYSA-O' },
103 'HMDB0006088' => { 'monisotopic_molecular_weight' => '180.063388116',
104 '[M+H]+' => '181.070664516',
105 '[M-H]-' => '179.056111716',
106 'inchikey' => 'CDAISMWEOUEBRE-CDRYSYESSA-N',
107 'chemical_formula' => 'C6H12O6',
108 'metabolite_name' => 'scyllo-Inositol' }
109 },
110 ['HMDB_ID','MzBank', '[M+H]+', '[M-H]-','MetName', 'ChemFormula', 'INChIkey']
111 ),
112 [
113 [
114 'HMDB_ID',
115 'MzBank',
116 '[M+H]+',
117 '[M-H]-',
118 'MetName',
119 'ChemFormula',
120 'INChIkey'
121 ],
122 [
123 'HMDB0001565',
124 '184.073869485',
125 '185.081145885',
126 '183.066593085',
127 'Phosphorylcholine',
128 'C5H15NO4P',
129 'YHHSONZFOIEMCP-UHFFFAOYSA-O'
130 ],
131 [
132 'HMDB0006088',
133 '180.063388116',
134 '181.070664516',
135 '179.056111716',
136 'scyllo-Inositol',
137 'C6H12O6',
138 'CDAISMWEOUEBRE-CDRYSYESSA-N'
139 ]
140 ],
141 'Method \'buildMetabolitesArray\' works with a valid metabolites list and return the attended output (Array)');
142
143 ## - - - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - -
144 # ARGVTS : $argt1, ...
145 sleep 1 ; print "\n** Test $current_test setMetaboliteAcurrateMzToModesMz with a hash of metabolites **\n" ; $current_test++ ;
146 is_deeply( setMetaboliteAcurrateMzToModesMzTest ( ## input parameters : here only one argt
147 'CARD',
148 [
149 {
150 'COMMON_NAME' => 'SM(d18:0/24:1(15Z)(OH))',
151 'LOCATION' => 'Rumen',
152 'MZ_AVERAGE' => '829.224',
153 'INCHI' => 'InChI=1/C47H93N2O7P/c1-6-8-10-12-14-16-18-20-21-22-23-24-25-27-28-30-32-34-36-38-44(50)42-47(52)48-45(43-56-57(53,54)55-41-40-49(3,4)5)46(51)39-37-35-33-31-29-26-19-17-15-13-11-9-7-2/h20-21,37,39,44-46,50-51H,6-19,22-36,38,40-43H2,1-5H3,(H-,48,52,53,54)/b21-20-,39-37+/t44?,45-,46+/m0/s1',
154 'FORMULA' => 'C47H93N2O7P',
155 'TAXONOMY' => 'Lipids',
156 'HMDB_ID' => 'HMDB13469',
157 'KEGG_ID' => 'C00550',
158 'BIOCYC_ID' => 'Not Available',
159 'IUPAC' => 'Not Available',
160 'CAS' => 'Not Available',
161 'MZ_MONO' => '828.672058'
162 }
163 ]
164 ),
165 [
166 {
167 'MZ_[M-H]-' => '827.6647816',
168 'COMMON_NAME' => 'SM(d18:0/24:1(15Z)(OH))',
169 'LOCATION' => 'Rumen',
170 'MZ_[M+H]+' => '829.6793344',
171 'MZ_AVERAGE' => '829.224',
172 'INCHI' => 'InChI=1/C47H93N2O7P/c1-6-8-10-12-14-16-18-20-21-22-23-24-25-27-28-30-32-34-36-38-44(50)42-47(52)48-45(43-56-57(53,54)55-41-40-49(3,4)5)46(51)39-37-35-33-31-29-26-19-17-15-13-11-9-7-2/h20-21,37,39,44-46,50-51H,6-19,22-36,38,40-43H2,1-5H3,(H-,48,52,53,54)/b21-20-,39-37+/t44?,45-,46+/m0/s1',
173 'FORMULA' => 'C47H93N2O7P',
174 'TAXONOMY' => 'Lipids',
175 'HMDB_ID' => 'HMDB13469',
176 'KEGG_ID' => 'C00550',
177 'BIOCYC_ID' => 'Not Available',
178 'IUPAC' => 'Not Available',
179 'CAS' => 'Not Available',
180 'MZ_MONO' => '828.672058'
181 }
182 ],
183 'Method \'setMetaboliteAcurrateMzToModesMz\' works with XML FORMAT AND a valid metabolites list and return the attended output (Array)');
184
185 ## - - - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - -
186 # ARGVTS : $argt1, ...
187 sleep 1 ; print "\n** Test $current_test setMetaboliteAcurrateMzToModesMz with a hash of metabolites **\n" ; $current_test++ ;
188 is_deeply( setMetaboliteAcurrateMzToModesMzTest ( ## input parameters : here only one argt
189 'XML',
190 { 'HMDB0001565' => { 'metabolite_name' => 'Phosphorylcholine',
191 'monisotopic_molecular_weight' => '184.073869485',
192 'chemical_formula' => 'C5H15NO4P',
193 'inchikey' => 'YHHSONZFOIEMCP-UHFFFAOYSA-O' },
194 'HMDB0006088' => { 'monisotopic_molecular_weight' => '180.063388116',
195 'inchikey' => 'CDAISMWEOUEBRE-CDRYSYESSA-N',
196 'chemical_formula' => 'C6H12O6',
197 'metabolite_name' => 'scyllo-Inositol' }
198 }
199 ),
200 { 'HMDB0001565' => { 'metabolite_name' => 'Phosphorylcholine',
201 'monisotopic_molecular_weight' => '184.073869485',
202 '[M+H]+' => '185.081145885',
203 '[M-H]-' => '183.066593085',
204 'chemical_formula' => 'C5H15NO4P',
205 'inchikey' => 'YHHSONZFOIEMCP-UHFFFAOYSA-O' },
206 'HMDB0006088' => { 'monisotopic_molecular_weight' => '180.063388116',
207 '[M+H]+' => '181.070664516',
208 '[M-H]-' => '179.056111716',
209 'inchikey' => 'CDAISMWEOUEBRE-CDRYSYESSA-N',
210 'chemical_formula' => 'C6H12O6',
211 'metabolite_name' => 'scyllo-Inositol' }
212 },
213 'Method \'setMetaboliteAcurrateMzToModesMz\' works with XML FORMAT AND a valid metabolites list and return the attended output (Array)');
214
215 } ## END ELSIF SEQ02
216
217 #### #### ##### ###### ################################################ ###### ##### ##### ###### ######
218
219 ## END of SEQ02 SEQUENCE ##
220
221 #### #### ##### ###### ################################################ ###### ##### ##### ###### ######
222
223
224 else {
225 croak "Can\'t launch any test : no sequence clearly defined !!!!\n" ;
226 }
227