JAL-3829 do better at detecting structure type, prompt to retrieve Uniprot ids for...
[jalview.git] / src / jalview / gui / structurechooser / StructureChooserQuerySource.java
index b5646db..1023b59 100644 (file)
@@ -216,21 +216,33 @@ public abstract class StructureChooserQuerySource
           SequenceI[] selectedSeqs)
   {
     ThreeDBStructureChooserQuerySource tdbSource = new ThreeDBStructureChooserQuerySource();
-    boolean hasUniprot=false;
+    boolean hasUniprot=false,hasCanonical=false;
     boolean hasNA=false,hasProtein=false;
-    for (SequenceI seq:selectedSeqs)
+    int protWithoutUni=0;
+    for (SequenceI seq : selectedSeqs)
     {
-      hasNA|=!seq.isProtein();
+      hasNA |= !seq.isProtein();
       hasProtein |= seq.isProtein();
       if (seq.isProtein())
       {
-        String query = tdbSource.buildQuery(seq);
-        if (query!=null && query.length()>0)
+        int refsAvailable = ThreeDBStructureChooserQuerySource.checkUniprotRefs(seq.getDBRefs());
+        if (refsAvailable > -2)
         {
-          hasUniprot=true;
+          if (refsAvailable > -1)
+            hasCanonical = true;
         }
+        hasUniprot = true;
+      }
+      else
+      {
+        protWithoutUni++;
       }
     }
+    //
+    // logic: all canonicals - no fetchdb
+    // some uniprot no canonicals: prompt do fetchDb for remaining
+    // no uniprot but protein: offer 3d-beacons search
+    //
     if (hasProtein && hasUniprot && !hasNA)
     {
       return tdbSource;