comparison lib/hr.pm @ 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
comparison
equal deleted inserted replaced
2:23970530a518 3:78afd7f439f3
12 12
13 use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS); 13 use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS);
14 14
15 our $VERSION = "1.0"; 15 our $VERSION = "1.0";
16 our @ISA = qw(Exporter); 16 our @ISA = qw(Exporter);
17 our @EXPORT = qw( manage_atoms_and_ranges manage_atoms check_hr_exe manage_atom_and_range manage_tolerance manage_mode config_hr_exe ); 17 our @EXPORT = qw( manageAtomsConf manage_atoms_and_ranges check_hr_exe manage_tolerance manage_mode config_hr_exe );
18 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 )] ); 18 our %EXPORT_TAGS = ( ALL => [qw(manageAtomsConf manage_atoms_and_ranges check_hr_exe manage_tolerance manage_mode config_hr_exe )] );
19 19
20 =head1 NAME 20 =head1 NAME
21 21
22 lib::hr - A module for managing / launching hr binary (structure elucidation c++ progr) 22 lib::hr - A module for managing / launching hr binary (structure elucidation c++ progr)
23 23
52 bless($self) ; 52 bless($self) ;
53 return $self ; 53 return $self ;
54 } 54 }
55 ### END of SUB 55 ### END of SUB
56 56
57
58 =head2 METHOD manageAtomsConf
59
60 ## Description : take all max atom values from CONF file and personal choice
61 ## 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
62 ## Output : $atomFullConfig
63 ## 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 ) ;
64
65 =cut
66 ## START of SUB
67 sub manageAtomsConf{
68 ## Retrieve Values
69 my $self = shift ;
70 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) = @_ ;
71
72 my %atomFullConfig = () ;
73 $atomFullConfig{'C'} = {'min' => 0, 'max' => 0} ;
74 $atomFullConfig{'H'} = {'min' => 0, 'max' => 0} ;
75 $atomFullConfig{'N'} = {'min' => 0, 'max' => 0} ;
76 $atomFullConfig{'O'} = {'min' => 0, 'max' => 0} ;
77 $atomFullConfig{'P'} = {'min' => 0, 'max' => 0} ;
78 $atomFullConfig{'S'} = {'min' => 0, 'max' => 0} ;
79 $atomFullConfig{'F'} = {'min' => 0, 'max' => 0} ;
80 $atomFullConfig{'L'} = {'min' => 0, 'max' => 0} ;
81 $atomFullConfig{'K'} = {'min' => 0, 'max' => 0} ;
82 $atomFullConfig{'B'} = {'min' => 0, 'max' => 0} ;
83 $atomFullConfig{'A'} = {'min' => 0, 'max' => 0} ;
84 $atomFullConfig{'1'} = {'min' => 0, 'max' => 0} ;
85
86 if (defined $C12_max_value) { $atomFullConfig{'C'}{'max'} = $C12_max_value ; }
87 else { $atomFullConfig{'C'}{'max'} = $confFile->{'C'} }
88
89 if (defined $H_max_value) { $atomFullConfig{'H'}{'max'} = $H_max_value ; }
90 else { $atomFullConfig{'H'}{'max'} = $confFile->{'H'} }
91
92 if (defined $N_max_value) { $atomFullConfig{'N'}{'max'} = $N_max_value ; }
93 else { $atomFullConfig{'N'}{'max'} = $confFile->{'N'} }
94
95 if (defined $O_max_value) { $atomFullConfig{'O'}{'max'} = $O_max_value ; }
96 else { $atomFullConfig{'O'}{'max'} = $confFile->{'O'} }
97
98 if (defined $P_max_value) { $atomFullConfig{'P'}{'max'} = $P_max_value ; }
99 else { $atomFullConfig{'P'}{'max'} = $confFile->{'DEFAULT_MAX'} }
100
101 if (defined $S_max_value) { $atomFullConfig{'S'}{'max'} = $S_max_value ; }
102 else { $atomFullConfig{'S'}{'max'} = $confFile->{'DEFAULT_MAX'} }
103
104 if (defined $F_max_value) { $atomFullConfig{'F'}{'max'} = $F_max_value ; }
105 else { $atomFullConfig{'F'}{'max'} = $confFile->{'DEFAULT_MAX'} }
106
107 if (defined $Cl_max_value) { $atomFullConfig{'L'}{'max'} = $Cl_max_value ; }
108 else { $atomFullConfig{'L'}{'max'} = $confFile->{'DEFAULT_MAX'} }
109
110 if (defined $K_max_value) { $atomFullConfig{'K'}{'max'} = $K_max_value ; }
111 else { $atomFullConfig{'K'}{'max'} = $confFile->{'DEFAULT_MAX'} }
112
113 if (defined $Br_max_value) { $atomFullConfig{'B'}{'max'} = $Br_max_value ; }
114 else { $atomFullConfig{'B'}{'max'} = $confFile->{'DEFAULT_MAX'} }
115
116 if (defined $Na_max_value) { $atomFullConfig{'A'}{'max'} = $Na_max_value ; }
117 else { $atomFullConfig{'A'}{'max'} = $confFile->{'DEFAULT_MAX'} }
118
119 if (defined $C13_max_value) { $atomFullConfig{'1'}{'max'} = $C13_max_value ; }
120 else { $atomFullConfig{'1'}{'max'} = $confFile->{'DEFAULT_MAX'} }
121
122 return (\%atomFullConfig) ;
123 }
124 ### END of SUB
125
57 =head2 METHOD manage_atoms_and_ranges 126 =head2 METHOD manage_atoms_and_ranges
58 127
59 ## Description : allow from an initial config to add or delete atoms and their range 128 ## Description : allow from an initial config to add or delete atoms and their range
60 ## Input : $atomsconfig, $atombasic, $atomsupp 129 ## Input : $atomsconfig, $atombasic, $atomsupp
61 ## Output : $atomcleanconfig 130 ## Output : $atomcleanconfig
64 =cut 133 =cut
65 ## START of SUB 134 ## START of SUB
66 sub manage_atoms_and_ranges { 135 sub manage_atoms_and_ranges {
67 ## Retrieve Values 136 ## Retrieve Values
68 my $self = shift ; 137 my $self = shift ;
69 my ( $atomsconfig, $CONF, $atombasic, $atomsupp ) = @_; 138 my ( $atomFullconfig, $atombasic, $atomsupp ) = @_;
70 my ( $atomcleanconfig ) = ( undef ) ; 139 my ( $atomConfigCmd ) = ( undef ) ;
140 my %atomCurrentConfig = () ;
141 $atomCurrentConfig{'C'} = {'min' => 0, 'max' => 0} ;
142 $atomCurrentConfig{'H'} = {'min' => 0, 'max' => 0} ;
143 $atomCurrentConfig{'N'} = {'min' => 0, 'max' => 0} ;
144 $atomCurrentConfig{'O'} = {'min' => 0, 'max' => 0} ;
145 $atomCurrentConfig{'P'} = {'min' => 0, 'max' => 0} ;
146 $atomCurrentConfig{'S'} = {'min' => 0, 'max' => 0} ;
147 $atomCurrentConfig{'F'} = {'min' => 0, 'max' => 0} ;
148 $atomCurrentConfig{'L'} = {'min' => 0, 'max' => 0} ;
149 $atomCurrentConfig{'K'} = {'min' => 0, 'max' => 0} ;
150 $atomCurrentConfig{'B'} = {'min' => 0, 'max' => 0} ;
151 $atomCurrentConfig{'A'} = {'min' => 0, 'max' => 0} ;
152 $atomCurrentConfig{'1'} = {'min' => 0, 'max' => 0} ;
71 153
72 # basic atoms case: 154 # basic atoms case:
73 foreach my $atom ( (split(",", $atombasic )) ) { 155 foreach my $atom ( (split(",", $atombasic )) ) {
74 if ( exists $CONF->{$atom} ) { $atomsconfig->{$atom}{'max'} = $CONF->{$atom} ; } 156 if ( exists $atomFullconfig->{$atom}{'max'} ) { $atomCurrentConfig{$atom}{'max'} = $atomFullconfig->{$atom}{'max'} ; }
75 else { print "*** $atom not recognized***\n" ; } 157 else { print "*** $atom not recognized***\n" ; }
76 } 158 }
77 159
78 # suppl. atoms case 160 # suppl. atoms case
79 foreach my $atom ( (split(",", $atomsupp )) ) { 161 foreach my $atom ( (split(",", $atomsupp )) ) {
80 #print "*** $atom***\n" ; 162 #print "*** $atom***\n" ;
81 if ( exists $atomsconfig->{$atom} ) { $atomsconfig->{$atom}{'max'} = $CONF->{'DEFAULT_MAX'} ; } 163 if ( exists $atomFullconfig->{$atom}{'max'} ) { $atomCurrentConfig{$atom}{'max'} = $atomFullconfig->{$atom}{'max'} ; }
82 else { print "*** $atom not recognized***\n" ; } 164 else { print "*** $atom not recognized***\n" ; }
83 165
84 } 166 }
85 167
86 # Create atoms and range parameters: 168 # Create atoms and range parameters:
87 foreach my $selectedAtom ( keys %{$atomsconfig} ) { 169 foreach my $selectedAtom ( keys %atomCurrentConfig ) {
88 $atomcleanconfig .= ' -'.$selectedAtom.' '.$atomsconfig->{$selectedAtom}{'min'}.'-'.$atomsconfig->{$selectedAtom}{'max'} ; 170 $atomConfigCmd .= ' -'.$selectedAtom.' '.$atomCurrentConfig{$selectedAtom}{'min'}.'-'.$atomCurrentConfig{$selectedAtom}{'max'} ;
89 } 171 }
90 172
91 return ($atomcleanconfig) ; 173 return ($atomConfigCmd) ;
92 } 174 }
93 ### END of SUB 175 ### END of SUB
94
95
96
97 =head2 METHOD manage_atoms ### DEPRECATED
98
99 ## Description : controles atoms input list and prepare it like hr binary parameter
100 ## Input : $input_atoms, $conf_atoms
101 ## Output : $hr_atoms_param
102 ## Usage : my ( $hr_atoms_param ) = manage_atoms( $input_atoms, $conf_atoms ) ;
103 ### DEPRECATED
104
105 =cut
106 ## START of SUB
107 sub manage_atoms { ### DEPRECATED
108 ## Retrieve Values
109 my $self = shift ;
110 my ( $input_atoms, $conf_atoms ) = @_ ;
111 my $hr_atoms_param = undef ;
112
113 if ( ( defined $$input_atoms ) and ( defined $$conf_atoms ) ) {
114 if ( ( $$input_atoms eq 'None' ) or ( $$input_atoms eq '' ) or ( $$input_atoms eq ' ' ) ) { $hr_atoms_param = $$conf_atoms ; }
115 elsif ( $$input_atoms =~ /[P|S|F|L|K|B|A|1|,]+/ ) { $hr_atoms_param = $$conf_atoms.','.$$input_atoms ; }
116 else { $hr_atoms_param = $$conf_atoms ; }
117 } ## END IF
118 elsif ( !defined $$input_atoms ) { $hr_atoms_param = $$conf_atoms ; }
119 elsif ( !defined $$conf_atoms ) { warn "hr module can't manage any atom list (undef values in conf)\n" ; }
120 else { warn "hr module musn't manage any atom list\n" ; }
121
122 return(\$hr_atoms_param) ;
123 }
124 ## END of SUB
125
126 =head2 METHOD manage_atom_and_range ### DEPRECATED
127
128 ## Description : build atom range with defined value in conf file
129 ## Input : $atom, $min, $max
130 ## Output : $hr_range
131 ## Usage : my ( ) = manage_atom_and_range( $atom, $min, $max ) ;
132 ### DEPRECATED
133
134 =cut
135 ## START of SUB
136 sub manage_atom_and_range { ### DEPRECATED
137 ## Retrieve Values
138 my $self = shift ;
139 my ( $atom, $min, $max ) = @_ ;
140 my $hr_range = undef ;
141
142 if ( ( defined $$atom ) and ( defined $$min ) and ( defined $$max ) ) {
143 ## manage ragne like "-C 0-200"
144 $hr_range = ' -'.$$atom.' '.$$min.'-'.$$max ;
145 } ## END IF
146 else {
147 warn "Some argvts are missing to build the current atom range line\n" ;
148 }
149 return(\$hr_range) ;
150 }
151 ## END of SUB
152 176
153 =head2 METHOD manage_tolerance 177 =head2 METHOD manage_tolerance
154 178
155 ## Description : check range and format of tolerance 179 ## Description : check range and format of tolerance
156 ## Input : $tolerance, $default_value 180 ## Input : $tolerance, $default_value
755 779
756 =head1 Exports 780 =head1 Exports
757 781
758 =over 4 782 =over 4
759 783
760 =item :ALL is manage_atoms, check_hr_exe, manage_tolerance 784 =item :ALL is manageAtomsConf manage_atoms_and_ranges check_hr_exe manage_tolerance manage_mode config_hr_exe
761 785
762 =back 786 =back
763 787
764 =head1 AUTHOR 788 =head1 AUTHOR
765 789
771 795
772 =head1 VERSION 796 =head1 VERSION
773 797
774 version 1 : 02 / 20 / 2014 798 version 1 : 02 / 20 / 2014
775 799
776 version 2 : ?? 800 version 2 : 02/ 15 / 2023 - Add personal max value for each atom manager methods, remove deprecated methods
777 801
778 =cut 802 =cut