JAL-4114 alphafold now marked as AB-INITIO so adjust ranking in categories
[jalview.git] / src / jalview / gui / structurechooser / TDBResultAnalyser.java
index 09ff0aa..fcc1ffe 100644 (file)
@@ -1,7 +1,25 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.gui.structurechooser;
 
-import java.util.Locale;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.BitSet;
@@ -9,6 +27,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
+import java.util.Locale;
 
 import jalview.datamodel.SequenceI;
 import jalview.fts.api.FTSData;
@@ -25,8 +44,8 @@ public class TDBResultAnalyser
    */
   private static List<String> EXP_CATEGORIES = Arrays
           .asList(new String[]
-          { "EXPERIMENTALLY DETERMINED", "DEEP-LEARNING", "TEMPLATE-BASED",
-              "AB-INITIO", "CONFORMATIONAL ENSEMBLE" });
+          { "EXPERIMENTALLY DETERMINED", "DEEP-LEARNING", "AB-INITIO",
+              "TEMPLATE-BASED", "CONFORMATIONAL ENSEMBLE" });
 
   private SequenceI seq;
 
@@ -111,18 +130,22 @@ public class TDBResultAnalyser
     // ignore anything outside the sequence region
     for (FTSData row : collectedResults)
     {
-      int up_s = (Integer) row.getSummaryData()[idx_ups];
-      int up_e = (Integer) row.getSummaryData()[idx_upe];
-      String provider = (String) row.getSummaryData()[idx_mprov];
-      String mcat = (String) row.getSummaryData()[idx_mcat];
-      // this makes sure all new categories are in the score array.
-      int scorecat = scoreCategory(mcat);
-      if (sourceFilter == null || sourceFilter.equals(provider))
+      if (row.getSummaryData() != null
+              && row.getSummaryData()[idx_ups] != null)
       {
-        if (seq == row.getSummaryData()[0] && up_e > seq.getStart()
-                && up_s < seq.getEnd())
+        int up_s = (Integer) row.getSummaryData()[idx_ups];
+        int up_e = (Integer) row.getSummaryData()[idx_upe];
+        String provider = (String) row.getSummaryData()[idx_mprov];
+        String mcat = (String) row.getSummaryData()[idx_mcat];
+        // this makes sure all new categories are in the score array.
+        int scorecat = scoreCategory(mcat);
+        if (sourceFilter == null || sourceFilter.equals(provider))
         {
-          filteredResponse.add(row);
+          if (seq == row.getSummaryData()[0] && up_e > seq.getStart()
+                  && up_s < seq.getEnd())
+          {
+            filteredResponse.add(row);
+          }
         }
       }
     }
@@ -154,6 +177,7 @@ public class TDBResultAnalyser
             int o2_xtent = o2_e - o2_s;
             if (o1_xtent == o2_xtent)
             {
+              // EXPERIMENTAL DATA ALWAYS TRUMPS MODELS
               if (o1_cat == scoreCategory(EXP_CATEGORIES.get(0)))
               {
                 if (o1_prov.equals(o2_prov))
@@ -207,6 +231,12 @@ public class TDBResultAnalyser
         }
         else
         {
+          // if both are not experimental, then favour alphafold
+          if (o2_cat > 0 && o1_cat > 0)
+          {
+            return "ALPHAFOLD DB".equals(o1_prov) ? -1
+                    : "ALPHAFOLD DB".equals(o2_prov) ? 1 : 0;
+          }
           return o2_cat - o1_cat;
         }
       }