diff hr2_manager.pl @ 3:78afd7f439f3 draft default tip

master branch Updating with tag :CI_COMMIT_TAG - - Fxx
author fgiacomoni
date Wed, 15 Feb 2023 15:57:49 +0000
parents 23970530a518
children
line wrap: on
line diff
--- a/hr2_manager.pl	Tue Jan 17 10:31:32 2023 +0000
+++ b/hr2_manager.pl	Wed Feb 15 15:57:49 2023 +0000
@@ -4,6 +4,7 @@
 ## VERSIONS :
 #	- 01/03/2019 : Fix P issue, permit more flexible atom settings and add requirements for conda auto managing.
 #	- 09/12/2022 : Fix "Additional atomes not taken into account" - Ticket issue #7 
+#	- 15/02/2023 : New feature - optionnal managing max atom value
 
 #=============================================================================
 #                              Included modules and versions
@@ -32,6 +33,8 @@
 my ( $input_file, $line_header, $col_id, $col_mass ) = ( undef, undef, undef, undef ) ; # manage input option file of masses
 my ( $mass ) = ( undef ) ; # manage input option masses list
 my ( $tolerance, $mode, $charge, $has_golden_rules, $atomes, $atomes_basic ) = ( undef, undef, undef, undef, undef, undef ) ; # manage params
+my ( $C13_max_value, $C12_max_value, $H_max_value, $N_max_value, $O_max_value, $P_max_value, $S_max_value, $F_max_value, $Cl_max_value, $K_max_value, $Br_max_value, $Na_max_value) = (undef, undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef) ;
+my ($customAtomValues) = (undef) ;
 my ( $output_csv, $output_html ) = ( undef, undef) ; # manage ouputs
 my $verbose = 2 ;
 
@@ -50,6 +53,21 @@
 				"regleOr:s"		=>	\$has_golden_rules,
 				"atomes_basic:s"=>	\$atomes_basic, # [basic atoms like CNOHP]
 				"atomes_sup:s"	=>	\$atomes,
+				#"customAtomValues:s"=>	\$customAtomValues,
+				
+				"C12_max_value:i"	=>	\$C12_max_value, # OPTIONNAL
+		    	"C13_max_value:i"	=>	\$C13_max_value,
+		    	"H_max_value:i"		=>	\$H_max_value,
+		    	"N_max_value:i"		=>	\$N_max_value,
+		    	"O_max_value:i"		=>	\$O_max_value,
+		    	"P_max_value:i"		=>	\$P_max_value,
+		    	"S_max_value:i"		=>	\$S_max_value,
+		    	"F_max_value:i"		=>	\$F_max_value,
+		    	"Cl_max_value:i"	=>	\$Cl_max_value,
+		    	"K_max_value:i"		=>	\$K_max_value,
+		    	"Br_max_value:i"	=>	\$Br_max_value,
+		    	"Na_max_value:i"	=>	\$Na_max_value,
+				
 				"output1:s"		=>	\$output_csv,
 				"outputView:s"	=>	\$output_html,
 				"verbose:i"		=> 	\$verbose,
@@ -63,19 +81,19 @@
 #=============================================================================
 #                                MAIN SCRIPT
 #=============================================================================
-my %atomsConf = () ;
-$atomsConf{'C'} = {'min' => 0, 'max' =>  0} ;
-$atomsConf{	'H'} = {'min' => 0, 'max' => 0} ;
-$atomsConf{	'N'} = {'min' => 0, 'max' => 0} ;
-$atomsConf{	'O'} = {'min' => 0, 'max' => 0} ;
-$atomsConf{	'P'} = {'min' => 0, 'max' => 0} ;
-$atomsConf{	'S'} = {'min' => 0, 'max' => 0} ;
-$atomsConf{	'F'} = {'min' => 0, 'max' => 0} ;
-$atomsConf{	'L'} = {'min' => 0, 'max' => 0} ;
-$atomsConf{	'K'} = {'min' => 0, 'max' => 0} ;
-$atomsConf{	'B'} = {'min' => 0, 'max' => 0} ;
-$atomsConf{	'A'} = {'min' => 0, 'max' => 0} ;
-$atomsConf{	'1'} = {'min' => 0, 'max' => 0} ;
+
+#print "CUSTOM C12: $C12_max_value\n" if (defined $C12_max_value) ;
+#print "CUSTOM H: $H_max_value if (defined $H_max_value) ;
+#print "CUSTOM N: $N_max_value if (defined $N_max_value) ;
+#print "CUSTOM O: $O_max_value if (defined $O_max_value) ;
+#print "CUSTOM P: $P_max_value if (defined $P_max_value) ;
+#print "CUSTOM S: $S_max_value if (defined $S_max_value) ;
+#print "CUSTOM F: $F_max_value if (defined $F_max_value) ;
+#print "CUSTOM Cl: $Cl_max_value if (defined $Cl_max_value) ;
+#print "CUSTOM K: $K_max_value if (defined $K_max_value) ;
+#print "CUSTOM Br: $Br_max_value if (defined $Br_max_value) ;
+#print "CUSTOM Na: $Na_max_value if (defined $Na_max_value) ;
+#print "CUSTOM C13: $C13_max_value if (defined $C13_max_value) ;
 
 ## -------------- Conf file and verbose ------------------------ :
 my ( $CONF ) = ( undef ) ; ## verbose level is 3 for debugg
@@ -104,18 +122,10 @@
 #$hr_atoms_list = $ohr->manage_atoms(\$atomes, \$CONF->{'DEFAULT_ATOMS'}) ; ## DEPRECATED
 
 # manage atoms and their ranges with a hash structure
-my $atomsCurrentConf = $ohr->manage_atoms_and_ranges(\%atomsConf, $CONF, $atomes_basic, $atomes) ;
 
-#if ( defined $hr_atoms_list ) {
-#	## implements range foreach atom
-#	foreach my $atom ( (split(",", $$hr_atoms_list )) ) {
-#		my $range_max = $CONF->{'DEFAULT_MAX'} ; # manage max value in case of
-#		if ( exists $CONF->{$atom} ) 	{ $range_max = $CONF->{$atom} ; }
-#		my $ref_range = $ohr->manage_atom_and_range(\$atom, \$CONF->{'DEFAULT_MIN'}, \$range_max ) ;
-#		$hr_atoms_and_ranges .= $$ref_range ; ## concat ranges
-#	}
-#}
-#else { 	croak "No atom detected with input params\n" ; }
+my $AtomsFullConf = $ohr->manageAtomsConf($CONF, $C12_max_value, $C13_max_value, $H_max_value, $N_max_value, $O_max_value, $P_max_value, $S_max_value, $F_max_value, $Cl_max_value, $K_max_value, $Br_max_value, $Na_max_value ) ;
+
+my $atomsCurrentConf = $ohr->manage_atoms_and_ranges($AtomsFullConf, $atomes_basic, $atomes) ;
 
 ## Parsing input file with masses/ids or unik mass :
 ## manage only one mass
@@ -155,12 +165,11 @@
 	## computes mass
 	my $ohr_mode = lib::hr->new() ;
 	my ( $exact_mass ) = $ohr_mode->manage_mode( \$mode, \$charge, \$CONF->{'electron'}, \$CONF->{'proton'}, \$mz ) ;
-	print "Current MZ send to HR\n"  if $verbose == 3 ;
-	print Dumper $exact_mass if $verbose == 3 ;
+	print "Current MZ $$exact_mass send to HR\n"  if $verbose == 3 ;
 	## build exe line
 	my $ohr_exe = lib::hr->new() ;
 	my $hr_cmd = $ohr_exe->config_hr_exe( \$CONF->{'HR2_EXE'}, \$tolerance, $exact_mass, \$has_golden_rules, \$atomsCurrentConf ) ;
-	print "$$hr_cmd\n" if $verbose == 3 ;
+	print "\t$$hr_cmd\n" if $verbose == 3 ;
 	push(@{$hr_cmds}, $$hr_cmd) ;
 }
 
@@ -225,7 +234,7 @@
 
 ### VERBOSE OUTPUTs
 if ( $verbose == 3 ) {
-	print "-- Conf file contains :\n" ;
+	print "\n\n-- Conf file contains :\n" ;
 	print Dumper $CONF ;
 	print "-- Atoms input list :\n" ;
 	print Dumper $atomes_basic ;
@@ -340,4 +349,6 @@
 
 version 5 : 09/12/2022
 
+version 6 : 15/02/2023
+
 =cut
\ No newline at end of file