<div dir="ltr"><div>Hi, <br>Magali<br>Thanks for your quick reply. I followed your instruction and modified line 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">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><div><span style="color:rgb(204,0,0)">#one more question: where could I find those informations like host, user, and dbname that I needed to get data object or adaptor wanted ?</span><br>
</div><div><br></div># now use the DBAdaptor to get_adaptor <br><div>my $goada=$ontology_dba->get_adaptor('Multi','Ontology','OntologyTerm');<br></div><div><span style="color:rgb(204,0,0)"># in your reply is  $goada=$registry, but i think it shoud by  $goada=$ontology_dba, right?</span><br>
<br></div><div>the output:<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><div>
I check the doxygen for OntologyDBAdaptor, the new() methods, but returned examples were all Bio::EnsEMBL::DBSQL::DBAdaptor::new(), so I think new method is no longer supported by OntologyDBAdaptor, so I also tried <br>my $ontology_dba=Bio::EnsEMBL::DBSQL::DBAdaptor->new(.....<br>
<br></div><div>unfortunately, output came:<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 37.<br><br></div><div>### confusion on understanding Ensembl API<br>
</div><div>Use API to fetch data, you need to use the right database and the corresponding DBAdaptor, and then use the right object adaptor and methods to do it. Is my understanding right? <br>I am confused by that:<br></div>
<div>my genes was in the bacteria database, I could fetch them, but if the gene ontology terms was in another database, how could the connected and does that mean I need two DBAdaptor for each of them?<br></div><div>Hope those not bothering you too much!<br>
###<br></div><div>Thank you very much!<br></div><div><br></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>
The get_GeneAdaptor method is equivalent using get_Adaptor('Gene').<br>
More documentation can be found here:<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, 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>
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>
<div><div class="h5"><br>
> Hi all<br>
>   I am new to API. Now I am trying to use it to get all GO terms for each<br>
> genes of a archaea(Methanocella conradii HZ254), and want to get a table<br>
> with two columns, on for gene name and the other for GO term 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>
</div></div>> <a href="http://hz254.pl" target="_blank">hz254.pl</a> line 27.<br>
<div class="im">> 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>
</div>> _______________________________________________<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>
</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>