Archive Ensembl HomeArchive Ensembl Home
SitewiseOmegaAdaptor.pm
Go to the documentation of this file.
00001 #
00002 # Ensembl module for Bio::EnsEMBL::Compara::DBSQL::SitewiseOmegaAdaptor
00003 #
00004 # Cared for by Albert Vilella <avilella@ebi.ac.uk>
00005 #
00006 # Copyright Albert Vilella
00007 #
00008 # You may distribute this module under the same terms as perl itself
00009 
00010 # POD documentation - main docs before the code
00011 
00012 =head1 NAME
00013 
00014 Bio::EnsEMBL::Compara::DBSQL::SitewiseOmegaAdaptor - DESCRIPTION of Object
00015 
00016 =head1 SYNOPSIS
00017 
00018 Give standard usage here
00019 
00020 =head1 DESCRIPTION
00021 
00022 Describe the object here
00023 
00024 =head1 AUTHOR - Albert Vilella
00025 
00026 This modules is part of the Ensembl project http://www.ensembl.org
00027 
00028 Email aVilella@ebi.ac.uk
00029 
00030 Describe contact details here
00031 
00032 =head1 APPENDIX
00033 
00034 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
00035 
00036 =cut
00037 
00038 
00039 # Let the code begin...
00040 
00041 
00042 package Bio::EnsEMBL::Compara::DBSQL::SitewiseOmegaAdaptor;
00043 use vars qw(@ISA);
00044 use strict;
00045 
00046 use Bio::EnsEMBL::DBSQL::BaseAdaptor;
00047 use Bio::EnsEMBL::Compara::SitewiseOmega;
00048 use Bio::EnsEMBL::Utils::Exception;
00049 
00050 @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);
00051 
00052 sub fetch_all_by_ProteinTreeId {
00053     my ($self, $protein_tree_id) = @_;
00054     my $sitewise_dnds_values = [];
00055 
00056     my $sql = qq{
00057     SELECT
00058         sitewise_id,
00059         aln_position,
00060         node_id,
00061         tree_node_id,
00062         omega,
00063         omega_lower,
00064         omega_upper,
00065         optimal,
00066         threshold_on_branch_ds,
00067         type
00068     FROM
00069         sitewise_aln
00070     WHERE
00071         node_id = ?
00072     };
00073 
00074     my $sth = $self->prepare($sql);
00075     $sth->execute($protein_tree_id);
00076 
00077     my $sitewise_dnds;
00078     while (my ($sitewise_id,$aln_position,$node_id,$tree_node_id,
00079                $omega,$omega_lower,$omega_upper,$optimal,
00080                $threshold_on_branch_ds,$type) = $sth->fetchrow_array()) {
00081     $sitewise_dnds = Bio::EnsEMBL::Compara::SitewiseOmega->new_fast(
00082                        {'adaptor' => $self,
00083                     '_dbID' => $sitewise_id,
00084                     'aln_position' => $aln_position,
00085                     'node_id' => $node_id,
00086                     'tree_node_id' => $tree_node_id,
00087                     'omega' => $omega,
00088                     'omega_lower' => $omega_lower,
00089                     'omega_upper' => $omega_upper,
00090                     'optimal' => $optimal,
00091                     'threshold_on_branch_ds' => $threshold_on_branch_ds,
00092                     'type' => $type});
00093     push(@$sitewise_dnds_values, $sitewise_dnds);
00094     }
00095 
00096     #sort into numerical order based on aln_position
00097     my @sorted_values = sort {$a->{aln_position} <=> $b->{aln_position}} @$sitewise_dnds_values;
00098     return \@sorted_values;
00099 }
00100 
00101 
00102 1;