[Bioperl-l] standards for wrapped exes

Jason Stajich jason@cgt.mc.duke.edu
Fri, 14 Jun 2002 18:58:33 -0400 (EDT)


For anyone developing wrappers around application so they can run as a
bioperl module, I think we need to agree upon some standards.  I'm not
totally happy with the existing setup which seems to use a lot of class
variables and rely heavily on environment variables.  I would like us to
have some standards that can eventually be thrown into an interface.

Here are the methods as I have setup in my PAML wrappers to be committed
soon.  Feel free to critique, this is what I have setup and it may have
problems (NB code below should be thought of a pseudo code).

I like TMTOWTDI, but I also think uniformity makes it easier to
write new wrappers and for these to be more interchangeable.  Feedback
encouraged.

sub run() {
  # Will run the program
  # some setup is done before here of course
   my $exe = $self->executable || $self->throw("Couldn't find the
executable - check you have it installed in your path or your env
variables set correctly");
   open(RUN, $exe . " " . $self->run_parameters() . " |") ||
   $self->throw("Cannot run the executable ".$self->executable.
" with the parameters ". $self->run_parameteres());
   my @output = <RUN>;
   $self->error_string(join('', @output);
}

set_parameter($name, $value);
get_parameter($name);
run_pameters() { # return the properly formatted parameters for running
the program, empty string if the program does not take any }
error_string() { # get/set the program STDOUT output (maybe a separate
method/variable for the stderr output? }

# you should test the output from this method
# to see if your exe exists!
executable() {
  # this will determine the path to executable
  # an undef is returned if exe is not found

  unless defined ( $self->{'_pathtoexe'} ) {
  # handle the case where we've already found it
  # or it was nicely set in the BEGIN block
    if( $PROGRAM && -e $PROGRAM && -x $PROGRAM ) {
      $self->{'_pathtoexe'} = $PROGRAM;
    } else {
	# or find it with the Root::IO exists_exe
       if( (my $exe = $self->io->exists_exe($PROGRAMNAME)) && -x $exe ) {
          $self->{'_pathtoexe'} = $exe;
       } else {
        $self->warn("Cannot find executable for $PROGRAMNAME");
        $self->{'_pathtoexe'} = undef;
       }
    }
  }
  $self->{'_pathtoexe'};
}

program_version() {
 # will try and determine the program version if possible
 # YOU SHOULD USE $self->executable for any calls that invoke the
 # the program
}


-- 
Jason Stajich
Duke University
jason at cgt.mc.duke.edu