The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

LICENSE

Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2024] EMBL-European Bioinformatics Institute

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

CONTACT

  Please email comments or questions to the public Ensembl
  developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.

  Questions may also be sent to the Ensembl help desk at
  <http://www.ensembl.org/Help/Contact>.

AUTHOR

Juguang Xiao <juguang@tll.org.sg>

NAME

Bio::EnsEMBL::Utils::EasyArgv

SYNOPSIS

  use Bio::EnsEMBL::Utils::EasyArgv;

  my $db = get_ens_db_from_argv;    # this method is exported.

  use Getopt::Long;

  my $others;
  &GetOptions( 'others=s' => \$others );

DESCRIPTION

This is a lazy but easy way to get the db-related arguments. All you need to do is to invoke get_ens_db_from_argv before using standard Getopt. The below options will be absorbed and removed from @ARGV.

db_file, host, db_host, dbhost, user, db_user, dbuser, pass, db_pass, dbpass, dbname, db_name.

Now you can take advantage of Perl's do method to execute a file as perl script and get returned the last line of it. For your most accessed db setting, you can have a file named, say, ensdb_homo_core_18.perlobj, with the content like

  use strict;    # The ceiling line

  use Bio::EnsEMBL::DBSQL::DBAdaptor;

  my $db = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
    -host   => 'ensembldb.ensembl.org',
    -user   => 'anonymous',
    -dbname => 'homo_sapiens_core_18_34'
  );

  $db;           # The floor line

In the your command line, you just need to write like

  perl my_script.pl -db_file ensdb_homo_core_18.perlobj

rather than the verbose

  -host ensembldb.ensembl.org -user anonymous \
  -dbname homo_sapiens_core_18_34

METHODS