private boolean cachedPDBExists;
+ private Collection<FTSData> lastDiscoveredStructuresSet;
+
private static StructureViewer lastTargetedView = null;
public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
{
getResultTable()
.setModel(data.getTableModel(discoveredStructuresSet));
+
noOfStructuresFound = discoveredStructuresSet.size();
+ lastDiscoveredStructuresSet=discoveredStructuresSet;
mainFrame.setTitle(MessageManager.formatMessage(
"label.structure_chooser_no_of_structures",
noOfStructuresFound, totalTime));
{
Thread filterThread = new Thread(new Runnable()
{
+
@Override
public void run()
{
reorderedStructuresSet.addAll(discoveredStructuresSet);
getResultTable()
.setModel(data.getTableModel(reorderedStructuresSet));
-
+
FTSRestResponse.configureTableColumn(getResultTable(),
wantedFields, tempUserPrefs);
getResultTable().getColumn("Ref Sequence").setPreferredWidth(120);
protected void populateFilterComboBox(boolean haveData,
boolean cachedPDBExist)
{
+ populateFilterComboBox(haveData, cachedPDBExist, null);
+ }
+ /**
+ * Populates the filter combo-box options dynamically depending on discovered
+ * structures
+ */
+ protected void populateFilterComboBox(boolean haveData,
+ boolean cachedPDBExist, FilterOption lastSel)
+ {
+
/*
* temporarily suspend the change listener behaviour
*/
cmb_filterOption.removeItemListener(this);
-
+ int selSet=-1;
cmb_filterOption.removeAllItems();
if (haveData)
{
List<FilterOption> filters = data.getAvailableFilterOptions(VIEWS_FILTER);
+ data.updateAvailableFilterOptions(VIEWS_FILTER, filters, lastDiscoveredStructuresSet);
+ int p=0;
for (FilterOption filter:filters)
{
+ if (lastSel!=null && filter.equals(lastSel)) {
+ selSet=p;
+ }
+ p++;
cmb_filterOption.addItem(filter);
}
}
MessageManager.getString("label.cached_structures"), "-",
VIEWS_LOCAL_PDB, false,null);
cmb_filterOption.addItem(cachedOption);
- cmb_filterOption.setSelectedItem(cachedOption);
+ if (selSet==-1) {
+ cmb_filterOption.setSelectedItem(cachedOption);
+ }
+ }
+ if (selSet>-1)
+ {
+ cmb_filterOption.setSelectedIndex(selSet);
}
-
cmb_filterOption.addItemListener(this);
}
if (selectedFilterOpt.getView() == VIEWS_FILTER)
{
mainFrame.setTitle(filterTitle);
- chk_invertFilter.setVisible(true);
+ // TDB Query has no invert as yet
+ chk_invertFilter.setVisible(selectedFilterOpt.getQuerySource() instanceof PDBStructureChooserQuerySource);
if (data!=selectedFilterOpt.getQuerySource() || data.needsRefetch(selectedFilterOpt))
{
public void run()
{
fetchStructuresMetaData();
+ //populateFilterComboBox(true, cachedPDBExists);
+
filterResultSet(
((FilterOption) cmb_filterOption.getSelectedItem())
.getValue());
private int idx_resol;
+ /**
+ * selection model
+ */
+ private String filter=null;
+ /**
+ * limit to particular source
+ */
+ private String sourceFilter=null;
+
+ private int idx_mprov;
+
public TDBResultAnalyser(SequenceI seq,
Collection<FTSData> collectedResults,
- FTSRestRequest lastTdbRequest)
+ FTSRestRequest lastTdbRequest, String fieldToFilterBy, String string)
{
this.seq = seq;
this.collectedResults = collectedResults;
this.lastTdbRequest = lastTdbRequest;
+ this.filter = fieldToFilterBy;
+ this.sourceFilter = string;
idx_ups = lastTdbRequest.getFieldIndex("Uniprot Start");
idx_upe = lastTdbRequest.getFieldIndex("Uniprot End");
idx_mcat = lastTdbRequest.getFieldIndex("Model Category");
+ idx_mprov = lastTdbRequest.getFieldIndex("Provider");
idx_mqual = lastTdbRequest.getFieldIndex("Confidence");
idx_resol = lastTdbRequest.getFieldIndex("Resolution");
}
{
int up_s = (Integer) row.getSummaryData()[idx_ups];
int up_e = (Integer) row.getSummaryData()[idx_upe];
-
- if (seq == row.getSummaryData()[0] && up_e > seq.getStart()
- && up_s < seq.getEnd())
+ String provider = (String) row.getSummaryData()[idx_mprov];
+ if (sourceFilter == null || sourceFilter.equals(provider))
{
- filteredResponse.add(row);
+ if (seq == row.getSummaryData()[0] && up_e > seq.getStart()
+ && up_s < seq.getEnd())
+ {
+ filteredResponse.add(row);
+ }
}
}
// sort according to decreasing length,
// increasing start
Collections.sort(filteredResponse, new Comparator<FTSData>()
{
-
-
@Override
public int compare(FTSData o1, FTSData o2)
{
return o2_xt-o1_xt;
}
});
+ if (filter.equals(ThreeDBStructureChooserQuerySource.FILTER_FIRST_BEST_COVERAGE))
+ {
+ return selected.subList(0, 1);
+ }
return selected;
}
extends StructureChooserQuerySource
{
- private static final String FILTER_TDBEACONS_COVERAGE = "3d_beacons_coverage";
+ private Set<String> tdBeaconsFilters = null, defaultFilters = null;
+
+ public static final String FILTER_TDBEACONS_COVERAGE = "3d_beacons_coverage";
+
+ public static final String FILTER_FIRST_BEST_COVERAGE = "3d_beacons_first_best_coverage";
+
+ private static final String FILTER_SOURCE_PREFIX = "only_";
private static int MAX_QLENGTH = 7820;
public ThreeDBStructureChooserQuerySource()
{
+ defaultFilters = new LinkedHashSet<String>();
+ defaultFilters.add(FILTER_TDBEACONS_COVERAGE);
+ defaultFilters.add(FILTER_FIRST_BEST_COVERAGE);
+
tdbRestClient = TDBeaconsFTSRestClient.getInstance();
docFieldPrefs = new FTSDataColumnPreferences(
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);
-
- lastTdbRequest = tdbRequest;
-
- // Query the PDB and add additional metadata
- FTSRestResponse pdbResponse = fetchStructuresMetaDataFor(getPDBQuerySource(), resultList);
- FTSRestResponse joinedResp = joinResponses(resultList,
- pdbResponse);
- return resultList;
- }
+ if (selectedFilterOpt!=null && tdBeaconsFilter(selectedFilterOpt.getValue()))
+ {
+ FTSRestRequest tdbRequest = getTDBeaconsRequest(seq, wantedFields);
+ resultList = tdbRestClient.executeRequest(tdbRequest);
+
+ lastTdbRequest = tdbRequest;
+
+ // Query the PDB and add additional metadata
+ FTSRestResponse pdbResponse = fetchStructuresMetaDataFor(
+ getPDBQuerySource(), resultList);
+ FTSRestResponse joinedResp = joinResponses(resultList, pdbResponse);
+ return resultList;
+ }
// use the PDBFTS directly
- resultList = getPDBQuerySource().fetchStructuresMetaData(seq, wantedFields, selectedFilterOpt, b);
+ resultList = getPDBQuerySource().fetchStructuresMetaData(seq,
+ wantedFields, selectedFilterOpt, b);
lastTdbRequest = getPDBQuerySource().lastPdbRequest;
- lastPdbRequest = lastTdbRequest; // both queries the same - indicates we rank using PDBe
+ lastPdbRequest = lastTdbRequest; // both queries the same - indicates we
+ // rank using PDBe
return resultList;
-
+
}
- PDBStructureChooserQuerySource pdbQuerySource=null;
+ PDBStructureChooserQuerySource pdbQuerySource = null;
+
private PDBStructureChooserQuerySource getPDBQuerySource()
{
- if (pdbQuerySource==null)
+ if (pdbQuerySource == null)
{
pdbQuerySource = new PDBStructureChooserQuerySource();
}
@Override
public List<FilterOption> getAvailableFilterOptions(String VIEWS_FILTER)
{
- List<FilterOption> filters = getPDBQuerySource().getAvailableFilterOptions(VIEWS_FILTER);
-
- filters.add(0,
- new FilterOption("3D-Beacons Coverage",
- FILTER_TDBEACONS_COVERAGE, VIEWS_FILTER, true, this));
+ List<FilterOption> filters = getPDBQuerySource()
+ .getAvailableFilterOptions(VIEWS_FILTER);
+ tdBeaconsFilters = new LinkedHashSet<String>();
+ tdBeaconsFilters.addAll(defaultFilters);
+ filters.add(0, new FilterOption("Best 3D-Beacons Coverage",
+ FILTER_FIRST_BEST_COVERAGE, VIEWS_FILTER, false, this));
+ filters.add(1, new FilterOption("Multiple 3D-Beacons Coverage",
+ FILTER_TDBEACONS_COVERAGE, VIEWS_FILTER, true, this));
+
return filters;
}
+
+ @Override
+ public void updateAvailableFilterOptions(String VIEWS_FILTER,
+ List<FilterOption> xtantOptions, Collection<FTSData> tdbEntries)
+ {
+ if (tdbEntries !=null && lastTdbRequest != null)
+ {
+ int prov_idx = lastTdbRequest.getFieldIndex("Provider");
+
+ for (FTSData row : tdbEntries)
+ {
+ String provider = (String) row.getSummaryData()[prov_idx];
+ FilterOption providerOpt = new FilterOption("3DB Provider - " + provider,
+ FILTER_SOURCE_PREFIX + provider, VIEWS_FILTER,
+ false, this);
+ if (!xtantOptions.contains(providerOpt))
+ {
+ xtantOptions.add(1,
+ providerOpt);
+ tdBeaconsFilters.add(FILTER_SOURCE_PREFIX+provider);
+
+ }
+ }
+ }
+
+ }
+
private boolean tdBeaconsFilter(String fieldToFilterBy)
{
- return FILTER_TDBEACONS_COVERAGE.equals(fieldToFilterBy);
+ return tdBeaconsFilters != null
+ && tdBeaconsFilters.contains(fieldToFilterBy);
+ }
+
+ private String remove_prefix(String fieldToFilterBy)
+ {
+ if (tdBeaconsFilters != null
+ && tdBeaconsFilters.contains(fieldToFilterBy)
+ && !defaultFilters.contains(fieldToFilterBy))
+ {
+ return fieldToFilterBy.substring(FILTER_SOURCE_PREFIX.length());
+ }
+ else
+ {
+ return null;
+ }
}
@Override
public boolean needsRefetch(FilterOption selectedFilterOpt)
{
- return tdBeaconsFilter(selectedFilterOpt.getValue()) && lastPdbRequest!=lastTdbRequest;
+ return selectedFilterOpt==null || !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))
+ if (fieldToFilterBy!=null && tdBeaconsFilter(fieldToFilterBy))
{
TDBResultAnalyser analyser = new TDBResultAnalyser(seq,
- collectedResults, lastTdbRequest);
+ collectedResults, lastTdbRequest, fieldToFilterBy,
+ remove_prefix(fieldToFilterBy));
FTSRestResponse resultList = new FTSRestResponse();
return resultList;
}
// Fall back to PDBe rankings
- return getPDBQuerySource().selectFirstRankedQuery(seq, collectedResults, wantedFields, fieldToFilterBy, b);
+ return getPDBQuerySource().selectFirstRankedQuery(seq, collectedResults,
+ wantedFields, fieldToFilterBy, b);
}
-
@Override
public PDBEntry[] collectSelectedRows(JTable restable, int[] selectedRows,
List<SequenceI> selectedSeqsToView)
int typeColumnIndex = restable.getColumn("Provider").getModelIndex();
int categoryColumnIndex = restable.getColumn("Model Category")
.getModelIndex();
- final int up_start_idx = restable.getColumn("Uniprot Start").getModelIndex();
- final int up_end_idx = restable.getColumn("Uniprot End").getModelIndex();
- int i=0;
-
+ final int up_start_idx = restable.getColumn("Uniprot Start")
+ .getModelIndex();
+ final int up_end_idx = restable.getColumn("Uniprot End")
+ .getModelIndex();
+ int i = 0;
+
// bleugh!
Integer[] sellist = new Integer[selectedRows.length];
- for (Integer row: selectedRows)
+ for (Integer row : selectedRows)
{
sellist[i++] = row;
}
// Sort rows by coverage
- Arrays.sort(sellist,new Comparator<Integer>()
+ Arrays.sort(sellist, new Comparator<Integer>()
{
@Override
public int compare(Integer o1, Integer o2)
{
- int o1_xt = ((Integer)restable.getValueAt(o1, up_end_idx)) - (Integer)restable.getValueAt(o1, up_start_idx);
- int o2_xt = ((Integer)restable.getValueAt(o2, up_end_idx)) - (Integer)restable.getValueAt(o2, up_start_idx);
- return o2_xt-o1_xt;
+ int o1_xt = ((Integer) restable.getValueAt(o1, up_end_idx))
+ - (Integer) restable.getValueAt(o1, up_start_idx);
+ int o2_xt = ((Integer) restable.getValueAt(o2, up_end_idx))
+ - (Integer) restable.getValueAt(o2, up_start_idx);
+ return o2_xt - o1_xt;
}
});
-
for (int row : sellist)
{
// unique id - could be a horrible hash
int pdbIdx = lastPdbRequest.getFieldIndex("PDB Id");
int pdbTitle_idx = lastPdbRequest.getFieldIndex("Title");
int tdbTitle_idx = getLastFTSRequest().getFieldIndex("Title");
-
+
List<FTSData> joinedRows = new ArrayList<FTSData>();
for (final FTSData row : upResponse.getSearchSummary())
{
.getSummaryData()[pdbTitle_idx];
}
}
- } else {
+ }
+ else
+ {
row.getSummaryData()[tdbTitle_idx] = "Model from TDB";
}
}