import jalview.fts.api.FTSData;
import jalview.fts.api.FTSDataColumnI;
import jalview.fts.api.FTSRestClientI;
+import jalview.fts.core.FTSDataColumnPreferences;
import jalview.fts.core.FTSRestRequest;
import jalview.fts.core.FTSRestResponse;
import jalview.fts.service.pdb.PDBFTSRestClient;
private Collection<FTSData> discoveredStructuresSet;
- private StructureChooserQuerySource data = StructureChooserQuerySource.getPDBfts();
+ private StructureChooserQuerySource data;
+
+ @Override
+ protected FTSDataColumnPreferences getFTSDocFieldPrefs()
+ {
+ return data.getDocFieldPrefs();
+ }
private String selectedPdbFileName;
public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
AlignmentPanel ap)
{
+ // which FTS engine to use
+ data = StructureChooserQuerySource
+ .getPDBfts();
+ initDialog();
+
this.ap = ap;
this.selectedSequence = selectedSeq;
this.selectedSequences = selectedSeqs;
this.progressIndicator = (ap == null) ? null : ap.alignFrame;
init();
+
}
/**
if (view.isLinkedWith(ap))
{
- targetView.insertItemAt(viewHandler,
- linkedViewsAt++);
+ targetView.insertItemAt(viewHandler, linkedViewsAt++);
}
else
{
void fetchStructuresMetaData()
{
long startTime = System.currentTimeMillis();
- Collection<FTSDataColumnI> wantedFields = pdbDocFieldPrefs
+ Collection<FTSDataColumnI> wantedFields = data.getDocFieldPrefs()
.getStructureSummaryFields();
discoveredStructuresSet = new LinkedHashSet<>();
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
.getSelectedItem());
-
+
for (SequenceI seq : selectedSequences)
{
FTSRestResponse resultList;
try
{
- resultList = data.fetchStructuresMetaData(seq, wantedFields, selectedFilterOpt, !chk_invertFilter.isSelected());
+ resultList = data.fetchStructuresMetaData(seq, wantedFields,
+ selectedFilterOpt, !chk_invertFilter.isSelected());
} catch (Exception e)
{
e.printStackTrace();
if (discoveredStructuresSet != null
&& !discoveredStructuresSet.isEmpty())
{
- getResultTable().setModel(data.getTableModel(discoveredStructuresSet));
+ getResultTable()
+ .setModel(data.getTableModel(discoveredStructuresSet));
noOfStructuresFound = discoveredStructuresSet.size();
mainFrame.setTitle(MessageManager.formatMessage(
"label.structure_chooser_no_of_structures",
{
long startTime = System.currentTimeMillis();
lbl_loading.setVisible(true);
- Collection<FTSDataColumnI> wantedFields = pdbDocFieldPrefs
+ Collection<FTSDataColumnI> wantedFields = data.getDocFieldPrefs()
.getStructureSummaryFields();
Collection<FTSData> filteredResponse = new HashSet<>();
HashSet<String> errors = new HashSet<>();
for (SequenceI seq : selectedSequences)
{
-
+
FTSRestResponse resultList;
try
{
- resultList = data.selectFirstRankedQuery(seq, wantedFields, fieldToFilterBy,
- !chk_invertFilter.isSelected());
+ resultList = data.selectFirstRankedQuery(seq, wantedFields,
+ fieldToFilterBy, !chk_invertFilter.isSelected());
} catch (Exception e)
{
Collection<FTSData> reorderedStructuresSet = new LinkedHashSet<>();
reorderedStructuresSet.addAll(filteredResponse);
reorderedStructuresSet.addAll(discoveredStructuresSet);
- getResultTable().setModel(data.getTableModel(reorderedStructuresSet));
+ getResultTable()
+ .setModel(data.getTableModel(reorderedStructuresSet));
FTSRestResponse.configureTableColumn(getResultTable(),
wantedFields, tempUserPrefs);
@Override
protected void pdbFromFile_actionPerformed()
{
- // TODO: JAL-3048 not needed for Jalview-JS until JSmol dep and StructureChooser
+ // TODO: JAL-3048 not needed for Jalview-JS until JSmol dep and
+ // StructureChooser
// works
jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
if (cachedPDBExist)
{
FilterOption cachedOption = new FilterOption(
- MessageManager.getString("label.cached_structures"),
- "-", VIEWS_LOCAL_PDB, false);
+ MessageManager.getString("label.cached_structures"), "-",
+ VIEWS_LOCAL_PDB, false);
cmb_filterOption.addItem(cachedOption);
cmb_filterOption.setSelectedItem(cachedOption);
}
}
return found;
}
-
+
/**
* Handles the 'New View' action
*/
if (currentView == VIEWS_FILTER)
{
- int pdbIdColIndex = restable.getColumn("PDB Id")
- .getModelIndex();
+ int pdbIdColIndex = restable.getColumn("PDB Id").getModelIndex();
int refSeqColIndex = restable.getColumn("Ref Sequence")
.getModelIndex();
int[] selectedRows = restable.getSelectedRows();
List<SequenceI> selectedSeqsToView = new ArrayList<>();
for (int row : selectedRows)
{
- String pdbIdStr = restable
- .getValueAt(row, pdbIdColIndex).toString();
- SequenceI selectedSeq = (SequenceI) restable
- .getValueAt(row, refSeqColIndex);
+ String pdbIdStr = restable.getValueAt(row, pdbIdColIndex)
+ .toString();
+ SequenceI selectedSeq = (SequenceI) restable.getValueAt(row,
+ refSeqColIndex);
selectedSeqsToView.add(selectedSeq);
PDBEntry pdbEntry = selectedSeq.getPDBEntry(pdbIdStr);
if (pdbEntry == null)
DataSourceType.FILE, selectedSequence, true,
Desktop.instance);
- sViewer = launchStructureViewer(
- ssm, new PDBEntry[]
- { fileEntry }, ap,
- new SequenceI[]
+ sViewer = launchStructureViewer(ssm, new PDBEntry[] { fileEntry },
+ ap, new SequenceI[]
{ selectedSequence });
}
SwingUtilities.invokeLater(new Runnable()
* @param ssm
* @return
*/
- StructureViewer getTargetedStructureViewer(
- StructureSelectionManager ssm)
+ StructureViewer getTargetedStructureViewer(StructureSelectionManager ssm)
{
Object sv = targetView.getSelectedItem();
* @return
*/
private StructureViewer launchStructureViewer(
- StructureSelectionManager ssm,
- final PDBEntry[] pdbEntriesToView,
+ StructureSelectionManager ssm, final PDBEntry[] pdbEntriesToView,
final AlignmentPanel alignPanel, SequenceI[] sequences)
{
long progressId = sequences.hashCode();
}
if (pdbEntriesToView.length > 1)
{
- setProgressBar(MessageManager.getString(
- "status.fetching_3d_structures_for_selected_entries"),
+ setProgressBar(
+ MessageManager.getString(
+ "status.fetching_3d_structures_for_selected_entries"),
progressId);
theViewer.viewStructures(pdbEntriesToView, sequences, alignPanel);
}
{
setProgressBar(MessageManager.formatMessage(
"status.fetching_3d_structures_for",
- pdbEntriesToView[0].getId()),progressId);
+ pdbEntriesToView[0].getId()), progressId);
theViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
}
setProgressBar(null, progressId);
&& !discoveredStructuresSet.isEmpty();
}
- protected int PDB_ID_MIN = 3;// or: (Jalview.isJS() ? 3 : 1); // Bob proposes this.
+ protected int PDB_ID_MIN = 3;// or: (Jalview.isJS() ? 3 : 1); // Bob proposes
+ // this.
// Doing a search for "1" or "1c" is valuable?
// Those work but are enormously slow.
protected void txt_search_ActionPerformed()
{
String text = txt_search.getText().trim();
- if (text.length() >= PDB_ID_MIN)
- new Thread()
- {
-
- @Override
- public void run()
+ if (text.length() >= PDB_ID_MIN)
+ new Thread()
{
- errorWarning.setLength(0);
- isValidPBDEntry = false;
- if (text.length() > 0)
+
+ @Override
+ public void run()
{
- // TODO move this pdb id search into the PDB specific FTSSearchEngine
- // for moment, it will work fine as is because it is self-contained
- String searchTerm = text.toLowerCase();
- searchTerm = searchTerm.split(":")[0];
- // System.out.println(">>>>> search term : " + searchTerm);
- List<FTSDataColumnI> wantedFields = new ArrayList<>();
- FTSRestRequest pdbRequest = new FTSRestRequest();
- pdbRequest.setAllowEmptySeq(false);
- pdbRequest.setResponseSize(1);
- pdbRequest.setFieldToSearchBy("(pdb_id:");
- pdbRequest.setWantedFields(wantedFields);
- pdbRequest.setSearchTerm(searchTerm + ")");
- pdbRequest.setAssociatedSequence(selectedSequence);
- FTSRestClientI pdbRestClient = PDBFTSRestClient.getInstance();
- wantedFields.add(pdbRestClient.getPrimaryKeyColumn());
- FTSRestResponse resultList;
- try
- {
- resultList = pdbRestClient.executeRequest(pdbRequest);
- } catch (Exception e)
- {
- errorWarning.append(e.getMessage());
- return;
- } finally
- {
- validateSelections();
- }
- if (resultList.getSearchSummary() != null
- && resultList.getSearchSummary().size() > 0)
+ errorWarning.setLength(0);
+ isValidPBDEntry = false;
+ if (text.length() > 0)
{
- isValidPBDEntry = true;
+ // TODO move this pdb id search into the PDB specific
+ // FTSSearchEngine
+ // for moment, it will work fine as is because it is self-contained
+ String searchTerm = text.toLowerCase();
+ searchTerm = searchTerm.split(":")[0];
+ // System.out.println(">>>>> search term : " + searchTerm);
+ List<FTSDataColumnI> wantedFields = new ArrayList<>();
+ FTSRestRequest pdbRequest = new FTSRestRequest();
+ pdbRequest.setAllowEmptySeq(false);
+ pdbRequest.setResponseSize(1);
+ pdbRequest.setFieldToSearchBy("(pdb_id:");
+ pdbRequest.setWantedFields(wantedFields);
+ pdbRequest.setSearchTerm(searchTerm + ")");
+ pdbRequest.setAssociatedSequence(selectedSequence);
+ FTSRestClientI pdbRestClient = PDBFTSRestClient.getInstance();
+ wantedFields.add(pdbRestClient.getPrimaryKeyColumn());
+ FTSRestResponse resultList;
+ try
+ {
+ resultList = pdbRestClient.executeRequest(pdbRequest);
+ } catch (Exception e)
+ {
+ errorWarning.append(e.getMessage());
+ return;
+ } finally
+ {
+ validateSelections();
+ }
+ if (resultList.getSearchSummary() != null
+ && resultList.getSearchSummary().size() > 0)
+ {
+ isValidPBDEntry = true;
+ }
}
+ validateSelections();
}
- validateSelections();
- }
- }.start();
+ }.start();
}
@Override
{
return sViewer == null ? null : sViewer.sview;
}
+
+ @Override
+ protected void setFTSDocFieldPrefs(FTSDataColumnPreferences newPrefs)
+ {
+ data.setDocFieldPrefs(newPrefs);
+
+ }
}