JAL-2755 canonicalise the database source for a dbref before resolving a database...
[jalview.git] / src / jalview / util / DBRefUtils.java
index 50a34fc..bded248 100755 (executable)
@@ -65,6 +65,9 @@ public class DBRefUtils
     canonicalSourceNameLookup.put("ensembl-tr", DBRefSource.ENSEMBL);
     canonicalSourceNameLookup.put("ensembl-gn", DBRefSource.ENSEMBL);
 
+    canonicalSourceNameLookup.put("ensemblgenomes",
+            DBRefSource.ENSEMBLGENOMES);
+
     // Make sure we have lowercase entries for all canonical string lookups
     Set<String> keys = canonicalSourceNameLookup.keySet();
     for (String k : keys)
@@ -160,6 +163,20 @@ public class DBRefUtils
       return null;
     }
     String canonical = canonicalSourceNameLookup.get(source.toLowerCase());
+    if (canonical==null)
+    {
+      if (source.toLowerCase().startsWith("ensembl"))
+      {
+        canonical = DBRefSource.ENSEMBL;
+        for (String ensembls: new String[] { "Protists","Plants","Bacteria","Fungi","Metazoa"})
+        {
+          if (source.toLowerCase().endsWith(ensembls.toLowerCase()))
+          {
+            canonical = DBRefSource.ENSEMBLGENOMES;
+          }
+        }
+      }
+    }
     return canonical == null ? source : canonical;
   }
 
@@ -599,7 +616,8 @@ public class DBRefUtils
     {
       for (DBRefEntry dbref : dbRefs)
       {
-        if (source.equalsIgnoreCase(dbref.getSource()))
+        if (source.equalsIgnoreCase(
+                DBRefUtils.getCanonicalName(dbref.getSource())))
         {
           matches.add(dbref);
         }