Mercurial > repos > fgiacomoni > hmdb_ms_search
view t/hmdb_managerTest.pl @ 20:b5a1d5e43685 draft
Master branch Updating - - Fxx
author | fgiacomoni |
---|---|
date | Wed, 23 Jan 2019 07:49:34 -0500 |
parents | 4eb2de7c24d1 |
children | 2d8a310e86ce |
line wrap: on
line source
#! perl use diagnostics; use warnings; no warnings qw/void/; use strict; no strict "refs" ; use Test::More qw( no_plan ); use Test::Exception; use FindBin ; use Carp ; ## Specific Modules use lib $FindBin::Bin ; my $binPath = $FindBin::Bin ; use lib::hmdbTest qw( :ALL ) ; ## To launch the right sequence : API, MAPPER, THREADER, ... #my $sequence = 'MAPPER' ; my $sequence = 'MAIN' ; my $current_test = 1 ; if ($sequence eq "MAIN") { print "\n\t\t\t\t * * * * * * \n" ; print "\t * * * - - - Test HMDB Main script - - - * * * \n\n" ; print "\n** Test $current_test extract_sub_mz_lists with an empty list of mzs **\n" ; $current_test++; throws_ok{ extract_sub_mz_listsTest([], 3)} '/The provided mzs list is empty/', 'Method \'extract_sub_mz_lists\' detects empty argument and died correctly' ; print "\n** Test $current_test extract_sub_mz_lists with a list of mzs and a limit of 3 **\n" ; $current_test++; is_deeply( extract_sub_mz_listsTest( ['175.01', '238.19', '420.16', '780.32', '956.25', '1100.45' ], 3), [ [ '175.01', '238.19', '420.16' ], [ '780.32', '956.25', '1100.45' ] ], 'Method \'extract_sub_mz_lists\' works with a list and return a well formated list of sublist of mzs'); print "\n** Test $current_test prepare_multi_masses_query with an empty list of mzs **\n" ; $current_test++; throws_ok{ prepare_multi_masses_queryTest([])} '/The input method parameter mass list is empty/', 'Method \'prepare_multi_masses_query\' detects empty argument and died correctly' ; print "\n** Test $current_test prepare_multi_masses_query with a list of mzs **\n" ; $current_test++; is_deeply( prepare_multi_masses_queryTest( ['175.01', '238.19', '420.16', '780.32', '956.25', '1100.45' ] ), '175.01%0D%0A238.19%0D%0A420.16%0D%0A780.32%0D%0A956.25%0D%0A1100.45%0D%0A', 'Method \'prepare_multi_masses_query\' works with a list of and return a well formated string for hmdb querying'); print "\n** Test $current_test get_matches_from_hmdb_ua with a well-formated string of mzs **\n" ; $current_test++; is_deeply( get_matches_from_hmdb_uaTest( '175.01%0D%0A420.16%0D%0A780.32%0D%0A956.25%0D%0A1100.45%0D%0A', 0.001, 'positive'), [ 'query_mass,compound_id,compound_name,kegg_id,formula,monoisotopic_mass,adduct,adduct_type,adduct_m/z,delta(ppm)', # '175.01,HMDB60293,H2O3S2,113.94453531,M+IsoProp+H,+,175.009875,0.000125', # '175.01,HMDB03745,C2H6O3S2,141.975835438,M+CH3OH+H,+,175.009324,0.000676', # '175.01,HMDB31436,H4O4Si,95.987885149,M+DMSO+H,+,175.009105,0.000895', # '175.01,HMDB33657,C17H10O6,310.047738052,M+H+K,+,175.009086,0.000914', # '175.01,HMDB35230,C17H10O6,310.047738052,M+H+K,+,175.009086,0.000914', # '420.16,HMDB60838,C17H17N3O4S,359.093976737,M+IsoProp+H,+,420.159317,0.000683', # '420.16,HMDB60836,C17H17N3O4S,359.093976737,M+IsoProp+H,+,420.159317,0.000683' ## Update format - 2018-01-19... HMDB V04 # '175.01,HMDB0060293,Hydroxidodioxidosulfidosulfate,C05529,H2O3S2,113.94453531,M+IsoProp+H,+,175.009875,1', # '175.01,HMDB0003745,Mesna,C03576,C2H6O3S2,141.975835438,M+CH3OH+H,+,175.009324,4', # '175.01,HMDB0031436,Silicic acid,n/a,H4O4Si,95.987885149,M+DMSO+H,+,175.009105,5', # '175.01,HMDB0033657,De-o-methylsterigmatocystin,C03683,C17H10O6,310.047738052,M+H+K,+,175.009086,5', # '175.01,HMDB0035230,"6,7-Dihydroxy-3-(4-hydroxyphenyl)furo[3,2-b]chromen-2-one",n/a,C17H10O6,310.047738052,M+H+K,+,175.009086,5', # '420.16,HMDB0060838,"4-hydroxy-5-[(4-{2-[(5-hydroxy-1,2-dihydropyridin-2-ylidene)amino]ethoxy}phenyl)methyl]-2,5-dihydro-1,3-thiazol-2-one",n/a,C17H17N3O4S,359.093976737,M+IsoProp+H,+,420.159317,2', # '420.16,HMDB0060836,N-Desmethyl O-hydroxyrosiglitazone,n/a,C17H17N3O4S,359.093976737,M+IsoProp+H,+,420.159317,2', ## Update results - 2018-09-20... HMDBv4 #'query_mass,compound_id,compound_name,kegg_id,formula,monoisotopic_mass,adduct,adduct_type,adduct_m/z,delta(ppm)', '175.01,HMDB0149376,"2-{[5,6-dihydroxy-3-(4-hydroxyphenyl)-4-oxo-3,4-dihydro-2H-1-benzopyran-7-yl]oxy}-3-(sulfooxy)butanedioic acid",n/a,C19H16O14S,500.026076369,M+2H+Na,+,175.009949,0', '175.01,HMDB0149375,"2-({5,6-dihydroxy-4-oxo-3-[4-(sulfooxy)phenyl]-3,4-dihydro-2H-1-benzopyran-7-yl}oxy)-3-hydroxybutanedioic acid",n/a,C19H16O14S,500.026076369,M+2H+Na,+,175.009949,0', '175.01,HMDB0149419,"2-{[5,8-dihydroxy-3-(4-hydroxyphenyl)-4-oxo-3,4-dihydro-2H-1-benzopyran-7-yl]oxy}-3-(sulfooxy)butanedioic acid",n/a,C19H16O14S,500.026076369,M+2H+Na,+,175.009949,0', '175.01,HMDB0149418,"2-({5,8-dihydroxy-4-oxo-3-[4-(sulfooxy)phenyl]-3,4-dihydro-2H-1-benzopyran-7-yl}oxy)-3-hydroxybutanedioic acid",n/a,C19H16O14S,500.026076369,M+2H+Na,+,175.009949,0', '175.01,HMDB0149392,"2-{[3-(3,4-dihydroxyphenyl)-5-hydroxy-4-oxo-3,4-dihydro-2H-1-benzopyran-7-yl]oxy}-3-(sulfooxy)butanedioic acid",n/a,C19H16O14S,500.026076369,M+2H+Na,+,175.009949,0', '175.01,HMDB0149391,"2-hydroxy-3-({5-hydroxy-3-[4-hydroxy-3-(sulfooxy)phenyl]-4-oxo-3,4-dihydro-2H-1-benzopyran-7-yl}oxy)butanedioic acid",n/a,C19H16O14S,500.026076369,M+2H+Na,+,175.009949,0', '175.01,HMDB0000257,Thiosulfate,C05529,H2O3S2,113.94453531,M+IsoProp+H,+,175.009875,1', '175.01,HMDB0060293,Thiosulfate,C05529,H2O3S2,113.94453531,M+IsoProp+H,+,175.009875,1', '175.01,HMDB0141391,{4-[(1E)-3-oxo-3-phenylprop-1-en-1-yl]phenyl}oxidanesulfonic acid,n/a,C15H12O5S,304.04054466,M+2Na,+,175.00949,3', '175.01,HMDB0141389,{3-[(1E)-3-oxo-3-phenylprop-1-en-1-yl]phenyl}oxidanesulfonic acid,n/a,C15H12O5S,304.04054466,M+2Na,+,175.00949,3', '175.01,HMDB0135622,{4-[(2E)-3-phenylprop-2-enoyl]phenyl}oxidanesulfonic acid,n/a,C15H12O5S,304.04054466,M+2Na,+,175.00949,3', '175.01,HMDB0135448,{3-[(2E)-3-phenylprop-2-enoyl]phenyl}oxidanesulfonic acid,n/a,C15H12O5S,304.04054466,M+2Na,+,175.00949,3', '175.01,HMDB0240280,Methanesulfonic acid,C11145,CH4O3S,95.988114684,M+DMSO+H,+,175.009335,4', '175.01,HMDB0003745,Coenzyme m,C03576,C2H6O3S2,141.975835438,M+CH3OH+H,+,175.009324,4', '175.01,HMDB0142159,[2-hydroxy-2-(2-hydroxyphenyl)-1-phenylethoxy]sulfonic acid,n/a,C14H14O6S,310.051109345,M+H+K,+,175.010772,4', '175.01,HMDB0142160,[2-hydroxy-1-(2-hydroxyphenyl)-2-phenylethoxy]sulfonic acid,n/a,C14H14O6S,310.051109345,M+H+K,+,175.010772,4', '175.01,HMDB0142162,"[3-(1,2-dihydroxy-2-phenylethyl)phenyl]oxidanesulfonic acid",n/a,C14H14O6S,310.051109345,M+H+K,+,175.010772,4', '175.01,HMDB0142166,"[4-(1,2-dihydroxy-2-phenylethyl)phenyl]oxidanesulfonic acid",n/a,C14H14O6S,310.051109345,M+H+K,+,175.010772,4', '175.01,HMDB0142164,[2-hydroxy-1-(3-hydroxyphenyl)-2-phenylethoxy]sulfonic acid,n/a,C14H14O6S,310.051109345,M+H+K,+,175.010772,4', '175.01,HMDB0142163,[2-hydroxy-2-(3-hydroxyphenyl)-1-phenylethoxy]sulfonic acid,n/a,C14H14O6S,310.051109345,M+H+K,+,175.010772,4', '175.01,HMDB0142167,[2-hydroxy-2-(4-hydroxyphenyl)-1-phenylethoxy]sulfonic acid,n/a,C14H14O6S,310.051109345,M+H+K,+,175.010772,4', '175.01,HMDB0142168,[2-hydroxy-1-(4-hydroxyphenyl)-2-phenylethoxy]sulfonic acid,n/a,C14H14O6S,310.051109345,M+H+K,+,175.010772,4', '175.01,HMDB0129951,"{3-[2-(3,5-dihydroxyphenyl)ethyl]phenyl}oxidanesulfonic acid",n/a,C14H14O6S,310.051109345,M+H+K,+,175.010772,4', '175.01,HMDB0031436,Silicic acid,n/a,H4O4Si,95.987885149,M+DMSO+H,+,175.009105,5', '175.01,HMDB0033657,"11,15-Dihydroxy-6,8,20-trioxapentacyclo[10.8.0.0²,⁹.0³,⁷.0¹⁴,¹⁹]icosa-1(12),2(9),4,10,14,16,18-heptaen-13-one",C03683,C17H10O6,310.047738052,M+H+K,+,175.009086,5', '175.01,HMDB0035230,"6,7-Dihydroxy-3-(4-hydroxyphenyl)-2H-furo[3,2-b]chromen-2-one",n/a,C17H10O6,310.047738052,M+H+K,+,175.009086,5', '175.01,HMDB0155176,5-Hydroxy-6-hydrouracil,n/a,C4H6N2O3,130.037842061,M+2Na-H,+,175.009002,6', '420.16,HMDB0060838,N-Desmethyl-p-hydroxyrosiglitazone,n/a,C17H17N3O4S,359.093976737,M+IsoProp+H,+,420.159317,2', '420.16,HMDB0060836,N-Desmethyl-O-hydroxy rosiglitazone,n/a,C17H17N3O4S,359.093976737,M+IsoProp+H,+,420.159317,2', '420.16,HMDB0160148,"6-[(5-carboxy-3-methylpentanoyl)oxy]-3,4,5-trihydroxyoxane-2-carboxylic acid",n/a,C13H20O10,336.105646844,M+IsoProp+Na+H,+,420.160757,2', '420.16,HMDB0160149,"6-[(5-carboxy-4-methylpentanoyl)oxy]-3,4,5-trihydroxyoxane-2-carboxylic acid",n/a,C13H20O10,336.105646844,M+IsoProp+Na+H,+,420.160757,2', '420.16,HMDB0165020,"6-{[2-(acetyloxy)-3-methylbutanoyl]oxy}-3,4,5-trihydroxyoxane-2-carboxylic acid",n/a,C13H20O10,336.105646844,M+IsoProp+Na+H,+,420.160757,2', '420.16,HMDB0175397,"6-{[3-(acetyloxy)-3-methylbutanoyl]oxy}-3,4,5-trihydroxyoxane-2-carboxylic acid",n/a,C13H20O10,336.105646844,M+IsoProp+Na+H,+,420.160757,2', '420.16,HMDB0184353,"6-[(4-carboxy-3,3-dimethylbutanoyl)oxy]-3,4,5-trihydroxyoxane-2-carboxylic acid",n/a,C13H20O10,336.105646844,M+IsoProp+Na+H,+,420.160757,2' ], 'Method \'get_matches_from_hmdb_ua\' works with a well-formated string of mzs and return a complete csv from hmdb'); print "\n** Test $current_test test_matches_from_hmdb_ua to get hmdb status **\n" ; $current_test++; is_deeply (test_matches_from_hmdb_uaTest (), \'200', 'The HMDB server is available: returns successful HTTP requests' ) ; print "\n** Test $current_test check_state_from_hmdb_ua to manage script execution with the hmdb server status **\n" ; $current_test++; is_deeply (check_state_from_hmdb_uaTest (\'200'), 1, 'The status 200 returns no error/warn' ) ; print "\n** Test $current_test prepare_multi_masses_query with an empty list of mzs **\n" ; $current_test++; throws_ok{ check_state_from_hmdb_uaTest(\'504')} '/Gateway Timeout: The HMDB server was acting as a gateway or proxy and did not receive a timely response from the upstream server/', 'Method \'check_state_from_hmdb_ua\' detects HTTP error code returned by HMDB and died correctly' ; print "\n** Test $current_test parse_hmdb_csv_results with the correct inputs for hmdb outputs parsing (csv format) **\n" ; $current_test++; is_deeply ( parse_hmdb_csv_resultsTest ( [ 'query_mass,compound_id,compound_name,kegg_id,formula,monoisotopic_mass,adduct,adduct_type,adduct_m/z,delta(ppm)', # '175.01,HMDB60293,H2O3S2,113.94453531,M+IsoProp+H,+,175.009875,0.000125', # '175.01,HMDB03745,C2H6O3S2,141.975835438,M+CH3OH+H,+,175.009324,0.000676', # '175.01,HMDB31436,H4O4Si,95.987885149,M+DMSO+H,+,175.009105,0.000895', # '175.01,HMDB33657,C17H10O6,310.047738052,M+H+K,+,175.009086,0.000914', # '175.01,HMDB35230,C17H10O6,310.047738052,M+H+K,+,175.009086,0.000914', # '420.16,HMDB60838,C17H17N3O4S,359.093976737,M+IsoProp+H,+,420.159317,0.000683', # '420.16,HMDB60836,C17H17N3O4S,359.093976737,M+IsoProp+H,+,420.159317,0.000683' ## Update format - 2018-01-19... HMDB V04 '175.01,HMDB0060293,Hydroxidodioxidosulfidosulfate,C05529,H2O3S2,113.94453531,M+IsoProp+H,+,175.009875,1', '175.01,HMDB0003745,Mesna,C03576,C2H6O3S2,141.975835438,M+CH3OH+H,+,175.009324,4', '175.01,HMDB0031436,Silicic acid,n/a,H4O4Si,95.987885149,M+DMSO+H,+,175.009105,5', '175.01,HMDB0033657,De-o-methylsterigmatocystin,C03683,C17H10O6,310.047738052,M+H+K,+,175.009086,5', '175.01,HMDB0035230,"6,7-Dihydroxy-3-(4-hydroxyphenyl)furo[3,2-b]chromen-2-one",n/a,C17H10O6,310.047738052,M+H+K,+,175.009086,5', '420.16,HMDB0060838,"4-hydroxy-5-[(4-{2-[(5-hydroxy-1,2-dihydropyridin-2-ylidene)amino]ethoxy}phenyl)methyl]-2,5-dihydro-1,3-thiazol-2-one",n/a,C17H17N3O4S,359.093976737,M+IsoProp+H,+,420.159317,2', '420.16,HMDB0060836,N-Desmethyl O-hydroxyrosiglitazone,n/a,C17H17N3O4S,359.093976737,M+IsoProp+H,+,420.159317,2', ], ['175.01', '238.19', '420.16'], 10 ), [ [ { 'ENTRY_CPD_MZ' => '113.94453531', 'ENTRY_ENTRY_ID' => 'HMDB0060293', 'ENTRY_FORMULA' => 'H2O3S2', 'ENTRY_ADDUCT_MZ' => '175.009875', 'ENTRY_DELTA' => '1', 'ENTRY_ADDUCT_TYPE' => '+', 'ENTRY_ADDUCT' => 'M+IsoProp+H' }, {'ENTRY_DELTA' => '4','ENTRY_ADDUCT_TYPE' => '+','ENTRY_ADDUCT' => 'M+CH3OH+H','ENTRY_CPD_MZ' => '141.975835438','ENTRY_ENTRY_ID' => 'HMDB0003745','ENTRY_FORMULA' => 'C2H6O3S2','ENTRY_ADDUCT_MZ' => '175.009324'}, {'ENTRY_ENTRY_ID' => 'HMDB0031436','ENTRY_CPD_MZ' => '95.987885149','ENTRY_ADDUCT_MZ' => '175.009105','ENTRY_FORMULA' => 'H4O4Si','ENTRY_DELTA' => '5','ENTRY_ADDUCT_TYPE' => '+','ENTRY_ADDUCT' => 'M+DMSO+H'}, {'ENTRY_ADDUCT_MZ' => '175.009086','ENTRY_FORMULA' => 'C17H10O6','ENTRY_ENTRY_ID' => 'HMDB0033657','ENTRY_CPD_MZ' => '310.047738052','ENTRY_ADDUCT' => 'M+H+K','ENTRY_ADDUCT_TYPE' => '+','ENTRY_DELTA' => '5'}, {'ENTRY_ADDUCT_MZ' => '175.009086','ENTRY_FORMULA' => 'C17H10O6','ENTRY_ENTRY_ID' => 'HMDB0035230','ENTRY_CPD_MZ' => '310.047738052','ENTRY_ADDUCT_TYPE' => '+','ENTRY_ADDUCT' => 'M+H+K','ENTRY_DELTA' => '5'} ], [], [ {'ENTRY_FORMULA' => 'C17H17N3O4S','ENTRY_ADDUCT_MZ' => '420.159317','ENTRY_CPD_MZ' => '359.093976737','ENTRY_ENTRY_ID' => 'HMDB0060838','ENTRY_ADDUCT' => 'M+IsoProp+H','ENTRY_ADDUCT_TYPE' => '+','ENTRY_DELTA' => '2'}, {'ENTRY_DELTA' => '2','ENTRY_ADDUCT_TYPE' => '+','ENTRY_ADDUCT' => 'M+IsoProp+H','ENTRY_ENTRY_ID' => 'HMDB0060836','ENTRY_CPD_MZ' => '359.093976737','ENTRY_ADDUCT_MZ' => '420.159317','ENTRY_FORMULA' => 'C17H17N3O4S'} ] ], 'Method \'parse_hmdb_csv_results\' works with a well-formated csv output and returns a a well formated array' ) ; print "\n** Test $current_test parse_hmdb_csv_results with a void hmdb output and a list of mzs **\n" ; $current_test++; is_deeply ( parse_hmdb_csv_resultsTest ( [], ['175.01', '238.19', '420.16'] ), [ [], [], [] ], 'Method \'parse_hmdb_csv_results\' works with a empty csv output and returns an empty but well formatted array' ) ; print "\n** Test $current_test parse_hmdb_csv_results with a void hmdb output and a void mz list **\n" ; $current_test++; is_deeply ( parse_hmdb_csv_resultsTest ( [], [] ), [], 'Method \'parse_hmdb_csv_results\' works with a empty csv output/mz list and returns an empty but well formatted array' ) ; ## Other example... from mz 265.0567515 print "\n** Test $current_test parse_hmdb_csv_results with mz 265.0567515 and the correct inputs for hmdb outputs parsing (csv format) **\n" ; $current_test++; is_deeply ( parse_hmdb_csv_resultsTest ( [ 'query_mass,compound_id,compound_name,kegg_id,formula,monoisotopic_mass,adduct,adduct_type,adduct_m/z,delta(ppm)', '265.0567515,HMDB0059667,3-Methylsulfolene,n/a,C5H8O2S,132.02450019,2M+H,+,265.056276,2', '265.0567515,HMDB0038767,Camelliaside b,n/a,C32H38O19,726.200729034,M+3Na,+,265.056128,2', '265.0567515,HMDB0039759,Kaempferol 3-(2g-apiosylrobinobioside),n/a,C32H38O19,726.200729034,M+3Na,+,265.056128,2', '265.0567515,HMDB0040875,Isoschaftoside 4\'-glucoside,n/a,C32H38O19,726.200729034,M+3Na,+,265.056128,2', '265.0567515,HMDB0040878,Schaftoside 4\'-glucoside,n/a,C32H38O19,726.200729034,M+3Na,+,265.056128,2', '265.0567515,HMDB0059600,erythro-5-Phosphonooxy-L-lysine,C03366,C6H15N2O6P,242.066772734,M+Na,+,265.055991,3', '265.0567515,HMDB0061174,"2,4-Imidazolidinedione, 3-ethyl-5-(4-hydroxyphenyl)-",n/a,C11H12N2O3,220.08479226,M+2Na-H,+,265.055952,3', '265.0567515,HMDB0015571,Oxitriptan,C00643,C11H12N2O3,220.08479226,M+2Na-H,+,265.055952,3', '265.0567515,HMDB0000472,5-hydroxy-l-tryptophan,C01017,C11H12N2O3,220.08479226,M+2Na-H,+,265.055952,3', '265.0567515,HMDB0030584,Silidianin,n/a,C25H24O10,484.136946988,M+2Na,+,265.057691,4', ], ['265.0567515'], 5 ), [ [ { 'ENTRY_DELTA' => '2', 'ENTRY_FORMULA' => 'C5H8O2S', 'ENTRY_ENTRY_ID' => 'HMDB0059667', 'ENTRY_ADDUCT_MZ' => '265.056276', 'ENTRY_ADDUCT_TYPE' => '+', 'ENTRY_CPD_MZ' => '132.02450019', 'ENTRY_ADDUCT' => '2M+H' }, { 'ENTRY_ADDUCT_MZ' => '265.056128', 'ENTRY_ENTRY_ID' => 'HMDB0038767', 'ENTRY_ADDUCT_TYPE' => '+', 'ENTRY_CPD_MZ' => '726.200729034', 'ENTRY_ADDUCT' => 'M+3Na', 'ENTRY_DELTA' => '2', 'ENTRY_FORMULA' => 'C32H38O19' }, { 'ENTRY_DELTA' => '2', 'ENTRY_FORMULA' => 'C32H38O19', 'ENTRY_ENTRY_ID' => 'HMDB0039759', 'ENTRY_ADDUCT_MZ' => '265.056128', 'ENTRY_ADDUCT_TYPE' => '+', 'ENTRY_CPD_MZ' => '726.200729034', 'ENTRY_ADDUCT' => 'M+3Na' }, { 'ENTRY_FORMULA' => 'C32H38O19', 'ENTRY_DELTA' => '2', 'ENTRY_ADDUCT_TYPE' => '+', 'ENTRY_ADDUCT_MZ' => '265.056128', 'ENTRY_ENTRY_ID' => 'HMDB0040875', 'ENTRY_CPD_MZ' => '726.200729034', 'ENTRY_ADDUCT' => 'M+3Na' }, { 'ENTRY_ADDUCT_TYPE' => '+', 'ENTRY_ENTRY_ID' => 'HMDB0040878', 'ENTRY_ADDUCT_MZ' => '265.056128', 'ENTRY_ADDUCT' => 'M+3Na', 'ENTRY_CPD_MZ' => '726.200729034', 'ENTRY_FORMULA' => 'C32H38O19', 'ENTRY_DELTA' => '2' } ] ], 'Method \'parse_hmdb_csv_results\' works with a well-formated csv output and returns a a well formated array' ) ; } ## END of the script