JAL-3829 JAL-3865 StructureChooserQuerySource implementation now dependent on the...
authorJim Procter <j.procter@dundee.ac.uk>
Fri, 3 Sep 2021 14:37:29 +0000 (15:37 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Fri, 3 Sep 2021 14:37:29 +0000 (15:37 +0100)
src/jalview/gui/StructureChooser.java
src/jalview/gui/structurechooser/StructureChooserQuerySource.java

index 7a9da92..86158da 100644 (file)
@@ -104,7 +104,7 @@ public class StructureChooser extends GStructureChooser
   {
     // which FTS engine to use
     data = StructureChooserQuerySource
-            .getTDBfts();
+            .getQuerySourceFor(selectedSeqs);
     initDialog();
     
     this.ap = ap;
index 733e6fc..4faa2de 100644 (file)
@@ -206,4 +206,36 @@ public abstract class StructureChooserQuerySource
    *         will be constructed with 'addSeparator==true'
    */
   public abstract List<FilterOption> getAvailableFilterOptions(String VIEWS_FILTER);
+
+  /**
+   * construct a structure chooser query source for the given set of sequences
+   * @param selectedSeqs
+   * @return PDBe or 3DB query source
+   */
+  public static StructureChooserQuerySource getQuerySourceFor(
+          SequenceI[] selectedSeqs)
+  {
+    ThreeDBStructureChooserQuerySource tdbSource = new ThreeDBStructureChooserQuerySource();
+    boolean hasUniprot=false;
+    boolean hasNA=false,hasProtein=false;
+    for (SequenceI seq:selectedSeqs)
+    {
+      hasNA|=!seq.isProtein();
+      hasProtein |= seq.isProtein();
+      if (seq.isProtein())
+      {
+        String query = tdbSource.buildQuery(seq);
+        if (query!=null && query.length()>0)
+        {
+          hasUniprot=true;
+        }
+      }
+    }
+    if (hasProtein && hasUniprot && !hasNA)
+    {
+      return tdbSource;
+    }
+    return new PDBStructureChooserQuerySource();
+  }
+
 }
\ No newline at end of file