From 5b4a40539785c721defc3fda1c727b1c79e9617c Mon Sep 17 00:00:00 2001
From: Ewan Birney <birney@sanger.ac.uk>
Date: Wed, 17 Oct 2001 13:57:41 +0000
Subject: [PATCH] updates to Mapper. Now looks more sensible wrt API. Works for
 alignment mapping at least

---
 modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm |  4 +++-
 modules/Bio/EnsEMBL/Mapper.pm            | 10 +++++++++-
 modules/t/mapper.t                       |  2 +-
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm
index d3b0e0d40e..aaf6859f88 100644
--- a/modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm
+++ b/modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm
@@ -194,6 +194,7 @@ sub fetch_by_dbID {
   return $gene;
 }
 
+
 =head2 fetch_by_stable_id
 
  Title   : fetch_by_stable_id
@@ -244,12 +245,13 @@ sub fetch_by_contig_list{
    $str =~ s/\,$//g;
    $str = "($str)";
 
+
    # 
    # this is non-optimised, because we are going to make multiple
    # trips to the database. should fix here
    #
 
-   my $sth = $self->prepare("select distinct(t.gene_id) from transcript t,exon_transcript et,exon e,contig c where c.id in $str and c.internal_id = e.contig and et.exon_id = e.exon_id and et.transcript_id = t.transcript_id");
+   my $sth = $self->prepare("select distinct(t.gene_id) from transcript t,exon_transcript et,exon e,contig c where c.id in $str and c.internal_id = e.contig_id and et.exon_id = e.exon_id and et.transcript_id = t.transcript_id");
    $sth->execute;
 
    my @out;
diff --git a/modules/Bio/EnsEMBL/Mapper.pm b/modules/Bio/EnsEMBL/Mapper.pm
index d845a9d42f..d5940d94f5 100644
--- a/modules/Bio/EnsEMBL/Mapper.pm
+++ b/modules/Bio/EnsEMBL/Mapper.pm
@@ -67,11 +67,15 @@ use Bio::EnsEMBL::Mapper::Gap;
 sub new {
   my($class,@args) = @_;
 
-  my $to   = shift @args;
   my $from = shift @args;
+  my $to   = shift @args;
 
   my $self = {};
   bless $self,$class;
+
+  if( !defined $to ) {
+      $self->throw("Must supply from and to tags");
+  }
   
   $self->{'_pair_hash_to'} = {};
   $self->{'_pair_hash_from'} = {};
@@ -239,6 +243,10 @@ sub map_coordinates{
 sub add_map_coordinates{
    my ($self,$contig_start,$contig_end,$contig_id,$chr_start,$chr_end,$chr_name,$contig_ori) = @_;
 
+   if( !defined $contig_ori ) {
+       $self->throw("Need 7 arguments!");
+   }
+
    if( $contig_start !~ /\d+/ || $chr_start !~ /\d+/ ) {
        $self->throw("Not doable - $contig_start as start or $chr_start as start?");
    }
diff --git a/modules/t/mapper.t b/modules/t/mapper.t
index 5ee3bb02bf..df95e28f62 100644
--- a/modules/t/mapper.t
+++ b/modules/t/mapper.t
@@ -35,7 +35,7 @@ use Bio::EnsEMBL::Mapper;
 
 # testing the Bio::EnsEMBL::Mapper module
 
-$mapper = Bio::EnsEMBL::Mapper->new( "virtualcontig", "rawcontig" );
+$mapper = Bio::EnsEMBL::Mapper->new( "rawcontig", "virtualcontig" );
 load_sgp_dump( $mapper );
 $mapper->_freeze;
 
-- 
GitLab