From: Jim Procter Date: Fri, 3 Sep 2021 14:37:29 +0000 (+0100) Subject: JAL-3829 JAL-3865 StructureChooserQuerySource implementation now dependent on the... X-Git-Tag: Release_2_11_2_0~39^2~27 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4fc80882cbf9f5624e7235459de51aab4df2c642;p=jalview.git JAL-3829 JAL-3865 StructureChooserQuerySource implementation now dependent on the type of sequences and whether they have uniprot sequence IDs --- diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 7a9da92..86158da 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -104,7 +104,7 @@ public class StructureChooser extends GStructureChooser { // which FTS engine to use data = StructureChooserQuerySource - .getTDBfts(); + .getQuerySourceFor(selectedSeqs); initDialog(); this.ap = ap; diff --git a/src/jalview/gui/structurechooser/StructureChooserQuerySource.java b/src/jalview/gui/structurechooser/StructureChooserQuerySource.java index 733e6fc..4faa2de 100644 --- a/src/jalview/gui/structurechooser/StructureChooserQuerySource.java +++ b/src/jalview/gui/structurechooser/StructureChooserQuerySource.java @@ -206,4 +206,36 @@ public abstract class StructureChooserQuerySource * will be constructed with 'addSeparator==true' */ public abstract List 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