From 5ef39c6e844a608e61ca7c61213131311378dfca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20Kusalananda=20K=C3=A4h=C3=A4ri?=
 <ak4@sanger.ac.uk>
Date: Thu, 27 Oct 2011 23:06:19 +0000
Subject: [PATCH] Enable internal ID disabiguation for exons too.

---
 .../Bio/EnsEMBL/IdMapping/InternalIdMapper.pm |  7 +++--
 .../InternalIdMapper/EnsemblExonGeneric.pm    | 29 +++++++++++++++++++
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/modules/Bio/EnsEMBL/IdMapping/InternalIdMapper.pm b/modules/Bio/EnsEMBL/IdMapping/InternalIdMapper.pm
index 1ff9a12aeb..11dfaa587f 100644
--- a/modules/Bio/EnsEMBL/IdMapping/InternalIdMapper.pm
+++ b/modules/Bio/EnsEMBL/IdMapping/InternalIdMapper.pm
@@ -98,9 +98,9 @@ sub map_genes {
     # determine which plugin methods to run
     my @default_plugins = (qw(
       Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblGeneGeneric::init_basic
-      Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblGeneGeneric::synteny
       Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblGeneGeneric::best_transcript
       Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblGeneGeneric::biotype
+      Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblGeneGeneric::synteny
       Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblGeneGeneric::internal_id
     ));
 
@@ -198,10 +198,10 @@ sub map_transcripts {
     my @default_plugins = (qw(
       Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblTranscriptGeneric::init_basic
       Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblTranscriptGeneric::non_exact_translation
-      Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblTranscriptGeneric::mapped_gene
       Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblTranscriptGeneric::biotype
-      Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblTranscriptGeneric::internal_id
+      Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblTranscriptGeneric::mapped_gene
       Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblTranscriptGeneric::single_gene
+      Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblTranscriptGeneric::internal_id
     ));
 
     my @plugins = $self->conf->param('plugin_internal_id_mappers_transcript');
@@ -299,6 +299,7 @@ sub map_exons {
     my @default_plugins = (qw(
       Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblExonGeneric::init_basic
       Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblExonGeneric::mapped_transcript
+      Bio::EnsEMBL::IdMapping::InternalIdMapper::EnsemblExonGeneric::internal_id
     ));
 
     my @plugins = $self->conf->param('plugin_internal_id_mappers_exon');
diff --git a/modules/Bio/EnsEMBL/IdMapping/InternalIdMapper/EnsemblExonGeneric.pm b/modules/Bio/EnsEMBL/IdMapping/InternalIdMapper/EnsemblExonGeneric.pm
index 81729deb0d..e4597e34d3 100644
--- a/modules/Bio/EnsEMBL/IdMapping/InternalIdMapper/EnsemblExonGeneric.pm
+++ b/modules/Bio/EnsEMBL/IdMapping/InternalIdMapper/EnsemblExonGeneric.pm
@@ -88,5 +88,34 @@ sub mapped_transcript {
 }
   
 
+#
+# selectively rescore by penalising scores between exons with
+# different internalIDs
+#
+sub internal_id {
+  my $self        = shift;
+  my $num         = shift;
+  my $esb         = shift;
+  my $mappings    = shift;
+  my $exon_scores = shift;
+
+  $self->logger->info( "Retry with internalID disambiguation...\n",
+                       0, 'stamped' );
+
+  if ( !$exon_scores->loaded() ) {
+    $esb->internal_id_rescore($exon_scores);
+    $exon_scores->write_to_file();
+  }
+
+  $mappings = $self->basic_mapping( $exon_scores, "exon_mappings$num" );
+  $num++;
+  my $new_scores =
+    $esb->create_shrinked_matrix( $exon_scores, $mappings,
+                                  "exon_matrix$num" );
+
+  return ( $new_scores, $mappings );
+}
+
+
 1;
 
-- 
GitLab