| 1 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # BioPerl module for Bio::Tools::Run::WrapperBase::CommandExts | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Cared for by Mark A. Jensen <maj -at- fortinbras -dot- us> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # Copyright Mark A. Jensen | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | Bio::Tools::Run::WrapperBase::CommandExts - Extensions to WrapperBase for handling programs with commands *ALPHA* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | Devs, see L</DEVELOPER INTERFACE>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | Users, see L</USER INTERFACE>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | This is a developer-focused experimental module. The main idea is to | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | extend L<Bio::Tools::Run::WrapperBase> to make it relatively easy to | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | create run wrappers around I<suites> of related programs, like | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | C<samtools> or C<blast+>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | Some definitions: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | =item * program | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | The program is the command-line frontend application. C<samtools>, for example, is run from the command line as follows: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $ samtools view -bS in.bam > out.sam | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | $ samtools faidx | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | =item * command | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | The command is the specific component of a suite run by executing the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | program. In the example above, C<view> and C<faidx> are commands. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | =item * command prefix | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | The command prefix is an abbreviation of the command name used | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | internally by C<CommandExts> method, and sometimes by the user of the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | factory for specifying command line parameters to subcommands of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | composite commands. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | =item * composite command | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | A composite command is a pipeline or script representing a series of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | separate executions of different commands. Composite commands can be | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | specified by configuring C<CommandExts> appropriately; the composite | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | command can be run by the user from a factory in the same way as | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ordinary commands. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | =item * options, parameters, switches and filespecs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | An option is any command-line option; i.e., a specification set off by | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | a command-line by a specifier (like C<-v> or C<--outfile>). Parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | are command-line options that accept a value (C<-title mydb>); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | switches are boolean flags (C<--no-filter>). Filespecs are barewords | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | at the end of the command line that usually indicate input or output | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | files. In this module, this includes files that capture STDIN, STDOUT, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | or STDERR via redirection. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | =item * pseudo-program | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | A "pseudo-program" is a way to refer to a collection of related | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | applications that are run independently from the command line, rather | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | than via a frontend program. The C<blast+> suite of programs is an | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | example: C<blastn>, C<makeblastdb>, etc. C<CommandExts> can be | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | configured to create a single factory for a suite of related, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | independent programs that treats each independent program as a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | "pseudo-program" command. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | This module essentially adds the non-assembler-specific wrapper | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | machinery of fangly's L<Bio::Tools::Run::AssemblerBase> to the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | L<Bio::Tools::Run::WrapperBase> namespace, adding the general | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | command-handling capability of L<Bio::Tools::Run::BWA>. It creates run | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | factories that are automatically Bio::ParameterBaseI compliant, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | meaning that C<available_parameters()>, C<set_parameters()>, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | C<get_parameters>, C<reset_parameters()>, and C<parameters_changed()> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | are available. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | =head1 DEVELOPER INTERFACE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | C<CommandExts> is currently set up to read particular package globals | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | which define the program, the commands available, command-line options | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | for those commands, and human-readable aliases for those options. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | The easiest way to use C<CommandExts> is probably to create two modules: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | Bio::Tools::Run::YourRunPkg | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | Bio::Tools::Run::YourRunPkg::Config | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | The package globals should be defined in the C<Config> module, and the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | run package itself should begin with the following mantra: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | use YourRunPkg::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | use Bio::Tools::Run::WrapperBase; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | use Bio::Tools::Run::WrapperBase::CommandExts; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | my @args = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | my $self = $class->SUPER::new(@args); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | The following globals can/should be defined in the C<Config> module: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | $program_name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | $program_dir | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | $use_dash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | $join | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | @program_commands | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | %command_prefixes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | @program_params | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | @program_switches | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | %param_translation | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | %composite_commands | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | %command_files | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | See L</Config Globals> for detailed descriptions. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | The work of creating a run wrapper with C<CommandExts> lies mainly in | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | setting up the globals. The key methods for the developer interface are: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | =item * program_dir($path_to_programs) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | Set this to point the factory to the executables. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | =item * _run(@file_args) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | Runs an instantiated factory with the given file args. Use in the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | C<run()> method override. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | =item * _create_factory_set() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | Returns a hash of instantiated factories for each true command from a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | composite command factory. The hash keys are the true command names, so | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | you could do | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | $cmds = $composite_fac->_create_factory_set; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | for (@true_commands) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | $cmds->{$_}->_run(@file_args); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | =item * executables($cmd,[$fullpath]) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | For pseudo-programs, this gets/sets the full path to the executable of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | the true program corresponding to the command C<$cmd>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | =head2 Implementing Composite Commands | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | =head2 Implementing Pseudo-programs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | To indicate that a package wraps disparate programs under a single pseudo program, use an asterisk before the program name: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | package Bio::Tools::Run::YourPkg::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | our $program_name = '*blast+'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | and C<_run> will know what to do. Specify the rest of the globals as | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | if the desired programs were commands. Use the basename of the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | programs for the command names. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | If all the programs can be found in a single directory, just specify | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | that directory in C<program_dir()>. If not, use C<executables()> to set the paths to each program explicitly: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | foreach (keys %cmdpaths) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | $self->executables($_, $cmdpaths{$_}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | =head2 Config Globals | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | Here is an example config file. Further details in prose are below. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | package Dummy::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | no warnings qw(qw); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | use Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | our (@ISA, @EXPORT, @EXPORT_OK); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | push @ISA, 'Exporter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | @EXPORT = qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | $program_name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | $program_dir | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | $use_dash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | $join | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | @program_commands | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | %command_prefixes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | @program_params | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | @program_switches | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | %param_translation | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | %command_files | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | %composite_commands | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | our $program_name = '*flurb'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | our $program_dir = 'C:\cygwin\usr\local\bin'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | our $use_dash = 'mixed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | our $join = ' '; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | our @program_commands = qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | rpsblast | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | find | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | goob | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | blorb | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | multiglob | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | our %command_prefixes = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | blastp => 'blp', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | tblastn => 'tbn', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | goob => 'g', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | blorb => 'b', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | multiglob => 'm' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | our @program_params = qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | command | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | g|narf | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | g|schlurb | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | b|scroob | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | b|frelb | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | m|trud | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | our @program_switches = qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | g|freen | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | b|klep | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | our %param_translation = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 'g|narf' => 'n', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 'g|schlurb' => 'schlurb', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 'g|freen' => 'f', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 'b|scroob' => 's', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 'b|frelb' => 'frelb' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | our %command_files = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 'goob' => [qw( fas faq )], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | our %composite_commands = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 'multiglob' => [qw( blorb goob )] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | C<$use_dash> can be one of C<single>, C<double>, or C<mixed>. See L<Bio::Tools::Run::WrapperBase>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | There is a syntax for the C<%command_files> specification. The token | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | matching C<[a-zA-Z0-9_]+> in each element of each arrayref becomes the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | named filespec parameter for the C<_run()> method in the wrapper | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | class. Additional symbols surrounding this token indicate how this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | argument should be handled. Some examples: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | >out : stdout is redirected into the file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | specified by (..., -out => $file,... ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | <in : stdin is accepted from the file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | specified by (..., -in => $file,... ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 2>log : stderr is redirected into the file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | specified by (..., -log => $file,... ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | #opt : this filespec argument is optional | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | (no throw if -opt => $option is missing) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 2>#log: if -log is not specified in the arguments, the stderr() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | method will capture stderr | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | *lst : this filespec can take multiple arguments, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | specify using an arrayref (..., -lst => [$file1, $file2], ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | *#lst : an optional list | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | The tokens above are examples; they can be anything matching the above regexp. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | =head1 USER INTERFACE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | Using a wrapper created with C<Bio::Tools::Run::WrapperBase::CommandExts>: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | =item * Getting a list of available commands, parameters, and filespecs: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | To get a list of commands, simply: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | @commands = Bio::Tools::Run::ThePkg->available_commands; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | The wrapper will generally have human-readable aliases for each of the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | command-line options for the wrapped program and commands. To obtain a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | list of the parameters and switches available for a particular | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | command, do | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | $factory = Bio::Tools::Run::ThePkg->new( -command => 'glurb' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | @params = $factory->available_parameters('params'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | @switches = $factory->available_parameters('switches'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | @filespec = $factory->available_parameters('filespec'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | @filespec = $factory->filespec; # alias | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | =item * Create factories | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | The factory is a handle on the program and command you wish to | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | run. Create a factory using C<new> to set command-line parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | $factory = Bio::Tools::Run::ThePkg->new( -command => 'glurb', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | -freen => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | -furschlugginer => 'vreeble' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | A shorthand for this is: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | $factory = Bio::Tools::Run::ThePkg->new_glurb( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | -freen => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | -furschlugginer => 'vreeble' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | =item * Running programs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | To run the program, use the C<run> method, providing filespecs as arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | $factory = Bio::Tools::Run::ThePkg->new_assemble( -min_qual => 63 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | $factory->run( -faq1 => 'read1.fq', -faq2 => 'read2.fq', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | -ref => 'refseq.fas', -out => 'new.sam' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # do another | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | $factory->run( -faq1 => 'read-old1.fq', -faq2 => 'read-old2.fq', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | -ref => 'refseq.fas', -out => 'old.sam' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | Messages on STDOUT and STDERR are dumped into their respective attributes: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | $stdout = $factory->stdout; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | $stderr = $factory->stderr; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | unless STDOUT and/or STDERR are part of the named files in the filespec. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | =item * Setting/getting/resetting/polling parameters. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | A C<CommandExts>-based factory is always L<Bio::ParameterBaseI> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | compliant. That means that you may set, get, and reset parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | using C<set_parameters()>, C<get_parameters()>, and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | C<reset_parameters>. You can ask whether parameters have changed since | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | they were last accessed by using the predicate | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | C<parameters_changed>. See L<Bio::ParameterBaseI> for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | Once set, parameters become attributes of the factory. Thus, you can get their values as follows: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | if ($factory->freen) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | $furs = $factory->furshlugginer; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | #... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | =head2 Support | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | L<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | of the bugs and their resolution. Bug reports can be submitted via | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | the web: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | =head1 AUTHOR - Mark A. Jensen | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | Email maj -at- fortinbras -dot- us | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | Describe contact details here | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | =head1 CONTRIBUTORS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | Dan Kortschak ( dan -dot- kortschak -at- adelaide -dot- edu -dot- au ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | # Let the code begin... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | package Bio::Tools::Run::WrapperBase; # need these methods in WrapperBase/maj | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | $Bio::Tools::Run::WrapperBase::VERSION = '1.7.8'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 1 | ▶ | no warnings qw(redefine); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 1 | ▶ | use Bio::Root::Root; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 1 | ▶ | use IPC::Run; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 1 | ▶ | use base qw(Bio::Root::Root Bio::ParameterBaseI); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 1 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | =head2 new() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | Title : new | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | Function: constructor for WrapperBase::CommandExts ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | correctly binds configuration variables | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | to the WrapperBase object | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | Returns : Bio::Tools::Run::WrapperBase object with command extensions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | Args : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | Note : this method subsumes the old _register_program_commands and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | _set_program_options, leaving out the assembler-specific | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | parms ($qual_param and out_type()) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my ($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my $self = bless ({}, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | # pull in *copies* of the Config variables from the caller namespace: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my ($pkg, @goob) = caller(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my ($commands, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | $prefixes, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | $params, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | $switches, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | $translation, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | $use_dash, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | $join, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | $dir, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | $composite_commands, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | $files); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | for (qw( @program_commands | |||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | %command_prefixes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | @program_params | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | @program_switches | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | %param_translation | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | $use_dash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | $join | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | $program_name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | $program_dir | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | %composite_commands | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | %command_files ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | my ($sigil, $var) = m/(.)(.*)/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my $qualvar = "${sigil}${pkg}::${var}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | for ($sigil) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | /\@/ && do { $qualvar = "\[$qualvar\]" }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | /\%/ && do { $qualvar = "\{$qualvar\}" }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my $locvar = "\$${var}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $locvar =~ s/program_|command_|param_//g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | eval "$locvar = $qualvar"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | # set up the info registry hash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my %registry; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | if ($composite_commands) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | $self->_register_composite_commands($composite_commands, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | $params, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | $switches, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | $prefixes); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | @registry{qw( _commands _prefixes _files | |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | _params _switches _translation | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | _composite_commands )} = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | ($commands, $prefixes, $files, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | $params, $switches, $translation, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | $composite_commands); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | $self->{_options} = \%registry; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | if (not defined $use_dash) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | $self->{'_options'}->{'_dash'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | $self->{'_options'}->{'_dash'} = $use_dash; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | if (not defined $join) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | $self->{'_options'}->{'_join'} = ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $self->{'_options'}->{'_join'} = $join; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | if ($name =~ /^\*/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $self->is_pseudo(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $name =~ s/^\*//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | $self->program_name($name) if not defined $self->program_name(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | $self->program_dir($dir) if not defined $self->program_dir(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | $self->set_parameters(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | $self->parameters_changed(1); # set on instantiation, per Bio::ParameterBaseI | |||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | =head2 program_name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | Title : program_name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | Usage : $factory->program_name($name) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | Function: get/set the executable name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | Returns: string | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | Args : string | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | sub program_name { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
program_name: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | my ($self, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | $self->{'_program_name'} = $val if $val; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | return $self->{'_program_name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | =head2 program_dir | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | Title : program_dir | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | Usage : $factory->program_dir($dir) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | Function: get/set the program dir | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | Returns: string | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | Args : string | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | sub program_dir { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
program_dir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | my ($self, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | $self->{'_program_dir'} = $val if $val; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | return $self->{'_program_dir'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | =head2 _register_program_commands() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | Title : _register_program_commands | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | Usage : $factory->_register_program_commands( \@commands, \%prefixes ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | Function: Register the commands a program accepts (for programs that act | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | as frontends for a set of commands, each command having its own | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | set of params/switches) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | Returns : true on success | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | Args : arrayref to a list of commands (scalar strings), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | hashref to a translation table of the form | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | { $prefix1 => $command1, ... } [optional] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | Note : To implement a program with this kind of calling structure, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | include a parameter called 'command' in the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | @program_params global | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | Note : The translation table is used to associate parameters and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | switches specified in _set_program_options with the correct | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | program command. In the globals @program_params and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | @program_switches, specify elements as 'prefix1|param' and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 'prefix1|switch', etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | =head2 _set_program_options | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | Title : _set_program_options | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | Usage : $factory->_set_program_options( \@ args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | Function: Register the parameters and flags that an assembler takes. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | Returns : 1 for success | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | Args : - arguments passed by the user | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | - parameters that the program accepts, optional (default: none) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | - switches that the program accepts, optional (default: none) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | - parameter translation, optional (default: no translation occurs) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | - dash option for the program parameters, [1|single|double|mixed], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | optional (default: yes, use single dashes only) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | - join, optional (default: ' ') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | =head2 _translate_params | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | Title : _translate_params | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | Usage : @options = @{$assembler->_translate_params( )}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | Function: Translate the Bioperl arguments into the arguments to pass to the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | program on the command line | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | Returns : Arrayref of arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | Args : none | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | sub _translate_params { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_translate_params: not called CC=21 SCAR=61.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | # Get option string | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | my ($params, $switches, $join, $dash, $translat) = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | @{$self->{_options}}{qw(_params _switches _join _dash _translation)}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | # access the multiple dash choices of _setparams... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | my @dash_args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | $dash ||= 1; # default as advertised | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$dash ||= 1
MC/DC0%0/1
$dash ||= 1
$dash
Truth table0%0/2
A
A= $dash
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | for ($dash) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | $_ eq '1' && do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | @dash_args = ( -dash => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | /^s/ && do { #single dash only | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | @dash_args = ( -dash => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | /^d/ && do { # double dash only | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | @dash_args = ( -double_dash => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | /^m/ && do { # mixed dash: one-letter opts get -, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | # long opts get -- | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | @dash_args = ( -mixed_dash => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | do { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | $self->warn( "Dash spec '$dash' not recognized; using 'single'" ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | @dash_args = ( -dash => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | my $options = $self->_setparams( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | -params => $params, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | -switches => $switches, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | -join => $join, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | @dash_args | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | # Translate options | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | # parse more carefully - bioperl-run issue #12 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | $options =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | $options =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | my @options; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | my $in_quotes; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | for (split(/(\s|$join)/, $options)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | if (/^-/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | push @options, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | elsif (s/^"//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | $in_quotes=1 unless (s/["']$//); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | push @options, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | elsif (s/"$//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | $options[-1] .= $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | $in_quotes=0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | $in_quotes ? $options[-1] .= $_ : | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | push(@options, $_); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | $self->throw("Unmatched quote in option value") if $in_quotes; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | for (my $i = 0; $i < scalar @options; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | my ($prefix, $name) = ( $options[$i] =~ m/^(-{0,2})(.+)$/ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | if (defined $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | if ($name =~ /command/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | $name = $options[$i+2]; # get the command | |||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | splice @options, $i, 4; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | $i--; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | # don't add the command if this is a pseudo-program | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | ▶ | unshift @options, $name unless ($self->is_pseudo); # put command first | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | elsif (defined $$translat{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | $options[$i] = $prefix.$$translat{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | splice @options, $i, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | $i--; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | @options = grep (!/^\s*$/,@options); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | # this is a kludge for mixed options: the reason mixed doesn't | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | # work right on the pass through _setparams is that the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | # *aliases* and not the actual params are passed to it. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | # here we just rejigger the dashes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | ▶ | if ($dash =~ /^m/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | s/--([a-z0-9](?:\s|$))/-$1/gi for @options; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | # Now arrayify the options | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | return \@options; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | =head2 executable() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | Title : executable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | Function: find the full path to the main executable, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | or to the command executable for pseudo-programs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | Returns : full path, if found | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | Args : [optional] explicit path to the executable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | (will set the appropriate command exec if | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | applicable) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | [optional] boolean flag whether or not to warn when exe no found | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | Note : overrides WrapperBase.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | ▶ | sub executable { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
executable: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | my ($exe, $warn) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ▶ | if ($self->is_pseudo) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | return $self->{_pathtoexe} = $self->executables($self->command,$exe); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | # otherwise | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | # setter | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | if (defined $exe) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | $self->throw("binary '$exe' does not exist") unless -e $exe; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | $self->throw("'$exe' is not executable") unless -x $exe; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | return $self->{_pathtoexe} = $exe; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | # getter | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | return $self->{_pathtoexe} if defined $self->{_pathstoexe}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | # finder | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | return $self->{_pathtoexe} = $self->_find_executable($exe, $warn); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | =head2 executables() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | Title : executables | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | Function: find the full path to a command's executable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | Returns : full path (scalar string) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | Args : command (scalar string), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | [optional] explicit path to this command exe | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | [optional] boolean flag whether or not to warn when exe no found | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | sub executables { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
executables: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | my ($cmd, $exe, $warn) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | # for now, barf if this is not a pseudo program | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | $self->throw("This wrapper represents a single program with commands, not multiple programs; can't use executables()") unless $self->is_pseudo; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | ▶ | $self->throw("Command name required at arg 1") unless defined $cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | ▶ | $self->throw("The desired executable '$cmd' is not registered as a command") unless grep /^$cmd$/, @{$self->{_options}->{_commands}}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | # setter | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | if (defined $exe) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | $self->throw("binary '$exe' does not exist") unless -e $exe; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | ▶ | $self->throw("'$exe' is not executable") unless -x $exe; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | $self->{_pathstoexe} = {} unless defined $self->{_pathstoexe}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | return $self->{_pathstoexe}->{$cmd} = $exe; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | # getter | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | return $self->{_pathstoexe}->{$cmd} if defined $self->{_pathstoexe}->{$cmd}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | $exe ||= $cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$exe ||= $cmd
MC/DC0%0/2
$exe ||= $cmd
$exe
$cmd
Truth table0%0/3
A ||= B
A= $exeB= $cmd
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | # finder | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | return $self->{_pathstoexe}->{$cmd} = $self->_find_executable($exe, $warn); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | =head2 _find_executable() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | Title : _find_executable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | Usage : my $exe_path = $fac->_find_executable($exe, $warn); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | Function: find the full path to a named executable, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | Returns : full path, if found | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | Args : name of executable to find | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | [optional] boolean flag whether or not to warn when exe no found | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | Note : differs from executable and executables in not | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | setting any object attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | ▶ | sub _find_executable { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_executable: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | my ($exe, $warn) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | ▶ | if ($self->is_pseudo && !$exe) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->is_pseudo and not $exe
MC/DC0%0/2
$self->is_pseudo and not $exe
$self->is_pseudo
not $exe
Truth table0%0/3
A and not(B)
A= $self->is_pseudoB= not $exe
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | if (!$self->command) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | # this throw probably appropriate | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | # the rest are now warns if $warn.../maj | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | $self->throw( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | "The ".__PACKAGE__." wrapper represents several different programs;". | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | "arg1 to _find_executable must be specified explicitly,". | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | "or the command() attribute set"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | $exe = $self->command; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | ▶ | $exe ||= $self->program_path; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$exe ||= $self->program_path
MC/DC0%0/2
$exe ||= $self->program_path
$exe
$self->program_path
Truth table0%0/3
A ||= B
A= $exeB= $self->program_path
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | my $path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | ▶ | if ($self->program_dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | $path = File::Spec->catfile($self->program_dir, $exe); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | $path = $exe; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | $self->warn('Program directory not specified; use program_dir($path).') if $warn; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | # use provided info - we are allowed to follow symlinks, but refuse directories | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | map { return $path.$_ if ( -x $path.$_ && !(-d $path.$_) ) } ('', '.exe') if defined $path; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
-x $path . $_ and not -d $path . $_
MC/DC0%0/2
-x $path . $_ and not -d $path . $_
-x $path . $_
not -d $path . $_
Truth table0%0/3
A and not(B)
A= -x $path . $_B= not -d $path . $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | # couldn't get path to executable from provided info, so use system path | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | $path = $path ? " in $path" : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | ▶ | $self->warn("Executable $exe not found$path, trying system path...") if $warn; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | ▶ | if ($path = $self->io->exists_exe($exe)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | return $path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | ▶ | $self->warn("Cannot find executable for program '".($self->is_pseudo ? $self->command : $self->program_name)."'") if $warn; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | =head2 _register_composite_commands() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | Title : _register_composite_commands | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | Function: adds subcomand params and switches for composite commands | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | Returns : true on success | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | Args : \%composite_commands, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | \@program_params, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | \@program_switches | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | ▶ | sub _register_composite_commands { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_register_composite_commands: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | my ($composite_commands, $program_params, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | $program_switches, $command_prefixes) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | my @sub_params; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | my @sub_switches; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | foreach my $cmd (keys %$composite_commands) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | ▶ | my $pfx = $command_prefixes->{$cmd} || $cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$command_prefixes->{$cmd} || $cmd
MC/DC0%0/2
$command_prefixes->{$cmd} || $cmd
$command_prefixes->{$cmd}
$cmd
Truth table0%0/3
A || B
A= $command_prefixes->{$cmd}B= $cmd
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | foreach my $subcmd ( @{$$composite_commands{$cmd}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | my $spfx = $command_prefixes->{$subcmd} || $subcmd; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$command_prefixes->{$subcmd} || $subcmd
MC/DC0%0/2
$command_prefixes->{$subcmd} || $subcmd
$command_prefixes->{$subcmd}
$subcmd
Truth table0%0/3
A || B
A= $command_prefixes->{$subcmd}B= $subcmd
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | my @sub_program_params = grep /^$spfx\|/, @$program_params; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | my @sub_program_switches = grep /^$spfx\|/, @$program_switches; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | for (@sub_program_params) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | m/^$spfx\|(.*)/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | push @sub_params, "$pfx\|${spfx}_".$1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | for (@sub_program_switches) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | m/^$spfx\|(.*)/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | push @sub_switches, "$pfx\|${spfx}_".$1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | push @$program_params, @sub_params; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | push @$program_switches, @sub_switches; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | # translations for subcmd params/switches not necessary | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | =head2 _create_factory_set() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | Title : _create_factory_set | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | Usage : @facs = $self->_create_factory_set | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | Function: instantiate a set of individual command factories for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | a given composite command | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | Factories will have the correct parameter fields set for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | their own subcommand | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | Returns : hash of factories: ( $subcmd_prefix => $subcmd_factory, ... ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | Args : none | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | ▶ | sub _create_factory_set { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_factory_set: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | ▶ | $self->throw('command not set') unless $self->command; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | my $cmd = $self->command; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | $self->throw('_create_factory_set only works on composite commands') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | ▶ | unless grep /^$cmd$/, keys %{$self->{_options}->{_composite_commands}}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | my %ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | my $class = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | my $subargs_hash = $self->_collate_subcmd_args($cmd); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | for (keys %$subargs_hash) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | $ret{$_} = $class->new( -command => $_, @{$$subargs_hash{$_}} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | return %ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | =head2 _collate_subcmd_args() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | Title : _collate_subcmd_args | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | Usage : $args_hash = $self->_collate_subcmd_args | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | Function: collate parameters and switches into command-specific | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | arg lists for passing to new() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | Returns : hash of named argument lists | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | Args : [optional] composite cmd prefix (scalar string) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | [default is 'run'] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | ▶ | sub _collate_subcmd_args { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_collate_subcmd_args: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | my $cmd = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | my %ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | # default command is 'run' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | ▶ | $cmd ||= 'run'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$cmd ||= "run"
MC/DC0%0/1
$cmd ||= "run"
$cmd
Truth table0%0/2
A
A= $cmd
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | ▶ | return unless $self->{'_options'}->{'_composite_commands'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | ▶ | return unless $self->{'_options'}->{'_composite_commands'}->{$cmd}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | my @subcmds = @{$self->{'_options'}->{'_composite_commands'}->{$cmd}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | my $cur_options = $self->{'_options'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | # collate | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | foreach my $subcmd (@subcmds) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | # find the composite cmd form of the argument in | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | # the current params and switches | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | # e.g., map_max_mismatches | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | ▶ | my $pfx = $self->{_options}->{_prefixes}->{$subcmd} || $subcmd; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'_options'}{'_prefixes'}{$subcmd} || $subcmd
MC/DC0%0/2
$self->{'_options'}{'_prefixes'}{$subcmd} || $subcmd
$self->{'_options'}{'_prefixes'}{$subcmd}
$subcmd
Truth table0%0/3
A || B
A= $self->{'_options'}{'_prefixes'}{$subcmd}B= $subcmd
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | my @params = grep /^${pfx}_/, @{$$cur_options{'_params'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | my @switches = grep /^${pfx}_/, @{$$cur_options{'_switches'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | $ret{$subcmd} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | # create an argument list suitable for passing to new() of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | # the subcommand factory... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | foreach my $opt (@params, @switches) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | my $subopt = $opt; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | $subopt =~ s/^${pfx}_//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | ▶ | push(@{$ret{$subcmd}}, '-'.$subopt => $self->$opt) if defined $self->$opt; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | return \%ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | =head2 _run | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | Title : _run | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | Usage : $fac->_run( @file_args ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | Function: Run a command as specified during object construction | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | Returns : true on success | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | Args : a specification of the files to operate on according | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | to the filespec | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | sub _run { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run: not called CC=32 SCAR=69.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | # _translate_params will provide an array of command/parameters/switches | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | # -- these are set at object construction | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | # to set up the run, need to add the files to the call | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | # -- provide these as arguments to this function | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | ▶ | my $cmd = $self->command if $self->can('command'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | my $opts = $self->{_options}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | my %args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | ▶ | $self->throw("No command specified for the object") unless $cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | # setup files necessary for this command | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | my $filespec = $opts->{'_files'}->{$cmd}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | my @switches; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | my ($in, $out, $err); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | # some applications rely completely on switches | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | ▶ | if (defined $filespec && @$filespec) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $filespec and @$filespec
MC/DC0%0/2
defined $filespec and @$filespec
defined $filespec
@$filespec
Truth table0%0/3
A and B
A= defined $filespecB= @$filespec
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | # parse args based on filespec | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | # require named args | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | ▶ | $self->throw("Named args are required") unless !(@args % 2); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | s/^-// for @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | %args = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | # validate | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | my @req = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | my $s = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | $s =~ s/^-.*\|//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | $s =~ s/^[012]?[<>]//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | $s =~ s/[^a-zA-Z0-9_]//g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | $s | |||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | } grep !/[#]/, @$filespec; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | ▶ | !defined($args{$_}) && $self->throw("Required filearg '$_' not specified") for @req; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | # set up redirects and file switches | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | for (@$filespec) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | ▶ | m/^1?>#?(.*)/ && do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | ▶ | defined($args{$1}) && ( open $out, '>', $args{$1} or $self->throw("Could not write file '$args{$1}': $!") ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $args{$1} && (open($out, '>', $args{$1}) || $self->throw("Could not write file '$args{$1}': $!"))
open $out, ">", $args{$1} or $self->throw("Could not write file '$args{$1}': $!")
MC/DC0%0/3
defined $args{$1} && (open($out, '>', $args{$1}) || $self->throw("Could not write file '$args{$1}': $!"))
defined $args{$1}
open $out, ">", $args{$1}
$self->throw("Could not write file '$args{$1}': $!")
Truth table0%0/4
A && B or C
A= defined $args{$1}B= open $out, ">", $args{$1}C= $self->throw("Could not write file '$args{$1}': $!")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | ▶ | m/^2>#?(.*)/ && do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | ▶ | defined($args{$1}) && ( open $err, '>', $args{$1} or $self->throw("Could not write file '$args{$1}': $!") ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $args{$1} && (open($err, '>', $args{$1}) || $self->throw("Could not write file '$args{$1}': $!"))
open $err, ">", $args{$1} or $self->throw("Could not write file '$args{$1}': $!")
MC/DC0%0/3
defined $args{$1} && (open($err, '>', $args{$1}) || $self->throw("Could not write file '$args{$1}': $!"))
defined $args{$1}
open $err, ">", $args{$1}
$self->throw("Could not write file '$args{$1}': $!")
Truth table0%0/4
A && B or C
A= defined $args{$1}B= open $err, ">", $args{$1}C= $self->throw("Could not write file '$args{$1}': $!")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | ▶ | m/^<#?(.*)/ && do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | ▶ | defined($args{$1}) && ( open $in, '<', $args{$1} or $self->throw("Could not read file '$args{$1}': $!") ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $args{$1} && (open($in, '<', $args{$1}) || $self->throw("Could not read file '$args{$1}': $!"))
open $in, "<", $args{$1} or $self->throw("Could not read file '$args{$1}': $!")
MC/DC0%0/3
defined $args{$1} && (open($in, '<', $args{$1}) || $self->throw("Could not read file '$args{$1}': $!"))
defined $args{$1}
open $in, "<", $args{$1}
$self->throw("Could not read file '$args{$1}': $!")
Truth table0%0/4
A && B or C
A= defined $args{$1}B= open $in, "<", $args{$1}C= $self->throw("Could not read file '$args{$1}': $!")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | ▶ | if (m/^-(.*)\|/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | push @switches, $self->_dash_switch($1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | push @switches, undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | my $dum; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | ▶ | $in || ($in = \$dum); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | ▶ | $out || ($out = \$self->{'stdout'}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | ▶ | $err || ($err = \$self->{'stderr'}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | # Get program executable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | my $exe = $self->executable; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | ▶ | $self->throw("Can't find executable for '".($self->is_pseudo ? $self->command : $self->program_name)."'; can't continue") unless $exe; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | # Get command-line options | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | my $options = $self->_translate_params(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | # Get file specs sans redirects in correct order | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | my @specs = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | my $s = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | $s =~ s/^-.*\|//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | $s =~ s/[^a-zA-Z0-9_]//g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | $s | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | } grep !/[<>]/, @$filespec; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | my @files = @args{@specs}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | # expand arrayrefs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | my $l = $#files; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | # Note: below code block may be brittle, see link on this: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | # http://lists.open-bio.org/pipermail/bioperl-l/2010-June/033439.html | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | for (0..$l) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | ▶ | if (ref($files[$_]) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | splice(@switches, $_, 1, ($switches[$_]) x @{$files[$_]}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | splice(@files, $_, 1, @{$files[$_]}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | @files = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | my $s = shift @switches; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | ▶ | defined $_ ? ($s, $_): () | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | } @files; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | ▶ | @files = map { defined $_ ? $_ : () } @files; # squish undefs | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | my @ipc_args = ( $exe, @$options, @files ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | $self->{_last_execution} = join( $self->{'_options'}->{'_join'}, @ipc_args ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | ▶ | IPC::Run::run(\@ipc_args, $in, $out, $err) or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | die ("There was a problem running $exe : ".$$err); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | ▶ | $self->throw("$exe call crashed: $@") unless $self->no_throw_on_crash; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | =head2 no_throw_on_crash() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | Title : no_throw_on_crash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | Function: prevent throw on execution error | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | Returns : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | Args : [optional] boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | ▶ | sub no_throw_on_crash { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
no_throw_on_crash: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | ▶ | return $self->{'_no_throw'} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | return $self->{'_no_throw'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | =head2 last_execution() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | Title : last_execution | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | Function: return the last executed command with options | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | Returns : string of command line sent to IPC::Run | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | Args : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | ▶ | sub last_execution { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_execution: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | return $self->{'_last_execution'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | =head2 _dash_switch() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | Title : _dash_switch | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | Usage : $version = $fac->_dash_switch( $switch ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | Function: Returns an appropriately dashed switch for the executable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | Args : A string containing a switch without dashes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | Returns : string containing an appropriately dashed switch for the current executable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | ▶ | sub _dash_switch { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dash_switch: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 0 | my ($self, $switch) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | my $dash = $self->{'_options'}->{'_dash'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 0 | for ($dash) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | ▶ | $_ eq '1' && do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | $switch = '-'.$switch; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | ▶ | /^s/ && do { #single dash only | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | $switch = '-'.$switch; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | ▶ | /^d/ && do { # double dash only | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | $switch = '--'.$switch; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 0 | ▶ | /^m/ && do { # mixed dash: one-letter opts get -, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | $switch = '-'.$switch; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | $switch =~ s/^(-[a-z0-9](?:\w+))$/-$1/i; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 0 | do { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | $self->warn( "Dash spec '$dash' not recognized; using 'single'" ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | $switch = '-'.$switch; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | return $switch; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | =head2 stdout() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | Title : stdout | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | Usage : $fac->stdout() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | Function: store the output from STDOUT for the run, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | if no file specified in _run arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | Example : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | Returns : scalar string | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | Args : on set, new value (a scalar or undef, optional) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | ▶ | sub stdout { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stdout: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 0 | ▶ | return $self->{'stdout'} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | return $self->{'stdout'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | =head2 stderr() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | Title : stderr | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | Usage : $fac->stderr() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | Function: store the output from STDERR for the run, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | if no file is specified in _run arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | Example : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | Returns : scalar string | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | Args : on set, new value (a scalar or undef, optional) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | ▶ | sub stderr { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stderr: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | ▶ | return $self->{'stderr'} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 0 | return $self->{'stderr'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | =head2 is_pseudo() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | Title : is_pseudo | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | Usage : $obj->is_pseudo($newval) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | Function: returns true if this factory represents | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | a pseudo-program | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | Example : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | Returns : value of is_pseudo (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | Args : on set, new value (a scalar or undef, optional) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | ▶ | sub is_pseudo { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_pseudo: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | ▶ | return $self->{'is_pseudo'} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | return $self->{'is_pseudo'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | =head2 AUTOLOAD | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | AUTOLOAD permits | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | $class->new_yourcommand(@args); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | as an alias for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | $class->new( -command => 'yourcommand', @args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 0 | my $tok = $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 0 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | $tok =~ s/.*:://; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | ▶ | unless ($tok =~ /^new_/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 0 | ▶ | $class->throw("Can't locate object method '$tok' via package '".ref($class)?ref($class):$class); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | my ($cmd) = $tok =~ m/new_(.*)/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | return $class->new( -command => $cmd, @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | =head1 Bio:ParameterBaseI compliance | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | =head2 set_parameters() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | Title : set_parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | Usage : $pobj->set_parameters(%params); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | Function: sets the parameters listed in the hash or array | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | Returns : true on success | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | Args : [optional] hash or array of parameter/values. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | ▶ | sub set_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_parameters: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | # currently stored stuff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | my $opts = $self->{'_options'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | my $params = $opts->{'_params'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | my $switches = $opts->{'_switches'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | my $translation = $opts->{'_translation'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | my $use_dash = $opts->{'_dash'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | my $join = $opts->{'_join'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | ▶ | unless (($self->can('command') && $self->command) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->can("command") and $self->command or grep /command/, @args
$self->can("command") and $self->command
MC/DC0%0/3
$self->can("command") and $self->command or grep /command/, @args
$self->can("command")
$self->command
grep /command/, @args
Truth table0%0/5
A and B or C
A= $self->can("command")B= $self->commandC= grep /command/, @args
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | || (grep /command/, @args)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | push @args, '-command', 'run'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | my %args = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 0 | ▶ | my $cmd = $args{'-command'} || $args{'command'} || ($self->can('command') && $self->command); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$args{'-command'} || $args{'command'} || $self->can('command') && $self->command
$args{"-command"} or $args{"command"}
$self->can("command") and $self->command
MC/DC0%0/4
$args{'-command'} || $args{'command'} || $self->can('command') && $self->command
$args{"-command"}
$args{"command"}
$self->can("command")
$self->command
Truth table0%0/5
A or B || C and D
A= $args{"-command"}B= $args{"command"}C= $self->can("command")D= $self->command
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | ▶ | if ($cmd) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | my (@p,@s, %x); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 0 | ▶ | $self->warn('Command present, but no commands registered') unless $self->{'_options'}->{'_commands'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | ▶ | $self->throw("Command '$cmd' not registered") unless grep /^$cmd$/, @{$self->{'_options'}->{'_commands'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | 0 | ▶ | $cmd = $self->{_options}->{_prefixes}->{$cmd} || $cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'_options'}{'_prefixes'}{$cmd} || $cmd
MC/DC0%0/2
$self->{'_options'}{'_prefixes'}{$cmd} || $cmd
$self->{'_options'}{'_prefixes'}{$cmd}
$cmd
Truth table0%0/3
A || B
A= $self->{'_options'}{'_prefixes'}{$cmd}B= $cmd
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | @p = (grep(!/^.*?\|/, @$params), grep(/^${cmd}\|/, @$params)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | @s = (grep(!/^.*?\|/, @$switches), grep(/^${cmd}\|/, @$switches)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | s/.*?\|// for @p; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | s/.*?\|// for @s; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | @x{@p, @s} = @{$translation}{ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | grep( !/^.*?\|/, @$params, @$switches), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | grep(/^${cmd}\|/, @$params, @$switches) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | $opts->{_translation} = $translation = \%x; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | $opts->{_params} = $params = \@p; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | $opts->{_switches} = $switches = \@s; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | $self->_set_from_args( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 0 | \@args, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | -methods => [ @$params, @$switches, 'program_name', 'program_dir', 'out_type' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | -create => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | # when our parms are accessed, signal parameters are unchanged for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | # future reads (until set_parameters is called) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | -code => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | ' my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | $self->parameters_changed(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | return $self->{\'_\'.$method} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | return $self->{\'_\'.$method};' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | # the question is, are previously-set parameters left alone when | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | # not specified in @args? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | $self->parameters_changed(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | =head2 reset_parameters() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | Title : reset_parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | Usage : resets values | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | Function: resets parameters to either undef or value in passed hash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | Args : [optional] hash of parameter-value pairs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 0 | ▶ | sub reset_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_parameters: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 0 | my @reset_args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | # currently stored stuff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | my $opts = $self->{'_options'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | my $params = $opts->{'_params'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 0 | my $switches = $opts->{'_switches'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | my $translation = $opts->{'_translation'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | my $qual_param = $opts->{'_qual_param'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | my $use_dash = $opts->{'_dash'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | my $join = $opts->{'_join'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | # handle command name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | my %args = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | ▶ | my $cmd = $args{'-command'} || $args{'command'} || $self->command; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$args{'-command'} || $args{'command'} || $self->command
$args{"-command"} or $args{"command"}
MC/DC0%0/3
$args{'-command'} || $args{'command'} || $self->command
$args{"-command"}
$args{"command"}
$self->command
Truth table0%0/4
A or B || C
A= $args{"-command"}B= $args{"command"}C= $self->command
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 0 | $args{'command'} = $cmd; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | delete $args{'-command'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | @args = %args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | # don't like this, b/c _set_program_args will create a bunch of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | # accessors with undef values, but oh well for now /maj | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | for my $p (@$params) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 0 | ▶ | push(@reset_args, $p => undef) unless grep /^[-]?$p$/, @args; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | 0 | for my $s (@$switches) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 0 | ▶ | push(@reset_args, $s => undef) unless grep /^[-]?$s$/, @args; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 0 | push @args, @reset_args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 0 | $self->set_parameters(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 0 | $self->parameters_changed(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | =head2 parameters_changed() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | Title : parameters_changed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | Usage : if ($pobj->parameters_changed) {...} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | Function: Returns boolean true (1) if parameters have changed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | Returns : Boolean (0 or 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | Args : [optional] Boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 0 | ▶ | sub parameters_changed { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parameters_changed: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 0 | ▶ | return $self->{'_parameters_changed'} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | return $self->{'_parameters_changed'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | =head2 available_parameters() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | Title : available_parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | Usage : @params = $pobj->available_parameters() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | Function: Returns a list of the available parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | Returns : Array of parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | Args : 'params' for settable program parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 'switches' for boolean program switches | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | default: all | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | ▶ | sub available_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
available_parameters: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | 0 | my $subset = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | my $opts = $self->{'_options'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 0 | my @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 0 | for ($subset) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | ▶ | (!defined || /^a/) && do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $_ or /^a/
MC/DC0%0/2
not defined $_ or /^a/
not defined $_
/^a/
Truth table0%0/3
not(A) or B
A= not defined $_B= /^a/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 0 | @ret = (@{$opts->{'_params'}}, @{$opts->{'_switches'}}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 0 | ▶ | m/^p/i && do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 0 | @ret = @{$opts->{'_params'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 0 | ▶ | m/^s/i && do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 0 | @ret = @{$opts->{'_switches'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | ▶ | m/^c/i && do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 0 | @ret = @{$opts->{'_commands'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 0 | ▶ | m/^f/i && do { # get file spec | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 0 | return @{$opts->{'_files'}->{$self->command}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | do { #fail | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | $self->throw("available_parameters: unrecognized subset"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 0 | ▶ | sub available_commands { shift->available_parameters('commands') } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
available_commands: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 0 | ▶ | sub filespec { shift->available_parameters('filespec') } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filespec: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | =head2 get_parameters() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | Title : get_parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | Usage : %params = $pobj->get_parameters; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | Function: Returns list of key-value pairs of parameter => value | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | Returns : List of key-value pairs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | Args : [optional] A string is allowed if subsets are wanted or (if a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | parameter subset is default) 'all' to return all parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 0 | ▶ | sub get_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_parameters: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 0 | my $subset = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | 0 | ▶ | $subset ||= 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$subset ||= "all"
MC/DC0%0/1
$subset ||= "all"
$subset
Truth table0%0/2
A
A= $subset
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | 0 | my @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | 0 | my $opts = $self->{'_options'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | for ($subset) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | ▶ | m/^p/i && do { #params only | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | for (@{$opts->{'_params'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | ▶ | push(@ret, $_, $self->$_) if $self->can($_) && defined $self->$_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->can($_) and defined $self->$_
MC/DC0%0/2
$self->can($_) and defined $self->$_
$self->can($_)
defined $self->$_
Truth table0%0/3
A and B
A= $self->can($_)B= defined $self->$_
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | ▶ | m/^s/i && do { #switches only | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | 0 | for (@{$opts->{'_switches'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | ▶ | push(@ret, $_, $self->$_) if $self->can($_) && defined $self->$_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->can($_) and defined $self->$_
MC/DC0%0/2
$self->can($_) and defined $self->$_
$self->can($_)
defined $self->$_
Truth table0%0/3
A and B
A= $self->can($_)B= defined $self->$_
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | ▶ | m/^a/i && do { # all | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | for ((@{$opts->{'_params'}},@{$opts->{'_switches'}})) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 0 | ▶ | push(@ret, $_, $self->$_) if $self->can($_) && defined $self->$_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->can($_) and defined $self->$_
MC/DC0%0/2
$self->can($_) and defined $self->$_
$self->can($_)
defined $self->$_
Truth table0%0/3
A and B
A= $self->can($_)B= defined $self->$_
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 0 | do { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 0 | $self->throw("get_parameters: unrecognized subset"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | 0 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||