# HG changeset patch # User fgiacomoni # Date 1676476669 0 # Node ID 78afd7f439f3799dfa0079b35f74accd50e4003c # Parent 23970530a5186fa4ad960b616e7d8ca168e5840e master branch Updating with tag :CI_COMMIT_TAG - - Fxx diff -r 23970530a518 -r 78afd7f439f3 HR2.xml --- a/HR2.xml Tue Jan 17 10:31:32 2023 +0000 +++ b/HR2.xml Wed Feb 15 15:57:49 2023 +0000 @@ -1,4 +1,4 @@ - + find a chemical formula from a accurate mass @@ -34,9 +34,27 @@ #end if -regleOr "$regleOr" -atomes_basic "$atomes_basic" -atomes_sup "$atomes_sup" + + #if str($max_custom_atom_condition.max_custom_atom_choice) == "YES": + -C12_max_value "${max_custom_atom_condition.C12_max_value}" + -C13_max_value "${max_custom_atom_condition.C13_max_value}" + -H_max_value "${max_custom_atom_condition.H_max_value}" + -N_max_value "${max_custom_atom_condition.N_max_value}" + -O_max_value "${max_custom_atom_condition.O_max_value}" + -P_max_value "${max_custom_atom_condition.P_max_value}" + -S_max_value "${max_custom_atom_condition.S_max_value}" + -F_max_value "${max_custom_atom_condition.F_max_value}" + -Cl_max_value "${max_custom_atom_condition.Cl_max_value}" + -K_max_value "${max_custom_atom_condition.K_max_value}" + -Br_max_value "${max_custom_atom_condition.Br_max_value}" + -Na_max_value "${max_custom_atom_condition.Na_max_value}" + + #end if + -output1 "$variableMetadata" -outputView "$hr2ResView" -verbose "$verbose" ]]> + @@ -104,6 +122,28 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -118,7 +158,7 @@ - + @@ -129,7 +169,7 @@ - + @@ -140,11 +180,12 @@ - + + diff -r 23970530a518 -r 78afd7f439f3 hr2_manager.pl --- 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 diff -r 23970530a518 -r 78afd7f439f3 lib/hr.pm --- a/lib/hr.pm Tue Jan 17 10:31:32 2023 +0000 +++ b/lib/hr.pm Wed Feb 15 15:57:49 2023 +0000 @@ -14,8 +14,8 @@ our $VERSION = "1.0"; our @ISA = qw(Exporter); -our @EXPORT = qw( manage_atoms_and_ranges manage_atoms check_hr_exe manage_atom_and_range manage_tolerance manage_mode config_hr_exe ); -our %EXPORT_TAGS = ( ALL => [qw(manage_atoms_and_ranges manage_atoms check_hr_exe manage_atom_and_range manage_tolerance manage_mode config_hr_exe )] ); +our @EXPORT = qw( manageAtomsConf manage_atoms_and_ranges check_hr_exe manage_tolerance manage_mode config_hr_exe ); +our %EXPORT_TAGS = ( ALL => [qw(manageAtomsConf manage_atoms_and_ranges check_hr_exe manage_tolerance manage_mode config_hr_exe )] ); =head1 NAME @@ -54,6 +54,75 @@ } ### END of SUB + +=head2 METHOD manageAtomsConf + + ## Description : take all max atom values from CONF file and personal choice + ## Input : $confFile, $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 + ## Output : $atomFullConfig + ## Usage : my ( $atomFullConfig ) = manageAtomsConf ( $confFile, $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 ) ; + +=cut +## START of SUB +sub manageAtomsConf{ + ## Retrieve Values + my $self = shift ; + my ($confFile, $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 %atomFullConfig = () ; + $atomFullConfig{'C'} = {'min' => 0, 'max' => 0} ; + $atomFullConfig{'H'} = {'min' => 0, 'max' => 0} ; + $atomFullConfig{'N'} = {'min' => 0, 'max' => 0} ; + $atomFullConfig{'O'} = {'min' => 0, 'max' => 0} ; + $atomFullConfig{'P'} = {'min' => 0, 'max' => 0} ; + $atomFullConfig{'S'} = {'min' => 0, 'max' => 0} ; + $atomFullConfig{'F'} = {'min' => 0, 'max' => 0} ; + $atomFullConfig{'L'} = {'min' => 0, 'max' => 0} ; + $atomFullConfig{'K'} = {'min' => 0, 'max' => 0} ; + $atomFullConfig{'B'} = {'min' => 0, 'max' => 0} ; + $atomFullConfig{'A'} = {'min' => 0, 'max' => 0} ; + $atomFullConfig{'1'} = {'min' => 0, 'max' => 0} ; + + if (defined $C12_max_value) { $atomFullConfig{'C'}{'max'} = $C12_max_value ; } + else { $atomFullConfig{'C'}{'max'} = $confFile->{'C'} } + + if (defined $H_max_value) { $atomFullConfig{'H'}{'max'} = $H_max_value ; } + else { $atomFullConfig{'H'}{'max'} = $confFile->{'H'} } + + if (defined $N_max_value) { $atomFullConfig{'N'}{'max'} = $N_max_value ; } + else { $atomFullConfig{'N'}{'max'} = $confFile->{'N'} } + + if (defined $O_max_value) { $atomFullConfig{'O'}{'max'} = $O_max_value ; } + else { $atomFullConfig{'O'}{'max'} = $confFile->{'O'} } + + if (defined $P_max_value) { $atomFullConfig{'P'}{'max'} = $P_max_value ; } + else { $atomFullConfig{'P'}{'max'} = $confFile->{'DEFAULT_MAX'} } + + if (defined $S_max_value) { $atomFullConfig{'S'}{'max'} = $S_max_value ; } + else { $atomFullConfig{'S'}{'max'} = $confFile->{'DEFAULT_MAX'} } + + if (defined $F_max_value) { $atomFullConfig{'F'}{'max'} = $F_max_value ; } + else { $atomFullConfig{'F'}{'max'} = $confFile->{'DEFAULT_MAX'} } + + if (defined $Cl_max_value) { $atomFullConfig{'L'}{'max'} = $Cl_max_value ; } + else { $atomFullConfig{'L'}{'max'} = $confFile->{'DEFAULT_MAX'} } + + if (defined $K_max_value) { $atomFullConfig{'K'}{'max'} = $K_max_value ; } + else { $atomFullConfig{'K'}{'max'} = $confFile->{'DEFAULT_MAX'} } + + if (defined $Br_max_value) { $atomFullConfig{'B'}{'max'} = $Br_max_value ; } + else { $atomFullConfig{'B'}{'max'} = $confFile->{'DEFAULT_MAX'} } + + if (defined $Na_max_value) { $atomFullConfig{'A'}{'max'} = $Na_max_value ; } + else { $atomFullConfig{'A'}{'max'} = $confFile->{'DEFAULT_MAX'} } + + if (defined $C13_max_value) { $atomFullConfig{'1'}{'max'} = $C13_max_value ; } + else { $atomFullConfig{'1'}{'max'} = $confFile->{'DEFAULT_MAX'} } + + return (\%atomFullConfig) ; +} +### END of SUB + =head2 METHOD manage_atoms_and_ranges ## Description : allow from an initial config to add or delete atoms and their range @@ -66,90 +135,45 @@ sub manage_atoms_and_ranges { ## Retrieve Values my $self = shift ; - my ( $atomsconfig, $CONF, $atombasic, $atomsupp ) = @_; - my ( $atomcleanconfig ) = ( undef ) ; + my ( $atomFullconfig, $atombasic, $atomsupp ) = @_; + my ( $atomConfigCmd ) = ( undef ) ; + my %atomCurrentConfig = () ; + $atomCurrentConfig{'C'} = {'min' => 0, 'max' => 0} ; + $atomCurrentConfig{'H'} = {'min' => 0, 'max' => 0} ; + $atomCurrentConfig{'N'} = {'min' => 0, 'max' => 0} ; + $atomCurrentConfig{'O'} = {'min' => 0, 'max' => 0} ; + $atomCurrentConfig{'P'} = {'min' => 0, 'max' => 0} ; + $atomCurrentConfig{'S'} = {'min' => 0, 'max' => 0} ; + $atomCurrentConfig{'F'} = {'min' => 0, 'max' => 0} ; + $atomCurrentConfig{'L'} = {'min' => 0, 'max' => 0} ; + $atomCurrentConfig{'K'} = {'min' => 0, 'max' => 0} ; + $atomCurrentConfig{'B'} = {'min' => 0, 'max' => 0} ; + $atomCurrentConfig{'A'} = {'min' => 0, 'max' => 0} ; + $atomCurrentConfig{'1'} = {'min' => 0, 'max' => 0} ; # basic atoms case: foreach my $atom ( (split(",", $atombasic )) ) { - if ( exists $CONF->{$atom} ) { $atomsconfig->{$atom}{'max'} = $CONF->{$atom} ; } + if ( exists $atomFullconfig->{$atom}{'max'} ) { $atomCurrentConfig{$atom}{'max'} = $atomFullconfig->{$atom}{'max'} ; } else { print "*** $atom not recognized***\n" ; } } # suppl. atoms case foreach my $atom ( (split(",", $atomsupp )) ) { #print "*** $atom***\n" ; - if ( exists $atomsconfig->{$atom} ) { $atomsconfig->{$atom}{'max'} = $CONF->{'DEFAULT_MAX'} ; } + if ( exists $atomFullconfig->{$atom}{'max'} ) { $atomCurrentConfig{$atom}{'max'} = $atomFullconfig->{$atom}{'max'} ; } else { print "*** $atom not recognized***\n" ; } } # Create atoms and range parameters: - foreach my $selectedAtom ( keys %{$atomsconfig} ) { - $atomcleanconfig .= ' -'.$selectedAtom.' '.$atomsconfig->{$selectedAtom}{'min'}.'-'.$atomsconfig->{$selectedAtom}{'max'} ; + foreach my $selectedAtom ( keys %atomCurrentConfig ) { + $atomConfigCmd .= ' -'.$selectedAtom.' '.$atomCurrentConfig{$selectedAtom}{'min'}.'-'.$atomCurrentConfig{$selectedAtom}{'max'} ; } - return ($atomcleanconfig) ; + return ($atomConfigCmd) ; } ### END of SUB - - -=head2 METHOD manage_atoms ### DEPRECATED - - ## Description : controles atoms input list and prepare it like hr binary parameter - ## Input : $input_atoms, $conf_atoms - ## Output : $hr_atoms_param - ## Usage : my ( $hr_atoms_param ) = manage_atoms( $input_atoms, $conf_atoms ) ; - ### DEPRECATED - -=cut -## START of SUB -sub manage_atoms { ### DEPRECATED - ## Retrieve Values - my $self = shift ; - my ( $input_atoms, $conf_atoms ) = @_ ; - my $hr_atoms_param = undef ; - - if ( ( defined $$input_atoms ) and ( defined $$conf_atoms ) ) { - if ( ( $$input_atoms eq 'None' ) or ( $$input_atoms eq '' ) or ( $$input_atoms eq ' ' ) ) { $hr_atoms_param = $$conf_atoms ; } - elsif ( $$input_atoms =~ /[P|S|F|L|K|B|A|1|,]+/ ) { $hr_atoms_param = $$conf_atoms.','.$$input_atoms ; } - else { $hr_atoms_param = $$conf_atoms ; } - } ## END IF - elsif ( !defined $$input_atoms ) { $hr_atoms_param = $$conf_atoms ; } - elsif ( !defined $$conf_atoms ) { warn "hr module can't manage any atom list (undef values in conf)\n" ; } - else { warn "hr module musn't manage any atom list\n" ; } - - return(\$hr_atoms_param) ; -} -## END of SUB - -=head2 METHOD manage_atom_and_range ### DEPRECATED - - ## Description : build atom range with defined value in conf file - ## Input : $atom, $min, $max - ## Output : $hr_range - ## Usage : my ( ) = manage_atom_and_range( $atom, $min, $max ) ; - ### DEPRECATED - -=cut -## START of SUB -sub manage_atom_and_range { ### DEPRECATED - ## Retrieve Values - my $self = shift ; - my ( $atom, $min, $max ) = @_ ; - my $hr_range = undef ; - - if ( ( defined $$atom ) and ( defined $$min ) and ( defined $$max ) ) { - ## manage ragne like "-C 0-200" - $hr_range = ' -'.$$atom.' '.$$min.'-'.$$max ; - } ## END IF - else { - warn "Some argvts are missing to build the current atom range line\n" ; - } - return(\$hr_range) ; -} -## END of SUB - =head2 METHOD manage_tolerance ## Description : check range and format of tolerance @@ -757,7 +781,7 @@ =over 4 -=item :ALL is manage_atoms, check_hr_exe, manage_tolerance +=item :ALL is manageAtomsConf manage_atoms_and_ranges check_hr_exe manage_tolerance manage_mode config_hr_exe =back @@ -773,6 +797,6 @@ version 1 : 02 / 20 / 2014 -version 2 : ?? +version 2 : 02/ 15 / 2023 - Add personal max value for each atom manager methods, remove deprecated methods =cut \ No newline at end of file diff -r 23970530a518 -r 78afd7f439f3 test-data/input06.tabular --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/input06.tabular Wed Feb 15 15:57:49 2023 +0000 @@ -0,0 +1,4 @@ +id mz formula +01 257.1704 [13]C11 H20 O5 N +02 305.1373 [13]C11 H20 O6 N S +03 344.2046 [13]C13 H23 O6 N4 \ No newline at end of file diff -r 23970530a518 -r 78afd7f439f3 test-data/out6.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/out6.html Wed Feb 15 15:57:49 2023 +0000 @@ -0,0 +1,1 @@ +Galaxy HR2 queries - All results
Results of HR elucidation queries - Mode used: positive / Charge: +1 / Mass tolerance: 1.0 / Composition: -S 0-10 -O 0-70 -L 0-0 -K 0-0 -P 0-10 -F 0-0 -N 0-40 -B 0-0 -A 0-0 -1 0-40 -C 0-0 -H 0-200

ID from inputMass (m/z)FormulaCompound MW (Da)DeltaTotal
01257.17042
iC11H19N1O5256.1632259-0.10
iC12H21O3P1256.16308920.03
02305.13733
iC13H13N3O5304.12913340.89
iC11H19N1O6S1304.1302113-0.19
iC12H21O4P1S1304.1300745-0.05
03344.20467
iC7H20N12O4343.19653110.79
iC13H22N4O6343.1975474-0.22
iC8H22N11O2P1343.19639430.93
iC14H24N3O4P1343.1974106-0.09
iC15H26N2O2P2343.19727390.05
iC16H28N1P3343.19713720.19
iC13H30O5S2343.19707830.25

Valid CSS!

Copyright © INRAE, N Paulhe, L Pavot, F Giacomoni 2023

\ No newline at end of file diff -r 23970530a518 -r 78afd7f439f3 test-data/out6.tabular --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/out6.tabular Wed Feb 15 15:57:49 2023 +0000 @@ -0,0 +1,4 @@ +id mz formula hr2 +01 257.1704 "[13]C11 H20 O5 N" -0.10::(iC11H19N1O5)::256.1632259|0.03::(iC12H21O3P1)::256.1630892 +02 305.1373 "[13]C11 H20 O6 N S" 0.89::(iC13H13N3O5)::304.1291334|-0.19::(iC11H19N1O6S1)::304.1302113|-0.05::(iC12H21O4P1S1)::304.1300745 +03 344.2046 "[13]C13 H23 O6 N4" 0.79::(iC7H20N12O4)::343.1965311|-0.22::(iC13H22N4O6)::343.1975474|0.93::(iC8H22N11O2P1)::343.1963943|-0.09::(iC14H24N3O4P1)::343.1974106|0.05::(iC15H26N2O2P2)::343.1972739|0.19::(iC16H28N1P3)::343.1971372|0.25::(iC13H30O5S2)::343.1970783