6 # Don't edit the line below, it must look exactly like this.
7 # Everything above this line will be replaced #
17 $options{'precision'} = 4;
19 my $opts = { "h|?" => $options{'help'},
20 "help" => $options{'long_help'},
21 "debug:0" => $options{'debug'},
22 "debug_package:s" => $options{'debug_package'},
23 "debug_subroutine:s" => $options{'debug_subroutine'},
24 "compact_format:1" => $options{'compact_format'},
25 "csv" => $options{'csv'},
26 "precision:4" => $options{'precision'},
27 "confidence_interval" => $options{'confidence_interval'},
28 "c_level:95" => $options{'c_level'} };
31 my $res = GetOptions( \%options, %{$opts} );
35 if ( scalar( @ARGV ) < 1 and !($options{'help'} or $options{'long_help'}) ){
36 print "At least one list file must be specified. Use 'sumo.pl -h' for help.\n";
41 if($options{'help'} or $options{'long_help'}) {
46 Perl script for summarizing output data.
50 sumo.pl [ -h | -? ] [ -help ]
52 [ -debug_package='string' ]
53 [ -debug_subroutine='string' ]
58 if( $options{'long_help'} and !$options{'help'} ){
64 Sumo is short for SUmmarize Output. And it does exactly that. It
65 gathers some usefull information from NONMEM ouputfiles and prints
70 Get summary from an output file:
76 The following options are valid:
80 Print a list of options.
85 Print this, longer, help message.
92 This is mainly for developers who whish to debug PsN. By default
93 'integer' is zero but you can try setting it to '1' and you might
94 get some helpfull warnings. If you run in to problems that require
95 support, you might be told to crank this number up and send the
99 -debug_package='string'
101 Default value is: empty string
103 If use together with '-debug' it is possible to choose which part
104 of PsN you want to see debug messages from. Again this is mostly
108 -debug_subroutine='string'
110 Default value is: empty string
112 With this option it is possible to specify, with even finer
113 granularity, which part of PsN you want to see debug messages
114 from. This is definitly only for developers.
121 debug
-> level
( $options{'debug'} );
122 debug
-> package( $options{'debug_package'} );
123 debug
-> subroutine
( $options{'debug_subroutine'} );
125 my $form = '%.' . $options{'precision'} . 'g';
127 my $outfile = $ARGV[0];
129 my $outobj = output
-> new
('filename'=> $outfile);
132 my @output_matrix_sizes;
134 my %c_levels = ( '90' => 1.6449,
139 if( $options{'confidence_interval'} ) {
140 if( not defined $c_levels{$options{'c_level'}} ) {
141 die "Sorry, confidence intervals for level ".$options{'c_level'}.
142 " can not be output. Valid levels are: ".join(',', keys %c_levels).
148 #print Dumper( $outobj );
150 print "$outfile\n\n";
152 for( my $problems = 0; $problems <= $#{$outobj -> problems}; $problems++){
154 for( my $sub_problems = 0; $sub_problems <= $#{$outobj -> problems -> [$problems] -> subproblems}; $sub_problems++){
156 my ( %nam, %est, %cest, %ses );
157 my @thetas = defined $outobj -> thetas
-> [$problems][$sub_problems] ? @
{$outobj -> thetas
-> [$problems][$sub_problems]} : ();
158 my @thnam = defined $outobj -> thetanames
-> [$problems] ? @
{$outobj -> thetanames
-> [$problems]} : ();
159 my @sethet = defined $outobj -> sethetas
-> [$problems][$sub_problems] ? @
{$outobj -> sethetas
-> [$problems][$sub_problems]} : ();
160 $nam{'theta'} = \
@thnam;
161 $est{'theta'} = \
@thetas;
162 $ses{'theta'} = \
@sethet;
165 my @omegas = defined $outobj -> omegas
-> [$problems][$sub_problems] ? @
{$outobj -> omegas
-> [$problems][$sub_problems]} : ();
166 my @comegas = defined $outobj -> comegas
-> [$problems][$sub_problems] ? @
{$outobj -> comegas
-> [$problems][$sub_problems]} : ();
167 my @omnam = defined $outobj -> omeganames
-> [$problems] ? @
{$outobj -> omeganames
-> [$problems]} : ();
168 my @seomeg = defined $outobj -> seomegas
-> [$problems][$sub_problems] ? @
{$outobj -> seomegas
-> [$problems][$sub_problems]} : ();
169 $nam{'omega'} = \
@omnam;
170 $est{'omega'} = \
@omegas;
171 $cest{'omega'} = \
@comegas;
172 $ses{'omega'} = \
@seomeg;
174 my @sigmas = defined $outobj -> sigmas
-> [$problems][$sub_problems] ? @
{$outobj -> sigmas
-> [$problems][$sub_problems]} : ();
175 my @csigmas = defined $outobj -> csigmas
-> [$problems][$sub_problems] ? @
{$outobj -> csigmas
-> [$problems][$sub_problems]} : ();
176 my @signam = defined $outobj -> sigmanames
-> [$problems] ? @
{$outobj -> sigmanames
-> [$problems]} : ();
177 my @sesigm = defined $outobj -> sesigmas
-> [$problems][$sub_problems] ? @
{$outobj -> sesigmas
-> [$problems][$sub_problems]} : ();
178 $nam{'sigma'} = \
@signam;
179 $est{'sigma'} = \
@sigmas;
180 $cest{'sigma'} = \
@csigmas;
181 $ses{'sigma'} = \
@sesigm;
183 my $ofv = $outobj -> ofv
-> [$problems][$sub_problems];
184 my $termess= $outobj -> minimization_message
-> [$problems][$sub_problems];
187 print join( "",@
{$termess} ), "\n";
190 if ( defined $ofv ) {
191 print "Objective function value: ",$ofv,"\n\n";
193 print "Objective function value: UNDEFINED\n\n";
202 @cvsethet = @
{$outobj -> cvsethetas
-> [$problems][$sub_problems]};
203 @cvseomeg = @
{$outobj -> cvseomegas
-> [$problems][$sub_problems]};
204 @cvsesigm = @
{$outobj -> cvsesigmas
-> [$problems][$sub_problems]};
208 push( @
{$output_matrix[$row_counter]}, "","THETA","","","OMEGA","","","SIGMA", "" );
209 for( my $i = 0; $i <= $#{$output_matrix[$row_counter]}; $i++ ){
210 if( $output_matrix_sizes[$i] < length( $output_matrix[$row_counter][$i] ) ){
211 $output_matrix_sizes[$i] = length( $output_matrix[$row_counter][$i] );
216 #printf "%-4s %-29s %-29s %-18s\n"," ","THETA","OMEGA","SIGMA";
218 my $max_par = $#thetas;
219 $max_par = $#omegas if ( $#omegas > $max_par );
220 $max_par = $#sigmas if ( $#sigmas > $max_par );
222 for ( my $i = 0; $i <= $max_par; $i++ ) {
224 if( $options{'confidence_interval'} ) {
225 foreach my $param ( 'theta', 'omega', 'sigma' ) {
226 if ( defined $est{$param}[$i] ) {
227 my $diff = $c_levels{$options{'c_level'}}*$ses{$param}[$i];
229 if( defined $diff ) {
230 $lo = $est{$param}[$i]-$diff;
231 $up = $est{$param}[$i]+$diff;
233 my $cis = sprintf( "($form - $form)", $lo, $up );
234 push( @row, $nam{$param}[$i],
235 sprintf( $form, $est{$param}[$i] ),
238 push( @row, '','','' );
242 if ( defined $thnam[$i] ) {
243 push( @row, $thnam[$i], defined $thetas[$i] ?
sprintf( $form, $thetas[$i] ) : '........',
244 $cvsethet[$i] ?
sprintf( "($form)", $cvsethet[$i] ) : '(........)' );
246 push( @row, '','','' );
248 if ( defined $omnam[$i] ) {
249 push( @row, $omnam[$i], defined $comegas[$i] ?
sprintf( $form, $comegas[$i] ) : '........' ,
250 $cvseomeg[$i] ?
sprintf( "($form)", $cvseomeg[$i] ) : '(........)' );
252 push( @row, '','','');
254 if ( defined $signam[$i] ) {
255 push( @row, $signam[$i], defined $sigmas[$i] ?
sprintf( $form, $sigmas[$i] ) : '........',
256 $cvsesigm[$i] ?
sprintf( "($form)", $cvsesigm[$i] ) : '(........)' );
258 push( @row, '','','');
262 push(@
{$output_matrix[$row_counter]}, @row);
263 for( my $i = 0; $i <= $#{$output_matrix[$row_counter]}; $i++ ){
264 if( $output_matrix_sizes[$i] < length( $output_matrix[$row_counter][$i] ) ){
265 $output_matrix_sizes[$i] = length( $output_matrix[$row_counter][$i] );
274 #for( my $j = 0; $j <= $#output_matrix; $j++ ){
275 # for( my $i = 0; $i <= $#{$output_matrix[$j]}; $i++ ){
276 # if( $output_matrix_sizes[$i] < length( $output_matrix[$j][$i] ) ){
277 # $output_matrix_sizes[$i] = length( $output_matrix[$j][$i] );
282 foreach my $row ( @output_matrix ){
283 for( my $i = 0; $i <= $#{$row}; $i++ ){
284 my $spaces = $output_matrix_sizes[$i] - length($row -> [$i]);
285 if( $options{'csv'} ){
286 print $row -> [$i], ",";
288 print " " x
$spaces, $row -> [$i], " ";
303 # push(@plist,shift @thnam);
312 # push(@plist,shift @thetas);
321 # push(@plist,"(".(sprintf "%.3g",shift @cvsethet).")");
325 # push @plist," " and $f.="%-12s ";
328 # if ( defined $omegas[0] ) {
330 # # push(@om_str,shift @omnam);
334 # # push(@om_str," ");
339 # # my ( $omega, @om_str );
341 # # $omega = shift( @omegas );
342 # # unless( defined $omega and not $compact_format){
343 # # push( @om_str, "NaN" );
345 # # } elsif ( $omega != 0 or not $compact_format ) {
346 # # push(@om_str,$omega);
351 # # push(@plist," ");
356 # # my $cvseomega = shift( @cvseomeg );
357 # # if ( $omega != 0 ) {
358 # # push(@plist,"(".(sprintf "%.3g",$cvseomega).")");
363 # # push(@plist," ");
368 # push(@plist,shift @signam);
377 # push(@plist,shift @sigmas);
386 # push(@plist,"(".(sprintf "%.3g",shift @cvsesigm).")");