package jalview.gui;
-import jalview.bin.Jalview;
-import jalview.datamodel.DBRefEntry;
-import jalview.datamodel.DBRefSource;
-import jalview.datamodel.PDBEntry;
-import jalview.datamodel.SequenceI;
-import jalview.fts.api.FTSData;
-import jalview.fts.api.FTSDataColumnI;
-import jalview.fts.api.FTSRestClientI;
-import jalview.fts.core.FTSRestRequest;
-import jalview.fts.core.FTSRestResponse;
-import jalview.fts.service.pdb.PDBFTSRestClient;
-import jalview.io.DataSourceType;
-import jalview.jbgui.GStructureChooser;
-import jalview.structure.StructureMapping;
-import jalview.structure.StructureSelectionManager;
-import jalview.util.MessageManager;
-import jalview.ws.DBRefFetcher;
-import jalview.ws.sifts.SiftsSettings;
-
import java.awt.event.ItemEvent;
import java.util.ArrayList;
import java.util.Collection;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
+import javax.swing.JTable;
+import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel;
+import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.bin.Cache;
+import jalview.bin.Jalview;
+import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.DBRefSource;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.fts.api.FTSData;
+import jalview.fts.api.FTSDataColumnI;
+import jalview.fts.api.FTSRestClientI;
+import jalview.fts.core.FTSRestRequest;
+import jalview.fts.core.FTSRestResponse;
+import jalview.fts.service.pdb.PDBFTSRestClient;
+import jalview.io.DataSourceType;
+import jalview.jbgui.GStructureChooser;
+import jalview.util.MessageManager;
+
/**
* Provides the behaviors for the Structure chooser Panel
*
public class StructureChooser extends GStructureChooser
implements IProgressIndicator
{
+ static final String AUTOSUPERIMPOSE = "AUTOSUPERIMPOSE";
+
private static int MAX_QLENGTH = 7820;
private SequenceI selectedSequence;
private FTSRestRequest lastPdbRequest;
- private FTSRestClientI pdbRestCleint;
+ private FTSRestClientI pdbRestClient;
private String selectedPdbFileName;
private boolean cachedPDBExists;
+ static StructureViewer lastTargetedView = null;
+
public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
AlignmentPanel ap)
{
/**
* Initializes parameters used by the Structure Chooser Panel
*/
- public void init()
+ protected void init()
{
if (!Jalview.isHeadlessMode())
{
progressBar = new ProgressBar(this.statusPanel, this.statusBar);
}
+ chk_superpose.setSelected(Cache.getDefault(AUTOSUPERIMPOSE, true));
+
// ensure a filter option is in force for search
populateFilterComboBox(true, cachedPDBExists);
Thread discoverPDBStructuresThread = new Thread(new Runnable()
fetchStructuresMetaData();
// revise filter options if no results were found
populateFilterComboBox(isStructuresDiscovered(), cachedPDBExists);
+ discoverStructureViews();
updateProgressIndicator(null, startTime);
mainFrame.setVisible(true);
updateCurrentView();
}
/**
+ * Builds a drop-down choice list of existing structure viewers to which new
+ * structures may be added. If this list is empty then it, and the 'Add'
+ * button, are hidden.
+ */
+ private void discoverStructureViews()
+ {
+ if (Desktop.getInstance() != null)
+ {
+ targetView.removeAllItems();
+ if (lastTargetedView != null && !lastTargetedView.isVisible())
+ {
+ lastTargetedView = null;
+ }
+ int linkedViewsAt = 0;
+ for (StructureViewerBase view : Desktop.getInstance()
+ .getStructureViewers(null, null))
+ {
+ StructureViewer viewHandler = (lastTargetedView != null
+ && lastTargetedView.sview == view) ? lastTargetedView
+ : StructureViewer.reconfigure(view);
+
+ if (view.isLinkedWith(ap))
+ {
+ targetView.insertItemAt(viewHandler, linkedViewsAt++);
+ }
+ else
+ {
+ targetView.addItem(viewHandler);
+ }
+ }
+
+ /*
+ * show option to Add to viewer if at least 1 viewer found
+ */
+ targetView.setVisible(false);
+ if (targetView.getItemCount() > 0)
+ {
+ targetView.setVisible(true);
+ if (lastTargetedView != null)
+ {
+ targetView.setSelectedItem(lastTargetedView);
+ }
+ else
+ {
+ targetView.setSelectedIndex(0);
+ }
+ }
+ btn_add.setVisible(targetView.isVisible());
+ }
+ }
+
+ /**
* Updates the progress indicator with the specified message
*
* @param message
* @param id
* unique handle for this indicator
*/
- public void updateProgressIndicator(String message, long id)
+ protected void updateProgressIndicator(String message, long id)
{
if (progressIndicator != null)
{
* Retrieve meta-data for all the structure(s) for a given sequence(s) in a
* selection group
*/
- public void fetchStructuresMetaData()
+ void fetchStructuresMetaData()
{
long startTime = System.currentTimeMillis();
- pdbRestCleint = PDBFTSRestClient.getInstance();
+ pdbRestClient = PDBFTSRestClient.getInstance();
Collection<FTSDataColumnI> wantedFields = pdbDocFieldPrefs
.getStructureSummaryFields();
FTSRestResponse resultList;
try
{
- resultList = pdbRestCleint.executeRequest(pdbRequest);
+ resultList = pdbRestClient.executeRequest(pdbRequest);
} catch (Exception e)
{
e.printStackTrace();
}
}
- public void loadLocalCachedPDBEntries()
+ protected void loadLocalCachedPDBEntries()
{
ArrayList<CachedPDB> entries = new ArrayList<>();
for (SequenceI seq : selectedSequences)
* @return the built query string
*/
- public static String buildQuery(SequenceI seq)
+ static String buildQuery(SequenceI seq)
{
boolean isPDBRefsFound = false;
boolean isUniProtRefsFound = false;
StringBuilder queryBuilder = new StringBuilder();
Set<String> seqRefs = new LinkedHashSet<>();
+ /*
+ * note PDBs as DBRefEntry so they are not duplicated in query
+ */
+ Set<String> pdbids = new HashSet<>();
+
if (seq.getAllPDBEntries() != null
&& queryBuilder.length() < MAX_QLENGTH)
{
{
if (isValidSeqName(entry.getId()))
{
- queryBuilder.append("pdb_id:").append(entry.getId().toLowerCase())
- .append(" OR ");
+ String id = entry.getId().toLowerCase();
+ queryBuilder.append("pdb_id:").append(id).append(" OR ");
isPDBRefsFound = true;
+ pdbids.add(id);
}
}
}
- if (seq.getDBRefs() != null && seq.getDBRefs().length != 0)
+ List<DBRefEntry> refs = seq.getDBRefs();
+ if (refs != null && refs.size() != 0)
{
- for (DBRefEntry dbRef : seq.getDBRefs())
+ for (int ib = 0, nb = refs.size(); ib < nb; ib++)
{
+ DBRefEntry dbRef = refs.get(ib);
if (isValidSeqName(getDBRefId(dbRef))
&& queryBuilder.length() < MAX_QLENGTH)
{
else if (dbRef.getSource().equalsIgnoreCase(DBRefSource.PDB))
{
- queryBuilder.append("pdb_id:")
- .append(getDBRefId(dbRef).toLowerCase()).append(" OR ");
- isPDBRefsFound = true;
+ String id = getDBRefId(dbRef).toLowerCase();
+ if (!pdbids.contains(id))
+ {
+ queryBuilder.append("pdb_id:").append(id).append(" OR ");
+ isPDBRefsFound = true;
+ pdbids.add(id);
+ }
}
else
{
* @param seqName
* @return
*/
- public static boolean isValidSeqName(String seqName)
+ static boolean isValidSeqName(String seqName)
{
// System.out.println("seqName : " + seqName);
String ignoreList = "pdb,uniprot,swiss-prot";
return true;
}
- public static String getDBRefId(DBRefEntry dbRef)
+ static String getDBRefId(DBRefEntry dbRef)
{
String ref = dbRef.getAccessionId().replaceAll("GO:", "");
return ref;
* @param fieldToFilterBy
* the field to filter by
*/
- public void filterResultSet(final String fieldToFilterBy)
+ void filterResultSet(final String fieldToFilterBy)
{
Thread filterThread = new Thread(new Runnable()
{
public void run()
{
long startTime = System.currentTimeMillis();
- pdbRestCleint = PDBFTSRestClient.getInstance();
+ pdbRestClient = PDBFTSRestClient.getInstance();
lbl_loading.setVisible(true);
Collection<FTSDataColumnI> wantedFields = pdbDocFieldPrefs
.getStructureSummaryFields();
FTSRestResponse resultList;
try
{
- resultList = pdbRestCleint.executeRequest(pdbRequest);
+ resultList = pdbRestClient.executeRequest(pdbRequest);
} catch (Exception e)
{
e.printStackTrace();
* Handles action event for btn_pdbFromFile
*/
@Override
- public void pdbFromFile_actionPerformed()
+ protected void pdbFromFile_actionPerformed()
{
+ // 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"));
chooser.setFileView(new jalview.io.JalviewFileView());
* structures
*/
protected void populateFilterComboBox(boolean haveData,
- boolean cachedPDBExists)
+ boolean cachedPDBExist)
{
/*
* temporarily suspend the change listener behaviour
cmb_filterOption.removeAllItems();
if (haveData)
{
- cmb_filterOption.addItem(new FilterOption("Best Quality",
+ cmb_filterOption.addItem(new FilterOption(
+ MessageManager.getString("label.best_quality"),
"overall_quality", VIEWS_FILTER, false));
- cmb_filterOption.addItem(new FilterOption("Best Resolution",
+ cmb_filterOption.addItem(new FilterOption(
+ MessageManager.getString("label.best_resolution"),
"resolution", VIEWS_FILTER, false));
- cmb_filterOption.addItem(new FilterOption("Most Protein Chain",
+ cmb_filterOption.addItem(new FilterOption(
+ MessageManager.getString("label.most_protein_chain"),
"number_of_protein_chains", VIEWS_FILTER, false));
- cmb_filterOption.addItem(new FilterOption("Most Bound Molecules",
+ cmb_filterOption.addItem(new FilterOption(
+ MessageManager.getString("label.most_bound_molecules"),
"number_of_bound_molecules", VIEWS_FILTER, false));
- cmb_filterOption.addItem(new FilterOption("Most Polymer Residues",
+ cmb_filterOption.addItem(new FilterOption(
+ MessageManager.getString("label.most_polymer_residues"),
"number_of_polymer_residues", VIEWS_FILTER, true));
}
cmb_filterOption.addItem(
- new FilterOption("Enter PDB Id", "-", VIEWS_ENTER_ID, false));
+ new FilterOption(MessageManager.getString("label.enter_pdb_id"),
+ "-", VIEWS_ENTER_ID, false));
cmb_filterOption.addItem(
- new FilterOption("From File", "-", VIEWS_FROM_FILE, false));
+ new FilterOption(MessageManager.getString("label.from_file"),
+ "-", VIEWS_FROM_FILE, false));
- if (cachedPDBExists)
+ if (cachedPDBExist)
{
- FilterOption cachedOption = new FilterOption("Cached PDB Entries",
- "-", VIEWS_LOCAL_PDB, false);
+ FilterOption cachedOption = new FilterOption(
+ MessageManager.getString("label.cached_structures"), "-",
+ VIEWS_LOCAL_PDB, false);
cmb_filterOption.addItem(cachedOption);
cmb_filterOption.setSelectedItem(cachedOption);
}
}
/**
- * Validates user selection and activates the view button if all parameters
- * are correct
+ * Validates user selection and enables the 'Add' and 'New View' buttons if
+ * all parameters are correct (the Add button will only be visible if there is
+ * at least one existing structure viewer open). This basically means at least
+ * one structure selected and no error messages.
+ * <p>
+ * The 'Superpose Structures' option is enabled if either more than one
+ * structure is selected, or the 'Add' to existing view option is enabled, and
+ * disabled if the only option is to open a new view of a single structure.
*/
@Override
- public void validateSelections()
+ protected void validateSelections()
{
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
.getSelectedItem());
- btn_view.setEnabled(false);
+ btn_add.setEnabled(false);
String currentView = selectedFilterOpt.getView();
+ int selectedCount = 0;
if (currentView == VIEWS_FILTER)
{
- if (getResultTable().getSelectedRows().length > 0)
+ selectedCount = getResultTable().getSelectedRows().length;
+ if (selectedCount > 0)
{
- btn_view.setEnabled(true);
+ btn_add.setEnabled(true);
}
}
else if (currentView == VIEWS_LOCAL_PDB)
{
- if (tbl_local_pdb.getSelectedRows().length > 0)
+ selectedCount = tbl_local_pdb.getSelectedRows().length;
+ if (selectedCount > 0)
{
- btn_view.setEnabled(true);
+ btn_add.setEnabled(true);
}
}
else if (currentView == VIEWS_ENTER_ID)
{
validateAssociationFromFile();
}
+
+ btn_newView.setEnabled(btn_add.isEnabled());
+
+ /*
+ * enable 'Superpose' option if more than one structure is selected,
+ * or there are view(s) available to add structure(s) to
+ */
+ chk_superpose
+ .setEnabled(selectedCount > 1 || targetView.getItemCount() > 0);
}
/**
* Validates inputs from the Manual PDB entry panel
*/
- public void validateAssociationEnterPdb()
+ protected void validateAssociationEnterPdb()
{
AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel
.getCmb_assSeq().getSelectedItem();
txt_search.setEnabled(true);
if (isValidPBDEntry)
{
- btn_view.setEnabled(true);
+ btn_add.setEnabled(true);
lbl_pdbManualFetchStatus.setToolTipText("");
lbl_pdbManualFetchStatus.setIcon(goodImage);
}
/**
* Validates inputs for the manual PDB file selection options
*/
- public void validateAssociationFromFile()
+ protected void validateAssociationFromFile()
{
AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel
.getCmb_assSeq().getSelectedItem();
btn_pdbFromFile.setEnabled(true);
if (selectedPdbFileName != null && selectedPdbFileName.length() > 0)
{
- btn_view.setEnabled(true);
+ btn_add.setEnabled(true);
lbl_fromFileStatus.setIcon(goodImage);
}
}
}
@Override
- public void cmbAssSeqStateChanged()
+ protected void cmbAssSeqStateChanged()
{
validateSelections();
}
}
/**
- * Handles action event for btn_ok
+ * select structures for viewing by their PDB IDs
+ *
+ * @param pdbids
+ * @return true if structures were found and marked as selected
+ */
+ public boolean selectStructure(String... pdbids)
+ {
+ boolean found = false;
+
+ FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
+ .getSelectedItem());
+ String currentView = selectedFilterOpt.getView();
+ JTable restable = (currentView == VIEWS_FILTER) ? getResultTable()
+ : (currentView == VIEWS_LOCAL_PDB) ? tbl_local_pdb : null;
+
+ if (restable == null)
+ {
+ // can't select (enter PDB ID, or load file - need to also select which
+ // sequence to associate with)
+ return false;
+ }
+
+ int pdbIdColIndex = restable.getColumn("PDB Id").getModelIndex();
+ for (int r = 0; r < restable.getRowCount(); r++)
+ {
+ for (int p = 0; p < pdbids.length; p++)
+ {
+ if (String.valueOf(restable.getValueAt(r, pdbIdColIndex))
+ .equalsIgnoreCase(pdbids[p]))
+ {
+ restable.setRowSelectionInterval(r, r);
+ found = true;
+ }
+ }
+ }
+ return found;
+ }
+
+ /**
+ * Handles the 'New View' action
+ */
+ @Override
+ protected void newView_ActionPerformed()
+ {
+ targetView.setSelectedItem(null);
+ showStructures(false);
+ }
+
+ /**
+ * Handles the 'Add to existing viewer' action
*/
@Override
- public void ok_ActionPerformed()
+ protected void add_ActionPerformed()
+ {
+ showStructures(false);
+ }
+
+ /**
+ * structure viewer opened by this dialog, or null
+ */
+ private StructureViewer sViewer = null;
+
+ public void showStructures(boolean waitUntilFinished)
{
- final StructureSelectionManager ssm = ap.getStructureSelectionManager();
final int preferredHeight = pnl_filter.getHeight();
- new Thread(new Runnable()
+ final StructureViewer theViewer = getTargetedStructureViewer();
+ boolean superimpose = chk_superpose.isSelected();
+
+ Runnable viewStruc = new Runnable()
{
@Override
public void run()
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
.getSelectedItem());
String currentView = selectedFilterOpt.getView();
+ JTable restable = (currentView == VIEWS_FILTER) ? getResultTable()
+ : tbl_local_pdb;
+
if (currentView == VIEWS_FILTER)
{
- int pdbIdColIndex = getResultTable().getColumn("PDB Id")
+ int pdbIdColIndex = restable.getColumn("PDB Id").getModelIndex();
+ int refSeqColIndex = restable.getColumn("Ref Sequence")
.getModelIndex();
- int refSeqColIndex = getResultTable().getColumn("Ref Sequence")
- .getModelIndex();
- int[] selectedRows = getResultTable().getSelectedRows();
+ int[] selectedRows = restable.getSelectedRows();
PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
int count = 0;
List<SequenceI> selectedSeqsToView = new ArrayList<>();
for (int row : selectedRows)
{
- String pdbIdStr = getResultTable()
- .getValueAt(row, pdbIdColIndex).toString();
- SequenceI selectedSeq = (SequenceI) getResultTable()
- .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)
if (pdbEntry == null)
{
- pdbEntry = new PDBEntry();
- pdbEntry.setId(pdbIdStr);
- pdbEntry.setType(PDBEntry.Type.PDB);
+ pdbEntry = new PDBEntry(pdbIdStr, null, "pdb");
selectedSeq.getDatasetSequence().addPDBId(pdbEntry);
}
pdbEntriesToView[count++] = pdbEntry;
}
SequenceI[] selectedSeqs = selectedSeqsToView
.toArray(new SequenceI[selectedSeqsToView.size()]);
- launchStructureViewer(ssm, pdbEntriesToView, ap, selectedSeqs);
+ sViewer = StructureViewer.launchStructureViewer(ap, pdbEntriesToView,
+ selectedSeqs, superimpose, theViewer, progressBar);
}
else if (currentView == VIEWS_LOCAL_PDB)
{
}
SequenceI[] selectedSeqs = selectedSeqsToView
.toArray(new SequenceI[selectedSeqsToView.size()]);
- launchStructureViewer(ssm, pdbEntriesToView, ap, selectedSeqs);
+ sViewer = StructureViewer.launchStructureViewer(ap, pdbEntriesToView,
+ selectedSeqs, superimpose, theViewer, progressBar);
}
else if (currentView == VIEWS_ENTER_ID)
{
}
PDBEntry[] pdbEntriesToView = new PDBEntry[] { pdbEntry };
- launchStructureViewer(ssm, pdbEntriesToView, ap,
+ sViewer = StructureViewer.launchStructureViewer(ap, pdbEntriesToView,
new SequenceI[]
- { selectedSequence });
+ { selectedSequence }, superimpose, theViewer,
+ progressBar);
}
else if (currentView == VIEWS_FROM_FILE)
{
{
selectedSequence = userSelectedSeq;
}
- PDBEntry fileEntry = new AssociatePdbFileWithSeq()
- .associatePdbWithSeq(selectedPdbFileName,
- DataSourceType.FILE, selectedSequence, true,
- Desktop.instance);
-
- launchStructureViewer(ssm, new PDBEntry[] { fileEntry }, ap,
+ PDBEntry fileEntry = AssociatePdbFileWithSeq.associatePdbWithSeq(selectedPdbFileName,
+ DataSourceType.FILE, selectedSequence, true);
+ sViewer = StructureViewer.launchStructureViewer(ap, new PDBEntry[] { fileEntry },
new SequenceI[]
- { selectedSequence });
+ { selectedSequence }, superimpose, theViewer,
+ progressBar);
}
- closeAction(preferredHeight);
- mainFrame.dispose();
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ closeAction(preferredHeight);
+ mainFrame.dispose();
+ }
+ });
}
- }).start();
+ };
+ Thread runner = new Thread(viewStruc);
+ runner.start();
+ if (waitUntilFinished)
+ {
+ while (sViewer == null ? runner.isAlive()
+ : (sViewer.sview == null ? true
+ : !sViewer.sview.hasMapping()))
+ {
+ try
+ {
+ Thread.sleep(300);
+ } catch (InterruptedException ie)
+ {
+
+ }
+ }
+ }
}
private PDBEntry getFindEntry(String id, Vector<PDBEntry> pdbEntries)
return foundEntry;
}
- private void launchStructureViewer(StructureSelectionManager ssm,
- final PDBEntry[] pdbEntriesToView,
- final AlignmentPanel alignPanel, SequenceI[] sequences)
+ /**
+ * Answers a structure viewer (new or existing) configured to superimpose
+ * added structures or not according to the user's choice
+ *
+ * @param ssm
+ * @return
+ */
+ StructureViewer getTargetedStructureViewer()
{
- long progressId = sequences.hashCode();
- setProgressBar(MessageManager
- .getString("status.launching_3d_structure_viewer"), progressId);
- final StructureViewer sViewer = new StructureViewer(ssm);
- setProgressBar(null, progressId);
-
- if (SiftsSettings.isMapWithSifts())
- {
- List<SequenceI> seqsWithoutSourceDBRef = new ArrayList<>();
- int p = 0;
- // TODO: skip PDBEntry:Sequence pairs where PDBEntry doesn't look like a
- // real PDB ID. For moment, we can also safely do this if there is already
- // a known mapping between the PDBEntry and the sequence.
- for (SequenceI seq : sequences)
- {
- PDBEntry pdbe = pdbEntriesToView[p++];
- if (pdbe != null && pdbe.getFile() != null)
- {
- StructureMapping[] smm = ssm.getMapping(pdbe.getFile());
- if (smm != null && smm.length > 0)
- {
- for (StructureMapping sm : smm)
- {
- if (sm.getSequence() == seq)
- {
- continue;
- }
- }
- }
- }
- if (seq.getPrimaryDBRefs().size() == 0)
- {
- seqsWithoutSourceDBRef.add(seq);
- continue;
- }
- }
- if (!seqsWithoutSourceDBRef.isEmpty())
- {
- int y = seqsWithoutSourceDBRef.size();
- setProgressBar(MessageManager.formatMessage(
- "status.fetching_dbrefs_for_sequences_without_valid_refs",
- y), progressId);
- SequenceI[] seqWithoutSrcDBRef = new SequenceI[y];
- int x = 0;
- for (SequenceI fSeq : seqsWithoutSourceDBRef)
- {
- seqWithoutSrcDBRef[x++] = fSeq;
- }
-
- DBRefFetcher dbRefFetcher = new DBRefFetcher(seqWithoutSrcDBRef);
- dbRefFetcher.fetchDBRefs(true);
-
- setProgressBar("Fetch complete.", progressId); // todo i18n
- }
- }
- if (pdbEntriesToView.length > 1)
- {
- setProgressBar(MessageManager.getString(
- "status.fetching_3d_structures_for_selected_entries"),
- progressId);
- sViewer.viewStructures(pdbEntriesToView, sequences, alignPanel);
- }
- else
- {
- setProgressBar(MessageManager.formatMessage(
- "status.fetching_3d_structures_for",
- pdbEntriesToView[0].getId()),progressId);
- sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
- }
- setProgressBar(null, progressId);
+ return (StructureViewer) targetView.getSelectedItem();
}
/**
* a unique sequence when more than one sequence selection is made.
*/
@Override
- public void populateCmbAssociateSeqOptions(
+ protected void populateCmbAssociateSeqOptions(
JComboBox<AssociateSeqOptions> cmb_assSeq,
JLabel lbl_associateSeq)
{
}
}
- public boolean isStructuresDiscovered()
+ protected boolean isStructuresDiscovered()
{
return discoveredStructuresSet != null
&& !discoveredStructuresSet.isEmpty();
}
- public Collection<FTSData> getDiscoveredStructuresSet()
- {
- return discoveredStructuresSet;
- }
+ 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.
@Override
protected void txt_search_ActionPerformed()
{
- new Thread()
- {
- @Override
- public void run()
+ String text = txt_search.getText().trim();
+ if (text.length() >= PDB_ID_MIN)
+ new Thread()
{
- errorWarning.setLength(0);
- isValidPBDEntry = false;
- if (txt_search.getText().length() > 0)
+
+ @Override
+ public void run()
{
- String searchTerm = txt_search.getText().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);
- pdbRestCleint = PDBFTSRestClient.getInstance();
- wantedFields.add(pdbRestCleint.getPrimaryKeyColumn());
- FTSRestResponse resultList;
- try
- {
- resultList = pdbRestCleint.executeRequest(pdbRequest);
- } catch (Exception e)
+ errorWarning.setLength(0);
+ isValidPBDEntry = false;
+ if (text.length() > 0)
{
- errorWarning.append(e.getMessage());
- return;
- } finally
- {
- validateSelections();
- }
- if (resultList.getSearchSummary() != null
- && resultList.getSearchSummary().size() > 0)
- {
- isValidPBDEntry = true;
+ 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);
+ 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
- public void tabRefresh()
+ protected void tabRefresh()
{
if (selectedSequences != null)
{
{
progressBar.setProgressBar(message, id);
}
+
+ @Override
+ public void removeProgressBar(long id)
+ {
+ progressBar.removeProgressBar(id);
+ }
@Override
public void registerHandler(long id, IProgressIndicatorHandler handler)
{
return progressBar.operationInProgress();
}
+
+ public JalviewStructureDisplayI getOpenedStructureViewer()
+ {
+ return sViewer == null ? null : sViewer.sview;
+ }
+
}