ensembl-hive  2.5
Bio::EnsEMBL::Hive::Utils Class Reference

Public Member Functions

public stringify ()
 
public destringify ()
 
public dir_revhash ()
 
public parse_cmdline_options ()
 
public find_submodules ()
 
public load_file_or_module ()
 
public List split_for_bash ()
 
public go_figure_dbc ()
 
public Tuple join_command_args ()
 
public whoami ()
 
public The timeout ()
 

Detailed Description

Synopsis

# Example of an import:
use Bio::EnsEMBL::Hive::Utils 'stringify';
my $input_id_string = stringify($input_id_hash);
# Example of inheritance:
use base ('Bio::EnsEMBL::Hive::Utils', ...);
my $input_id_string = $self->stringify($input_id_hash);
# Example of a direct call:
use Bio::EnsEMBL::Hive::Utils;
my $input_id_string = Bio::EnsEMBL::Hive::Utils::stringify($input_id_hash);

Description

    This module provides general utility functions that can be used in different contexts through three different calling mechanisms:

          import:  another module/script can selectively import methods from this module into its namespace

          inheritance:  another module can inherit from this one and so implicitly acquire the methods into its namespace
        
          direct call to a module's method:  another module/script can directly call a method from this module prefixed with this module's name

Definition at line 34 of file Utils.pm.

Member Function Documentation

◆ destringify()

public Bio::EnsEMBL::Hive::Utils::destringify ( )
    Description: This function takes in a string that may or may not contain a stingified Perl structure.
                 If it seems to contain a hash/array/quoted_string, the contents is evaluated, otherwise it is returned "as is".
                 This function is mainly used to read values from 'meta' table that may represent Perl structures, but generally don't have to.
    Callers    : Bio::EnsEMBL::Hive::DBSQL::PipelineWideParametersAdaptor   # destringification of general 'meta' params
                 beekeeper.pl script                                        # destringification of the 'pipeline_name' meta param
 
Code:
click to view

◆ dir_revhash()

public Bio::EnsEMBL::Hive::Utils::dir_revhash ( )
    Description: This function takes in a string (which is usually a numeric id) and turns its reverse into a multilevel directory hash.
                 Please note that no directory is created at this step - it is purely a string conversion function.
    Callers    : Bio::EnsEMBL::Hive::Worker                 # hashing of the worker output directories
                 Bio::EnsEMBL::Hive::RunnableDB::JobFactory # hashing of an arbitrary id
 
Code:
click to view

◆ find_submodules()

public Bio::EnsEMBL::Hive::Utils::find_submodules ( )
    Description: This function takes one argument ("prefix" of a module name),
                transforms it into a directory name from the filesystem's point of view
                and finds all module names in these "directories".
                Each module_name found is reported only once,
                even if there are multiple matching files in different directories.
    Callers    : scripts
 
Code:
click to view

◆ go_figure_dbc()

public Bio::EnsEMBL::Hive::Utils::go_figure_dbc ( )
    Description: This function tries its best to build a DBConnection from $foo
                 It may need $reg_type if $foo is a Registry key and there are more than 1 DBAdaptors for it
 
Code:
click to view

◆ join_command_args()

public Tuple Bio::EnsEMBL::Hive::Utils::join_command_args ( )
    Argument[0]: String or Arrayref of Strings
    Description: Prepares the command to be executed by system(). It is needed if the
                 command is in fact composed of multiple commands.
    Returns:     Tuple (boolean,string). The boolean indicates whether it was needed to
                 join the arguments. The string is the new command-line string.
                 PS: Shamelessly adapted from http://www.perlmonks.org/?node_id=908096
 
Code:
click to view

◆ load_file_or_module()

public Bio::EnsEMBL::Hive::Utils::load_file_or_module ( )
    Description: This function takes one argument, tries to determine whether it is a module name ('::'-separated)
                or a path to the module ('/'-separated), finds the module_name and dynamically loads it.
    Callers    : scripts
 
Code:
click to view

◆ parse_cmdline_options()

public Bio::EnsEMBL::Hive::Utils::parse_cmdline_options ( )
    Description: This function reads all options from command line into a key-value hash
                (keys must be prefixed with a single or double dash, the following term becomes the value).
                The rest of the terms go into the list.
                Command line options are not removed from , so the same or another parser can be run again if needed.
    Callers    : scripts
 
Code:
click to view

◆ split_for_bash()

public List Bio::EnsEMBL::Hive::Utils::split_for_bash ( )
    Description: This function takes one argument (String) and splits it assuming it represents bash command line parameters.
                 It mainly splits on whitespace, except for cases when spaces are trapped between quotes or apostrophes.
                 In the latter case the outer quotes are removed.
    Returntype : list of Strings
 
Code:
click to view

◆ stringify()

public Bio::EnsEMBL::Hive::Utils::stringify ( )
    Description: This function takes in a Perl data structure and stringifies it using specific configuration
                 that allows us to store/recreate this data structure according to our specific storage/communication requirements.
                 NOTE: Some recursive structures are not stringified in a way that allows destringification with destringify
    Callers    : Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor      # stringification of input_id() hash
                 Bio::EnsEMBL::Hive::PipeConfig::HiveGeneric_conf   # stringification of parameters() hash
 
Code:
click to view

◆ timeout()

public The Bio::EnsEMBL::Hive::Utils::timeout ( )
    Argument[0]: (coderef) Callback subroutine
    Argument[1]: (integer) Time to wait (in seconds)
    Description: Calls the callback whilst ensuring it does not take more than the allowed time to run.
    Returns:     The return value (scalar context) of the callback or -2 if the
                 command had to be aborted.
                 FIXME: may need a better mechanism that allows callbacks to return -2 too
 
Code:
click to view

◆ whoami()

public Bio::EnsEMBL::Hive::Utils::whoami ( )
    Description: Returns the name of the user who's currently running Perl.
                 $ENV{'USER'} is the most common source but it can be missing
                 so we also default to a builtin method.
 
Code:
click to view

The documentation for this class was generated from the following file: