runnable version
[PsN.git] / lib / common_options.pm
blobf9456aea96698c0cc0ad9779c3875cb64ef96554
1 package common_options;
3 use FindBin qw($Bin);
4 use lib "$Bin/../lib";
5 use Getopt::Long;
6 use Text::Wrap;
8 ## Configure the command line parsing
9 Getopt::Long::config("auto_abbrev");
11 my @tool_options = ( "abort_on_fail",
12 "adaptive!",
13 "clean:i",
14 "compress",
15 "condition_number_limit:f",
16 "correlation_limit:f",
17 "crash_restarts:i",
18 "directory:s",
19 "drop_dropped",
20 "handle_maxevals",
21 "handle_msfo",
22 "handle_crashes!",
23 "large_theta_cv_limit:f",
24 "large_omega_cv_limit:f",
25 "large_sigma_cv_limit:f",
26 "lsf_job_name:s",
27 "lsf_options:s",
28 "lsf_project_name:s",
29 "lsf_queue:s",
30 "lsf_resources:s",
31 "lsf_ttl:s",
32 "max_runtime:i",
33 "min_retries:i",
34 "missing_data_token:s",
35 "near_bound_sign_digits:i",
36 "near_zero_boundary_limit:f",
37 "nice:i",
38 "nm_version:s",
39 "nm_directory:s",
40 "nonparametric_etas",
41 "nonparametric_marginals",
42 "picky",
43 "prepend_model_file_name",
44 "quick_summarize|quick_summary",
45 "rerun:i",
46 "retries:i",
47 "run_on_lsf!",
48 "run_on_ud!",
49 "run_on_sge!",
50 "run_on_zink!",
51 "sge_resource:s",
52 "sge_queue:s",
53 "seed:s",
54 "shrinkage",
55 "significant_digits_rerun:f",
56 "sign_digits_off_diagonals:i",
57 "summarize|summary",
58 "threads:i",
59 "tweak_inits:i",
60 "ud_native_retrieve",
61 "ud_sleep:i",
62 "verbose!",
63 "wrap_data",
64 "unwrap_table_files",
65 "near_bound_sign_digits:i",
66 "near_zero_boundary_limit:f",
67 "large_theta_cv_limit:f",
68 "large_omega_cv_limit:f",
69 "large_sigma_cv_limit:f",
70 "confidence_level:f",
71 "precision:i",
75 my @model_options = ("extra_data_files:s@",
76 "extra_files:s",
77 "extra_output:s",
78 "sde",
79 "cwres",
80 "mirror_plots:i",
81 "iofv",
82 "mirror_from_lst!",
83 "nm_version:s",
84 "outputfile:s",
87 my @script_options = ( "debug:i",
88 "debug_package:s",
89 "debug_subroutine:s",
90 "h|?",
91 "help",
92 "html_help",
93 # "project:s",
94 "silent",
95 # "user:s",
96 "version",
97 "warn_with_trace:i"
100 @get_opt_strings = (sort(@tool_options), sort(@model_options), sort(@script_options));
102 sub options_to_parameters {
103 my $opts = shift;
104 my @options = @{$opts};
106 my $parameter_string = '( ';
108 foreach my $opt ( @options ){
109 $opt =~ s/[!:|].*//g;
110 $parameter_string .= "$opt => \$options{'$opt'},\n";
112 $parameter_string .= ' )';
113 return $parameter_string;
116 $parameters = options_to_parameters([@tool_options,'top_tool']);
119 @extra_files;
120 @extra_output;
122 sub set_globals {
123 my $opts = shift;
124 my $command = shift;
125 my %options = %{$opts};
127 random_set_seed_from_phrase( $options{'seed'} ) if ( defined $options{'seed'} );
129 ui -> category( $command );
130 ui -> silent(1) if( $options{'silent'} );
132 debug -> level( $options{'debug'} );
133 debug -> package( $options{'debug_package'} );
134 debug -> subroutine( $options{'debug_subroutine'} );
135 debug -> warn_with_trace( $options{'warn_with_trace'} );
137 if ( $PsN::config -> {'_'} -> {'use_database'} ) {
139 $PsN::config -> {'_'} -> {'project'} =
140 defined $options{'project'} ? $options{'project'} :
141 $PsN::config -> {'_'} -> {'default_project'};
142 $PsN::config -> {'_'} -> {'user'} =
143 defined $options{'user'} ? $options{'user'} :
144 $PsN::config -> {'_'} -> {'default_user'};
145 print "Using database ".$PsN::config -> {'_'} -> {'project'}."\n";
146 if ( defined $options{'password'} ) {
147 $PsN::config -> {'_'} -> {'password'} = $options{'password'};
148 } elsif( defined $PsN::config -> {'_'} -> {'password'} ) {
149 $PsN::config -> {'_'} -> {'password'} =
150 $PsN::config -> {'_'} -> {'default_password'};
151 } else {
152 system( "stty -echo" );
153 print "Database password for ".$PsN::config -> {'_'} -> {'user'}.": ";
154 my $word;
155 chomp($word = <STDIN>);
156 print "\n";
157 system( "stty echo" );
158 $PsN::config -> {'_'} -> {'password'} = $word;
163 sub get_defaults {
164 my $options = shift;
165 my $tool = shift;
166 foreach my $default_option ( keys %{$PsN::config -> {'default_'.$tool.'_options'}} ){
167 unless( exists $options -> {$default_option} ){
168 $options -> {$default_option} = $PsN::config -> {'default_'.$tool.'_options'} -> {$default_option};
174 foreach my $default_option ( keys %{$PsN::config -> {'default_options'}} ){
175 unless( exists $options -> {$default_option} ){
176 $options -> {$default_option} = $PsN::config -> {'default_options'} -> {$default_option};
180 $options -> {'top_tool'} = 1;
183 sub sanity_checks {
184 my $options = shift;
185 my $tool = shift;
187 if( $options -> {'max_runtime'} ){
188 if( $Config{osname} eq 'MSWin32' ){
189 die "--max_runtime is not allowed when running on Windows";
191 if( $options -> {'run_on_sge'} ){
192 die "--max_runtime is not allowed when running on SGE";
194 if( $options -> {'run_on_lsf'} ){
195 die "--max_runtime is not allowed when running on LSF";
197 if( $options -> {'run_on_ud'} ){
198 die "--max_runtime is not allowed when running on UD Grid";
204 sub print_help {
205 my( $command, $required, $optional ) = @_;
206 my %is_required;
207 my %all_options = (%{$required},%{$optional});
209 foreach my $req( keys %{$required} ){
210 $is_required{$req} = 1;
213 my $option_help;
215 $option_help .= "[ -h | -? ] [ --help ]\n" . ' ' x (1+length($command));
217 my @loop_array;
218 if( $command eq 'execute' ){
219 @loop_array = sort(@get_opt_strings);
220 } else {
221 @loop_array = (keys %{$required}, keys %{$optional});
224 foreach my $help( @loop_array ) {
225 next if( $help eq 'help' or $help eq 'h|?' );
226 unless( $is_required{$help} ){
227 $option_help .= "[ ";
228 } else {
229 $option_help .= " ";
231 if( $all_options{$help} ne '' ){
232 $help =~ /^([^:]+)/;
233 $option_help .= "--$1=\'" . $all_options{$help} . "\'";
234 } elsif( $help =~ /(.+):s/ ){
235 $option_help .= "--$1=\'string\'";
236 } elsif( $help =~ /(.+):i/ ){
237 $option_help .= "--$1=\'integer\'";
238 } elsif( $help =~ /(.+):f/ ){
239 $option_help .= "--$1=\'number\'";
240 } elsif( $help =~ /(.+):(\d)/ ){
241 $option_help .= "--$1=$2";
242 } elsif( $help =~ /(.+)[^:]$/ ){
243 $option_help .= "--$help";
245 unless( $is_required{$help} ){
246 $option_help .= " ]";
248 $option_help .= "\n".' ' x (1+length($command));
251 return $option_help;
254 sub model_parameters {
255 my $options = shift;
256 #my %options = %{$opt};
258 if( defined $options -> {'extra_data_files'} ){
259 for( my $i=0; $i < scalar(@{$options -> {'extra_data_files'}}) ; $i++ ){
260 my @arr = split( /,/ , @{$options -> {'extra_data_files'}}[$i] );
261 if( @arr < 2 ){
262 die "extra_data_file must be of form: \"filename, head1, head2\"\n" ;
265 @{$options -> {'extra_data_files'}}[$i] = $arr[0];
266 my @subarray = @arr[1..$#arr];
267 push( @{$options -> {'extra_data_headers'}}, \@subarray )
271 push(@model_options, 'extra_data_headers');
273 if( defined $options -> {'extra_files'} ){
274 my @array = split( /,/ , $options -> {'extra_files'} );
275 $options -> {'extra_files'} = \@array;
278 if( defined $options -> {'extra_output'} ){
279 my @array = split( /,/ , $options -> {'extra_output'} );
280 $options -> {'extra_output'} = \@array;
283 return options_to_parameters(\@model_options);
288 sub online_help {
290 my $command = shift;
291 my $opts = shift;
292 my $help_text = shift;
293 my $required_options = shift;
294 my $optional_options = shift;
295 my %options = %{$opts};
297 my %help_hash;
299 $help_hash{Pre_help_message} = << 'EOF';
300 <h3 class="heading1">execute</h3>
302 Perl script running one or more modelfiles using PsN.
304 <h3 class="heading1">Usage:</h3>
307 $help_hash{Description} = <<'EOF';
308 <h3 class="heading1">Description:</h3>
310 The execute utility is a Perl script that allows you to run multiple
311 modelfiles either sequentially or in parallel. It is more or less an
312 nmfe replacement.
313 <br><br>
314 The execute utility creates subdirectories where it puts NONMEMs
315 input and output files, to make sure that parallel NONMEM runs do not
316 interfere with each other. The top directory is by default named
317 'modelfit_dirX' where 'X' is a number that starts at 0 and is
318 increased by one each time you run the execute utility.
319 <br><br>
320 When the NONMEM runs are finished, the output and table files will be
321 copied to the directory where execute started in which means that you
322 can normaly ignore the 'modelfit_dirX' directory. If you need to
323 access any special files you can find them inside the
324 'modelfit_dirX'. Inside the 'modelfit_dirX' you find a few
325 subdirectories named 'NM_runY'. For each model file you
326 specified on the command line there will be one 'NM_runY' directory in
327 which the actual NONMEM execution takes place. The order of the
328 'NM_runY' directories corresponds to the order of the modelfiles given
329 on the command line. The first run will take place inside 'NM_run1',
330 the second in 'NM_run2' and so on.
333 $help_hash{Examples} = <<'EOF';
334 <h3 class="heading1">Example:</h3>
336 <p align="justify" class="style2">$ execute pheno.mod </p>
338 <p align="justify">Runs one model file and accepts all default values.</p>
340 <p align="justify" class="style2">$ execute -threads=2 -retries=5 phenobarbital.mod pheno_alternate.mod</p>
342 <p align="justify">Runs two model files in parallel using 5 possible retries.</>p
345 $help_hash{Options} = <<'EOF';
346 <h3 class="heading1">Options:</h3>
348 The options are given here in their long form. Any option may be
349 abbreviated to any nonconflicting prefix. The <span class="style2">-threads</span> option may
350 be abbreviated to <span class="style2">-t</span> (or even <span class="style2">-thr</span>) but <span class="style2">-debug</span> may not be
351 abbreviated to <span class="style2">-d</span> because it conflicts with <span class="style2">-debug_packages</span> and
352 <span class="style2">-debug_subroutines</span>.
353 <br><br>
354 The following options are valid:
357 $help_hash{'-?'} = <<'EOF';
358 <p class="style2">-h | -?</p>
360 With <span class="style2">-h</span> or <span class="style2">-?</span> execute.pl prints the list of available options
361 and exit.
364 $help_hash{-help} = <<'EOF';
365 <p class="style2">-help</p>
367 With <span class="style2">-help</span> execute will print a longer help message.
370 $help_hash{-nm_version} = <<'EOF';
371 <p class="style2">-nm_version='integer'</p>
373 If you have more than one installation of NONMEM you can choose
374 between them using the <span class="style2">-nm_version</span> option. The installations must be
375 specified in the psn.conf file. The default value is 5.
378 $help_hash{-threads} = <<'EOF';
379 <p class="style2">-threads='integer'</p>
381 Use the threads option to enable parallel execution of multiple
382 NONMEM runs. On a desktop computer it is recommended to set
383 <span class="style2">-threads</span> to the number of CPUs in the system plus one. You can
384 specify more threads, but it will probably not increase the
385 performance. If you are running on a computer cluster, you should
386 consult your systems administrator to find out how many threads
387 you can specify. The <span class="style2">-threads</span> option will be ignored if you run on
388 a grid system, since gridshave ther own scheduling algoritms. The
389 default value for the <span class="style2">-threads</span> option is 1.
392 $help_hash{-nice} = <<'EOF';
393 <p class="style2">-nice='integer'</p>
395 This option only has effect on unix like operating systems. It
396 sets the priority (or nice value) on a process. You can give any
397 value that is legal for the "nice" command, likely it is between 0
398 and 19, where 0 is the highest priority. Check "man nice" for
399 details.
402 $help_hash{-directory} = <<'EOF';
403 <p class="style2">-directory='string'</p>
405 The directory option sets the directory in which execute will run
406 NONMEM. The default directory name is 'modelfit_dirX' where X will
407 be increased by one each time you run the execute utility. You do
408 not have to create the directory, it will be done for you.
410 If you abort execute or if your system crashes you can use the
411 '<span class="style2">-directory</span>' option set to the directory of the execute run that
412 crashed. Execute will then not run the modelfiles that had
413 finished before the crash, thereby saving some time. Notice that
414 is important that you give exactly the same options that you gave
415 the first time.
418 $help_hash{-drop_dropped} = <<'EOF';
419 <p class="style2">-drop_dropped</p>
421 If there are drop columns in your control file and <span class="style2">-drop_dropped</span>
422 is used, PsN will remove those columns from the data set used
423 internally. It saves both diskspace and conserves memory
424 usage. Note that PsN does NOT alter your original data set, only
425 those used internally in PsN.
428 $help_hash{-extra_data_files} = <<'EOF';
429 <p class="style2">-extra_data_files='extra_data1.dta, COLUMN1, COLUMN2'</p>
431 NONMEM only allows 20 column datasets, but PsN can add code to
432 control files that reads extra data columns from a separate
433 file. To use this feature you must create a new data file which
434 has the same ID row as the main data file. Then you specify a
435 comma separated list with <span class="style2">-extra_data_files</span>. The first element
436 in the list is the filename and the rest of the list is the header
437 of the extra data file. You can have multiple extra files if neccesary.
440 $help_hash{-extra_files} = <<'EOF';
441 <p class="style2">-extra_files='extra_file1.dta, extra_file2.dta'</p>
443 If you need extra files in the directory where NONMEM is run you
444 specify them in list to the <span class="style2">-extra_files</span> list. It could for
445 example be fortran subroutines you need compiled with NONMEM.
448 $help_hash{-handle_maxevals} = <<'EOF';
449 <p class="style2">-handle_maxevals='number'</p>
451 NONMEM only allows 9999 function evaluations. PsN can expand this
452 limit by adding an MSFO option to $ESTIMATION, later when NONMEM
453 hits the max number of function evaluations(9999) PsN will remove
454 intial estimates from the modelfile and add $MSFI and restart
455 NONMEM. PsN will do this until the number of evaluations specified
456 with <span class="style2">-handle_maxevals</span> is reached.
459 $help_hash{-seed} = <<'EOF';
460 <p class="style2">-seed='string'</p>
462 If you use the <span class="style2">-retries='integer'</span> option, execute will use a
463 random number to create new intial estimates for the model
464 parameters. To make sure that the same result is produced if you
465 redo the same run, you can set your own random seed with the <span class="style2">-seed</span>
466 option.
470 $help_hash{'-summarize|summary'} = <<'EOF';
471 <p><span class="style2">-summarize</span> or <span class="style2">-summary</span></p>
473 <span class="style2">summarize</span> or <span class="style2">-summary</span> will do a set of diagnostics test
474 and print minimization message for each model run.
477 $help_hash{-verbose} = <<'EOF';
478 <p class="style2">-verbose</p>
480 With <span class="style2">verbose</span> set to 1, PsN will print
481 more details about NONMEM runs. More precisely PsN will print the
482 minimization message for each successfull run and a R:X for each
483 retry PsN makes of a failed run, where X is the run number.
486 $help_hash{-wrap_data} = <<'EOF';
487 <p class="style2">-wrap_data</p>
489 NONMEM only allows 20 column datasets, but it is possible to wrap
490 observation lines into multiple rows by adding a CONT column. With
491 <span class="style2">wrap_data</span> PsN does it automatically.
494 $help_hash{-lsf_job_name} = <<'EOF';
495 <p class="style2">-lsf_job_name='string'</p>
497 <span class="style2">lsf_job_name</span> sets the name of the LSF job name of every NONMEM run,
498 they all get the same name.
501 $help_hash{-lsf_options} = <<'EOF';
502 <p class="style2">-lsf_options='string'</p>
504 LSF jobs are submitted using bsub and all LSF related options are
505 translated to corresponding bsub options. For maximum flexibility
506 we allow any string to be passed as options to bsub, so if a specific
507 bsub feature not available through any ot the other -lsf_ options
508 is needed, use <span class="style2">lsf_options</span> to pass any option to bsub.
511 $help_hash{-lsf_project_name} = <<'EOF';
512 <p class="style2">-lsf_project_name='string'</p>
514 Use <span class="style2">lsf_project_name</span> to assign a
515 project name to your LSF runs.
518 $help_hash{-lsf_resources} = <<'EOF';
519 <p class="style2">-lsf_resources='string'</p>
521 <span class="style2">lsf_resources</span> specifies which LSF resources is required when submiting
522 NONMEM runs.
525 $help_hash{-lsf_ttl} = <<'EOF';
526 <p class="style2">-lsf_ttl='string'</p>
528 <span class="style2">lsf_ttl</span> sets the maximum time a NONMEM run should be allowed to run on
529 the LSF grid.
532 $help_hash{-lsf_queue} = <<'EOF';
533 <p class="style2">-lsf_queue='string'</p>
535 <span class="style2">lsf_queue</span> specifies which LSF queue PsN should submit NONMEM runs
536 to and is used in conjuction with <span class="style2">-run_on_lsf</span>
539 $help_hash{-min_retries} = <<'EOF';
540 <p class="style2">-min_retries='string'</p>
542 <span class="style2">min_retries</span> forces the PsN to try
543 several initial values for each estimate and selecting the best
544 one. The best model is chosen in the following maner: if <span class="style2">-picky</span>
545 is used the model must pass the picky test. Then the one with
546 highest number of significant digits and an ofv value no more than
547 five units above than the lowest ofv value among all models.
550 $help_hash{-clean} = <<'EOF';
551 <p class="style2">-clean</p>
553 The <span class="style2">-clean</span> clean option can take four different values:
554 0 - means that nothing is removed, 1 - NONMEM intermediate files and binary is removed (this is the default),
555 2 - model and output files generated by PsN restarts are removed, 3 - the wholde NM_run directory is removed
556 and if it is not an "execute" command, all modelfit_dir's will be removed.
559 $help_hash{-missing_data_token} = <<'EOF';
560 <p class="style2">-missing_data_token='string'</p>
562 <span class="style2">missing_data_token</span> sets the string
563 that PsN accepts as missing data, default is -99.
566 $help_hash{-nm_directory} = <<'EOF';
567 <p class="style2">-nm_directory='string'</p>
569 The argument of <span class="style2">nm_directory</span> is
570 directory where NONMEM is installed. Normally its easiest to setup
571 a version in psn.conf and use <span class="style2">-nm_version</span> to access it.
574 $help_hash{-no_remote_compile} = <<'EOF';
575 <p class="style2">-no_remote_compile</p>
577 When running on LSF it is no guaranteed that NONMEM is available
578 on the computing node, then <span class="style2">-no_remote_compile</span> allows you to compile
579 NONMEM localy and only submit the NONMEM executable to the grid.
582 $help_hash{-no_remote_execution} = <<'EOF';
583 <p class="style2">-no_remote_execution</p>
585 <span class="style2">no_remote_execution</span> prohibits execution on the LSF grid. Used together
586 with <span class="style2">-no_remote_compile</span> it cancels out <span class="style2">-run_on_lsf</span>
589 $help_hash{-compress} = <<'EOF';
590 <p class="style2">-compress</p>
592 The execute utility will compress the contents of 'NM_runX' to the
593 file 'nonmem_files.tgz' if the <span class="style2">-compress</span> option is used and if you
594 have the archive and compress programs <strong>tar</strong> and <strong>gzip</strong> installed. If
595 you use the <span class="style2">-clean</span> options, run files will be
596 removed before the compression. The <span class="style2">-compress</span> option obviously has
597 no effect if you also use the <span class="style2">-clean</span> option.
600 $help_hash{-tweak_inits} = <<'EOF';
601 <p class="style2">-tweak_inits</p>
603 <!--/>If NONMEM terminates nonsuccessfully, PsN can perturb the initial
604 estimates and run NONMEM again. The generation of new initial
605 estimates init_i for the i:th retry are performed according to
607 init_i = init_0 + rand_uniform(+-0.1*i*init_0)
609 where init_0 are the initial estimates of the original run. The
610 updating procedure makes sure that boundary conditions on the
611 parameters are still valid. For this option to have effect, the
612 -retries option must be set to number larger than zero. The
613 default setting uses tweak_inits.<-->
614 <?php print '<p> If NONMEM terminates nonsuccessfully, PsN can perturb the initial estimates and run NONMEM again. The generation of new initial estimates <img src="images/init1.gif"> for the <em>i</em>:th retry are performed according to</p><p align="center"><img src="images/perturb1.gif" width="236" height="32"></p> <p>where <img src="images/init_orig1.gif" width="29" height="28"> are the initial estimates of the original run. The updating procedure makes sure that boundary conditions on the parameters are still valid. For this option to be valid, the <span class="style2">-retries</span> option must be set to a number larger than zero. The default setting uses tweak_inits. </p>'; ?>
617 $help_hash{-outputfile} = <<'EOF';
618 <p class="style2">-outputfile</p>
620 The <span class="style2">-outputfile</span> option specifies the output file name for the
621 NONMEM run. Currently This option is only valid when a single
622 model is supplied to the execute utility.
625 $help_hash{-picky} = <<'EOF';
626 <p class="style2">-picky</p>
628 The <span class="style2">-picky</span> option is only valid together with <span class="style2">-tweak_inits</span>.
629 Normally PsN only tries new initial estimates if
630 '<span class="style2">MINIMZATION SUCCESSFUL</span>' is not found in the NONMEM output
631 file. With the <span class="style2">-picky</span> option, PsN will regard any of the
632 following messages as a signal for rerunning:
633 <p class="style2">
634 0ESTIMATE OF THETA IS NEAR THE BOUNDARY<br>
635 0PARAMETER ESTIMATE IS NEAR ITS BOUNDARY<br>
636 0R MATRIX ALGORITHMICALLY SINGULAR<br>
637 0S MATRIX ALGORITHMICALLY SINGULAR</p>
640 $help_hash{'-quick_summarize|quick_summary'} = <<'EOF';
641 <p><span class="style2">-quick_summarize</span> or <span class="style2">-quick_summary</span></p>
643 If either of <span class="style2">quick_summarize</span> and <span class="style2">quick_summary</span> is used, PsN will print
644 the ofv value and minimization message for each NONMEM run.
647 $help_hash{-rerun} = <<'EOF';
648 <p class="style2">-rerun</p>
650 PsN can redo or resume a run using information in PsN run
651 directory(see documentation for <span class="style2">-directory</span>). It is called
652 a rerun. During a rerun PsN will consider to redo parts of
653 the run. With the <span class="style2">-rerun</span> option you can control which parts
654 will be redone. The default value of <span class="style2">-rerun</span> is 1.
655 With rerun set to 1 PsN will rerun any model with a missing
656 list file. Notice that every "retry" (see the documentation
657 for <span class="style2">-retries</span> and <span class="style2">-min_retries</span>) will be considered for a rerun.
658 This means you can change the value of the <span class="style2">-retries</span> and
659 <span class="style2">-min_retries</span> options if you like more or less retries.
660 Setting <span class="style2">-rerun</span> to 0 means that PsN will not check for
661 missing or incomplete "retry" list files. This is usefull
662 if you have one or more run modelfiles and you wish to have
663 a PsN raw_results file or a PsN summary, you do a "execute"
664 run with them as arguments and specify <span class="style2">-rerun=0</span>, PsN will not
665 do any NONMEM run, but produce usefull output summary.
666 You can also set <span class="style2">-rerun</span> to 2, and PsN will ignore any existing
667 list files and rerun everything, creating raw_results and
668 summaries from the new listfiles.
671 $help_hash{-run_on_lsf} = <<'EOF';
672 <p class="style2">-run_on_lsf</p>
674 PsN connects with Platform Load Sharing Facility (LsF). With
675 <span class="style2">-run_on_lsf</span>. PsN will submit to the queue defined in "psn.conf"
676 unless specified with <span class="style2">-lsf_queue</span>.
679 $help_hash{-run_on_ud} = <<'EOF';
680 <p class="style2">-run_on_ud</p>
682 PsN connects with United Devices Grid MP. With <span class="style2">-run_on_ud</span> PsN will submit to the UD grid
683 with parameters defined in the "uduserconf" file.
686 $help_hash{-retries} = <<'EOF';
687 <p class="style2">-retries='integer'</p>
689 The <span class="style2">-retries</span> option tells the execute utility how many times it
690 shall try to rerun a NONMEM job if it fails according to given criterias.. In
691 the current version of PsN (2.2), the <span class="style2">-retries</span> option is only
692 valid together with <span class="style2">-tweak_inits</span>. The default value of the
693 <span class="style2">-retries</span> option is 6.
696 $help_hash{-crash_restarts} = <<'EOF';
697 <p class="style2">-crash_restarts='integer'</p>
699 If a NONMEM outputfile is produced but PsN is unable to read it
700 properly it is assumed that NONMEM crashed, probably due to
701 something in the operating system, and PsN will start the run
702 again. But PsN will not consider it a retry and will not change
703 initial estimates. The default value is 4.
705 $help_hash{-significant_digits_rerun} = <<'EOF';
706 <p class="style2">-significant_digits_rerun='number'</p>
708 The <span class="style2">-picky</span> option is only valid together with <span class="style2">-tweak_inits</span>.
709 Normally PsN only tries new initial estimates if
710 '<span class="style2">MINIMZATION SUCCESSFUL</span>' is not found in the NONMEM output
711 file. With the <span class="style2">-significant_digits_rerun</span>, PsN will rerun if
712 the resulting significant digits is lower than the value
713 specified with this option.
716 $help_hash{-abort_on_fail} = <<'EOF';
717 <p class="style2">-abort_on_fail</p>
719 If the <span class="style2">-abort_on_fail</span> option is set and one of the NONMEM runs
720 fails, execute will stop scheduling more runs and try to stop
721 those that are currently running. A run is considered failed if it
722 fails to produce a list file which PsN can read. This can occure
723 if a nonmem run crashes or gets killed.
726 $help_hash{-adaptive} = <<'EOF';
727 <p class="style2">-adaptive</p>
729 <span class="style2">-adaptive</span> enables a highly experimental feature to dynamically
730 assign the number of threads depending on the number of running
731 nonmem processes on the computer. It requires a server program
732 which is not distributed with PsN. If you are interrested in this
733 feature, contact the PsN developers.
736 $help_hash{-run_on_nordugrid} = <<'EOF';
737 <p class="style2">-run_on_nordugrid</p>
739 !! Currently only valid for Linux system !!
740 execute will run on nordugrid clusters listed in ~/.ng_cluster .
741 If you do not know about Nordugrid, you can safely ignore this option.
742 Read more on http://www.nordugrid.org
745 $help_hash{-cpu_time} = <<'EOF';
746 <p class="style2">-cpu_time='integer'</p>
748 !! Currently only valid for Linux system !!
749 This option specifies the number of minutes allocated for a
750 gridjob. The default value is 120 minutes. This option is only
751 valid together with the <span class="style2">-run_on_nordugrid</span> option.
754 $help_hash{-grid_batch_size} = <<'EOF';
755 <p class="style2">-grid_batch_size='integer'</p>
757 This option specifies the number of nonmem runs that will be
758 grouped together into one grid job. The default number is 5. This
759 option is only valid together with the '<span class="style2">-run_on_nordugrid'</span> option.
762 $help_hash{-silent} = <<'EOF';
763 <p class="style2">-silent</p>
765 The silent option turns off all output from PsN. Results and log
766 files are still written to disk, but nothing is printed to the
767 screen.
770 $help_hash{-debug} = <<'EOF';
771 <p class="style2">-debug='integer'</p>
773 The <span class="style2">-debug</span> option is mainly intended for developers who whish to
774 debug PsN. By default <span class="style2">-debug</span> is set to zero but you can try
775 setting it to '1' to enable warning messages. If you run in to
776 problems that require support, you may have to increase this
777 number to 2 or 3 and send the output to us.
780 $help_hash{-debug_package} = <<'EOF';
781 <p class="style2">-debug_package='string'</p>
783 When used together with <span class="style2">-debug</span>, the <span class="style2">-debug_package</span> option makes is
784 possible to choose which part of PsN you want to see debug
785 messages for. Again, this option is mostly for developers.
788 $help_hash{-debug_subroutine} = <<'EOF';
789 <p class="style2">-debug_subroutine='string'</p>
791 Default value is: empty string
793 With this option it is possible to specify, with even finer
794 granularity, which part of PsN you want to see debug messages
795 from. This is definitly only for developers.
798 $help_hash{-warn_with_trace} = <<'EOF';
799 <p class="style2">-warn_with_trace</p>
801 If the <span class="style2">-debug</span> level is bigger than zero PsN will print warning
802 messages. If <span class="style2">-warn_with_trace</span> is set, PsN will print a stack
803 trace from the point where the warning message was printed.
804 This is definitly only for developers.
808 $help_hash{-sde} = <<'EOF';
809 <p class="style2">-sde</p>
811 If you are running SDE models, you must use this option, otherwise
812 PsN will destroy the formatting of the models, and the NONMEM runs
813 will fail.
816 $help_hash{'-h'} = $help_hash{'-?'};
819 if( defined $help_text ){
820 %help_hash = %{$help_text};
823 if( $options{'version'} ){
824 print "PsN version: $PsN::version\n";
825 exit;
828 my $help;
830 if($options{'h'} or $options{'?'} or $options{'help'} ) {
832 if( $options{'html_help'} ){
834 open(EXAMPLES, '>', 'html/' . $command . '_examples.php' );
835 print EXAMPLES $help_hash{Examples};
836 close( EXAMPLES );
838 open(SYNOPSIS, '>', 'html/' . $command . '_synopsis.php' );
839 print SYNOPSIS $help_hash{Pre_help_message},"\n";
840 print SYNOPSIS "<h3 class=\"heading1\">Synopsis</h3>\n";
841 print SYNOPSIS "<span class=\"option\">\n";
842 print SYNOPSIS "<pre>$command " . common_options::print_help($command,$required_options, $optional_options)."\n</pre></span>\n" ;
843 close( SYNOPSIS );
845 open(OPTIONS, '>', 'html/' . $command . '_options.php' );
846 my $opt_help;
848 if( $command eq 'execute' ){
849 @loop_array = @get_opt_strings;
850 } else {
851 @loop_array = (sort(keys %{$required_options}), sort(keys %{$optional_options}));
854 foreach my $option( @loop_array ){
855 #foreach my $option(keys %help_hash){
856 $option =~ s/[^\w]*$|:.*//;
857 if( exists $help_hash{'-'.$option}){
858 $opt_help .= $help_hash{'-'.$option}."\n\n";
859 } else {
860 $opt_help .= " <p class=\"option\">-$option</p> <p>No help available for '$option'</p>";
863 print OPTIONS $help_hash{Options} . $opt_help;
864 close( OPTIONS );
866 open(DESC, '>', 'html/' . $command . '_description.php' );
867 print DESC $help_hash{Description};
868 close( DESC );
870 exit;
871 } else {
873 if( scalar( @ARGV ) > 0 ){
874 foreach my $option ( @ARGV ){
876 if( exists $help_hash{'-'.$option} ){
877 $help .= "\n".$help_hash{'-'.$option}. "\n";
878 } else {
879 $help .= "\nNo help available for '$option'\n\n";
883 $help =~ s/<\?.*\?>//g;
884 $help =~ s/<[^>]*>//g;
885 print $help;
886 exit;
889 $help .= "\n" . $help_hash{Pre_help_message} . "\n";
890 $help .= "\t$command ";
891 $help .= common_options::print_help($command,$required_options, $optional_options);
894 if( $options{'help'} ){
896 $help .= "\n\n".$help_hash{Description}."\n\n";
897 $help .= $help_hash{Examples}."\n\n";
898 $help .= $help_hash{Options}."\n\n";
900 my @loop_array;
902 if( $command eq 'execute' ){
903 @loop_array = @get_opt_strings;
904 } else {
905 @loop_array = (sort(keys %{$required_options}), sort(keys %{$optional_options}));
908 foreach my $option( @loop_array ){
909 #print "special case: $option\n" if ( $option =~ /\W+$|:.*/ );
910 $option =~ s/[^\w]*$|:.*//;
911 #$option = '-'.$option unless( $option =~ /^-/ );
912 if( exists $help_hash{'-'.$option}){
913 $help .= $help_hash{'-'.$option}."\n\n";
914 } else {
915 $help .= " -$option\n\n No help available for '$option'\n\n\n";
919 $help .= $help_hash{Post_help_message} . "\n";
921 } else {
922 $help .= "\n Use '$command -help' for a longer desctription.\n\n";
925 $help =~ s/<\?.*\?>//g;
926 $help =~ s/<[^>]*>//g;
927 print $help;
929 exit;