From ac8e396b477275f1bca7d422738ecf257bc97061 Mon Sep 17 00:00:00 2001
From: Graham McVicker <mcvicker@sanger.ac.uk>
Date: Wed, 25 Feb 2004 10:11:23 +0000
Subject: [PATCH] throw if undefined coord systems are used for
 transform/project calls

---
 modules/Bio/EnsEMBL/Feature.pm | 6 +++++-
 modules/Bio/EnsEMBL/Slice.pm   | 5 +++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/modules/Bio/EnsEMBL/Feature.pm b/modules/Bio/EnsEMBL/Feature.pm
index fe286a8fba..50db11278f 100644
--- a/modules/Bio/EnsEMBL/Feature.pm
+++ b/modules/Bio/EnsEMBL/Feature.pm
@@ -386,12 +386,16 @@ sub transform {
     throw('Feature is not associated with a slice and may not be transformed');
   }
 
-
   #use db from slice since this feature may not yet be stored in a database
   my $db = $slice->adaptor->db();
   my $cs = $db->get_CoordSystemAdaptor->fetch_by_name($cs_name, $cs_version);
   my $current_cs = $slice->coord_system();
 
+  if(!$cs) {
+    throw("Cannot transform to unknown coordinate system " .
+          "[$cs_name $cs_version]\n");
+  }
+
   # if feature is already in the requested coordinate system, we can just
   # return a copy
   if( $cs->equals( $current_cs ) && $slice->start() == 1 &&
diff --git a/modules/Bio/EnsEMBL/Slice.pm b/modules/Bio/EnsEMBL/Slice.pm
index b1115e00e1..f9c70cda5d 100644
--- a/modules/Bio/EnsEMBL/Slice.pm
+++ b/modules/Bio/EnsEMBL/Slice.pm
@@ -606,6 +606,11 @@ sub project {
   my $cs = $csa->fetch_by_name($cs_name, $cs_version);
   my $slice_cs = $self->coord_system();
 
+  if(!$cs) {
+    throw("Cannot project to unknown coordinate system " .
+          "[$cs_name $cs_version]");
+  }
+
   #no mapping is needed if the requested coord system is the one we are in
   #but we do need to check if some of the slice is outside of defined regions
   if($slice_cs->equals($cs)) {
-- 
GitLab