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 foreach my $outfile ( @ARGV ) {
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 if( defined $outobj -> cvsethetas
-> [$problems][$sub_problems] ) {
203 @cvsethet = @
{$outobj -> cvsethetas
-> [$problems][$sub_problems]};
205 if( defined $outobj -> cvseomegas
-> [$problems][$sub_problems] ) {
206 @cvseomeg = @
{$outobj -> cvseomegas
-> [$problems][$sub_problems]};
208 if( defined $outobj -> cvsesigmas
-> [$problems][$sub_problems] ) {
209 @cvsesigm = @
{$outobj -> cvsesigmas
-> [$problems][$sub_problems]};
214 push( @
{$output_matrix[$row_counter]}, "","THETA","","","OMEGA","","","SIGMA", "" );
215 for( my $i = 0; $i <= $#{$output_matrix[$row_counter]}; $i++ ){
216 if( $output_matrix_sizes[$i] < length( $output_matrix[$row_counter][$i] ) ){
217 $output_matrix_sizes[$i] = length( $output_matrix[$row_counter][$i] );
222 #printf "%-4s %-29s %-29s %-18s\n"," ","THETA","OMEGA","SIGMA";
224 my $max_par = $#thetas;
225 $max_par = $#omegas if ( $#omegas > $max_par );
226 $max_par = $#sigmas if ( $#sigmas > $max_par );
228 for ( my $i = 0; $i <= $max_par; $i++ ) {
230 if( $options{'confidence_interval'} ) {
231 foreach my $param ( 'theta', 'omega', 'sigma' ) {
232 if ( defined $est{$param}[$i] ) {
233 my $diff = $c_levels{$options{'c_level'}}*$ses{$param}[$i];
235 if( defined $diff ) {
236 $lo = $est{$param}[$i]-$diff;
237 $up = $est{$param}[$i]+$diff;
239 my $cis = sprintf( "($form - $form)", $lo, $up );
240 push( @row, $nam{$param}[$i],
241 sprintf( $form, $est{$param}[$i] ),
244 push( @row, '','','' );
248 if ( defined $thnam[$i] ) {
249 push( @row, $thnam[$i], defined $thetas[$i] ?
sprintf( $form, $thetas[$i] ) : '........',
250 $cvsethet[$i] ?
sprintf( "($form)", $cvsethet[$i] ) : '(........)' );
252 push( @row, '','','' );
254 if ( defined $omnam[$i] ) {
255 push( @row, $omnam[$i], defined $comegas[$i] ?
sprintf( $form, $comegas[$i] ) : '........' ,
256 $cvseomeg[$i] ?
sprintf( "($form)", $cvseomeg[$i] ) : '(........)' );
258 push( @row, '','','');
260 if ( defined $signam[$i] ) {
261 push( @row, $signam[$i], defined $sigmas[$i] ?
sprintf( $form, $sigmas[$i] ) : '........',
262 $cvsesigm[$i] ?
sprintf( "($form)", $cvsesigm[$i] ) : '(........)' );
264 push( @row, '','','');
268 push(@
{$output_matrix[$row_counter]}, @row);
269 for( my $i = 0; $i <= $#{$output_matrix[$row_counter]}; $i++ ){
270 if( $output_matrix_sizes[$i] < length( $output_matrix[$row_counter][$i] ) ){
271 $output_matrix_sizes[$i] = length( $output_matrix[$row_counter][$i] );
280 #for( my $j = 0; $j <= $#output_matrix; $j++ ){
281 # for( my $i = 0; $i <= $#{$output_matrix[$j]}; $i++ ){
282 # if( $output_matrix_sizes[$i] < length( $output_matrix[$j][$i] ) ){
283 # $output_matrix_sizes[$i] = length( $output_matrix[$j][$i] );
288 foreach my $row ( @output_matrix ){
289 for( my $i = 0; $i <= $#{$row}; $i++ ){
290 my $spaces = $output_matrix_sizes[$i] - length($row -> [$i]);
291 if( $options{'csv'} ){
292 print $row -> [$i], ",";
294 print " " x
$spaces, $row -> [$i], " ";
309 # push(@plist,shift @thnam);
318 # push(@plist,shift @thetas);
327 # push(@plist,"(".(sprintf "%.3g",shift @cvsethet).")");
331 # push @plist," " and $f.="%-12s ";
334 # if ( defined $omegas[0] ) {
336 # # push(@om_str,shift @omnam);
340 # # push(@om_str," ");
345 # # my ( $omega, @om_str );
347 # # $omega = shift( @omegas );
348 # # unless( defined $omega and not $compact_format){
349 # # push( @om_str, "NaN" );
351 # # } elsif ( $omega != 0 or not $compact_format ) {
352 # # push(@om_str,$omega);
357 # # push(@plist," ");
362 # # my $cvseomega = shift( @cvseomeg );
363 # # if ( $omega != 0 ) {
364 # # push(@plist,"(".(sprintf "%.3g",$cvseomega).")");
369 # # push(@plist," ");
374 # push(@plist,shift @signam);
383 # push(@plist,shift @sigmas);
392 # push(@plist,"(".(sprintf "%.3g",shift @cvsesigm).")");