From 571f28ab34ee0308cb79ae3bc9ab3711f1b9cf88 Mon Sep 17 00:00:00 2001
From: Monika Komorowska <mk8@sanger.ac.uk>
Date: Mon, 18 Apr 2011 15:24:22 +0000
Subject: [PATCH] Internal method _build_circular_slice_cache added

---
 modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm | 39 ++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
index 13fd3e7095..931baf1be1 100644
--- a/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
+++ b/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm
@@ -120,7 +120,6 @@ sub new {
   $self->{'sr_name_cache'} = $seq_region_cache->{'name_cache'};
   $self->{'sr_id_cache'}   = $seq_region_cache->{'id_cache'};
 
-
   $self->{'lrg_region_test'} = undef;
   my $meta_container = $self->db->get_MetaContainer();
   my @values = $meta_container->list_value_by_key("LRG");
@@ -499,6 +498,7 @@ sub fetch_by_region_unique {
   my @out   = ();
   my $slice = $self->fetch_by_region(@_);
 
+
   if ( !exists( $self->{'asm_exc_cache'} ) ) {
     $self->_build_exception_cache();
   }
@@ -602,6 +602,7 @@ sub fetch_by_seq_region_id {
   my $arr = $self->{'sr_id_cache'}->{$seq_region_id};
   my ( $name, $length, $cs, $cs_id );
 
+
   if ( $arr && defined( $arr->[2] ) ) {
     ( $name, $cs_id, $length ) = ( $arr->[1], $arr->[2], $arr->[3] );
     $cs = $self->db->get_CoordSystemAdaptor->fetch_by_dbID($cs_id);
@@ -778,6 +779,7 @@ sub fetch_all {
 
   my %bad_vals=();
 
+
   #
   # Get a hash of non reference seq regions
   #
@@ -1241,6 +1243,7 @@ sub fetch_by_Feature{
     throw('Feature must be attached to a valid slice.');
   }
 
+
   my $fstart = $feature->start();
   my $fend   = $feature->end();
   if(!defined($fstart) || !defined($fend)) {
@@ -1864,6 +1867,36 @@ LSQL
 } ## end sub cache_toplevel_seq_mappings
 
 
+sub _build_circular_slice_cache {
+  my $self = shift;
+
+  # build up a cache of circular sequence region ids
+  my $sth =
+    	$self->prepare( "SELECT sra.seq_region_id FROM seq_region_attrib sra "
+		  	. "INNER JOIN attrib_type at ON sra.attrib_type_id = at.attrib_type_id "
+			. "INNER JOIN seq_region sr ON sra.seq_region_id = sr.seq_region_id "
+			. "INNER JOIN coord_system cs ON sr.coord_system_id = cs.coord_system_id "
+			. "WHERE code = 'circular_seq' and cs.species_id = ?");
+
+  $sth->bind_param( 1, $self->species_id(), SQL_INTEGER );
+  $sth->execute();
+
+  my $id;
+  my %hash;
+  if ( ($id) = $sth->fetchrow_array() ) {
+  	$self->{'circular_sr_id_cache'} = \%hash;
+        $self->{'is_circular'} = 1;
+	$hash{ $id } = $id;
+ 	while ( ($id) = $sth->fetchrow_array() ) {
+    		$hash{ $id } = $id;
+  	}
+  } else {
+	$self->{'is_circular'} = 0;
+  }
+  $sth->finish();
+} ## end _build_circular_slice_cache
+
+
 #####################################
 # sub DEPRECATED METHODs
 #####################################
@@ -2077,4 +2110,8 @@ sub fetch_by_chr_name{
 }
 
 
+
+
+
+
 1;
-- 
GitLab