<div dir="ltr"><div><div><div><div><div>Hi, <br>Magali<br></div>Sorry, the way you suggested above did not work. <br>using following, <br># get adaptor for ontology<br>my $ontology_dba = Bio::EnsEMBL::DBSQL::OntologyDBAdaptor->new(<br>
 -HOST => '<a href="http://mysql.ebi.ac.uk">mysql.ebi.ac.uk</a>',<br> -USER => 'anonymous',<br> -PORT => '4157',<br> -group   => 'ontology',<br> -dbname => 'ensemblgenomes_ontology_21_74',<br>
 -species => 'multi' );<br>my $goada = $ontology_dba->get_adaptor('OntologyTerm');<br></div>I still got the output before:<br>Can't locate object method "new" via package "Bio::EnsEMBL::DBSQL::OntologyDBAdaptor" at /home/liupf/<a href="http://hz254_2.pl">hz254_2.pl</a> line 21.<br>
<br></div>change the OntologyDBAdaptor to DBAdaptor<br>my $ontology_dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(<br><br></div>output:<br>Can't call method "fetch_by_accession" on an undefined value at /home/liupf/<a href="http://hz254_2.pl">hz254_2.pl</a> line 38.;<br>
<br></div>>>>>>>>>>>>>>>>>>my full list of code>>>>>>>>>>>><br># methanocella_conradii_hz254<br>#!/usr/bin/perl<br>use strict;<br>use warnings;<br>
use Bio::EnsEMBL::LookUp;<br># load the lookup from the main Ensembl Bacteria public server<br>my $lookup = Bio::EnsEMBL::LookUp->new(<br>  -URL => "<a href="http://bacteria.ensembl.org/registry.json">http://bacteria.ensembl.org/registry.json</a>",<br>
  -NO_CACHE => 1<br>);<br># find the correct database adaptor using a unique name<br>my ($dba) = @{$lookup->get_by_name_exact(<br>  'methanocella_conradii_hz254'<br>)};<br>my $genes = $dba->get_GeneAdaptor()->fetch_all(); # where is the get_GeneAdaptor() documentation<br>
# test<br>print "Found ".scalar @$genes." genes for ".$dba->species()."\n";<br><span style="color:rgb(255,0,0)"># get adaptor for ontology<br>my $ontology_dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(<br>
 -HOST => '<a href="http://mysql.ebi.ac.uk">mysql.ebi.ac.uk</a>',<br> -USER => 'anonymous',<br> -PORT => '4157',<br> -group   => 'ontology',<br> -dbname => 'ensemblgenomes_ontology_21_74',<br>
 -species => 'multi' );<br>my $goada = $ontology_dba->get_adaptor('OntologyTerm');</span><br># get go infomation<br>foreach my $gene (@$genes){<br>foreach my $link (@{ $gene->get_all_DBLinks } ){<br>
if ($link->database eq "GO"){<br>my $term_id=$link->display_id;<br>my $term_name='-';<br><span style="color:rgb(255,0,0)">my $term=$goada->fetch_by_accession($term_id);</span><br>if($term and $term->name){<br>
$term_name=$term->name;}<br>print $gene->stable_id.":$term_id ($term_name)\n";<br># fetch complete GO hierachy<br>foreach my $ancestor_term (@{$term->ancestors()}){<br>print "\t". $ancestor_term->accession." (".$ancestor_term->name.")\n";<br>
}<br>  }<br> }<br>}<br><div>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><br><div>Is there something else wrong in it cause the output above?<br>
</div><div>Thanks!<br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014/1/7  <span dir="ltr"><<a href="mailto:mr6@ebi.ac.uk" target="_blank">mr6@ebi.ac.uk</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Pengfei,<br>
<br>
Replies above<br>
<div class="im"><br>
> Hi,<br>
> Magali<br>
> Thanks for your quick reply. I followed your instruction and modified line<br>
> as follows:<br>
> # get adaptor for ontology<br>
> my $ontology_dba=Bio::EnsEMBL::DBSQL::OntologyDBAdaptor->new(<br>
> -HOST=>"<a href="http://mysql.ebi.ac.uk" target="_blank">mysql.ebi.ac.uk</a>",<br>
> -USER=>'anonymous',<br>
> -PORT=>'4157',<br>
> -group =>'ontology',<br>
> -dbname=>'ensemblgenomes_ontology_21_74',<br>
> -species=>'multi');<br>
><br>
> #one more question: where could I find those informations like host, user,<br>
> and dbname that I needed to get data object or adaptor wanted ?<br>
<br>
</div>I used the information provided in the ensembl bacteria documentation<br>
<a href="http://bacteria.ensembl.org/info/data/accessing_ensembl_bacteria.html#advanced-use" target="_blank">http://bacteria.ensembl.org/info/data/accessing_ensembl_bacteria.html#advanced-use</a><br>
The default host for ensembl genomes databases is <a href="http://mysql.ebi.ac.uk" target="_blank">mysql.ebi.ac.uk</a> with the<br>
connection details as mentioned.<br>
For the database name, an ontology database would normally be called<br>
ensemblgenomes_ontology_egrelease_erelease<br>
where egrelease refers to the ensembl genomes release version (here 21)<br>
and erelease corresponds to the ensembl release version (here 74)<br>
In ensembl, the corresponding database is called ensembl_ontology_74<br>
If you have a mysql server installed, you can log directly onto the<br>
ensembl genomes server to find the exact name of the database you are<br>
looking for<br>
<div class="im"><br>
><br>
> # now use the DBAdaptor to get_adaptor<br>
> my $goada=$ontology_dba->get_adaptor('Multi','Ontology','OntologyTerm');<br>
> # in your reply is $goada=$registry, but i think it shoud by<br>
> $goada=$ontology_dba, right?<br>
<br>
</div>Sorry about the confusion.<br>
We normally use registry objects to connect to databases, but it does not<br>
cope well with multi-species databases like the bacterial ones, hence the<br>
use of the lookup and direct DBadaptors.<br>
The correct syntax should have been:<br>
<div class="im">my $ontology_dba = Bio::EnsEMBL::DBSQL::OntologyDBAdaptor->new(<br>
 -HOST => '<a href="http://mysql.ebi.ac.uk" target="_blank">mysql.ebi.ac.uk</a>',<br>
 -USER => 'anonymous',<br>
 -PORT => '4157',<br>
 -group   => 'ontology',<br>
 -dbname => 'ensemblgenomes_ontology_21_74',<br>
 -species => 'multi' );<br>
<br>
</div>my $goada = $ontology_dba->get_adaptor('OntologyTerm');<br>
<br>
Hopefully, this should also solve the issue below.<br>
<div class="im"><br>
><br>
> the output:<br>
> Can't locate object method "new" via package<br>
> "Bio::EnsEMBL::DBSQL::OntologyDBAdaptor" at /home/liupf/<a href="http://hz254_2.pl" target="_blank">hz254_2.pl</a> line<br>
> 21.<br>
><br>
> I check the doxygen for OntologyDBAdaptor, the new() methods, but returned<br>
> examples were all Bio::EnsEMBL::DBSQL::DBAdaptor::new(), so I think new<br>
> method is no longer supported by OntologyDBAdaptor, so I also tried<br>
> my $ontology_dba=Bio::EnsEMBL::DBSQL::DBAdaptor->new(.....<br>
><br>
> unfortunately, output came:<br>
> Can't call method "fetch_by_accession" on an undefined value at<br>
> /home/liupf/<br>
> <a href="http://hz254_2.pl" target="_blank">hz254_2.pl</a> line 37.<br>
><br>
> ### confusion on understanding Ensembl API<br>
> Use API to fetch data, you need to use the right database and the<br>
> corresponding DBAdaptor, and then use the right object adaptor and methods<br>
> to do it. Is my understanding right?<br>
<br>
</div>That is correct.<br>
<div class="im"><br>
> I am confused by that:<br>
> my genes was in the bacteria database, I could fetch them, but if the gene<br>
> ontology terms was in another database, how could the connected and does<br>
> that mean I need two DBAdaptor for each of them?<br>
<br>
</div>The bacterial database contains the genes and all related information.<br>
It thus contains ontology terms attached to translations and genes.<br>
It does not however contain the definition for each ontology term, nor its<br>
relationships with other terms, like descendants and ancestors.<br>
This additional information is stored separately in the ontology database.<br>
<div class="im"><br>
> Hope those not bothering you too much!<br>
> ###<br>
> Thank you very much!<br>
<br>
<br>
</div>Hope this helps,<br>
Magali<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
><br>
><br>
> 2014/1/7 <<a href="mailto:mr6@ebi.ac.uk">mr6@ebi.ac.uk</a>><br>
><br>
>> Hi Pengfei,<br>
>><br>
>> The get_GeneAdaptor method is equivalent using get_Adaptor('Gene').<br>
>> More documentation can be found here:<br>
>><br>
>> <a href="http://www.ensembl.org/info/docs/Doxygen/core-api/classBio_1_1EnsEMBL_1_1DBSQL_1_1DBAdaptor.html#a2a1ee81ecb9507fc5ea7bdf39be97bf9" target="_blank">http://www.ensembl.org/info/docs/Doxygen/core-api/classBio_1_1EnsEMBL_1_1DBSQL_1_1DBAdaptor.html#a2a1ee81ecb9507fc5ea7bdf39be97bf9</a><br>

>><br>
>> As for the undefined value message you are getting.<br>
>> By calling get_adaptor on $dba, you are attempting to get an object<br>
>> adaptor defined in the context of your bacteria database.<br>
>> Ontologies are stored separately in their own database,<br>
>> ensembl_ontology.<br>
>><br>
>> The easiest way to access the ontology database would be as follow:<br>
>> my $ontology_dba = Bio::EnsEMBL::DBSQL::OntologyDBAdaptor->new(<br>
>> -HOST => '<a href="http://mysql.ebi.ac.uk" target="_blank">mysql.ebi.ac.uk</a>',<br>
>> -USER => 'anonymous',<br>
>> -PORT => '4157',<br>
>> -group   => 'ontology',<br>
>> -dbname => 'ensemblgenomes_ontology_21_74',<br>
>> -species => 'multi' );<br>
>><br>
>> my $goada = $registry->get_adaptor( 'Multi', 'Ontology', 'OntologyTerm'<br>
>> );<br>
>><br>
>> You should then be able to call fetch_by_accession on $goada for a given<br>
>> GO accession.<br>
>><br>
>><br>
>> Hope that helps,<br>
>> Magali<br>
>><br>
>> > Hi all<br>
>> >   I am new to API. Now I am trying to use it to get all GO terms for<br>
>> each<br>
>> > genes of a archaea(Methanocella conradii HZ254), and want to get a<br>
>> table<br>
>> > with two columns, on for gene name and the other for GO term<br>
>> correponding<br>
>> > to it<br>
>> ><br>
>> > Following the instruction of API and the modifications to use API for<br>
>> > bacteria, I use the following code to do the job:<br>
>> > # load the lookup from the main Ensembl Bacteria public server<br>
>> > my $lookup = Bio::EnsEMBL::LookUp->new(<br>
>> >   -URL => "<a href="http://bacteria.ensembl.org/registry.json" target="_blank">http://bacteria.ensembl.org/registry.json</a>",<br>
>> >   -NO_CACHE => 1<br>
>> > );<br>
>> > # find the correct database adaptor using a unique name<br>
>> > my ($dba) = @{$lookup->get_by_name_exact(<br>
>> >   'methanocella_conradii_hz254'<br>
>> > )};<br>
>> > # get adaptor for ontology<br>
>> > my $goada=$dba->get_adaptor('Multi','Ontology','OntologyTerm');<br>
>> > my $genes = $dba->get_GeneAdaptor()->fetch_all(); # where is the<br>
>> > get_GeneAdaptor() documentation<br>
>> > # ###test####<br>
>> > print "Found ".scalar @$genes." genes for ".$dba->species()."\n";<br>
>> ><br>
>> > # get go infomation (modified from <a href="http://kokocinsky.net" target="_blank">kokocinsky.net</a> ensembl coding)<br>
>> > foreach my $gene (@$genes){<br>
>> > my $links = $gene->get_all_DBLinks();<br>
>> > foreach my $link (@$links){<br>
>> > if ($link->database eq "GO"){<br>
>> > my $term_id=$link->display_id;<br>
>> > my $term_name='-';<br>
>> > my $term=$goada->fetch_by_accession($term_id);<br>
>> > if($term and $term->name){<br>
>> > $term_name=$term->name;}<br>
>> > print $gene->stable_id.":$term_id ($term_name)\n";<br>
>> > # fetch complete GO hierachy<br>
>> > foreach my $ancestor_term (@{$term->ancestors()}){<br>
>> > print "\t". $ancestor_term->accession." (".$ancestor_term->name.")\n";<br>
>> > }<br>
>> >   }<br>
>> >  }<br>
>> > }<br>
>> ><br>
>> > it works well before "get go information"<br>
>> > the output was as following:<br>
>> > Can't call method "fetch_by_accession" on an undefined value at<br>
>> > /home/liupf/<br>
>> > <a href="http://hz254.pl" target="_blank">hz254.pl</a> line 27.<br>
>> > 1, I do not understand the use of 'get_GeneAdaptor', I could not find<br>
>> > documentation on this synthax.<br>
>> > 2, please give me some suggestiones on how to fullfill my task.<br>
>> ><br>
>> > Thank you all!<br>
>> ><br>
>> > $ perl ~/ApiVersion.pl<br>
>> > The API version used is 74<br>
>> ><br>
>> > --<br>
>> > Pengfei Liu, PhD Candidate<br>
>> ><br>
>> > Lab of Microbial Ecology<br>
>> > College of Resources and Environmental Sciences<br>
>> > China Agricultural University<br>
>> > No.2 Yuanmingyuanxilu, Beijing, 100193<br>
>> > P.R. China<br>
>> ><br>
>> > Tel: +86-10-62731358<br>
>> > Fax: +86-10-62731016<br>
>> ><br>
>> > E-mail: <a href="mailto:liupfskygre@gmail.com">liupfskygre@gmail.com</a><br>
>> > _______________________________________________<br>
>> > Dev mailing list    <a href="mailto:Dev@ensembl.org">Dev@ensembl.org</a><br>
>> > Posting guidelines and subscribe/unsubscribe info:<br>
>> > <a href="http://lists.ensembl.org/mailman/listinfo/dev" target="_blank">http://lists.ensembl.org/mailman/listinfo/dev</a><br>
>> > Ensembl Blog: <a href="http://www.ensembl.info/" target="_blank">http://www.ensembl.info/</a><br>
>> ><br>
>><br>
>><br>
><br>
><br>
> --<br>
> Pengfei Liu, PhD Candidate<br>
><br>
> Lab of Microbial Ecology<br>
> College of Resources and Environmental Sciences<br>
> China Agricultural University<br>
> No.2 Yuanmingyuanxilu, Beijing, 100193<br>
> P.R. China<br>
><br>
> Tel: +86-10-62731358<br>
> Fax: +86-10-62731016<br>
><br>
> E-mail: <a href="mailto:liupfskygre@gmail.com">liupfskygre@gmail.com</a><br>
><br>
> If you are afraid of tomorrow, how can you enjoy today!<br>
> Keep hungry, Keep foolish!<br>
> Moving forward!<br>
><br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div>Pengfei Liu, PhD Candidate<br><br>Lab of Microbial Ecology<br>College of Resources and Environmental Sciences<br>China Agricultural University<br>No.2 Yuanmingyuanxilu, Beijing, 100193<br>
P.R. China<br><br>Tel: +86-10-62731358<br>Fax: +86-10-62731016<br> <br>E-mail: <a href="mailto:liupfskygre@gmail.com" target="_blank">liupfskygre@gmail.com</a></div>
<div> </div>
<div>If you are afraid of tomorrow, how can you enjoy today! </div>
<div>Keep hungry, Keep foolish! </div>
<div>Moving forward!</div>
</div>