From 7c49fea3dc63ad1596e05b43ec38d1d486a740ef Mon Sep 17 00:00:00 2001 From: k_harling Date: Fri, 15 Feb 2008 09:07:07 +0000 Subject: [PATCH] changed input options to allow list of alternative models, or none. Removed inapplicable options --- bin/mcs | 79 ++++++++++++++++++++++++++--------------------------------------- 1 file changed, 32 insertions(+), 47 deletions(-) diff --git a/bin/mcs b/bin/mcs index 6e318e9..c9d5db4 100644 --- a/bin/mcs +++ b/bin/mcs @@ -22,10 +22,9 @@ Getopt::Long::config("auto_abbrev"); my %options; ## Declare the options -my %required_options = ( 'case_column:s' => 'column_name|column_number', - 'samples:i' => '100', - 'alternative_model:s' => 'alt.mod' ); -my %optional_options = ( "bins:i" => '', +my %required_options = ( 'samples:i' => '100'); +my %optional_options = ( 'alternative_model:s' => 'alt1.mod,alt2.mod,...', + "bins:i" => '', "selection_method:s" => '\'random\'|\'consecutive\'' ); my $res = GetOptions( \%options, @@ -39,38 +38,11 @@ my %help_text; $help_text{Pre_help_message} = <<'EOF'; mc - Perl script for Monte-carlo Simulation of Case-Deletion Diagnostics of NONMEM runs. + Perl script for Monte-Carlo Simulation of NONMEM runs. Usage: EOF -$help_text{Description} = <<'EOF'; - Description: - - The Case Deletion Diagnostics tool is run from the command line - with a few mandatory arguments. MC is run as a diagnostic after - a model is regarded finished or at least mature enough to run - validation tool on. You need to specify the NONMEM modelfile - with a model that have successful termination. You also have to - specify the number or name of the datafile column on which to - select for deletion. You do so with the case_column option. -EOF - -$help_text{Examples} = <<'EOF'; - Example: - - mc -model=run89.mod -case_column=10 - - This will perform a Case Deletion Diagnostic on the model - specified in run89.mod based on the factors in column ten. If, - for example, column ten holds the ids of the seven centers - included in the study, this command will create seven copies of - the dataset, each with individuals included in one specific - center deleted. Say that the centers are numbered 1 to 7. Then - dataset 1 will have individuals from center 1 excluded, dataset - 2 individuals from center 2 and so on. -EOF - $help_text{Options} = <<'EOF'; Options: @@ -95,6 +67,14 @@ $help_text{-help} = <<'EOF'; With -help mc will print this, longer, help message. EOF +$help_text{-alternative_model} = <<'EOF'; + -alternative_model=alt1.mod,alt2.mod,... + + List of one or more alternative models to use for estimation + with simulated datasets. The filenames must be comma-separated, + no spaces. +EOF + $help_text{-bins} = <<'EOF'; -bins=$number @@ -115,9 +95,6 @@ $help_text{-selection_method} = <<'EOF'; Default value = 'consecutive' EOF -$help_text{-case_column} = <<'EOF'; - -case_column=column_name|column_number -EOF $help_text{Post_help_message} = <<'EOF'; Also see 'execute -help' for a description of common options. @@ -136,11 +113,6 @@ if( scalar(@ARGV) > 1 ){ exit; } -unless ( defined $options{'alternative_model'} ){ - print "alternative_model must be given\n" ; - exit; -} - unless ( defined $options{'samples'} ){ print "samples must be given\n" ; exit; @@ -160,18 +132,31 @@ my $model = model -> new ( eval( $eval_string ), filename => $ARGV[0], ignore_missing_output_files => 1 ); -my $alternative_model = model -> - new ( eval( $eval_string ), - filename => $options{'alternative_model'}, - ignore_missing_output_files => 1 ); -## Create new Mc object: +my @alternatives=(); + +if ( defined $options{'alternative_model'} ){ + #split string, assume comma separated + foreach my $altfile (split(/,/,$options{'alternative_model'})){ + if (length($altfile)>0){ + my $alternative_model = model -> + new ( eval( $eval_string ),filename => $altfile,ignore_missing_output_files => 1 ); + push(@alternatives,$alternative_model); + } + } + if (scalar(@alternatives)<1){ + die "Error: Option alternative_model used, but list of filenames could not be parsed.\n"; + } +}else{ + print "No alternative model given, will only estimate original model.\n" ; + +} + my $mc = tool::mc -> new ( eval( $common_options::parameters ), models => [ $model ], - alternative_models => [ $alternative_model ], + alternative_models => \@alternatives, samples => $options{'samples'} ); - open(CMD, ">", $mc -> directory . "/command.txt"); print CMD $cmd_line, "\n"; close(CMD); -- 2.11.4.GIT