3 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
4 * Copyright (C) 2014 The Jalview Authors
6 * This file is part of Jalview.
8 * Jalview is free software: you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation, either version 3
11 * of the License, or (at your option) any later version.
13 * Jalview is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
20 * The Jalview Authors are detailed in the 'AUTHORS' file.
25 import jalview.datamodel.DBRefEntry;
26 import jalview.datamodel.PDBEntry;
27 import jalview.datamodel.SequenceI;
28 import jalview.jbgui.GStructureChooser;
29 import jalview.jbgui.PDBDocFieldPreferences;
30 import jalview.structure.StructureSelectionManager;
31 import jalview.util.MessageManager;
32 import jalview.ws.dbsources.PDBRestClient;
33 import jalview.ws.dbsources.PDBRestClient.PDBDocField;
34 import jalview.ws.uimodel.PDBRestRequest;
35 import jalview.ws.uimodel.PDBRestResponse;
36 import jalview.ws.uimodel.PDBRestResponse.PDBResponseSummary;
38 import java.awt.event.ItemEvent;
39 import java.util.ArrayList;
40 import java.util.Collection;
41 import java.util.HashSet;
42 import java.util.Hashtable;
43 import java.util.LinkedHashSet;
44 import java.util.List;
46 import javax.swing.JCheckBox;
47 import javax.swing.JComboBox;
48 import javax.swing.JLabel;
49 import javax.swing.JOptionPane;
50 import javax.swing.table.DefaultTableModel;
54 * Provides the behaviors for the Structure chooser Panel
59 @SuppressWarnings("serial")
60 public class StructureChooser extends GStructureChooser
62 private boolean structuresDiscovered = false;
64 private SequenceI selectedSequence;
66 private SequenceI[] selectedSequences;
68 private IProgressIndicator progressIndicator;
70 private Collection<PDBResponseSummary> discoveredStructuresSet;
72 private PDBRestRequest lastPdbRequest;
74 private PDBRestClient pdbRestCleint;
76 private String selectedPdbFileName;
78 private boolean isValidPBDEntry;
80 private static Hashtable<String, PDBEntry> cachedEntryMap;
82 public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
86 this.selectedSequence = selectedSeq;
87 this.selectedSequences = selectedSeqs;
88 this.progressIndicator = (ap == null) ? null : ap.alignFrame;
93 * Initializes parameters used by the Structure Chooser Panel
97 Thread discoverPDBStructuresThread = new Thread(new Runnable()
102 long startTime = System.currentTimeMillis();
103 updateProgressIndicator(MessageManager
104 .getString("status.loading_cached_pdb_entries"), startTime);
105 loadLocalCachedPDBEntries();
106 updateProgressIndicator(null, startTime);
107 updateProgressIndicator(MessageManager
108 .getString("status.searching_for_pdb_structures"),
110 fetchStructuresMetaData();
111 populateFilterComboBox();
112 updateProgressIndicator(null, startTime);
113 mainFrame.setVisible(true);
117 discoverPDBStructuresThread.start();
121 * Updates the progress indicator with the specified message
124 * displayed message for the operation
126 * unique handle for this indicator
128 public void updateProgressIndicator(String message, long id)
130 if (progressIndicator != null)
132 progressIndicator.setProgressBar(message, id);
137 * Retrieve meta-data for all the structure(s) for a given sequence(s) in a
140 public void fetchStructuresMetaData()
142 long startTime = System.currentTimeMillis();
143 Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
144 .getStructureSummaryFields();
146 discoveredStructuresSet = new LinkedHashSet<PDBResponseSummary>();
147 HashSet<String> errors = new HashSet<String>();
148 for (SequenceI seq : selectedSequences)
150 PDBRestRequest pdbRequest = new PDBRestRequest();
151 pdbRequest.setAllowEmptySeq(false);
152 pdbRequest.setResponseSize(500);
153 pdbRequest.setFieldToSearchBy("(text:");
154 pdbRequest.setWantedFields(wantedFields);
155 pdbRequest.setSearchTerm(buildQuery(seq) + ")");
156 pdbRequest.setAssociatedSequence(seq);
157 pdbRestCleint = new PDBRestClient();
158 PDBRestResponse resultList;
161 resultList = pdbRestCleint.executeRequest(pdbRequest);
162 } catch (Exception e)
165 errors.add(e.getMessage());
168 lastPdbRequest = pdbRequest;
169 if (resultList.getSearchSummary() != null
170 && !resultList.getSearchSummary().isEmpty())
172 discoveredStructuresSet.addAll(resultList.getSearchSummary());
173 updateSequencePDBEntries(seq, resultList.getSearchSummary());
177 int noOfStructuresFound = 0;
178 String totalTime = (System.currentTimeMillis() - startTime)
180 if (discoveredStructuresSet != null
181 && !discoveredStructuresSet.isEmpty())
183 tbl_summary.setModel(PDBRestResponse.getTableModel(lastPdbRequest,
184 discoveredStructuresSet));
185 structuresDiscovered = true;
186 noOfStructuresFound = discoveredStructuresSet.size();
187 mainFrame.setTitle("Structure Chooser - " + noOfStructuresFound
188 + " Found (" + totalTime + ")");
193 .setTitle("Structure Chooser - Manual association");
194 if (errors.size() > 0)
196 StringBuilder errorMsg = new StringBuilder();
197 // "Operation was unsuccessful due to the following: \n");
198 for (String error : errors)
200 errorMsg.append(error).append("\n");
202 JOptionPane.showMessageDialog(this, errorMsg.toString(),
203 "PDB Web-service Error", JOptionPane.ERROR_MESSAGE);
208 public void loadLocalCachedPDBEntries()
210 DefaultTableModel tableModel = new DefaultTableModel()
213 public boolean isCellEditable(int row, int column)
218 tableModel.addColumn("Ref Sequence");
219 tableModel.addColumn("PDB Id");
220 tableModel.addColumn("Chain");
221 tableModel.addColumn("Type");
222 tableModel.addColumn("File");
223 cachedEntryMap = new Hashtable<String, PDBEntry>();
224 for (SequenceI seq : selectedSequences)
226 if (seq.getDatasetSequence() != null
227 && seq.getDatasetSequence().getPDBId() != null)
229 for (PDBEntry pdbEntry : seq.getDatasetSequence().getPDBId())
232 String chain = pdbEntry.getChainCode() == null ? "_" : pdbEntry
234 Object[] pdbEntryRowData = new Object[]
235 { seq, pdbEntry.getId(),
238 pdbEntry.getFile() };
239 if (pdbEntry.getFile() != null)
241 tableModel.addRow(pdbEntryRowData);
243 cachedEntryMap.put(pdbEntry.getId().toLowerCase(),
248 tbl_local_pdb.setModel(tableModel);
252 * Update the PDBEntry for a given sequence with values retrieved from
256 * the Sequence to update its DBRef entry
257 * @param responseSummaries
258 * a collection of PDBResponseSummary
260 public void updateSequencePDBEntries(SequenceI seq,
261 Collection<PDBResponseSummary> responseSummaries)
263 for (PDBResponseSummary response : responseSummaries)
265 String pdbIdStr = response.getPdbId();
266 PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase());
267 if (pdbEntry == null)
269 pdbEntry = new PDBEntry();
270 pdbEntry.setId(pdbIdStr);
271 pdbEntry.setType(PDBEntry.Type.PDB);
273 seq.getDatasetSequence().addPDBId(pdbEntry);
278 * Builds a query string for a given sequences using its DBRef entries
281 * the sequences to build a query for
282 * @return the built query string
285 public static String buildQuery(SequenceI seq)
287 HashSet<String> seqRefs = new LinkedHashSet<String>();
288 String seqName = seq.getName();
289 String[] names = seqName.toLowerCase().split("\\|");
290 for (String name : names)
292 // System.out.println("Found name : " + name);
294 if (isValidSeqName(name))
300 if (seq.getPDBId() != null)
302 for (PDBEntry entry : seq.getPDBId())
304 if (isValidSeqName(entry.getId()))
306 seqRefs.add(entry.getId());
311 if (seq.getDBRef() != null && seq.getDBRef().length != 0)
314 for (DBRefEntry dbRef : seq.getDBRef())
316 if (isValidSeqName(getDBRefId(dbRef)))
318 seqRefs.add(getDBRefId(dbRef));
328 StringBuilder queryBuilder = new StringBuilder();
329 for (String seqRef : seqRefs)
331 queryBuilder.append("text:").append(seqRef).append(" OR ");
333 int endIndex = queryBuilder.lastIndexOf(" OR ");
334 String query = queryBuilder.toString().substring(5, endIndex);
339 * Ensures sequence ref names are not less than 3 characters and does not
340 * contain a database name
345 public static boolean isValidSeqName(String seqName)
347 // System.out.println("seqName : " + seqName);
348 String ignoreList = "pdb,uniprot,swiss-prot";
349 if (seqName.length() < 3)
353 if (seqName.contains(":"))
357 seqName = seqName.toLowerCase();
358 for (String ignoredEntry : ignoreList.split(","))
360 if (seqName.contains(ignoredEntry))
368 public static String getDBRefId(DBRefEntry dbRef)
370 String ref = dbRef.getAccessionId().replaceAll("GO:", "");
375 * Filters a given list of discovered structures based on supplied argument
377 * @param fieldToFilterBy
378 * the field to filter by
380 public void filterResultSet(final String fieldToFilterBy)
382 Thread filterThread = new Thread(new Runnable()
387 long startTime = System.currentTimeMillis();
388 lbl_loading.setVisible(true);
389 Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
390 .getStructureSummaryFields();
391 Collection<PDBResponseSummary> filteredResponse = new HashSet<PDBResponseSummary>();
392 HashSet<String> errors = new HashSet<String>();
393 for (SequenceI seq : selectedSequences)
395 PDBRestRequest pdbRequest = new PDBRestRequest();
396 pdbRequest.setAllowEmptySeq(false);
397 pdbRequest.setResponseSize(1);
398 pdbRequest.setFieldToSearchBy("(text:");
399 pdbRequest.setFieldToSortBy(fieldToFilterBy,
400 !chk_invertFilter.isSelected());
401 pdbRequest.setSearchTerm(buildQuery(seq) + ")");
402 pdbRequest.setWantedFields(wantedFields);
403 pdbRequest.setAssociatedSequence(seq);
404 pdbRestCleint = new PDBRestClient();
405 PDBRestResponse resultList;
408 resultList = pdbRestCleint.executeRequest(pdbRequest);
409 } catch (Exception e)
412 errors.add(e.getMessage());
415 lastPdbRequest = pdbRequest;
416 if (resultList.getSearchSummary() != null
417 && !resultList.getSearchSummary().isEmpty())
419 filteredResponse.addAll(resultList.getSearchSummary());
423 String totalTime = (System.currentTimeMillis() - startTime)
425 if (!filteredResponse.isEmpty())
427 final int filterResponseCount = filteredResponse.size();
428 Collection<PDBResponseSummary> reorderedStructuresSet = new LinkedHashSet<PDBResponseSummary>();
429 reorderedStructuresSet.addAll(filteredResponse);
430 reorderedStructuresSet.addAll(discoveredStructuresSet);
431 tbl_summary.setModel(PDBRestResponse.getTableModel(
432 lastPdbRequest, reorderedStructuresSet));
434 // Update table selection model here
435 tbl_summary.addRowSelectionInterval(0, filterResponseCount - 1);
437 mainFrame.setTitle("Structure Chooser - Filter time ("
442 mainFrame.setTitle("Structure Chooser - Filter time ("
444 if (errors.size() > 0)
446 StringBuilder errorMsg = new StringBuilder();
447 for (String error : errors)
449 errorMsg.append(error).append("\n");
451 JOptionPane.showMessageDialog(null, errorMsg.toString(),
452 "PDB Web-service Error", JOptionPane.ERROR_MESSAGE);
456 lbl_loading.setVisible(false);
458 validateSelections();
461 filterThread.start();
466 * Handles action event for btn_pdbFromFile
468 public void pdbFromFile_actionPerformed()
470 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
471 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
472 chooser.setFileView(new jalview.io.JalviewFileView());
473 chooser.setDialogTitle(MessageManager.formatMessage(
474 "label.select_pdb_file_for", new String[]
475 { selectedSequence.getDisplayId(false) }));
476 chooser.setToolTipText(MessageManager.formatMessage(
477 "label.load_pdb_file_associate_with_sequence", new String[]
478 { selectedSequence.getDisplayId(false) }));
480 int value = chooser.showOpenDialog(null);
481 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
483 selectedPdbFileName = chooser.getSelectedFile().getPath();
484 jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedPdbFileName);
485 validateSelections();
490 * Populates the filter combo-box options dynamically depending on discovered
493 protected void populateFilterComboBox()
495 if (isStructuresDiscovered())
497 cmb_filterOption.addItem(new FilterOption("Best Quality",
498 PDBDocField.OVERALL_QUALITY.getCode(), VIEWS_FILTER));
499 cmb_filterOption.addItem(new FilterOption("Best UniProt Coverage",
500 PDBDocField.UNIPROT_COVERAGE.getCode(), VIEWS_FILTER));
501 cmb_filterOption.addItem(new FilterOption("Highest Resolution",
502 PDBDocField.RESOLUTION.getCode(), VIEWS_FILTER));
503 cmb_filterOption.addItem(new FilterOption("Highest Protein Chain",
504 PDBDocField.PROTEIN_CHAIN_COUNT.getCode(), VIEWS_FILTER));
505 cmb_filterOption.addItem(new FilterOption("Highest Bound Molecules",
506 PDBDocField.BOUND_MOLECULE_COUNT.getCode(), VIEWS_FILTER));
507 cmb_filterOption.addItem(new FilterOption("Highest Polymer Residues",
508 PDBDocField.POLYMER_RESIDUE_COUNT.getCode(), VIEWS_FILTER));
510 cmb_filterOption.addItem(new FilterOption("Enter PDB Id", "-",
512 cmb_filterOption.addItem(new FilterOption("From File", "-",
514 cmb_filterOption.addItem(new FilterOption("Cached PDB Entries", "-",
519 * Updates the displayed view based on the selected filter option
521 protected void updateCurrentView()
523 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
525 layout_switchableViews.show(pnl_switchableViews,
526 selectedFilterOpt.getView());
527 String filterTitle = mainFrame.getTitle();
528 mainFrame.setTitle(frameTitle);
529 chk_invertFilter.setVisible(false);
530 if (selectedFilterOpt.getView() == VIEWS_FILTER)
532 mainFrame.setTitle(filterTitle);
533 chk_invertFilter.setVisible(true);
534 filterResultSet(selectedFilterOpt.getValue());
536 else if (selectedFilterOpt.getView() == VIEWS_ENTER_ID
537 || selectedFilterOpt.getView() == VIEWS_FROM_FILE)
539 mainFrame.setTitle(filterTitle);
540 idInputAssSeqPanel.loadCmbAssSeq();
541 fileChooserAssSeqPanel.loadCmbAssSeq();
543 validateSelections();
547 * Validates user selection and activates the view button if all parameters
550 public void validateSelections()
552 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
554 btn_view.setEnabled(false);
555 String currentView = selectedFilterOpt.getView();
556 if (currentView == VIEWS_FILTER)
558 if (tbl_summary.getSelectedRows().length > 0)
560 btn_view.setEnabled(true);
563 else if (currentView == VIEWS_LOCAL_PDB)
565 if (tbl_local_pdb.getSelectedRows().length > 0)
567 btn_view.setEnabled(true);
570 else if (currentView == VIEWS_ENTER_ID)
572 validateAssociationEnterPdb();
574 else if (currentView == VIEWS_FROM_FILE)
576 validateAssociationFromFile();
581 * Validates inputs from the Manual PDB entry panel
583 public void validateAssociationEnterPdb()
585 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel
586 .getCmb_assSeq().getSelectedItem();
587 lbl_pdbManualFetchStatus.setIcon(errorImage);
588 lbl_pdbManualFetchStatus.setToolTipText("");
589 if (txt_search.getText().length() > 0)
591 lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
592 true, "No PDB entry found for \'" + txt_search.getText()
596 if (errorWarning.length() > 0)
598 lbl_pdbManualFetchStatus.setIcon(warningImage);
599 lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
600 true, errorWarning.toString()));
603 if (selectedSequences.length == 1
604 || !assSeqOpt.getName().equalsIgnoreCase(
605 "-Select Associated Seq-"))
607 txt_search.setEnabled(true);
610 btn_view.setEnabled(true);
611 lbl_pdbManualFetchStatus.setToolTipText("");
612 lbl_pdbManualFetchStatus.setIcon(goodImage);
617 txt_search.setEnabled(false);
618 lbl_pdbManualFetchStatus.setIcon(errorImage);
623 * Validates inputs for the manual PDB file selection options
625 public void validateAssociationFromFile()
627 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel
628 .getCmb_assSeq().getSelectedItem();
629 lbl_fromFileStatus.setIcon(errorImage);
630 if (selectedSequences.length == 1
631 || (assSeqOpt != null
632 && !assSeqOpt.getName().equalsIgnoreCase(
633 "-Select Associated Seq-")))
635 btn_pdbFromFile.setEnabled(true);
636 if (selectedPdbFileName != null && selectedPdbFileName.length() > 0)
638 btn_view.setEnabled(true);
639 lbl_fromFileStatus.setIcon(goodImage);
644 btn_pdbFromFile.setEnabled(false);
645 lbl_fromFileStatus.setIcon(errorImage);
650 public void cmbAssSeqStateChanged()
652 validateSelections();
656 * Handles the state change event for the 'filter' combo-box and 'invert'
660 protected void stateChanged(ItemEvent e)
662 if (e.getSource() instanceof JCheckBox)
668 if (e.getStateChange() == ItemEvent.SELECTED)
677 * Handles action event for btn_ok
680 public void ok_ActionPerformed()
682 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
684 String currentView = selectedFilterOpt.getView();
685 if (currentView == VIEWS_FILTER)
687 int pdbIdColIndex = tbl_summary.getColumn(
688 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
689 int refSeqColIndex = tbl_summary.getColumn("Ref Sequence")
691 int[] selectedRows = tbl_summary.getSelectedRows();
692 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
694 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
695 for (int summaryRow : selectedRows)
697 String pdbIdStr = tbl_summary.getValueAt(summaryRow, pdbIdColIndex)
699 SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(
700 summaryRow, refSeqColIndex);
701 selectedSeqsToView.add(selectedSeq);
702 PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase());
703 if (pdbEntry == null)
705 pdbEntry = new PDBEntry();
706 pdbEntry.setId(pdbIdStr);
707 pdbEntry.setType(PDBEntry.Type.PDB);
709 pdbEntriesToView[count++] = pdbEntry;
711 SequenceI[] selectedSeqs = selectedSeqsToView
712 .toArray(new SequenceI[selectedSeqsToView.size()]);
713 launchStructureViewer(ap.getStructureSelectionManager(),
714 pdbEntriesToView, ap, selectedSeqs);
716 else if(currentView == VIEWS_LOCAL_PDB){
717 int[] selectedRows = tbl_local_pdb.getSelectedRows();
718 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
720 int pdbIdColIndex = tbl_local_pdb.getColumn(
721 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
722 int refSeqColIndex = tbl_local_pdb.getColumn("Ref Sequence")
724 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
725 for (int row : selectedRows)
727 String entryKey = tbl_local_pdb.getValueAt(row, pdbIdColIndex)
730 pdbEntriesToView[count++] = cachedEntryMap.get(entryKey);
731 SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(row,
733 selectedSeqsToView.add(selectedSeq);
735 SequenceI[] selectedSeqs = selectedSeqsToView
736 .toArray(new SequenceI[selectedSeqsToView.size()]);
737 launchStructureViewer(ap.getStructureSelectionManager(),
738 pdbEntriesToView, ap, selectedSeqs);
740 else if (currentView == VIEWS_ENTER_ID)
742 SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel
743 .getCmb_assSeq().getSelectedItem()).getSequence();
744 if (userSelectedSeq != null)
746 selectedSequence = userSelectedSeq;
749 String pdbIdStr = txt_search.getText();
750 PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase());
751 if (pdbEntry == null)
753 pdbEntry = new PDBEntry();
754 pdbEntry.setId(txt_search.getText());
755 pdbEntry.setType(PDBEntry.Type.PDB);
758 selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
759 PDBEntry[] pdbEntriesToView = new PDBEntry[]
761 launchStructureViewer(ap.getStructureSelectionManager(),
762 pdbEntriesToView, ap, new SequenceI[]
763 { selectedSequence });
765 else if (currentView == VIEWS_FROM_FILE)
767 SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel
768 .getCmb_assSeq().getSelectedItem()).getSequence();
769 if (userSelectedSeq != null)
771 selectedSequence = userSelectedSeq;
773 PDBEntry fileEntry = new AssociatePdbFileWithSeq()
774 .associatePdbWithSeq(
775 selectedPdbFileName, jalview.io.AppletFormatAdapter.FILE,
776 selectedSequence, true, Desktop.instance);
778 launchStructureViewer(ap.getStructureSelectionManager(),
780 { fileEntry }, ap, new SequenceI[]
781 { selectedSequence });
786 private void launchStructureViewer(StructureSelectionManager ssm,
787 PDBEntry[] pdbEntriesToView, AlignmentPanel alignPanel,
788 SequenceI[] sequences)
790 StructureViewer sViewer = new StructureViewer(ssm);
791 if (pdbEntriesToView.length > 1)
793 sViewer.viewStructures(pdbEntriesToView, alignPanel.av.collateForPDB(pdbEntriesToView),
798 sViewer.viewStructures(pdbEntriesToView[0], sequences,
804 * Populates the combo-box used in associating manually fetched structures to
805 * a unique sequence when more than one sequence selection is made.
807 public void populateCmbAssociateSeqOptions(
808 JComboBox<AssociateSeqOptions> cmb_assSeq, JLabel lbl_associateSeq)
810 cmb_assSeq.removeAllItems();
811 cmb_assSeq.addItem(new AssociateSeqOptions("-Select Associated Seq-",
813 // cmb_assSeq.addItem(new AssociateSeqOptions("Auto Detect", null));
814 lbl_associateSeq.setVisible(false);
815 if (selectedSequences.length > 1)
817 for (SequenceI seq : selectedSequences)
819 cmb_assSeq.addItem(new AssociateSeqOptions(seq));
824 String seqName = selectedSequence.getDisplayId(false);
825 seqName = seqName.length() <= 40 ? seqName : seqName.substring(0, 39);
826 lbl_associateSeq.setText(seqName);
827 lbl_associateSeq.setVisible(true);
828 cmb_assSeq.setVisible(false);
832 public boolean isStructuresDiscovered()
834 return structuresDiscovered;
837 public void setStructuresDiscovered(boolean structuresDiscovered)
839 this.structuresDiscovered = structuresDiscovered;
842 public Collection<PDBResponseSummary> getDiscoveredStructuresSet()
844 return discoveredStructuresSet;
848 protected void txt_search_ActionPerformed()
850 errorWarning.setLength(0);
851 isValidPBDEntry = false;
852 if (txt_search.getText().length() > 0)
854 List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
855 wantedFields.add(PDBDocField.PDB_ID);
856 PDBRestRequest pdbRequest = new PDBRestRequest();
857 pdbRequest.setAllowEmptySeq(false);
858 pdbRequest.setResponseSize(1);
859 pdbRequest.setFieldToSearchBy("(pdb_id:");
860 pdbRequest.setWantedFields(wantedFields);
861 pdbRequest.setSearchTerm(txt_search.getText() + ")");
862 pdbRequest.setAssociatedSequence(selectedSequence);
863 pdbRestCleint = new PDBRestClient();
864 PDBRestResponse resultList;
867 resultList = pdbRestCleint.executeRequest(pdbRequest);
868 } catch (Exception e)
870 errorWarning.append(e.getMessage());
874 validateSelections();
876 if (resultList.getSearchSummary() != null
877 && resultList.getSearchSummary().size() > 0)
879 isValidPBDEntry = true;
882 validateSelections();
886 public void tabRefresh()
888 if (selectedSequences != null)
890 Thread refreshThread = new Thread(new Runnable()
895 fetchStructuresMetaData();
896 filterResultSet(((FilterOption) cmb_filterOption
897 .getSelectedItem()).getValue());
900 refreshThread.start();