Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Problems with ensembl perl script

by bioinfo (Initiate)
on Feb 01, 2009 at 11:32 UTC ( #740529=perlquestion: print w/ replies, xml ) Need Help??
bioinfo has asked for the wisdom of the Perl Monks concerning the following question:

Buenos días hermanos: I need some help for this script:
use strict; use warnings; use Bio::EnsEMBL::Registry; ## Load the registry automatically my $reg = "Bio::EnsEMBL::Registry"; $reg->load_registry_from_url('mysql://anonymous@ensembldb.ensembl. +org'); ## Get the human gene adaptor my $human_gene_adaptor = $reg->get_adaptor('Homo sapiens', 'core', 'Gene'); ## Get the compara member adaptor my $member_adaptor = $reg->get_adaptor('Compara', 'compara', 'Member'); ## Get the compara homology adaptor my $homology_adaptor = $reg->get_adaptor ('Multi', 'compara', 'MethodLinkSpeciesSet') +; my @BreastCANgenes = ('ABCA3','ABCB10','ABCB8'); open ('archivo', '>homologos.txt'); my $gen; foreach $gen (@BreastCANgenes) { ## Get all existing gene object my $ctdp1_genes = $human_gene_adaptor->fetch_all_by_external_name( +$gen); ## For each of these genes... foreach my $ctdp1_gene (@$ctdp1_genes) { ## Get the compara member my $member = $member_adaptor->fetch_by_source_stable_id( "ENSEMBLGENE", $ctdp1_gene->stable_id); ## Get all the orthologues my $all_homologies = $homology_adaptor->fetch_all_by_MethodLinkS +peciesSet_orthology_type_subtype($member,'ortholog_one2one','Mammalia +'); ## For each homology foreach my $this_homology (@$all_homologies) { ## print the description (type of homology) and the ## subtype (taxonomy level of the event: duplic. or speciation +) print $this_homology->description, " [", $this_homology->subty +pe, "]\n"; print archivo $this_homology->description, " [", $this_homolog +y->subtype, "]\n"; ## print the members in this homology my $members = $this_homology->get_all_Members(); foreach my $this_member (@$members) { print archivo $this_member->source_name, " ", $this_member->stable_id, " (", $this_member->genome_db->name, ")\n" } print "\n"; } } } close ('archivo');
it isn't works. The error: Can't locate object method "fetch_all_by_MethodLinkSpeciesSet_orthology_type_subtype" via package "Bio::EnsEMBL::Compara::DBSQL::MethodLinkSpeciesSetAdaptor" at ortologos.pl line 34.

Comment on Problems with ensembl perl script
Select or Download Code
Re: Problems with ensembl perl script
by shmem (Canon) on Feb 01, 2009 at 17:09 UTC

    Hmm... fetch_all_by_MethodLinkSpeciesSet_orthology_type_subtype ? That looks like a weird copy / paste error. I'd read that as at least 3 tokens: fetch_all_by_Method, LinkSpecies, and Set_orthology_type_subtype. Or then, that could also be fetch_all_by_, MethodLinkSpeciesSet (since you have that token a few lines earlier), and _orthology_type_subtype

    I'd say to the author of that script: concatenatingmethodnames doesn't create new ones.

    Of course I could be mistaken all together, and there's only a typo somewhere. But not having the Bio::EnsEMBL::Compara::DBSQL::MethodLinkSpeciesSetAdaptor package handy (looks like a constructed namespace, anyways), I can't tell.

Re: Problems with ensembl perl script
by tfrayner (Curate) on Feb 02, 2009 at 09:24 UTC
    The Ensembl API docs and tutorial describe a HomologyAdaptor class which has a fetch_all_by_MethodLinkSpeciesSet_orthology_type_subtype method. However, I'm pretty sure that the adaptor you are using is a MethodLinkSpeciesSetAdaptor, which doesn't inherit from HomologyAdaptor. This is just a guess, but what happens if you change this:
    my $homology_adaptor = $reg->get_adaptor ('Multi', 'compara', 'MethodLinkSpeciesSet') +;
    to this:
    my $homology_adaptor = $reg->get_adaptor ('Multi', 'compara', 'Homology');
    ?

    Cheers,

    Tim

      Thank you both for the help and for your time. I'm stuck with this problem and do not know how to fix it. I made this change that you propose tfrayner but still gives an error:
      -------------------- EXCEPTION -------------------- MSG: [Bio::EnsEMBL::Compara::Member=HASH(0x9adfe40)] must be a Bio::En +sEMBL::Compara::MethodLinkSpeciesSet object STACK Bio::EnsEMBL::Compara::DBSQL::HomologyAdaptor::fetch_all_by_Meth +odLinkSpeciesSet_orthology_type_subtype /home/david/src/ensembl-compa +ra/modules/Bio/EnsEMBL/Compara/DBSQL/HomologyAdaptor.pm:430 STACK toplevel ortologos.pl:35 ---------------------------------------------------

      I started with perl and Ensembl recently and I do not quite understand yet. The documentation is here:

      http://www.ensembl.org/info/docs/api/Pdoc/ensembl-compara/modules/Bio/EnsEMBL/Compara/DBSQL/HomologyAdaptor.html#POD7

      So there should show only the orthologous of Mammalia which are one-to-one.This another code works and returns all species homologues, but I only want mammalian orthologues.
      use strict; use warnings; use Bio::EnsEMBL::Registry; ## Load the registry automatically my $reg = "Bio::EnsEMBL::Registry"; $reg->load_registry_from_url('mysql://anonymous@ensembldb.ensembl. +org'); ## Get the human gene adaptor my $human_gene_adaptor = $reg->get_adaptor("Homo sapiens", "core", "Gene"); ## Get the compara member adaptor my $member_adaptor = $reg->get_adaptor("Compara", "compara", "Member"); ## Get the compara homology adaptor my $homology_adaptor = $reg->get_adaptor("Compara", "compara", "Homology"); my @BreastCANgenes = ('ABCA3','ABCB10','ABCB8','ACADM'); open ("archivo", ">homologos.txt"); my $gen; foreach $gen (@BreastCANgenes) { ## Get all existing gene object my $ctdp1_genes = $human_gene_adaptor->fetch_all_by_external_name( +$gen); ## For each of these genes... foreach my $ctdp1_gene (@$ctdp1_genes) { ## Get the compara member my $member = $member_adaptor->fetch_by_source_stable_id( "ENSEMBLGENE", $ctdp1_gene->stable_id); ## Get all the homologues my $all_homologies = $homology_adaptor->fetch_all_by_Member($mem +ber); ## For each homology foreach my $this_homology (@$all_homologies) { ## print the description (type of homology) and the ## subtype (taxonomy level of the event: duplic. or speciation +) print $this_homology->description, " [", $this_homology->subty +pe, "]\n"; print archivo $this_homology->description, " [", $this_homolog +y->subtype, "]\n"; ## print the members in this homology my $members = $this_homology->get_all_Members(); foreach my $this_member (@$members) { print archivo $this_member->source_name, " ", $this_member->stable_id, " (", $this_member->genome_db->name, ")\n" } print "\n"; } } } close ("archivo");
        Hmm; I think I see what you're trying to do here, and I can see why you'd be frustrated. I've checked out the latest ensembl-compara code from CVS and it looks as though the (poorly named) fetch_all_by_MethodLinkSpeciesSet_orthology_type_subtype method has been removed, and it doesn't seem to have been replaced by anything with equivalent functionality. Maybe I'm wrong, and I guess the Ensembl devs would be the best people to ask. Maybe they've had a DB schema change that meant the old SQL query used to filter on subtype is no longer valid? Anyway, it may be that the best you can do is filter the homologies yourself:
        ## For each homology foreach my $this_homology (@$all_homologies) { next unless $this_homology->subtype eq 'Mammalia';
        ... and then the rest of your loop from the second script. That works on my machine and is reasonably fast, at least for this small gene set. I have no idea whether it will scale to meet your final requirements, though.

        Cheers
        Tim

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://740529]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-07-14 02:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (254 votes), past polls