From 4fc80882cbf9f5624e7235459de51aab4df2c642 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 3 Sep 2021 15:37:29 +0100 Subject: [PATCH] JAL-3829 JAL-3865 StructureChooserQuerySource implementation now dependent on the type of sequences and whether they have uniprot sequence IDs --- src/jalview/gui/StructureChooser.java | 2 +- .../StructureChooserQuerySource.java | 32 ++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) 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 -- 1.7.10.2