From bbeb1814805e9e3c756a2f93b41b2b0f281172d0 Mon Sep 17 00:00:00 2001
From: Yuan Chen <yuan@sanger.ac.uk>
Date: Mon, 10 Oct 2005 10:21:03 +0000
Subject: [PATCH] check strand for REGULATORY_REGION as well

---
 .../Bio/EnsEMBL/Utils/TranscriptAlleles.pm    | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/modules/Bio/EnsEMBL/Utils/TranscriptAlleles.pm b/modules/Bio/EnsEMBL/Utils/TranscriptAlleles.pm
index bb74845580..91ab625ff2 100644
--- a/modules/Bio/EnsEMBL/Utils/TranscriptAlleles.pm
+++ b/modules/Bio/EnsEMBL/Utils/TranscriptAlleles.pm
@@ -42,11 +42,12 @@ use Bio::EnsEMBL::Utils::Exception qw(throw warning);
 use Bio::EnsEMBL::Variation::ConsequenceType;
 use vars qw(@ISA @EXPORT_OK);
 
+use Data::Dumper;
+
 @ISA = qw(Exporter);
 
 @EXPORT_OK = qw(get_all_ConsequenceType type_variation);
 
-use Data::Dumper;
 
 =head2 get_all_ConsequenceType
 
@@ -75,7 +76,7 @@ sub get_all_ConsequenceType {
     throw('Bio::EnsEMBL::Transcript argument is required.');
   }
 
-  if(!ref($alleles) || (ref($alleles) ne 'ARRAY') {
+  if(!ref($alleles) || (ref($alleles) ne 'ARRAY')) {
     throw('Reference to a list of Bio::EnsEMBL::Variation::AlleleFeature objects is required');
   }
 
@@ -185,14 +186,16 @@ sub type_variation {
     return [];
   }
 
-  my @features = $tr->fetch_all_regulatory_features();
+  my @features = @{$tr->fetch_all_regulatory_features()};
 
   #regulatory_features and consequence_type feature are all in genomic coordinates,
-  #so just to check whether they overlap with each other or not
-  foreach my $feature (@features) {
-    if ($var->end >= $feature->start and $var->start <= $feature->end) {
-      $var->regulatory_region('REGULATORY_REGION');
-      last;
+  #so just to check whether they overlap with each other or not also in same strand
+  if (@features) {
+    foreach my $feature (@features) {
+      if ($var->end >= $feature->start and $var->start <= $feature->end and $var->strand == $feature->strand) {
+	$var->regulatory_region('REGULATORY_REGION');
+	last;
+      }
     }
   }
 
-- 
GitLab