ensembl-hive
2.6
|
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 () |
public | print_aligned_fields () |
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
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
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
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
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
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
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
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 @ARGV, so the same or another parser can be run again if needed.
Callers : scripts
public Bio::EnsEMBL::Hive::Utils::print_aligned_fields | ( | ) |
Argument[0]: Arrayref of key-value Hashrefs Argument[1]: Template string Description: For each hashref the template string will be interpolated (replacing each key with its value) and printed, but making sure the same fields are (right) aligned across all lines. The interpolator searches for %(key) patterns and replaces them with the value found in the hashref. The key name can be prefixed with a dash to require a left alignment instead.
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
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
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
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.