X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2Fstructurechooser%2FStructureChooserQuerySource.java;h=b5646db46ad46ceefb8aab178cf2051b0845bebc;hb=896b63f7908297dfe7a48e198d7bce847e2804b8;hp=733e6fc6a2851139e1a81a26d1e4bd07ee670cb0;hpb=bf5bc203579d7a291844f3b34d5e8431984ee8e2;p=jalview.git diff --git a/src/jalview/gui/structurechooser/StructureChooserQuerySource.java b/src/jalview/gui/structurechooser/StructureChooserQuerySource.java index 733e6fc..b5646db 100644 --- a/src/jalview/gui/structurechooser/StructureChooserQuerySource.java +++ b/src/jalview/gui/structurechooser/StructureChooserQuerySource.java @@ -28,9 +28,6 @@ import jalview.jbgui.FilterOption; */ public abstract class StructureChooserQuerySource { - protected FTSRestRequest lastPdbRequest; - - protected FTSRestClientI pdbRestClient; protected FTSDataColumnPreferences docFieldPrefs; @@ -170,6 +167,7 @@ public abstract class StructureChooserQuerySource * * @param seq * - seq to generate a query for + * @param discoveredStructuresSet - existing set of entries - allows client side selection * @param wantedFields * - fields to retrieve * @param selectedFilterOpt @@ -180,7 +178,7 @@ public abstract class StructureChooserQuerySource * @throws Exception */ public abstract FTSRestResponse selectFirstRankedQuery(SequenceI seq, - Collection wantedFields, String fieldToFilterBy, + Collection discoveredStructuresSet, Collection wantedFields, String fieldToFilterBy, boolean b) throws Exception; /** @@ -191,10 +189,12 @@ public abstract class StructureChooserQuerySource public TableModel getTableModel( Collection discoveredStructuresSet) { - return FTSRestResponse.getTableModel(lastPdbRequest, + return FTSRestResponse.getTableModel(getLastFTSRequest(), discoveredStructuresSet); } + protected abstract FTSRestRequest getLastFTSRequest(); + public abstract PDBEntry[] collectSelectedRows(JTable restable, int[] selectedRows, List selectedSeqsToView); @@ -206,4 +206,50 @@ public abstract class StructureChooserQuerySource * will be constructed with 'addSeparator==true' */ public abstract List getAvailableFilterOptions(String VIEWS_FILTER); -} \ No newline at end of file + + /** + * 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(); + } + + /** + * some filter options may mean the original query needs to be executed again. + * @param selectedFilterOpt + * @return true if the fetchStructuresMetadata method needs to be called again + */ + public abstract boolean needsRefetch(FilterOption selectedFilterOpt); + + + + public void updateAvailableFilterOptions(String VIEWS_FILTER, + List xtantOptions, Collection lastFTSData) + { + // TODO Auto-generated method stub + + }} \ No newline at end of file