Why can't I run my Ensembl API scripts in older versions of perl?
1
0
Entering edit mode
8.8 years ago

I wrote a script to gather some data using the Ensembl API on my personal linux machine running perl 5.20. I cloned the install folder to a work machine that runs Perl 5.10.1(not upgradable) to show my findings to some peers and I started receiving errors:

#!/usr/bin/env perl

use warnings;
use strict;
use lib "$ENV{HOME}/Ensembl/src/bioperl-1.6.1";
use lib "$ENV{HOME}/Ensembl/src/ensembl/modules";
use lib "$ENV{HOME}/Ensembl/src/ensembl-compara/modules";
use lib "$ENV{HOME}/Ensembl/src/ensembl-variation/modules";
use lib "$ENV{HOME}/Ensembl/src/ensembl-funcgen/modules";
use Bio::EnsEMBL::Registry;
use Bio::EnsEMBL::Utils::Slice qw(split_Slices);
use Data::Dumper;
use Switch;

print"Establishing connection...";

my $registry = 'Bio::EnsEMBL::Registry';
$registry->load_registry_from_db(
  -host => 'ensembldb.ensembl.org',
  -user => 'anonymous',
  #-port => 3337, #add this line for hg37
);
my $slice_adaptor = $registry->get_adaptor('human','core','slice');
my $chr   = '4';
my $start = '152328241';
my $end   = '152328241';
my $slice = $slice_adaptor->fetch_by_region('chromosome',$chr,$start,$end);
my $pf_adaptor = $registry->get_adaptor('human', 'variation', 'phenotypefeature');
my $vf_adaptor = $registry->get_adaptor('human', 'variation', 'variationfeature');
my $pfs = $pf_adaptor->fetch_all_by_Slice($slice);
my $somatic_vfs = $vf_adaptor->fetch_all_somatic_by_Slice($slice);
my $germline_vfs = $vf_adaptor->fetch_all_by_Slice($slice);

Specifically I get "Can't call method "fetch_by_region" on an undefined value at metric.pl line 29". I'm not sure what's causing these errors. The Ensembl package is surely being loaded, otherwise there would be a warning further up about dependencies. I would think it has something to do with explicitly loading in the package for the "fetch_by_region" method, but I make these kinds of calls many more times and it would make my script significantly bulkier.

http://www.ensembl.org/info/docs/Doxygen/core-api//classBio_1_1EnsEMBL_1_1DBSQL_1_1SliceAdaptor.html

Anyone have any ideas of why this is happening? Seems like it's a different way functions are handled with 5.10

Thanks

perl ensembl • 2.0k views
ADD COMMENT
0
Entering edit mode

Hi, did you find the answer to this? Can you please share? Thanks

ADD REPLY
0
Entering edit mode
8.8 years ago
Ben Moore ★ 2.4k

Hi,

This means the slice_adaptor is undefined, which is most likely due to the registry not finding a human database, which could be a version incompatibility issue.

I would recommend checking what the version is in the APIVersion module (ensembl/modules/Bio/EnsEMBL/APIVersion.pm). You can also add a -verbose => 1 flag in the load_registry_from_db call, which should list all the databases found by the registry.

ADD COMMENT

Login before adding your answer.

Traffic: 1736 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6