[ensembl-dev] problems on fetching GO terms for all genes of a bacteria using API

刘鹏飞 liupfskygre at gmail.com
Tue Jan 7 09:32:22 GMT 2014


Hi all
  I am new to API. Now I am trying to use it to get all GO terms for each
genes of a archaea(Methanocella conradii HZ254), and want to get a table
with two columns, on for gene name and the other for GO term correponding
to it

Following the instruction of API and the modifications to use API for
bacteria, I use the following code to do the job:
# load the lookup from the main Ensembl Bacteria public server
my $lookup = Bio::EnsEMBL::LookUp->new(
  -URL => "http://bacteria.ensembl.org/registry.json",
  -NO_CACHE => 1
);
# find the correct database adaptor using a unique name
my ($dba) = @{$lookup->get_by_name_exact(
  'methanocella_conradii_hz254'
)};
# get adaptor for ontology
my $goada=$dba->get_adaptor('Multi','Ontology','OntologyTerm');
my $genes = $dba->get_GeneAdaptor()->fetch_all(); # where is the
get_GeneAdaptor() documentation
# ###test####
print "Found ".scalar @$genes." genes for ".$dba->species()."\n";

# get go infomation (modified from kokocinsky.net ensembl coding)
foreach my $gene (@$genes){
my $links = $gene->get_all_DBLinks();
foreach my $link (@$links){
if ($link->database eq "GO"){
my $term_id=$link->display_id;
my $term_name='-';
my $term=$goada->fetch_by_accession($term_id);
if($term and $term->name){
$term_name=$term->name;}
print $gene->stable_id.":$term_id ($term_name)\n";
# fetch complete GO hierachy
foreach my $ancestor_term (@{$term->ancestors()}){
print "\t". $ancestor_term->accession." (".$ancestor_term->name.")\n";
}
  }
 }
}

it works well before "get go information"
the output was as following:
Can't call method "fetch_by_accession" on an undefined value at /home/liupf/
hz254.pl line 27.
1, I do not understand the use of 'get_GeneAdaptor', I could not find
documentation on this synthax.
2, please give me some suggestiones on how to fullfill my task.

Thank you all!

$ perl ~/ApiVersion.pl
The API version used is 74

-- 
Pengfei Liu, PhD Candidate

Lab of Microbial Ecology
College of Resources and Environmental Sciences
China Agricultural University
No.2 Yuanmingyuanxilu, Beijing, 100193
P.R. China

Tel: +86-10-62731358
Fax: +86-10-62731016

E-mail: liupfskygre at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ensembl.org/pipermail/dev_ensembl.org/attachments/20140107/3f32ddcb/attachment.html>


More information about the Dev mailing list