JAL-1999 JAL-1479 implemented configurable fail-safe mechanism for SIFTS mapping...
[jalview.git] / src / jalview / ws / sifts / SiftsClient.java
index 5b03ddb..f866127 100644 (file)
@@ -103,7 +103,9 @@ public class SiftsClient implements SiftsClientI
 
   private final static String NEWLINE = System.lineSeparator();
 
-  private final static int THRESHOLD_IN_DAYS = 2;
+  // private final static int CACHE_THRESHOLD_IN_DAYS = 2;
+  //
+  // private final static int FAIL_SAFE_PID_THRESHOLD = 30;
 
   private String curSourceDBRef;
 
@@ -233,7 +235,8 @@ public class SiftsClient implements SiftsClientI
       // The line below is required for unit testing... don't comment it out!!!
       System.out.println(">>> SIFTS File already downloaded for " + pdbId);
 
-      if (isFileOlderThanThreshold(siftsFile, THRESHOLD_IN_DAYS))
+      if (isFileOlderThanThreshold(siftsFile,
+              SiftsSettings.getCacheThresholdInDays()))
       {
         // System.out.println("Downloaded file is out of date, hence re-downloading...");
         siftsFile = downloadSiftsFile(pdbId.toLowerCase());
@@ -578,6 +581,10 @@ public class SiftsClient implements SiftsClientI
 
     Integer[] keys = mapping.keySet().toArray(new Integer[0]);
     Arrays.sort(keys);
+    if (keys.length < 1)
+    {
+      throw new SiftsException(">>> Empty SIFTS mapping generated!!");
+    }
     seqStart = keys[0];
     seqEnd = keys[keys.length - 1];
 
@@ -987,9 +994,10 @@ public class SiftsClient implements SiftsClientI
       output.append(NEWLINE).append(NEWLINE);
     }
     float pid = (float) matchedSeqCount / seqRes.length() * 100;
-    if (pid < 2)
+    if (pid < SiftsSettings.getFailSafePIDThreshold())
     {
-      throw new SiftsException("Low PID detected for SIFTs mapping...");
+      throw new SiftsException(
+">>> Low PID detected for SIFTs mapping...");
     }
     output.append("Length of alignment = " + seqRes.length()).append(
             NEWLINE);