From 56025656cbe1fa5f90eecb770653bf368cb1fb7e Mon Sep 17 00:00:00 2001
From: Magali Ruffier <mr6@ebi.ac.uk>
Date: Tue, 7 Jun 2016 17:28:15 +0100
Subject: [PATCH] ENSCORESW-1731: remove synonyms if not from display xref

---
 misc-scripts/xref_mapping/XrefMapper/DisplayXrefs.pm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/misc-scripts/xref_mapping/XrefMapper/DisplayXrefs.pm b/misc-scripts/xref_mapping/XrefMapper/DisplayXrefs.pm
index 17a0f547c6..2fcd205594 100644
--- a/misc-scripts/xref_mapping/XrefMapper/DisplayXrefs.pm
+++ b/misc-scripts/xref_mapping/XrefMapper/DisplayXrefs.pm
@@ -718,6 +718,15 @@ DXS
   $reset_status_sth->execute();
   $reset_status_sth->finish;
 
+  #
+  # Clean up synonyms linked to xrefs which are not the display xref
+  # Synonyms are only used as alternative gene names, so should be synonyms of the gene symbol chosen
+  #
+
+  my $syn_clean_sth = $self->core->dbc->prepare("DELETE es FROM external_synonym es, xref x LEFT JOIN gene g ON g.display_xref_id = x.xref_id WHERE es.xref_id = x.xref_id AND isnull(g.display_xref_id)");
+  $syn_clean_sth->execute();
+  $syn_clean_sth->finish();
+
 
 }
 
-- 
GitLab