Archive Ensembl HomeArchive Ensembl Home
UnconventionalTranscriptAssociationAdaptor.pm
Go to the documentation of this file.
00001 =head1 LICENSE
00002 
00003   Copyright (c) 1999-2012 The European Bioinformatics Institute and
00004   Genome Research Limited.  All rights reserved.
00005 
00006   This software is distributed under a modified Apache license.
00007   For license details, please see
00008 
00009     http://www.ensembl.org/info/about/code_licence.html
00010 
00011 =head1 CONTACT
00012 
00013   Please email comments or questions to the public Ensembl
00014   developers list at <dev@ensembl.org>.
00015 
00016   Questions may also be sent to the Ensembl help desk at
00017   <helpdesk@ensembl.org>.
00018 
00019 =cut
00020 
00021 =head1 NAME
00022 
00023 Bio::EnsEMBL::DBSQL::UnconventionalTranscriptAssociationAdaptor
00024 
00025 =head1 SYNOPSIS
00026 
00027   $utaa = $registry->get_adaptor( 'Human', 'Core',
00028     'UnconventionalTranscriptAssociation' );
00029 
00030   my $uta = $utaa->fetch_all_by_type('antisense');
00031 
00032 =head1 DESCRIPTION
00033 
00034 This is an adaptor for the retrieval and storage of
00035 UnconventionalTranscriptAssociation objects from the database.  Most of
00036 the implementation is in the superclass BaseFeatureAdaptor.
00037 
00038 =head1 METHODS
00039 
00040 =cut
00041 
00042 package Bio::EnsEMBL::DBSQL::UnconventionalTranscriptAssociationAdaptor;
00043 
00044 use strict;
00045 use Bio::EnsEMBL::DBSQL::BaseAdaptor;
00046 use Bio::EnsEMBL::UnconventionalTranscriptAssociation;
00047 
00048 use vars qw(@ISA);
00049 
00050 @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);
00051 
00052 
00053 
00054 
00055 =head2 fetch_all_by_interaction_type
00056 
00057   Arg [1]    : String type
00058                the type of associations to obtain
00059   Example    : $utas = $utaa->fetch_all_by_type('antisense');
00060   Description: Obtains all unconventional transcript associations that
00061                have a particular interaction type.
00062                NOTE:  In a multi-species database, this method will
00063                return all the entries matching the search criteria, not
00064                just the ones associated with the current species.
00065   Returntype : listREF of Bio::EnsEMBL::UnconventionalTranscriptAssociations
00066   Exceptions : none
00067   Caller     : general
00068   Status     : At Risk
00069              : under development
00070 
00071 =cut
00072 
00073 sub fetch_all_by_interaction_type {
00074 
00075   my( $self, $type) = @_;
00076 
00077   my $sth = $self->prepare("SELECT transcript_id, gene_id, interaction_type " .
00078                "FROM unconventional_transcript_association " .
00079                "WHERE interaction_type = ?");
00080 
00081   $sth->bind_param(1, $type, SQL_VARCHAR);
00082   $sth->execute();
00083 
00084   my $results = $self->_objs_from_sth($sth);
00085 
00086   $sth->finish();
00087 
00088   return $results;
00089 
00090 }
00091 
00092 
00093 =head2 fetch_all_by_gene
00094 
00095   Arg [1]    : String gene the gene of associations to obtain
00096   Arg [2]    : (optional) An interaction type; if set, only associations of this type will be returned.
00097   Example    : $utas = $utaa->fetch_all_by_gene($gene, 'antisense');
00098   Description: Obtains all unconventional transcript associations that involve
00099                a particular gene.
00100   Returntype : listREF of Bio::EnsEMBL::UnconventionalTranscriptAssociations
00101   Exceptions : none
00102   Caller     : general
00103   Status     : At Risk
00104              : under development
00105 
00106 =cut
00107 
00108 sub fetch_all_by_gene {
00109 
00110   my( $self, $gene, $type) = @_;
00111 
00112   if(!ref($gene) || !$gene->isa('Bio::EnsEMBL::Gene')) {
00113     throw('$gene must be a Bio::EnsEMBL::Gene');
00114   }
00115 
00116   my $sql = "SELECT transcript_id, gene_id, interaction_type FROM unconventional_transcript_association WHERE gene_id = ?";
00117   $sql .= " AND interaction_type = ?" if ($type);
00118 
00119   my $sth = $self->prepare($sql);
00120 
00121   $sth->bind_param(1, $gene->dbID(), SQL_INTEGER);
00122   $sth->bind_param(2, $type, SQL_VARCHAR) if ($type);
00123 
00124   $sth->execute();
00125 
00126   my $results = $self->_objs_from_sth($sth);
00127 
00128   $sth->finish();
00129 
00130   return $results;
00131 
00132 }
00133 
00134 
00135 =head2 fetch_all_by_transcript
00136 
00137   Arg [1]    : String transcript the transcript of associations to obtain
00138   Arg [2]    : (optional) An interaction type; if set, only associations of this type will be returned.
00139   Example    : $utas = $utaa->fetch_all_by_transcript($transcript, 'antisense');
00140   Description: Obtains all unconventional transcript associations that involve
00141                a particular transcript.
00142   Returntype : listREF of Bio::EnsEMBL::UnconventionalTranscriptAssociations
00143   Exceptions : none
00144   Caller     : general
00145   Status     : At Risk
00146              : under development
00147 
00148 =cut
00149 
00150 sub fetch_all_by_transcript {
00151 
00152   my( $self, $transcript, $type) = @_;
00153 
00154   if(!ref($transcript) || !$transcript->isa('Bio::EnsEMBL::Transcript')) {
00155     throw('$transcript must be a Bio::EnsEMBL::Transcript');
00156   }
00157 
00158   my $sql = "SELECT transcript_id, gene_id, interaction_type FROM unconventional_transcript_association WHERE transcript_id = ?";
00159   $sql .= " AND interaction_type = ?" if ($type);
00160 
00161   my $sth = $self->prepare($sql);
00162 
00163   $sth->bind_param(1, $transcript->dbID(), SQL_INTEGER);
00164   $sth->bind_param(2, $type, SQL_VARCHAR) if ($type);
00165 
00166   $sth->execute();
00167 
00168   my $results = $self->_objs_from_sth($sth);
00169 
00170   $sth->finish();
00171 
00172   return $results;
00173 
00174 }
00175 
00176 
00177 =head2 store
00178 
00179   Arg [1]    : Bio::EnsEMBL::UnconventionalTranscriptAssociation
00180                the unconventional transcript association to store in the database
00181   Example    : $utaa_adaptor->store($uta);
00182   Description: stores unconventional transcript associations in the database
00183   Returntype : none
00184   Exceptions :
00185   Caller     : general
00186   Status     : At Risk
00187              : under development
00188 
00189 =cut
00190 
00191 sub store {
00192 
00193   my( $self, $uta ) = @_;
00194 
00195   if(!ref($uta) || !$uta->isa('Bio::EnsEMBL::UnconventionalTranscriptAssociation')) {
00196     throw('$uta must be a Bio::EnsEMBL::UnconventionalTranscriptAssociation');
00197   }
00198 
00199   my $sth = $self->prepare(qq {INSERT into unconventional_transcript_association
00200                    (transcript_id, gene_id, interaction_type) VALUES (?,?,?)});
00201 
00202   $sth->bind_param(1, $uta->transcript()->dbID(), SQL_INTEGER);
00203   $sth->bind_param(2, $uta->gene()->dbID,         SQL_INTEGER);
00204   $sth->bind_param(3, $uta->interaction_type(),   SQL_VARCHAR);
00205 
00206   $sth->execute();
00207 
00208 }
00209 
00210 
00211 
00212 sub _objs_from_sth {
00213 
00214   my ($self, $sth) = @_;
00215 
00216   my $transcript_adaptor = $self->db()->get_TranscriptAdaptor();
00217   my $gene_adaptor = $self->db()->get_GeneAdaptor();
00218 
00219   my ($gene_id, $transcript_id, $type);
00220   $sth->bind_columns(\$transcript_id, \$gene_id, \$type);
00221 
00222   my @results;
00223 
00224   while($sth->fetch()) {
00225 
00226     my $gene = $gene_adaptor->fetch_by_dbID($gene_id);
00227     my $transcript = $transcript_adaptor->fetch_by_dbID($transcript_id);
00228 
00229     my $obj = Bio::EnsEMBL::UnconventionalTranscriptAssociation->new($transcript, $gene, $type);
00230     push @results, $obj;
00231 
00232   }
00233 
00234   return \@results;
00235 }
00236 
00237 1;
00238 
00239