JAL-1479 JAL- Fix to eradicate duplicate mapping output and further improvement for...
[jalview.git] / src / jalview / ws / sifts / SiftsClient.java
index e04bbb7..3c2e703 100644 (file)
@@ -360,7 +360,8 @@ public class SiftsClient implements SiftsClientI
       DBRefEntry[] dbRefs = seq.getDBRefs();
       if (dbRefs == null || dbRefs.length < 1)
       {
-        throw new SiftsException("Could not get source DB Ref");
+        throw new SiftsException(
+                "Source DBRef could not be determined. DBRefs might not have been retrieved.");
       }
 
       for (DBRefEntryI dbRef : dbRefs)
@@ -374,6 +375,7 @@ public class SiftsClient implements SiftsClientI
                 && (dbRef.getSource().equalsIgnoreCase(DBRefSource.UNIPROT) || dbRef
                         .getSource().equalsIgnoreCase(DBRefSource.PDB)))
         {
+          seq.setSourceDBRef(dbRef);
           return dbRef;
         }
       }
@@ -413,7 +415,8 @@ public class SiftsClient implements SiftsClientI
                 .getMapRegion();
         for (MapRegion mapRegion : mapRegions)
         {
-          accessions.add(mapRegion.getDb().getDbAccessionId());
+          accessions
+                  .add(mapRegion.getDb().getDbAccessionId().toLowerCase());
         }
       }
     }
@@ -464,12 +467,9 @@ public class SiftsClient implements SiftsClientI
             jalview.util.Comparison.GapChars, seq.getSequenceAsString());
     HashMap<Integer, int[]> mapping = new HashMap<Integer, int[]>();
     DBRefEntryI sourceDBRef = seq.getSourceDBRef();
-    if (sourceDBRef == null)
-    {
-      sourceDBRef = getValidSourceDBRef(seq);
-      // TODO ensure sequence start/end is in the same coordinate system and
-      // consistent with the choosen sourceDBRef
-    }
+    sourceDBRef = getValidSourceDBRef(seq);
+    // TODO ensure sequence start/end is in the same coordinate system and
+    // consistent with the choosen sourceDBRef
 
     // set sequence coordinate system - default value is UniProt
     if (sourceDBRef.getSource().equalsIgnoreCase(DBRefSource.PDB))
@@ -752,8 +752,9 @@ public class SiftsClient implements SiftsClientI
 
   private boolean isFoundInSiftsEntry(String accessionId)
   {
+    HashSet<String> siftsDBRefs = getAllMappingAccession();
     return accessionId != null
-            && getAllMappingAccession().contains(accessionId);
+            && siftsDBRefs.contains(accessionId.toLowerCase());
   }
 
   /**