<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Elena,<br>
    <br>
    The issue here is that the fetch_all_by_descendant_term method, and
    all similar methods dealing with ontology terms, have their own API.<br>
    <br>
    With the get_all_DBLinks method, you can fetch xrefs for an object,
    and some of these objects can be ontology accession.<br>
    But an xref object only has limited information that does not cover
    all the complexity of ontology objects.<br>
    <br>
    To deal with this, we have a separate database, the ontology
    database, which contains not only ontology accessions, but also the
    whole definition as in GO as well as the links between ontology
    terms.<br>
    <br>
    In your script2, goslim is still a DBEntry object (or xrefs).<br>
    To be able to access the meta information about ontologies, you need
    to create an OntologyTerm object using the GO accession.<br>
    <blockquote>my $accession = $goslim->display_id();<br>
      my $go_term = $goa->fetch_by_accession($accession);<br>
    </blockquote>
    From there on, you should be able to use methods like
    fetch_all_by_descendant_term on that go term.<br>
    <blockquote>$goa->fetch_all_by_descendant_term($go_term);<br>
    </blockquote>
    Note we do not need to restrict the method to a specific external_db
    (like goslim_goa), because we already are in the realm of
    ontologies.<br>
    <br>
    I hope that helps.<br>
    <br>
    <br>
    Regards,<br>
    Magali<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 06/07/13 09:10, Elena Grassi wrote:<br>
    </div>
    <blockquote
cite="mid:CALp0JQAAV1GY38=sib8x-5MA6+Y0_o66RE+BSv8KxtTJd2J_xw@mail.gmail.com"
      type="cite">
      <pre wrap="">I'm sorry to bother you but I'm puzzled (again) by the comparisons
between the query-script v1-script with ancenstors results (apart from
the difference in time...the query is almost instantaneous while the
perl script are really slow).

Number of line resulting from the first script, the version that calls
fetch_all_by_parent_term and the SQL query:
data@tungsteno:/rogue/bioinfotree/prj/expr_evol/local/src$ sort
goslim_api.tsv | uniq | wc -l
216713
data@tungsteno:/rogue/bioinfotree/prj/expr_evol/local/src$ sort
goslim_inclusive_api.tsv | uniq | wc -l
216713
data@tungsteno:/rogue/bioinfotree/prj/expr_evol/local/src$ sort
goslim_api.tsv | uniq | wc -l
216713

They are all the same!

script1 relevant part:

        foreach my $gene (@$genes) {
                print_DBEntries($gene->get_all_DBLinks('goslim_goa'),
$gene->stable_id());
        }

sub print_DBEntries
{
    my $db_entries = shift;
    my $gene = shift;

    foreach my $dbe ( @{$db_entries} ) {
        print $gene . "\t" . $dbe->display_id() . "\t" .
$dbe->description() . "\n";
    }
}

script2:
        foreach my $gene (@$genes) {
                my $goslims = $gene->get_all_DBLinks('goslim_goa');
                foreach my $goslim (@$goslims) {
                        bless $goslim, 'Bio::EnsEMBL::OntologyTerm';
                        if (!defined($ancestors{$goslim})) {
                                my $goa = $registry->get_adaptor(
'Multi', 'Ontology', 'OntologyTerm' );
                                $ancestors{$goslim} =
$goa->fetch_all_by_descendant_term($goslim, 'goslim_goa');
                        }
                        bless $goslim, 'Bio::EnsEMBL::DBEntry';
                        print $gene->stable_id() . "\t" .
$goslim->display_id() . "\t" . $goslim->description() . "\n";
                        foreach my $ancestor (@{ $ancestors{$goslim} }) {
                                print $gene->stable_id() . "\t" .
$ancestor->display_id() . "\t" . $ancestor->description() . "\n";
                        }
                }

        }

SQL:
select g.stable_id,x.dbprimary_acc,x.description from xref as x,
object_xref as o, transcript as t, translation as tr, gene as g where
x.external_db_id = "12700" AND o.xref_id=x.xref_id and g.gene_id =
t.gene_id AND t.transcript_id = tr.transcript_id AND tr.translation_id
= o.ensembl_id;

Thanks,
E.

_______________________________________________
Dev mailing list    <a class="moz-txt-link-abbreviated" href="mailto:Dev@ensembl.org">Dev@ensembl.org</a>
Posting guidelines and subscribe/unsubscribe info: <a class="moz-txt-link-freetext" href="http://lists.ensembl.org/mailman/listinfo/dev">http://lists.ensembl.org/mailman/listinfo/dev</a>
Ensembl Blog: <a class="moz-txt-link-freetext" href="http://www.ensembl.info/">http://www.ensembl.info/</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>