Archive Ensembl HomeArchive Ensembl Home
AttributeAdaptor.pm
Go to the documentation of this file.
00001 package Bio::EnsEMBL::Compara::DBSQL::AttributeAdaptor;
00002 
00003 use strict;
00004 use Bio::EnsEMBL::DBSQL::BaseAdaptor;
00005 
00006 our @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);
00007 
00008 sub fetch_by_Member_Relation {
00009   my ($self, $member, $relation) = @_;
00010 
00011   my $sth;
00012   my @attributes;
00013 
00014   if ($relation->isa('Bio::EnsEMBL::Compara::Family')) {
00015     my $sql = "SELECT * from family_member where family_id = ? AND member_id = ?";
00016     $sth = $self->prepare($sql);
00017     $sth->execute($relation->dbID, $member->dbID);
00018   }
00019   elsif ($relation->isa('Bio::EnsEMBL::Compara::Domain')) {
00020     my $sql = "SELECT * from domain_member where domain_id = ? AND member_id = ?";
00021     $sth = $self->prepare($sql);
00022     $sth->execute($relation->dbID, $member->dbID);
00023   }
00024   elsif ($relation->isa('Bio::EnsEMBL::Compara::Homology')) {
00025     my $sql = "SELECT * from homology_member where homology_id = ? AND member_id = ?";
00026     $sth = $self->prepare($sql);
00027     $sth->execute($relation->dbID, $member->dbID);
00028   }
00029   
00030   my %column;
00031   $sth->bind_columns( \( @column{ @{$sth->{NAME_lc} } } ));
00032 
00033   while ($sth->fetch()) {
00034     my $attribute = new Bio::EnsEMBL::Compara::Attribute;
00035     foreach my $key (keys %column) {
00036       $attribute->$key($column{$key});
00037     }
00038     push @attributes, $attribute;
00039   }
00040 
00041   return \@attributes;
00042   # need to return a array list, because in the case of domain, a member can have more
00043   # than one attribute, repetition of the same domain in the protein...
00044   # not the case for Family and Homology
00045 }
00046 
00047 1;