view 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
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::More tests => 8 ; ## with MAPPER SEQUENCE
use FindBin ;
use Carp ;

## Specific Modules
use lib $FindBin::Bin.'/lib' ;
my $binPath = $FindBin::Bin ;
use utilsTest qw( :ALL ) ;
use hmdb_apiTest qw( :ALL ) ;


## If needed to launch parallele test sequences : SEQ01, SEQ02, SEQ03, ...
my $sequence = 'SEQ02' ; 
my $current_test = 1 ;

#### #### ##### ###### ################################################ ###### ##### ##### ###### ######

								## START of SEQ01 SEQUENCE ## 
							
#### #### ##### ###### ################################################ ###### ##### ##### ###### ######

if ($sequence eq "SEQ01") {
	
	print "\n\t\t\t\t  * * * * * * \n" ;
	print "\t  * * * - - - Test module utils - - - * * * \n\n" ;

	##		- - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - - -
	# ARGVTS : $argt1, ...
	sleep 1 ; print "\n** Test $current_test getHttpFileVersion with a valid url **\n" ; $current_test++ ; 
	is_deeply( getHttpFileVersionTest ( ## input parameters : here only one argt
			'http://www.hmdb.ca/system/downloads/current/urine_metabolites.zip', 
		),
		'v2018Jul09',
	'Method \'getHttpFileVersion\' works with a valid url and return the attended output');


	##		- - - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - -
	# ARGVTS : $argt1, ...
	sleep 1 ; print "\n** Test $current_test getHttpFile with a valid url and fileName **\n" ; $current_test++ ; 
	is_deeply( getHttpFileTest ( ## input parameters : here only one argt
			'http://www.hmdb.ca/system/downloads/current/csf_metabolites.zip',
			'/tmp/CSF_v2018Jul09/CSF_v2018Jul09.zip'
		),
		1,
	'Method \'getHttpFile\' works with a valid url and a file name and return the attended output (a file)');
	
	
	##		- - - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - -
	# ARGVTS : $argt1, ...
	sleep 1 ; print "\n** Test $current_test unzipFile with a valid url, a dir and fileName **\n" ; $current_test++ ; 
	is_deeply( unzipFileTest ( ## input parameters : here only one argt
			'/tmp/CSF_v2018Jul09/CSF_v2018Jul09.zip',
			'/tmp/CSF_v2018Jul09/csf_metabolites.xml',
			'csf_metabolites.xml'
			
		),
		1,
	'Method \'unzipFile\' works with a valid url and a file name and return the attended output (1)');
	
#### #### ##### ###### ################################################ ###### ##### ##### ###### ######

								## END of SEQ01 SEQUENCE ## 
							
#### #### ##### ###### ################################################ ###### ##### ##### ###### ######
	
}

#### #### ##### ###### ################################################ ###### ##### ##### ###### ######

								## START of SEQ02 SEQUENCE ## 
							
#### #### ##### ###### ################################################ ###### ##### ##### ###### ######
elsif ($sequence eq "SEQ02") {
	print "\n\t\t\t\t  * * * * * * \n" ;
	print "\t  * * * - - - Test SEQ02 Main script - - - * * * \n\n" ;
	
	##		- - - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - -
	# ARGVTS : $argt1, ...
#	sleep 1 ; print "\n** Test $current_test getMetaboliteFeatures with a valid xml file **\n" ; $current_test++ ; 
#	is_deeply( getMetaboliteFeaturesTest ( ## input parameters : here only one argt
#			'/Users/fgiacomoni/Inra/labs/perl/downloader-bank-hmdb/banks/CSF_v2018Jul09/csf_metabolites.xml',
#		),
#		450,
#	'Method \'getMetaboliteFeatures\' works with a valid xml and return the attended output (HASH)');
	
	##		- - - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - -
	# ARGVTS : $argt1, ...
	sleep 1 ; print "\n** Test $current_test buildMetabolitesArray with a hash of metabolites **\n" ; $current_test++ ; 
	is_deeply( buildMetabolitesArrayTest ( ## input parameters : here only one argt
		{		'HMDB0001565' => {		'metabolite_name' => 'Phosphorylcholine',
				                    'monisotopic_molecular_weight' => '184.073869485',
				                    '[M+H]+' => '185.081145885',
					            	'[M-H]-' => '183.066593085',
                			        'chemical_formula' => 'C5H15NO4P',
                           			'inchikey' => 'YHHSONZFOIEMCP-UHFFFAOYSA-O' },
          		'HMDB0006088' => {	'monisotopic_molecular_weight' => '180.063388116',
          							'[M+H]+' => '181.070664516',
					            	'[M-H]-' => '179.056111716',
                           			'inchikey' => 'CDAISMWEOUEBRE-CDRYSYESSA-N',
                           			'chemical_formula' => 'C6H12O6',
                           			'metabolite_name' => 'scyllo-Inositol' }
		},
		['HMDB_ID','MzBank', '[M+H]+', '[M-H]-','MetName', 'ChemFormula', 'INChIkey']
		),
		[
          [
            'HMDB_ID',
            'MzBank',
            '[M+H]+', 
            '[M-H]-',
            'MetName',
            'ChemFormula',
            'INChIkey'
          ],
          [
            'HMDB0001565',
            '184.073869485',
            '185.081145885',
            '183.066593085',
            'Phosphorylcholine',
            'C5H15NO4P',
            'YHHSONZFOIEMCP-UHFFFAOYSA-O'
          ],
          [
            'HMDB0006088',
            '180.063388116',
            '181.070664516',
			'179.056111716',
            'scyllo-Inositol',
            'C6H12O6',
            'CDAISMWEOUEBRE-CDRYSYESSA-N'
          ]
        ],
	'Method \'buildMetabolitesArray\' works with a valid metabolites list and return the attended output (Array)');
	    
	##		- - - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - -
	# ARGVTS : $argt1, ...
	sleep 1 ; print "\n** Test $current_test setMetaboliteAcurrateMzToModesMz with a hash of metabolites **\n" ; $current_test++ ; 
	is_deeply( setMetaboliteAcurrateMzToModesMzTest ( ## input parameters : here only one argt
			'CARD',
			[
				{
	            'COMMON_NAME' => 'SM(d18:0/24:1(15Z)(OH))',
	            'LOCATION' => 'Rumen',
	            'MZ_AVERAGE' => '829.224',
	            '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',
	            'FORMULA' => 'C47H93N2O7P',
	            'TAXONOMY' => 'Lipids',
	            'HMDB_ID' => 'HMDB13469',
	            'KEGG_ID' => 'C00550',
	            'BIOCYC_ID' => 'Not Available',
	            'IUPAC' => 'Not Available',
	            'CAS' => 'Not Available',
	            'MZ_MONO' => '828.672058'
	          	}
	        ]
		),
		[
				{
	            'MZ_[M-H]-' => '827.6647816',
	            'COMMON_NAME' => 'SM(d18:0/24:1(15Z)(OH))',
	            'LOCATION' => 'Rumen',
	            'MZ_[M+H]+' => '829.6793344',
	            'MZ_AVERAGE' => '829.224',
	            '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',
	            'FORMULA' => 'C47H93N2O7P',
	            'TAXONOMY' => 'Lipids',
	            'HMDB_ID' => 'HMDB13469',
	            'KEGG_ID' => 'C00550',
	            'BIOCYC_ID' => 'Not Available',
	            'IUPAC' => 'Not Available',
	            'CAS' => 'Not Available',
	            'MZ_MONO' => '828.672058'
	          }
	     ],
	'Method \'setMetaboliteAcurrateMzToModesMz\' works with XML FORMAT AND a valid metabolites list and return the attended output (Array)');
	
	##		- - - - - - - - - - - - - - - - - - - NEXT - - - - - - - - - - - - - - - - - - -
	# ARGVTS : $argt1, ...
	sleep 1 ; print "\n** Test $current_test setMetaboliteAcurrateMzToModesMz with a hash of metabolites **\n" ; $current_test++ ; 
	is_deeply( setMetaboliteAcurrateMzToModesMzTest ( ## input parameters : here only one argt
			'XML',
			{	'HMDB0001565' => {		'metabolite_name' => 'Phosphorylcholine',
					                    'monisotopic_molecular_weight' => '184.073869485',
	                			        'chemical_formula' => 'C5H15NO4P',
	                           			'inchikey' => 'YHHSONZFOIEMCP-UHFFFAOYSA-O' },
	             'HMDB0006088' => {	'monisotopic_molecular_weight' => '180.063388116',
                           			'inchikey' => 'CDAISMWEOUEBRE-CDRYSYESSA-N',
                           			'chemical_formula' => 'C6H12O6',
                           			'metabolite_name' => 'scyllo-Inositol' }
			}
		),
		{	'HMDB0001565' => {	'metabolite_name' => 'Phosphorylcholine',
					            'monisotopic_molecular_weight' => '184.073869485',
					            '[M+H]+' => '185.081145885',
					            '[M-H]-' => '183.066593085',
	                			'chemical_formula' => 'C5H15NO4P',
	                           	'inchikey' => 'YHHSONZFOIEMCP-UHFFFAOYSA-O' },
	         'HMDB0006088' => {	'monisotopic_molecular_weight' => '180.063388116',
	         					'[M+H]+' => '181.070664516',
					            '[M-H]-' => '179.056111716',
                           		'inchikey' => 'CDAISMWEOUEBRE-CDRYSYESSA-N',
                           		'chemical_formula' => 'C6H12O6',
                           		'metabolite_name' => 'scyllo-Inositol' }
		},
	'Method \'setMetaboliteAcurrateMzToModesMz\' works with XML FORMAT AND a valid metabolites list and return the attended output (Array)');
	    
} ## END ELSIF SEQ02
		
#### #### ##### ###### ################################################ ###### ##### ##### ###### ######

								## END of SEQ02 SEQUENCE ## 
							
#### #### ##### ###### ################################################ ###### ##### ##### ###### ######


else {
	croak "Can\'t launch any test : no sequence clearly defined !!!!\n" ;
}