6 # Don't edit the line below, it must look exactly like this.
7 # Everything above this line will be replaced #
17 my $cmd_line = $0 . " " . join( " ", @ARGV );
19 ## Configure the command line parsing
20 Getopt::Long::config("auto_abbrev");
23 ## Declare the options
25 my %required_options = ( 'samples:i' => '200');
26 #my %optional_options = ( 'alternative_models:s' => 'alt1.mod,alt2.mod,...',
27 # 'ref_ofv:i' => '500',
28 # 'estimate_simulation!' => '1' );
30 my %optional_options = ("etas:i"=>'',
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 );
41 common_options::get_defaults( \%options, 'nonpb' );
42 common_options::sanity_checks( \%options, 'nonpb' );
46 $help_text{Pre_help_message} = <<'EOF';
49 Perl script for Non-Parametric Bootstrap.
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 -? nonpb will print a list of options and exit.
72 $help_text{-help
} = <<'EOF';
75 With -help nonpb will print this, longer, help message.
78 $help_text{-samples
} = <<'EOF';
81 Required option. The number of samples for the bootstrap.
85 $help_text{-etas
} = <<'EOF';
88 Optional, the number of ETAs (starting with ETA1) for which the
89 nonp_bootstrap should be run. Default is all ETAs.
93 $help_text{-lst
} = <<'EOF';
96 Optional, the lst-file from where to read initial parameter estimates.
97 Default is the same name as the model file but with .mod replaced with .lst.
101 $help_text{Post_help_message
} = <<'EOF';
102 Also see 'execute -help' for a description of common options.
105 common_options
::online_help
( 'nonpb', \
%options, \
%help_text, \
%required_options, \
%optional_options);
107 ## Check that we do have a model file
108 if ( scalar(@ARGV) < 1 ) {
109 print "A simulation model file must be specified. Use 'nonpb -h' for help.\n";
113 if( scalar(@ARGV) > 1 ){
114 print "NONPB can only handle one modelfile, you listed: ",
115 join(',',@ARGV),". Use 'nonpb -h' for help.\n";die;
120 if (defined $options{'lst'}){
121 $lst_file=$options{'lst'};
123 #assume modelfile ends with .mod
124 $lst_file = (substr ($ARGV[0],0,-3)).'lst'; #keep from beginning, skip last four characters
125 unless ( -e
$lst_file ){
126 print "When option -lst is omitted, the name of the lst-file is assumed to be the same\n".
127 "as the modelfile except that the last three letters are lst. Cannot find file $lst_file\.";
132 #unless ( defined $options{'clean'} ){
133 # Clean may be changed by default
134 # $options{'clean'} = 1;
137 ui
-> category
( 'nonpb' );
138 ui
-> silent
(1) if( $options{'silent'} );
140 debug
-> level
( $options{'debug'} );
141 debug
-> package( $options{'debug_package'} );
142 debug
-> subroutine
( $options{'debug_subroutine'} );
143 debug
-> warn_with_trace
( $options{'warn_with_trace'} );
145 my $eval_string = common_options
::model_parameters
(\
%options);
147 my $model = model
-> new
( eval( $eval_string ),
148 filename
=> $ARGV[0],
149 ignore_missing_output_files
=> 1 );
151 my $nonpb = tool
::nonpb
->
152 new
( eval( $common_options::parameters
),
154 lst_file
=> $lst_file,
155 samples
=> $options{'samples'},
156 etas
=> $options{'etas'});
159 open(CMD
, ">", $nonpb -> directory
. "/command.txt");
160 print CMD
$cmd_line, "\n";
163 unless( -d
$nonpb -> directory
. "/intermediate_files" ){
164 mkdir( $nonpb -> directory
. "/intermediate_files" );
166 unless( -d
$nonpb -> directory
. "/result_files" ){
167 mkdir( $nonpb -> directory
. "/result_files" );
170 #this is sec 1 and 2 of URS nonp_bootstrap_v2
171 #individual step 1a,1b,2a done by bootstrap tool, can simply collect results
172 #from bootstrap object
176 ##do the bootstrap in a specific sub-directory of nonpb_dirY : 'bootstrap'
177 #must carry a whole hash of options here, can lump them together according to Pontus, how???.
178 #ask Pontus about not having to list all options
180 chdir( $nonpb -> directory
);
181 my $type = defined $options{'bca'} ?
'bca' : undef;
182 my $bs = tool
::bootstrap
->
183 new
( eval( $common_options::parameters
),
184 directory
=> 'bootstrap',
185 models
=> [ $model ],
186 samples
=> $options{'samples'}
187 #the hash!!! Ask Pontus....
190 $bs -> prepare_results
();
191 $bs -> print_results
();
193 #Does this work? I set model array here and not in 'new' since
194 #must have bootstrap model array first. Want to have
195 #nonpb directory before running bootstrap, therefore do new nonpb before bootstrap
196 #use function here instead of assignment???
197 $nonpb -> {'start_bs_models'} = $bs -> {'prepared_models'}[0]{'own'}; #bara referens?
203 #open( TMP, ">", 'ofv.done' );
208 #$nonpb -> prepare_results;
209 #$nonpb -> print_results;