}
cmb_filterOption.addItem(
new FilterOption(MessageManager.getString("label.enter_pdb_id"),
- "-", VIEWS_ENTER_ID, false));
+ "-", VIEWS_ENTER_ID, false,null));
cmb_filterOption.addItem(
new FilterOption(MessageManager.getString("label.from_file"),
- "-", VIEWS_FROM_FILE, false));
+ "-", VIEWS_FROM_FILE, false,null));
if (cachedPDBExist)
{
FilterOption cachedOption = new FilterOption(
MessageManager.getString("label.cached_structures"), "-",
- VIEWS_LOCAL_PDB, false);
+ VIEWS_LOCAL_PDB, false,null);
cmb_filterOption.addItem(cachedOption);
cmb_filterOption.setSelectedItem(cachedOption);
}
{
mainFrame.setTitle(filterTitle);
chk_invertFilter.setVisible(true);
- filterResultSet(selectedFilterOpt.getValue());
+
+ if (data!=selectedFilterOpt.getQuerySource() || data.needsRefetch(selectedFilterOpt))
+ {
+ data = selectedFilterOpt.getQuerySource();
+ // rebuild the views completely, since prefs will also change
+ tabRefresh();
+ return;
+ } else {
+ filterResultSet(selectedFilterOpt.getValue());
+ }
}
else if (selectedFilterOpt.getView() == VIEWS_ENTER_ID
|| selectedFilterOpt.getView() == VIEWS_FROM_FILE)
List<FilterOption> filters = new ArrayList<FilterOption>();
filters.add(new FilterOption(
MessageManager.getString("label.best_quality"),
- "overall_quality", VIEWS_FILTER, false));
+ "overall_quality", VIEWS_FILTER, false,this));
filters.add(new FilterOption(
MessageManager.getString("label.best_resolution"),
- "resolution", VIEWS_FILTER, false));
+ "resolution", VIEWS_FILTER, false,this));
filters.add(new FilterOption(
MessageManager.getString("label.most_protein_chain"),
- "number_of_protein_chains", VIEWS_FILTER, false));
+ "number_of_protein_chains", VIEWS_FILTER, false,this));
filters.add(new FilterOption(
MessageManager.getString("label.most_bound_molecules"),
- "number_of_bound_molecules", VIEWS_FILTER, false));
+ "number_of_bound_molecules", VIEWS_FILTER, false,this));
filters.add(new FilterOption(
MessageManager.getString("label.most_polymer_residues"),
- "number_of_polymer_residues", VIEWS_FILTER, true));
+ "number_of_polymer_residues", VIEWS_FILTER, true,this));
return filters;
}
+ @Override
+ public boolean needsRefetch(FilterOption selectedFilterOpt)
+ {
+ // PDBe queries never need a refetch first
+ return false;
+ }
+
/**
* FTSRestClient specific query builder to pick top ranked entry from a
* fetchStructuresMetaData query
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);
+
}
\ No newline at end of file
extends StructureChooserQuerySource
{
+ private static final String FILTER_TDBEACONS_COVERAGE = "3d_beacons_coverage";
+
private static int MAX_QLENGTH = 7820;
protected FTSRestRequest lastTdbRequest;
PreferenceSource.STRUCTURE_CHOOSER,
TDBeaconsFTSRestClient.getInstance());
- }
+ }
/**
* Builds a query string for a given sequences using its DBRef entries 3d
FilterOption selectedFilterOpt, boolean b) throws Exception
{
FTSRestResponse resultList;
+ if (tdBeaconsFilter(selectedFilterOpt.getValue())) {
FTSRestRequest tdbRequest = getTDBeaconsRequest(seq, wantedFields);
resultList = tdbRestClient.executeRequest(tdbRequest);
FTSRestResponse joinedResp = joinResponses(resultList,
pdbResponse);
return resultList;
+ }
+ // use the PDBFTS directly
+ resultList = getPDBQuerySource().fetchStructuresMetaData(seq, wantedFields, selectedFilterOpt, b);
+ lastTdbRequest = getPDBQuerySource().lastPdbRequest;
+ lastPdbRequest = lastTdbRequest; // both queries the same - indicates we rank using PDBe
+ return resultList;
+
}
PDBStructureChooserQuerySource pdbQuerySource=null;
@Override
public List<FilterOption> getAvailableFilterOptions(String VIEWS_FILTER)
{
- List<FilterOption> filters = new ArrayList<FilterOption>();
- filters.add(
- new FilterOption(MessageManager.getString("label.best_quality"),
- "overall_quality", VIEWS_FILTER, false));
- filters.add(new FilterOption(
- MessageManager.getString("label.best_resolution"), "resolution",
- VIEWS_FILTER, false));
- filters.add(new FilterOption(
- MessageManager.getString("label.most_protein_chain"),
- "number_of_protein_chains", VIEWS_FILTER, false));
- filters.add(new FilterOption(
- MessageManager.getString("label.most_bound_molecules"),
- "number_of_bound_molecules", VIEWS_FILTER, false));
- filters.add(new FilterOption(
- MessageManager.getString("label.most_polymer_residues"),
- "number_of_polymer_residues", VIEWS_FILTER, true));
-
+ List<FilterOption> filters = getPDBQuerySource().getAvailableFilterOptions(VIEWS_FILTER);
+
+ filters.add(0,
+ new FilterOption("3D-Beacons Coverage",
+ FILTER_TDBEACONS_COVERAGE, VIEWS_FILTER, true, this));
return filters;
}
+ private boolean tdBeaconsFilter(String fieldToFilterBy)
+ {
+ return FILTER_TDBEACONS_COVERAGE.equals(fieldToFilterBy);
+ }
+ @Override
+ public boolean needsRefetch(FilterOption selectedFilterOpt)
+ {
+ return tdBeaconsFilter(selectedFilterOpt.getValue()) && lastPdbRequest!=lastTdbRequest;
+ }
/**
* FTSRestClient specific query builder to pick top ranked entry from a
* fetchStructuresMetaData query
Collection<FTSDataColumnI> wantedFields, String fieldToFilterBy,
boolean b) throws Exception
{
+ if (tdBeaconsFilter(fieldToFilterBy))
+ {
+ TDBResultAnalyser analyser = new TDBResultAnalyser(seq,
+ collectedResults, lastTdbRequest);
- TDBResultAnalyser analyser= new TDBResultAnalyser(seq,collectedResults, lastTdbRequest);
-
-
- FTSRestResponse resultList = new FTSRestResponse();
+ FTSRestResponse resultList = new FTSRestResponse();
- List<FTSData> filteredResponse = analyser.getFilteredResponse();
-
- List<FTSData> selectedStructures = analyser.selectStructures(filteredResponse);
- resultList.setNumberOfItemsFound(selectedStructures.size());
- resultList.setSearchSummary(selectedStructures);
- return resultList;
+ List<FTSData> filteredResponse = analyser.getFilteredResponse();
+
+ List<FTSData> selectedStructures = analyser
+ .selectStructures(filteredResponse);
+ resultList.setNumberOfItemsFound(selectedStructures.size());
+ resultList.setSearchSummary(selectedStructures);
+ return resultList;
+ }
+ // Fall back to PDBe rankings
+ return getPDBQuerySource().selectFirstRankedQuery(seq, collectedResults, wantedFields, fieldToFilterBy, b);
}
+
@Override
public PDBEntry[] collectSelectedRows(JTable restable, int[] selectedRows,
List<SequenceI> selectedSeqsToView)
package jalview.jbgui;
+import jalview.gui.structurechooser.StructureChooserQuerySource;
+import jalview.gui.structurechooser.ThreeDBStructureChooserQuerySource;
+
/**
* This inner class provides the data model for the structure filter combo-box
*
private String view;
private boolean addSeparatorAfter;
+
+ private StructureChooserQuerySource querySource;
/**
* Model for structure filter option
* @param addSeparatorAfter
* - if true, a horizontal separator is rendered immediately after
* this filter option, otherwise
+ * @param structureChooserQuerySource - the query source that actions this filter
*/
public FilterOption(String name, String value, String view,
- boolean addSeparatorAfter)
+ boolean addSeparatorAfter, StructureChooserQuerySource structureChooserQuerySource)
{
this.name = name;
this.value = value;
this.view = view;
+ this.querySource=structureChooserQuerySource;
this.addSeparatorAfter = addSeparatorAfter;
}
{
this.addSeparatorAfter = addSeparatorAfter;
}
+
+ public StructureChooserQuerySource getQuerySource()
+ {
+ return querySource;
+ }
}
\ No newline at end of file