From 01224e7f1910fe3f3aac9a234a147e8985826aa5 Mon Sep 17 00:00:00 2001
From: Glenn Proctor <gp1@sanger.ac.uk>
Date: Fri, 23 Sep 2005 08:56:56 +0000
Subject: [PATCH] Added coding_gene() and coding_transcript() methods to pull
 data from regulatory_factor_coding table.

---
 modules/Bio/EnsEMBL/RegulatoryFactor.pm | 82 +++++++++++++++++++++++--
 1 file changed, 78 insertions(+), 4 deletions(-)

diff --git a/modules/Bio/EnsEMBL/RegulatoryFactor.pm b/modules/Bio/EnsEMBL/RegulatoryFactor.pm
index f8edfee8f5..7f19d40bef 100644
--- a/modules/Bio/EnsEMBL/RegulatoryFactor.pm
+++ b/modules/Bio/EnsEMBL/RegulatoryFactor.pm
@@ -57,9 +57,10 @@ sub new_fast {
 
 =head2 name
 
-  Arg [1]    : string $name (optional)
-  Example    : $name = $regulatory_factor->name()
-  Description: Getter/Setter for the name of this regulatory factor
+  Arg [1]    : none
+  Example    : $trans = $regulatory_factor->get_coding_transcript()
+  Description: Returns the transcript that codes for this regulatory factor,
+               if it is defined.
   Returntype : string
   Exceptions : none
   Caller     : general
@@ -75,11 +76,84 @@ sub name {
 }
 
 
+=head2 coding_transcript
+
+  Arg [1]    : none
+  Example    : $transcript = $regulatory_factor->coding_transcript()
+  Description: Get the transcript which codes for this regulatory factor.
+  Returntype : Bio::EnsEMBL::Transcript, or undef
+  Exceptions : none
+  Caller     : general
+  Status     : At Risk
+             : under development
+
+=cut
+
+sub coding_transcript {
+
+  my $self = shift;
+
+  my ($transcript_id);
+
+  my $sth = $self->adaptor()->db()->dbc()->prepare("SELECT transcript_id
+			                            FROM regulatory_factor_coding
+			                            WHERE regulatory_factor_id=?");
+
+  $sth->execute($self->dbID());
+  $sth->bind_columns(\$transcript_id);
+
+  my $transcript_adaptor = $self->adaptor()->db()->get_TranscriptAdaptor();
+  my $transcript;
+  if ($sth->fetch) {
+    $transcript = $transcript_adaptor->fetch_by_dbID($transcript_id);
+  }
+
+  return $transcript;
+}
+
+
+=head2 coding_gene
+
+  Arg [1]    : none
+  Example    : $gene = $regulatory_factor->coding_gene()
+  Description: Get the gene which codes for this regulatory factor.
+  Returntype : Bio::EnsEMBL::Gene, or undef
+  Exceptions : none
+  Caller     : general
+  Status     : At Risk
+             : under development
+
+=cut
+
+sub coding_gene {
+
+  my $self = shift;
+
+  my ($gene_id);
+
+  my $sth = $self->adaptor()->db()->dbc()->prepare("SELECT gene_id
+			                            FROM regulatory_factor_coding
+			                            WHERE regulatory_factor_id=?");
+
+  $sth->execute($self->dbID());
+  $sth->bind_columns(\$gene_id);
+
+  my $gene_adaptor = $self->adaptor()->db()->get_GeneAdaptor();
+  my $gene;
+  if ($sth->fetch) {
+    $gene = $gene_adaptor->fetch_by_dbID($gene_id);
+  }
+
+  return $gene;
+}
+
+
+
 =head2 type
 
   Arg [1]    : string $type
   Example    : $type = $regulatory_factor->type()
-  Description: Getter/Setter for the length of this regulatory factor
+  Description: Getter/Setter for the type of this regulatory factor
   Returntype : int
   Exceptions : none
   Caller     : general
-- 
GitLab