0

I am attempting to connect to the Ensembl API using the following Perl code:

    #!/bin/perl

    use Bio::EnsEMBL::Registry;
    use DBI qw(:sql_types);


    my $registry = 'Bio::EnsEMBL::Registry';

    $registry->load_registry_from_db(
        -host => 'ensembldb.ensembl.org', # alternatively 'useastdb.ensembl.org'
        -user => 'anonymous'
    );

    my @db_adaptors = @{ $registry->get_all_DBAdaptors() };

    foreach my $db_adaptor (@db_adaptors) {
        my $db_connection = $db_adaptor->dbc();

        printf(
            "species/group\t%s/%s\ndatabase\t%s\nhost:port\t%s:%s\n\n",
            $db_adaptor->species(),   $db_adaptor->group(),
            $db_connection->dbname(), $db_connection->host(),
            $db_connection->port()
        );
    }

Bioperl and CPAN are both required to use the Ensembl API, and I am pretty sure that these are correctly installed on my Ubuntu. I have also added the required modules to the PERL5LIB environment variable. Despite all of this I get the following error message:

    Bareword "SQL_INTEGER" not allowed while "strict subs" in use at /home/src/ensembl/modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm line 299.
    Compilation failed in require at /home/src/ensembl/modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm line 45.
    BEGIN failed--compilation aborted at /home/src/ensembl/modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm line 45.
    Compilation failed in require at /home/src/ensembl/modules/Bio/EnsEMBL/DBSQL/DBAdaptor.pm line 60.
    BEGIN failed--compilation aborted at /home/src/ensembl/modules/Bio/EnsEMBL/DBSQL/DBAdaptor.pm line 60.
    Compilation failed in require at /home/src/ensembl/modules/Bio/EnsEMBL/Registry.pm line 127.
    BEGIN failed--compilation aborted at /home/src/ensembl/modules/Bio/EnsEMBL/Registry.pm line 127.

Here is the registry file which the script is using in order to connect to the Ensembl databases:

    Bio::EnsEMBL::Registry->load_registry_from_db(
        -host    => 'ensembldb.ensembl.org',
        -user    => 'anonymous',
        -verbose => '1'
    );

    use strict;
    use Bio::EnsEMBL::Utils::ConfigRegistry;
    use Bio::EnsEMBL::DBSQL::DBAdaptor;


    new Bio::EnsEMBL::DBSQL::DBAdaptor(
        -host    => 'ensembldb.ensembl.org',
        -user    => 'anonymous',
        -port    => '3306',
        -species => 'homo_sapiens',
        -group   => 'core',
        -dbname  => 'homo_sapiens_core_70_37'
    );

    my @aliases = ( 'H_Sapiens', 'Homo sapiens', 'human' );

    Bio::EnsEMBL::Utils::ConfigRegistry->add_alias(
        -species => 'homo_sapiens',
        -alias   => \@aliases
    );
    1
user2639056
  • 295
  • 1
  • 5
  • 10
  • perhaps some constant was not imported? – mpapec Oct 24 '13 at 14:28
  • The problem is in code you haven't shown. – hobbs Oct 24 '13 at 14:28
  • I get no errors. Not likely to be an installation error. More likely an old version of DBI. What's the output of `perl -MDBI -le'print $DBI::VERSION' ; perl -Mstrict -MDBI=:sql_types -le'print STDOUT SQL_INTEGER'` – ikegami Oct 24 '13 at 14:54
  • The command "perl -MDBI -le'print $DBI::VERSION'" prints nothing. And the second command prints "Bareword "SQL_INTEGER" not allowed while "strict subs" in use at -e line 1. Execution of -e aborted due to compilation errors." – user2639056 Oct 24 '13 at 15:18
  • huh? it's impossible that it prints nothing?! Modules must have a version to be on CPAN. `use DBI;` is loading something other than DBI, meaning you have a garbage `DBI.pm` on your system. – ikegami Oct 24 '13 at 16:18

1 Answers1

0

Does the file /home/src/ensembl/modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm have the line use DBI qw(:sql_types); before line 299? No? Maybe you have an old version of Bio::EnsEMBL::DBSQL::BaseAdaptor.

Maybe your DBI is not what it is supposed to be. What does perldoc -l DBI say is the location of DBI? Is it correct? How did you install DBI? You did not just copy ".pm" files, did you?

runrig
  • 6,486
  • 2
  • 27
  • 44
  • I reinstalled DBI. Now I get a different error: "DBD::mysql initialisation failed: Can't locate object method "driver" via package "DBD::mysql" at /usr/local/lib/perl/5.14.2/DBI.pm line 819" – user2639056 Oct 25 '13 at 11:36
  • Is DBD::mysql installed? – runrig Oct 25 '13 at 17:11