[Bioperl-l] standards for wrapped exes

shawnh@worf.fugu-sg.org shawnh@worf.fugu-sg.org
Sat, 15 Jun 2002 10:46:51 +0800 (SGT)


> 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).
Looks good. I think some of the ones I wrote are pretty similar..which
were modelled after Bio::Tools::Clustalw. But once we fix the interface, I will
change the semantics,naming etc.
cheers,

shawn

> 
> 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
> }
> 
> 
> 

-- 
'Torture the data long enough and they will reveal anything'
********************************
* Shawn Hoon
* http://www.fugu-sg.org/~shawnh
********************************