From 62bdd49d0c9221d60b86e11efa6fd23d885d7904 Mon Sep 17 00:00:00 2001
From: Ian Longden <ianl@sanger.ac.uk>
Date: Thu, 30 Jun 2011 12:53:09 +0000
Subject: [PATCH] better warning for projections

---
 modules/Bio/EnsEMBL/Feature.pm | 39 ++++++++++++++++++++++++++++------
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/modules/Bio/EnsEMBL/Feature.pm b/modules/Bio/EnsEMBL/Feature.pm
index 40a14d20b7..669e1ba8a3 100644
--- a/modules/Bio/EnsEMBL/Feature.pm
+++ b/modules/Bio/EnsEMBL/Feature.pm
@@ -565,16 +565,23 @@ sub transform {
     bless $new_feature, ref $self;
     return $new_feature;
   }
+  my $projection;
+  if(defined($to_slice)){
+    $projection = $self->project_to_slice( $to_slice );  }
+  else{
+    $projection = $self->project( $cs_name, $cs_version );
+  }
 
-  my $projection = $self->project( $cs_name, $cs_version );
-
+  if(@$projection == 0){
+    return undef;
+  }
   if( @$projection != 1 and !defined($to_slice)) {
- #    warn "MORE than one projection and NO slice specified ";
- #    warn "from ".$self->slice->name." to $cs_name, $cs_version\n";
+#    warn "MORE than one projection and NO slice specified ";
+#    warn "from ".$self->slice->name." to $cs_name, $cs_version\n";
     return undef;
   }
   my $index = 0;
-  if(defined($to_slice) and @$projection != 1 ){
+  if(defined($to_slice)){
     my $found = 0;
     my $i = 0;
     foreach my $proj (@{$projection}) {
@@ -586,7 +593,27 @@ sub transform {
       $i++;
     }
     if(!$found){
-      warn "MORE than one projection and none to slice specified\n";
+      if(@$projection != 1){
+	if(@$projection == 0){
+	  warn "number of mappings is ".@$projection."\n";
+	  warn "could not project feature ".ref($self)." from ".$self->slice->seq_region_name." to ".$to_slice->seq_region_name."\n";
+	  warn "In the region of ".$self->slice->start." <-> ".$self->slice->end."\n";
+	  warn "feat start=".($self->slice->start+$self->start)."\tend=".($self->slice->start+$self->end)."\n";
+	}
+	else{
+	  foreach my $proj (@{$projection}) {
+	    my $slice = $proj->[2];
+	    warn "available slice ".$slice->seq_regon_name."\n";
+	  }
+	  warn "MORE than one projection and none to slice specified (".$to_slice->seq_region_name.")\n";
+	}
+      }	
+      else {
+	foreach my $proj (@{$projection}) {
+	  warn "Mapping is to ".$proj->[2]->seq_region_name."\n";
+	}
+	warn "One projection but none to slice specified\n";
+      }
       return undef;
     }
   }
-- 
GitLab