[ensembl-dev] Homology

Andy Yates ayates at ebi.ac.uk
Sat Nov 12 10:19:50 GMT 2011


Hi James,

Javier is quite right that this normally happens when you have used the wrong version of the Api. To see what the registry is loading you can add a 

-VERBOSE => 1

Argument to the load_registry_from_db() call.

Hope this helps,

Andy

P.S. if you downloaded the tar ball Api recently (about 1-2 weeks ago) then it had become corrupted but is ok now

Sent from my brain

On 11 Nov 2011, at 17:50, James Blackshaw <jab250 at mrc-mbu.cam.ac.uk> wrote:

> Hi,
> I've been trying to put together some scripts for finding the homolgies
> for some lists of genes I'm interested in, but I keep getting errors
> with the "fetch" methods.
> 
> "Can't call method "fetch_by_source_stable_id" on an undefined value at
> sandbox3.pl line 15."
> 
> I've used one script taken from a presentation by Stephen Fitzgerald at
> Edinburgh, and another from this maining list. I'm including both.
> 
> From the powerpoint:
> use strict;
> use Bio::EnsEMBL::Registry;
> my $reg = "Bio::EnsEMBL::Registry";
> 
> $reg->load_registry_from_db(
>    -host=>"ensembldb.ensembl.org",
>    -user =>  "anonymous");
> 
> 
> my $ma = $reg->get_adaptor(
>    "Multi", "compara", "Member");
> my $member = $ma->fetch_by_source_stable_id(
>    "ENSEMBLGENE", "ENSG00000000971");
> 
> my $homology_adaptor = $reg->get_adaptor(
>    "Multi", "compara", "Homology");
> 
> my $homologies = $homology_adaptor->
>    fetch_all_by_Member($member);
> 
> foreach my $this_homology (@$homologies) {
>  print $this_homology->description, "\n";
>  my $member_attributes = $this_homology->
>      get_all_Member_Attribute();
>  foreach my $this_mem_attr (@$member_attributes) {
>    my ($this_member, $this_attribute) =
>        @$this_mem_attr;
>    print $this_member->genome_db->name, " ",
>            $this_member->source_name, " ",
>            $this_member->stable_id, "\n";
>  }
>  print "\n";
> }
> 
> ==========================================
> 
> From the list:
> use Bio::EnsEMBL::Registry;
> Bio::EnsEMBL::Registry->load_registry_from_db(
>    -host =>  'ensembldb.ensembl.org',
>    -user =>  'anonymous',
>    -port =>  5306);
> my $member_adaptor = Bio::EnsEMBL::Registry->get_adaptor(
>    'Multi','compara','Member');
> 
> # fetch a Member
> # get the MemberAdaptor
> my $member_adaptor =
> Bio::EnsEMBL::Registry->get_adaptor('Multi','compara','Member');
> 
> # fetch a Memmy $member =
> $member_adaptor->fetch_by_source_stable_id('ENSEMBLPROTEIN','ENSG00000004059');
> my $member =
> $member_adaptor->fetch_by_source_stable_id('ENSEMBLPEP','ENSDARP00000103634');
> # print out some information about the Member
> print $member->description, "\n";
> 
> 
> 
> my $homology_adaptor = Bio::EnsEMBL::Registry->get_adaptor('Multi',
> 'compara', 'Homology');
> my $homologies = $homology_adaptor->fetch_all_by_Member($member);
> 
> # That will return a reference to an array with all
> homologies(orthologues in
> # other species and paralogues in the same one)
> # Then for each homology, you can get all the Members implicated
> 
> foreach my $homology (@{$homologies}) {
>  # You will find different kind of description
>  # UBRH, MBRH, RHS, YoungParalogues
>  # see ensembl-compara/docs/docs/schema_doc.html for more details
> 
>  print $homology->description," ", $homology->subtype,"\n";
> # And if they are defined dN and dS related values
>  print " dn ", $homology->dn,"\n";
>  print " ds ", $homology->ds,"\n";
>  print " dnds_ratio ", $homology->dnds_ratio,"\n";
> }
> 
> my $homology = $homologies->[0];
> # take one of the homologies and lookinto it
> 
> foreach my $member_attribute (@{$homology->get_all_Member_Attribute}) {
> 
>  # for each Member, you get information on the Member specifically and in
>  # relation to the homology relation via Attribute object
> 
>  my ($member, $attribute) = @{$member_attribute};
>  print (join " ", map { $member->$_ }  qw(stable_id taxon_id))."\n";
>  print (join " ", map { $attribute->$_ } qw(perc_id
> perc_posperc_cov))."\n";
> 
> }
> ====================================================
> 
> 
> 
> James Blackshaw
> PhD Student
> MRC Mitochondrial Biology Unit
> 
> 
> _______________________________________________
> Dev mailing list    Dev at ensembl.org
> List admin (including subscribe/unsubscribe): http://lists.ensembl.org/mailman/listinfo/dev
> Ensembl Blog: http://www.ensembl.info/




More information about the Dev mailing list