ensembl-hive  2.7.0
Bio::EnsEMBL::Utils::CliHelper Class Reference

Public Member Functions

public Arrayref get_dba_opts ()
 
public Hashref process_args ()
 
public Arrayref get_dba_args_for_opts ()
 
public get_dbas_for_opts ()
 
public Int load_registry_for_opts ()
 

Detailed Description

Synopsis

# get the basic options for connecting to a database server
my $optsd = $cli->get_dba_opts();
# add another option
push(@$optsd,"print");
# process the command line with the supplied options plus a reference to a help subroutine
my $opts = $cli->process_args($optsd,\&usage);
# use the command line options to get an array of database details
for my $db_args (@{$cli->get_dba_args_for_opts($opts)}) {
# use the args to create a DBA
my $dba = new Bio::EnsEMBL::DBSQL::DBAdaptor(%{$db_args});
...
if(defined $opts->{print}) {
...
}
}
For adding secondary databases, a prefix can be supplied. For instance, to add a second set of
db params prefixed with dna (-dnahost -dbport etc.) use the prefix argument with get_dba_opts and
# get the basic options for connecting to a database server
my $optsd =
[ @{ $cli_helper->get_dba_opts() }, @{ $cli_helper->get_dba_opts('gc') } ];
# process the command line with the supplied options plus a help subroutine
my $opts = $cli_helper->process_args( $optsd, \&usage );
# get the dna details
my ($dna_dba_details) =
@{ $cli_helper->get_dba_args_for_opts( $opts, 1, 'dna' ) };
my $dna_db =
Bio::EnsEMBL::DBSQL::DBAdaptor->new( %{$dna_dba_details} ) );

Description

Utilities for a more consistent approach to parsing and handling EnsEMBL script command lines

Definition at line 55 of file CliHelper.pm.

Member Function Documentation

◆ get_dba_args_for_opts()

public Arrayref Bio::EnsEMBL::Utils::CliHelper::get_dba_args_for_opts ( )
    Arg [1]     : Hash of options (e.g. parsed from command line options by process_args())
    Arg [2]     : If set to 1, the databases are assumed to have a single species only. Default is 0 if database name matches collection, 1 otherwise.
    Arg [3]     : Optional prefix to use when parsing e.g. dna
    Description : Uses the parsed command line options to generate an array of DBAdaptor arguments 
                : (e.g. expands dbpattern, finds all species_ids for multispecies databases)
                : These can then be passed directly to Bio::EnsEMBL::DBSQL::DBAdaptor->new()
    Returntype  : Arrayref of DBA argument hash refs 
    Status      : Under development
 
Code:
click to view
    Arg [1]     : Hash of options (e.g. parsed from command line options by process_args())
    Arg [2]     : If set to 1, the databases are assumed to have a single species only. Default is 0.
    Arg [3]     : Optional prefix to use when parsing e.g. dna
    Description : Uses the parsed command line options to generate an array DBAdaptors. 
                : Note this can overload connections on a server
    Returntype  : Arrayref of Bio::EnsEMBL::DBSQL::DBAdaptor
    Status      : Under development
 

/**

◆ get_dba_opts()

public Arrayref Bio::EnsEMBL::Utils::CliHelper::get_dba_opts ( )
  Arg [1]     : Optional prefix for dbnames e.g. dna
  Description : Retrieves the standard options for connecting to one or more Ensembl databases
  Returntype  : Arrayref of option definitions
  Status      : Under development
 
Code:
click to view

◆ get_dbas_for_opts()

public Bio::EnsEMBL::Utils::CliHelper::get_dbas_for_opts ( )

Undocumented method

Code:
click to view

◆ load_registry_for_opts()

public Int Bio::EnsEMBL::Utils::CliHelper::load_registry_for_opts ( )
  Arg [1]       : Hash of options (e.g. parsed from command line options by process_args()) 
  Arg [2]     : Optional prefix to use when parsing e.g. dna or master 
  Description   : Loads a Registry from the given options hash. If a registry 
                option is given then the code will call load_all. Otherwise
                we use the database parameters given to call 
                load_registry_from_db().
  Returntype  : Integer of the number of DBAdaptors loaded
  Status      : Under development
 
Code:
click to view

◆ process_args()

public Hashref Bio::EnsEMBL::Utils::CliHelper::process_args ( )
    Arg [1]     : Arrayref of supported command line options (e.g. from get_dba_opts)
    Arg [2]     : Ref to subroutine to be invoked when -help or -? is supplied
    Description : Retrieves the standard options for connecting to one or more Ensembl databases
    Returntype  : Hashref of parsed options
    Status      : Under development
 
Code:
click to view

The documentation for this class was generated from the following file:
usage
public usage()
Bio::EnsEMBL::DBSQL::DBAdaptor
Definition: DBAdaptor.pm:40
Bio::EnsEMBL::Utils::CliHelper::get_dba_opts
public Arrayref get_dba_opts()
map
public map()
Bio::EnsEMBL::Utils::CliHelper::get_dbas_for_opts
public get_dbas_for_opts()
Bio::EnsEMBL::Registry
Definition: Registry.pm:113
Bio::EnsEMBL::Utils::CliHelper::load_registry_for_opts
public Int load_registry_for_opts()
Bio::EnsEMBL::Utils::CliHelper::process_args
public Hashref process_args()
Bio::EnsEMBL::DBSQL::DBConnection
Definition: DBConnection.pm:42
Bio::EnsEMBL::Utils::CliHelper::get_dba_args_for_opts
public Arrayref get_dba_args_for_opts()
Bio::EnsEMBL::Registry::load_registry_from_db
public Int load_registry_from_db()
Bio::EnsEMBL::DBSQL::DBAdaptor::new
public Bio::EnsEMBL::DBSQL::DBAdaptor new()
Bio::EnsEMBL::DBSQL::DBConnection::new
public Bio::EnsEMBL::DBSQL::DBConnection new()
Bio::EnsEMBL::DBSQL::DBConnection::sql_helper
public Bio::EnsEMBL::Utils::SqlHelper sql_helper()
Bio::EnsEMBL::Utils::CliHelper
Definition: CliHelper.pm:55
Bio::EnsEMBL::Utils::SqlHelper::execute_simple
public ArrayRef execute_simple()
Bio::EnsEMBL::Registry::load_all
public Int load_all()