Bio::Installer Generic
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvs
Summary
Bio::Installer::Generic - DESCRIPTION of Object
Package variables
No package variables defined.
Included modules
Bio::Root::Root
HTTP::Request::Common
LWP
Inherit
Bio::Root::Root
Synopsis
Give standard usage here
Description
Describe the object here
Methods
newDescriptionCode
origin_download_dirDescriptionCode
destination_download_dirDescriptionCode
destination_install_dirDescriptionCode
package_nameDescriptionCode
directory_nameDescriptionCode
env_nameDescriptionCode
_remember_envDescriptionCode
_decompressDescriptionCode
downloadDescriptionCode
uninstallDescriptionCode
Methods description
newcode    nextTop
 Title   : new
Usage : my $obj = new Generic();
Function: Builds a new Generic object
Returns : an instance of Generic
Args : -origin_download_dir => from where is going to be downloaded
-destination_download_dir => where is going to be saved
-destination_install_dir => where is going to be installed
-package_name => name of the package to be downloaded
-directory_name => name of the directory once has been decompressed
origin_download_dircodeprevnextTop
 Title   : origin_download_dir
Usage : $obj->origin_download_dir($newval)
Function:
Example :
Returns : value of origin_download_dir (a scalar)
Args : on set, new value (a scalar or undef, optional)
destination_download_dircodeprevnextTop
 Title   : destination_download_dir
Usage : $obj->destination_download_dir($newval)
Function:
Example :
Returns : value of destination_download_dir (a scalar)
Args : on set, new value (a scalar or undef, optional)
destination_install_dircodeprevnextTop
 Title   : destination_install_dir
Usage : $obj->destination_install_dir($newval)
Function:
Example :
Returns : value of destination_install_dir (a scalar)
Args : on set, new value (a scalar or undef, optional)
package_namecodeprevnextTop
 Title   : package_name
Usage : $obj->package_name($newval)
Function:
Example :
Returns : value of package_name (a scalar)
Args : on set, new value (a scalar or undef, optional)
directory_namecodeprevnextTop
 Title   : directory_name
Usage : $obj->directory_name($newval)
Function:
Example :
Returns : value of directory_name (a scalar)
Args : on set, new value (a scalar or undef, optional)
env_namecodeprevnextTop
 Title   : env_name
Usage :
Function:
Example :
Returns :
Args :
_remember_envcodeprevnextTop
 Title   : _remember_env
Usage :
Function:
Example :
Returns :
Args :
_decompresscodeprevnextTop
 Title   : _decompress
Usage :
Function:
Example :
Returns :
Args :
downloadcodeprevnextTop
 Title   : download
Usage : $installer->download();
Function:
Example :
Returns :
Args :
uninstallcodeprevnextTop
 Title   : uninstall
Usage : $installer->uninstall();
Function:
Example :
Returns :
Args :
Methods code
newdescriptionprevnextTop
sub new {
    my($class,@args) = @_;

    my $self = $class->SUPER::new(@args);

    my ($origin_download_dir, 
        $destination_download_dir, 
        $destination_install_dir, 
        $package_name, 
        $directory_name) =
            $self->_rearrange( [qw(ORIGIN_DOWNLOAD_DIR 
                                   DESTINATION_DOWNLOAD_DIR 
                                   DESTINATION_INSTALL_DIR 
                                   PACKAGE_NAME 
                                   DIRECTORY_NAME)],
                               @args);
    defined $origin_download_dir && $self->origin_download_dir($origin_download_dir);
    defined $destination_download_dir && $self->destination_download_dir($destination_download_dir);
    defined $destination_install_dir && $self->destination_install_dir($destination_install_dir);
    defined $package_name && $self->package_name($package_name);
    defined $directory_name && $self->directory_name($directory_name);

    return $self;
}
origin_download_dirdescriptionprevnextTop
sub origin_download_dir {
    my $self = shift;

    return $self->{'origin_download_dir'} = shift if @_;
    return $self->{'origin_download_dir'} || $self->get_default('ORIGIN_DOWNLOAD_DIR');
}
destination_download_dirdescriptionprevnextTop
sub destination_download_dir {
    my $self = shift;

    return $self->{'destination_download_dir'} = shift if @_;
    return $self->{'destination_download_dir'} || $self->get_default('DESTINATION_DOWNLOAD_DIR');
}
destination_install_dirdescriptionprevnextTop
sub destination_install_dir {
    my $self = shift;

    return $self->{'destination_install_dir'} = shift if @_;
    return $self->{'destination_install_dir'} || $self->get_default('DESTINATION_INSTALL_DIR');
}
package_namedescriptionprevnextTop
sub package_name {
    my $self = shift;

    return $self->{'package_name'} = shift if @_;
    return $self->{'package_name'} || $self->get_default('PACKAGE_NAME');
}
directory_namedescriptionprevnextTop
sub directory_name {
    my $self = shift;

    return $self->{'directory_name'} = shift if @_;
    return $self->{'directory_name'} || $self->get_default('DIRECTORY_NAME');
}
env_namedescriptionprevnextTop
sub env_name {
   my $self = shift;
    return $self->{'env_name'} = shift if @_;
    return $self->{'env_name'} || $self->get_default('ENV_NAME');
}
_remember_envdescriptionprevnextTop
sub _remember_env {
   my ($self,@args) = @_;
   my $dir;
   $dir = $self->destination_install_dir;
   $dir =~ s|/$||;
   $dir .= "/" . $self->directory_name . "/" . $self->get_default('BIN_FOLDER');
   my $env_name = $self->env_name;
   print STDERR <<END;


You will need to enable \$$env_name to help bioperl find the
program. This can be done in (at least) two ways:
1. define an environmental variable \$$env_name:
export $env_name=$dir
or
2. include a definition of an environmental variable $env_name in
every script that will use the program in the corresponding
bioperl module.
BEGIN {\$ENV\{\'$env_name\'\}=$dir; }

END
;
}
_decompressdescriptionprevnextTop
sub _decompress {
   my ($self,@args) = @_;
   my $call;
   my $destination = $self->destination_download_dir . "/" . $self->package_name;;
   my $destination_install_dir = $self->destination_install_dir;
   if (($^O =~ /dec_osf|linux|unix|bsd|solaris|darwin/i)) {
       $call = "tar xzvf $destination --directory=$destination_install_dir";
       system("$call") == 0 or $self->throw("Error when trying to decompress package");
       $call = "rm -f $destination";
       system("$call") == 0 or $self->throw("Error when trying to delete compressed package");
   } else {
       $self->throw("_decompress not yet implemented in this platform");
   }
}
downloaddescriptionprevnextTop
sub download {
    my ($self,@args) = @_;
    print "\n\nDownloading package...(this might take a while)\n\n";sleep 1;
    my $file = $self->origin_download_dir;
    $file =~ s|/$||;
    $file .= "/" . $self->package_name;
    my $destination = $self->destination_download_dir;
    $destination =~ s|/$||;
    $destination .= "/" . $self->package_name;;
    my $ua = LWP::UserAgent->new;
    my $response = $ua->request( GET($file), $destination );
    die "Error at $file\n ", $response->status_line, "\n Aborting"
        unless $response->is_success;
    print "Package successfully downloaded at $destination.\n";

    return $self;
}
uninstalldescriptionprevnextTop
sub uninstall {
   my ($self,@args) = @_;
   my $call;
   my $destination = $self->destination_install_dir;
   $destination =~ s|/$||;
   $destination .= "/" . $self->directory_name;
   print "\n\nUninstalling now: this will delete the installed program\n\n";
   if (($^O =~ /dec_osf|linux|unix|bsd|solaris|darwin/i)) {
       $call = "rm -rf $destination";
       system("$call") == 0 or die "Error when trying to delete installed program $?\n";
   } else {
       $self->throw("uninstall not yet implemented in this platform");
   }
   return $self;
}


1;
}
General documentation
FEEDBACKTop
Mailing ListsTop
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
  bioperl-l@bioperl.org                  - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support Top
Please direct usage questions or support issues to the mailing list:
bioperl-l@bioperl.org
rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
Reporting BugsTop
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
the web:
  http://redmine.open-bio.org/projects/bioperl/
AUTHOR - Albert VilellaTop
Email avilella-AT-gmail-DOT-com
Describe contact details here
CONTRIBUTORSTop
Additional contributors names and emails here
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _