diff wsdl_hmdb.pl @ 21:63ba1cb240b7 draft

Prod branch Updating - - Fxx
author fgiacomoni
date Thu, 14 Feb 2019 08:36:52 -0500
parents b5a1d5e43685
children 453fbe98925a
line wrap: on
line diff
--- a/wsdl_hmdb.pl	Wed Jan 23 07:49:34 2019 -0500
+++ b/wsdl_hmdb.pl	Thu Feb 14 08:36:52 2019 -0500
@@ -27,7 +27,7 @@
 my ( $mass ) = undef ;
 my ( $masses_file, $col_id, $col_mass, $header_choice, $nbline_header ) = ( undef, undef, undef, undef, undef ) ;
 my $max_query = undef ;
-my ( $delta, $molecular_species, $out_tab, $out_html, $out_xls ) = ( undef, undef, undef, undef, undef ) ;
+my ( $adductType, $delta, $molecular_species, $out_tab, $out_html, $out_xls ) = ( undef, undef, undef, undef, undef, undef ) ;
 my $advancedFeatures = 0 ;
 my $VERBOSE = ( 3 ) ;
 
@@ -42,13 +42,14 @@
 				"header_choice:s"	=> \$header_choice,		## Presence or not of header in tabular file
 				"nblineheader:i"	=> \$nbline_header,		## numbre of header line present in file
 				"colfactor:i"		=> \$col_mass,			## Column id for retrieve formula list in tabular file
+				"adduct_type:s"		=> \$adductType,		## A list of selected adducts
 				"delta:f"			=> \$delta,
 				"mode:s"			=> \$molecular_species,	## Molecular species (positive/negative/neutral)
 				"maxquery:i"		=> \$max_query, 		## Maximum query return (default is 20 entries by query // min 1 & max 50 )
 				"output_tabular:s"	=> \$out_tab,			## option : path to the ouput (tabular : input+results )
 				"output_html|v:s"	=> \$out_html,			## option : path to the results view (output2)
 				"output_xlsx:s"		=> \$out_xls,			## option : path to the xls-like format output
-				"advancedFeatures:s"=> \$advancedFeatures,	## option : set to 1 to get advanced options or 0 to get first level only.
+				"advancedFeatures:i"=> \$advancedFeatures,	## option : set to 1 to get advanced options or 0 to get first level only.
 				"verbose:i"			=> \$VERBOSE,			## VERBOSE Of the tool
             ) ;
 
@@ -84,7 +85,13 @@
 my $metabocard_features = undef ;
 my $search_condition = "Search params : Molecular specie = $molecular_species / delta (mass-to-charge ratio) = $delta" ;
 
-print "\t with $search_condition\n" if ($VERBOSE>1) ;
+print "\twith $search_condition\n" if ($VERBOSE>1) ;
+
+## $adductType
+if (defined $adductType ) {
+	print "\twith Adducts: $adductType\n" if ($VERBOSE>1) ;	
+}
+
 
 ## --------------- retrieve input data -------------- :
 
@@ -122,12 +129,12 @@
 	my $oHmdb = lib::hmdb::new() ;
 	my $hmdb_pages = undef ;
 	my $status = undef ;
-	my $hmdb_ids = undef ;
+	my ($hmdb_ids, $idsNumber) = (undef, 0) ;
 	
 	$results = [] ; # prepare arrays ref
 	my $submasses = $oHmdb->extract_sub_mz_lists($masses, $CONF->{HMDB_LIMITS} ) ;
 	
-	print "\t and ".scalar(@$masses)." masses are submitted as ".scalar(@$submasses)." queries to HMDB \n\n" if ($VERBOSE>1) ;
+	print "\tand ".scalar(@$masses)." masses are submitted as ".scalar(@$submasses)." queries to HMDB \n\n" if ($VERBOSE>1) ;
 	
 	## get the hmdb server status by a test query - continuous queries or kill script.
 	$status = $oHmdb->testMatchesFromHmdbWithUA() ;
@@ -139,10 +146,11 @@
 		my $result = undef ;
 		
 		my ( $hmdb_masses, $nb_masses_to_submit ) = $oHmdb->prepare_multi_masses_query($mzs) ;
+		my ($hmdb_adducts, $nb_selected_adducts) = $oHmdb->prepareAdductListFormat($adductType) ;
 		
 		print "\n\tSubmission of m/z cluster ".sprintf '%04s',$cluster."" if ($VERBOSE>1) ;
 		
-		($hmdb_pages, $status) = $oHmdb->getMatchesFromHmdbWithUA($hmdb_masses, $delta, $molecular_species) ;
+		($hmdb_pages, $status) = $oHmdb->getMatchesFromHmdbWithUA($hmdb_masses, $delta, $molecular_species, $hmdb_adducts) ;
 		print "...HMDB reply results with status: $status\n" if ($VERBOSE>1) ;
 		
 #		print Dumper $hmdb_pages ;
@@ -161,15 +169,15 @@
 	if ($advancedFeatures > 0) {
 
 		## foreach metabolite get its own metabocard
-		$hmdb_ids = $oHmdb->get_unik_ids_from_results($results) ;
+		($hmdb_ids, $idsNumber) = $oHmdb->get_unik_ids_from_results($results) ;
 		
-		print "\tComplementary annotation: asking for ".scalar(@$results)." metabocards\n" if ($VERBOSE>1) ;
+		print "\tComplementary annotation: asking for $idsNumber metabocards\n" if ($VERBOSE>1) ;
 		
 	#	$hmdb_ids->{'HMDB03125'} = 1 ,
 		$metabocard_features = $oHmdb->get_hmdb_metabocard_from_id($hmdb_ids, $CONF->{'HMDB_METABOCARD_URL'}) ; ## Try to multithread the querying
-	#	print Dumper $results ;
+#		print Dumper $results ;
 	#	print Dumper $hmdb_ids ;
-	#	print Dumper $metabocard_features ;
+#		print Dumper $metabocard_features ;
 		## Map metabocards with results (add supplementary data)
 		if ( ( defined $results ) and ( defined $metabocard_features ) ) {
 			$results = $oHmdb->map_suppl_data_on_hmdb_results($results, $metabocard_features) ;
@@ -180,8 +188,6 @@
 		## Fill with msg not asked advanced annotation
 		$results = $oHmdb->map_suppl_data_on_hmdb_results($results, undef) ;
 	}
-	
-
 
 	## Uses N mz and theirs entries per page (see config file).
 	# how many pages you need with your input mz list?
@@ -327,4 +333,6 @@
 
 version 1.6 : 23 / 01 / 2019 - Manage UA http error and advanced feature from hmdb.
 
+version 1.6.1 : 30 / 01 / 2019 - Adding adducts and fixxing minors bugs and requirements
+
 =cut
\ No newline at end of file