6 # Don't edit the line below, it must look exactly like this.
7 # Everything above this line will be replaced #
18 my $cmd_line = $0 . " " . join( " ", @ARGV );
20 ## Configure the command line parsing
21 Getopt::Long::config("auto_abbrev");
24 ## Declare the options
26 my %required_options = ('samples:i' => 'N' );
27 my %optional_options = ( 'stratify_on:s' => 'column',
28 'no_of_strata:i' => 'N',
32 'unstable_override_estimation:i' => '1');
34 my $res = GetOptions( \%options,
35 @common_options::get_opt_strings,
36 keys(%required_options),
37 keys(%optional_options) );
40 common_options::set_globals( \%options, 'npc' );
41 common_options::get_defaults( \%options, 'npc' );
42 common_options::sanity_checks( \%options, 'npc' );
46 $help_text{Pre_help_message} = <<'EOF';
49 Perl script for Numerical Predictive Check.
54 $help_text{Options
} = <<'EOF';
57 The options are given here in their long form. Any option may be
58 abbreviated to any nonconflicting prefix. The -threads option
59 may be abbreviated to -t(or even -thr) but -debug may not be
60 abbreviated to -d because it conflicts with -debug_packages and
63 The following options are valid:
66 $help_text{-h
} = <<'EOF';
69 With -h or -? npc will print a list of options and exit.
72 $help_text{-help
} = <<'EOF';
75 With -help npc will print this, longer, help message.
78 $help_text{-samples
} = <<'EOF';
81 Number of simulated datasets to generate, required.
85 $help_text{-stratify_on
} = <<'EOF';
86 -stratify_on=COLUMN_HEADER
88 Header of column to stratify on.
89 The npc will stratify the data on unique values in the specified
90 column, and perform separate analyses on each set.
93 $help_text{-no_of_strata
} = <<'EOF';
96 Only allowed together with -stratify_on.
97 An integer requesting the number of strata.
98 The number must be equal to or less than the number of unique
99 values in the stratification column.
100 If the number is smaller than the number of unique values, the
101 observations will be grouped so that the number of observations in
102 each group/strata is approximately equal.
105 $help_text{-lst
} = <<'EOF';
108 The npc will update initial parameter estimates in the model to
109 the final values in the lst-file. Optional parameter.
110 Cannot be used together with -msfo option nor with a model
111 containing a $NONPARAMETRIC record.
114 $help_text{-lst
} = <<'EOF';
117 The npc will use the NONMEM state defined in the update file.
118 Cannot be used together with -lst option.
119 If the modelfile contains a $NONPARAMETRIC record this parameter
120 is required, otherwise it is optional.
123 $help_text{-dv
} = <<'EOF';
126 Name of dependent variable.
127 Default is DV, but any variable is allowed.
128 Case sensitive, must be exactly the same case and spelling as in modelfile.
129 Maximum of 4 letters because of NONMEM limitation, unless either IPRED or IWRES.
132 #$help_text{-unstable_override_estimation} = <<'EOF';
133 # -unstable_override_estimation=1
135 # Only for advanced users.
136 # Override the safety checks of the program and refuse estimation when
137 # -dv option is used. This option has not been tested and
141 $help_text{Post_help_message
} = <<'EOF';
142 Also see 'execute -help' for a description of common options.
147 common_options
::online_help
( 'npc', \
%options, \
%help_text, \
%required_options, \
%optional_options);
149 ## Check that we do have a model file
150 if ( scalar(@ARGV) < 1 ) {
151 print "A model file must be specified. Use 'npc -h' for help.\n";
155 if( scalar(@ARGV) > 1 ){
156 print "NPC can only handle one modelfile. Check that all options begin with".
157 " '-'.\nUse 'npc -h' for help.\n";die;
161 if ( defined $options{'no_of_strata'} ){
162 unless (defined $options{'stratify_on'}){
163 die "Error: The NPC does not allow option no_of_strata unless a ".
164 "stratification column has been specified.\n";
168 if (defined $options{'msfo'}){
169 if (defined $options{'extra_files'}){
170 $options{'extra_files'} .= ','.$options{'msfo'};
172 $options{'extra_files'} = $options{'msfo'};
176 my $eval_string = common_options
::model_parameters
(\
%options);
178 my $model = model
-> new
( eval( $eval_string ),
179 filename
=> $ARGV[0],
180 ignore_missing_output_files
=> 1 ,
181 cwres
=> ($options{'dv'} eq 'CWRES'));
184 my $do_estimation = ((defined $options{'dv'}) ||
185 (defined $options{'stratify_on'} &&
186 ($options{'stratify_on'} eq 'PRED')));
188 if (defined $options{'unstable_override_estimation'} &&
189 $options{'unstable_override_estimation'} == 1 &&
190 defined $options{'dv'} &&
191 !(defined $options{'stratify_on'} &&($options{'stratify_on'} eq 'PRED'))
196 my $npc = tool
::npc
->
197 new
( eval( $common_options::parameters
),
198 models
=> [ $model ],
199 stratify_on
=> $options{'stratify_on'},
200 no_of_strata
=> $options{'no_of_strata'},
201 samples
=> $options{'samples'},
202 lst_file
=> $options{'lst'},
203 msfo_file
=> $options{'msfo'},
204 dv
=> $options{'dv'},
205 do_estimation
=> $do_estimation
208 my $restart = ( -e
$npc -> {'directory'}."/command.txt" ) ?
1 : 0;
210 open(CMD
, ">", $npc -> directory
. "/command.txt");
211 print CMD
$cmd_line, "\n";
216 $npc -> print_results
;