[Bio] / FigKernelPackages / proml.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/proml.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9, Tue Jan 19 01:55:51 2010 UTC revision 1.10, Fri Nov 30 20:49:31 2012 UTC
# Line 52  Line 52 
52  #    Other:  #    Other:
53  #      keep_duplicates => bool        do not remove duplicate sequences (D = false) [NOT IMPLIMENTED]  #      keep_duplicates => bool        do not remove duplicate sequences (D = false) [NOT IMPLIMENTED]
54  #      program      => program        allows fully defined path  #      program      => program        allows fully defined path
55  #      tmp          => directory      directory for tmp_dir (D = /tmp or .)  #      tmp          => directory      directory for tmp_dir (D = SeedAware::location_of_tmp())
56  #      tmp_dir      => directory      directory for temporary files (D = $tmp/proml.$$)  #      tmp_dir      => directory      directory for temporary files (D = SeedAware::temporary_directory())
57  #      tree_format  => overbeek | gjo | fig  format of output tree  #      tree_format  => overbeek | gjo | fig  format of output tree
58  #  #
59  #  tmp_dir is created and deleted unless its name is supplied, and it already  #  tmp_dir is created and deleted unless its name is supplied, and it already
# Line 93  Line 93 
93  #  N cat  #  N cat
94  #  Rate values (n of them)  #  Rate values (n of them)
95    
96    use SeedAware;
97  use Data::Dumper;  use Data::Dumper;
98    
99  use strict;  use strict;
# Line 255  Line 255 
255      #  Options that are not proml options per se:      #  Options that are not proml options per se:
256      #---------------------------------------------------------------------------      #---------------------------------------------------------------------------
257    
258      my $program     = $options{ program } || 'proml';      my $program     = $options{ program } || SeedAware::executable_for( 'proml', \%options );
259    
260      my $tree_format = $options{ tree_format } =~ m/overbeek/i ? 'overbeek'      my $tree_format = $options{ tree_format } =~ m/overbeek/i ? 'overbeek'
261                      : $options{ tree_format } =~ m/gjo/i      ? 'gjonewick'                      : $options{ tree_format } =~ m/gjo/i      ? 'gjonewick'
262                      : $options{ tree_format } =~ m/fig/i      ? 'fig'                      : $options{ tree_format } =~ m/fig/i      ? 'fig'
263                      :                                           'overbeek'; # Default                      :                                           'overbeek'; # Default
264    
265      my ( $tmp_dir, $save_tmp ) = temporary_directory( \%options );      my ( $tmp_dir, $save_tmp ) = SeedAware::temporary_directory( \%options );
266    
267      #---------------------------------------------------------------------------      #---------------------------------------------------------------------------
268      #  Prepare data:      #  Prepare data:
# Line 398  Line 398 
398    
399      close PROML;      close PROML;
400    
401      system "$program < params > /dev/null";      my $redirects = { stdin  => 'params',
402                          stdout => '/dev/null'
403                        };
404        SeedAware::system_with_redirect( $program, $redirects )
405            and print STDERR "proml::proml: Failed to run '$program'.\n"
406            and reurn ();
407    
408      my @likelihoods = &read_outfile();      my @likelihoods = &read_outfile();
409    
# Line 421  Line 426 
426          @trees = map { gjonewicklib::gjonewick_to_overbeek( $_ ) } @trees;          @trees = map { gjonewicklib::gjonewick_to_overbeek( $_ ) } @trees;
427      }      }
428    
429      system "/bin/rm -r $tmp_dir" if ! $save_tmp;      system( '/bin/rm', -r => $tmp_dir ) if ! $save_tmp;
430    
431      return map { [ $_, shift @likelihoods ] } @trees;      return map { [ $_, shift @likelihoods ] } @trees;
432  }  }
# Line 616  Line 621 
621  }  }
622    
623    
 #-------------------------------------------------------------------------------  
 #  The SEED has things in special places.  Be aware of them if running SEED.  
 #-------------------------------------------------------------------------------  
   
 my $tmp;        #  The default place for temp files or directories  
 my $ext_bin;    #  FIG path to external binaries  
   
 eval { require FIG_Config;  
        $tmp     = $FIG_Config::temp;  
        $ext_bin = $FIG_Config::ext_bin;  
      };  
   
   
 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 #  $program = executable( $program, \%options )  
 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 sub executable  
 {  
     my ( $program, $options ) = @_;  
     return undef if ! $program;  
   
     $options ||= {};  
   
     return $options->{ $program } ? $options->{ $program } # explicit?  
          : $ext_bin               ? "$ext_bin/$program"    # SEED?  
          :                          $program;  
 }  
   
   
 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 #  Find or create a temporary directory.  
 #  If it does not exist, create it.  If it exists, mark it for saving.  
 #  
 #    $tmp_dir              = temporary_directory( \%options )  
 #  ( $tmp_dir, $save_tmp ) = temporary_directory( \%options )  
 #  
 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
   
 sub temporary_directory  
 {  
     my $options = shift || {};  
   
     my $tmp_dir  = $options->{ tmpdir }  || $options->{ tmp_dir };  
     my $save_tmp = $options->{ savetmp } || $options->{ save_tmp } || '';  
   
     if ( $tmp_dir )  
     {  
         if ( -d $tmp_dir ) { $options->{ savetmp } = $save_tmp = 1 }  
     }  
     else  
     {  
         if ( $options->{ tmp }  && -d  $options->{ tmp } )  
         {  
             $tmp = $options->{ tmp };  
         }  
         elsif ( ! $tmp || ! -d $tmp )  
         {  
             $options->{ tmp } = $tmp = -d '/tmp' ? '/tmp' : '.';  
         }  
   
         $tmp_dir = sprintf( "$tmp/" . __PACKAGE__ . "_tmp.%05d.%09d", $$, int(1000000000*rand) );  
         $options->{ tmpdir } = $tmp_dir;  
     }  
   
     if ( $tmp_dir && ! -d $tmp_dir )  
     {  
         mkdir $tmp_dir;  
         if ( ! -d $tmp_dir )  
         {  
             print STDERR __PACKAGE__ . "::temporary_directory could not create '$tmp_dir'\n";  
             $options->{ tmpdir } = $tmp_dir = undef;  
         }  
     }  
   
     return wantarray ? ( $tmp_dir, $save_tmp ) : $tmp_dir;  
 }  
   
   
624  1;  1;

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3