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;
53 * Provides the behaviors for the Structure chooser Panel
58 @SuppressWarnings("serial")
59 public class StructureChooser extends GStructureChooser
61 private boolean structuresDiscovered = false;
63 private SequenceI selectedSequence;
65 private SequenceI[] selectedSequences;
67 private IProgressIndicator progressIndicator;
69 private Collection<PDBResponseSummary> discoveredStructuresSet;
71 private PDBRestRequest lastPdbRequest;
73 private PDBRestClient pdbRestCleint;
75 private String selectedPdbFileName;
77 private boolean isValidPBDEntry;
79 private static Hashtable<String, PDBEntry> cachedEntryMap;
81 public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
85 this.selectedSequence = selectedSeq;
86 this.selectedSequences = selectedSeqs;
87 this.progressIndicator = (ap == null) ? null : ap.alignFrame;
92 * Initializes parameters used by the Structure Chooser Panel
96 Thread discoverPDBStructuresThread = new Thread(new Runnable()
101 long startTime = System.currentTimeMillis();
102 updateProgressIndicator(MessageManager
103 .getString("status.loading_cached_pdb_entries"), startTime);
104 loadLocalCachedPDBEntries();
105 updateProgressIndicator(null, startTime);
106 updateProgressIndicator(MessageManager
107 .getString("status.searching_for_pdb_structures"),
109 fetchStructuresMetaData();
110 populateFilterComboBox();
111 updateProgressIndicator(null, startTime);
112 mainFrame.setVisible(true);
116 discoverPDBStructuresThread.start();
120 * Updates the progress indicator with the specified message
123 * displayed message for the operation
125 * unique handle for this indicator
127 public void updateProgressIndicator(String message, long id)
129 if (progressIndicator != null)
131 progressIndicator.setProgressBar(message, id);
136 * Retrieve meta-data for all the structure(s) for a given sequence(s) in a
139 public void fetchStructuresMetaData()
141 long startTime = System.currentTimeMillis();
142 Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
143 .getStructureSummaryFields();
145 discoveredStructuresSet = new LinkedHashSet<PDBResponseSummary>();
146 HashSet<String> errors = new HashSet<String>();
147 for (SequenceI seq : selectedSequences)
149 PDBRestRequest pdbRequest = new PDBRestRequest();
150 pdbRequest.setAllowEmptySeq(false);
151 pdbRequest.setResponseSize(500);
152 pdbRequest.setFieldToSearchBy("(text:");
153 pdbRequest.setWantedFields(wantedFields);
154 pdbRequest.setSearchTerm(buildQuery(seq) + ")");
155 pdbRequest.setAssociatedSequence(seq);
156 pdbRestCleint = new PDBRestClient();
157 PDBRestResponse resultList;
160 resultList = pdbRestCleint.executeRequest(pdbRequest);
161 } catch (Exception e)
164 errors.add(e.getMessage());
167 lastPdbRequest = pdbRequest;
168 if (resultList.getSearchSummary() != null
169 && !resultList.getSearchSummary().isEmpty())
171 discoveredStructuresSet.addAll(resultList.getSearchSummary());
172 updateSequencePDBEntries(seq, resultList.getSearchSummary());
176 int noOfStructuresFound = 0;
177 String totalTime = (System.currentTimeMillis() - startTime)
179 if (discoveredStructuresSet != null
180 && !discoveredStructuresSet.isEmpty())
182 tbl_summary.setModel(PDBRestResponse.getTableModel(lastPdbRequest,
183 discoveredStructuresSet));
184 structuresDiscovered = true;
185 noOfStructuresFound = discoveredStructuresSet.size();
186 mainFrame.setTitle("Structure Chooser - " + noOfStructuresFound
187 + " Found (" + totalTime + ")");
191 mainFrame.setTitle("Structure Chooser - Manual association");
192 if (errors.size() > 0)
194 StringBuilder errorMsg = new StringBuilder();
195 // "Operation was unsuccessful due to the following: \n");
196 for (String error : errors)
198 errorMsg.append(error).append("\n");
200 JOptionPane.showMessageDialog(this, errorMsg.toString(),
201 "PDB Web-service Error", JOptionPane.ERROR_MESSAGE);
206 public void loadLocalCachedPDBEntries()
208 DefaultTableModel tableModel = new DefaultTableModel()
211 public boolean isCellEditable(int row, int column)
216 tableModel.addColumn("Ref Sequence");
217 tableModel.addColumn("PDB Id");
218 tableModel.addColumn("Chain");
219 tableModel.addColumn("Type");
220 tableModel.addColumn("File");
221 cachedEntryMap = new Hashtable<String, PDBEntry>();
222 for (SequenceI seq : selectedSequences)
224 if (seq.getDatasetSequence() != null
225 && seq.getDatasetSequence().getPDBId() != null)
227 for (PDBEntry pdbEntry : seq.getDatasetSequence().getPDBId())
230 String chain = pdbEntry.getChainCode() == null ? "_" : pdbEntry
232 Object[] pdbEntryRowData = new Object[]
233 { seq, pdbEntry.getId(), chain, pdbEntry.getType(),
234 pdbEntry.getFile() };
235 if (pdbEntry.getFile() != null)
237 tableModel.addRow(pdbEntryRowData);
239 cachedEntryMap.put(pdbEntry.getId().toLowerCase(), pdbEntry);
243 tbl_local_pdb.setModel(tableModel);
247 * Update the PDBEntry for a given sequence with values retrieved from
251 * the Sequence to update its DBRef entry
252 * @param responseSummaries
253 * a collection of PDBResponseSummary
255 public void updateSequencePDBEntries(SequenceI seq,
256 Collection<PDBResponseSummary> responseSummaries)
258 for (PDBResponseSummary response : responseSummaries)
260 String pdbIdStr = response.getPdbId();
261 PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase());
262 if (pdbEntry == null)
264 pdbEntry = new PDBEntry();
265 pdbEntry.setId(pdbIdStr);
266 pdbEntry.setType(PDBEntry.Type.PDB);
268 seq.getDatasetSequence().addPDBId(pdbEntry);
273 * Builds a query string for a given sequences using its DBRef entries
276 * the sequences to build a query for
277 * @return the built query string
280 public static String buildQuery(SequenceI seq)
282 HashSet<String> seqRefs = new LinkedHashSet<String>();
283 String seqName = seq.getName();
284 String[] names = seqName.toLowerCase().split("\\|");
285 for (String name : names)
287 // System.out.println("Found name : " + name);
289 if (isValidSeqName(name))
295 if (seq.getPDBId() != null)
297 for (PDBEntry entry : seq.getPDBId())
299 if (isValidSeqName(entry.getId()))
301 seqRefs.add(entry.getId());
306 if (seq.getDBRef() != null && seq.getDBRef().length != 0)
309 for (DBRefEntry dbRef : seq.getDBRef())
311 if (isValidSeqName(getDBRefId(dbRef)))
313 seqRefs.add(getDBRefId(dbRef));
323 StringBuilder queryBuilder = new StringBuilder();
324 for (String seqRef : seqRefs)
326 queryBuilder.append("text:").append(seqRef).append(" OR ");
328 int endIndex = queryBuilder.lastIndexOf(" OR ");
329 String query = queryBuilder.toString().substring(5, endIndex);
334 * Ensures sequence ref names are not less than 3 characters and does not
335 * contain a database name
340 public static boolean isValidSeqName(String seqName)
342 // System.out.println("seqName : " + seqName);
343 String ignoreList = "pdb,uniprot,swiss-prot";
344 if (seqName.length() < 3)
348 if (seqName.contains(":"))
352 seqName = seqName.toLowerCase();
353 for (String ignoredEntry : ignoreList.split(","))
355 if (seqName.contains(ignoredEntry))
363 public static String getDBRefId(DBRefEntry dbRef)
365 String ref = dbRef.getAccessionId().replaceAll("GO:", "");
370 * Filters a given list of discovered structures based on supplied argument
372 * @param fieldToFilterBy
373 * the field to filter by
375 public void filterResultSet(final String fieldToFilterBy)
377 Thread filterThread = new Thread(new Runnable()
382 long startTime = System.currentTimeMillis();
383 lbl_loading.setVisible(true);
384 Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
385 .getStructureSummaryFields();
386 Collection<PDBResponseSummary> filteredResponse = new HashSet<PDBResponseSummary>();
387 HashSet<String> errors = new HashSet<String>();
388 for (SequenceI seq : selectedSequences)
390 PDBRestRequest pdbRequest = new PDBRestRequest();
391 pdbRequest.setAllowEmptySeq(false);
392 pdbRequest.setResponseSize(1);
393 pdbRequest.setFieldToSearchBy("(text:");
394 pdbRequest.setFieldToSortBy(fieldToFilterBy,
395 !chk_invertFilter.isSelected());
396 pdbRequest.setSearchTerm(buildQuery(seq) + ")");
397 pdbRequest.setWantedFields(wantedFields);
398 pdbRequest.setAssociatedSequence(seq);
399 pdbRestCleint = new PDBRestClient();
400 PDBRestResponse resultList;
403 resultList = pdbRestCleint.executeRequest(pdbRequest);
404 } catch (Exception e)
407 errors.add(e.getMessage());
410 lastPdbRequest = pdbRequest;
411 if (resultList.getSearchSummary() != null
412 && !resultList.getSearchSummary().isEmpty())
414 filteredResponse.addAll(resultList.getSearchSummary());
418 String totalTime = (System.currentTimeMillis() - startTime)
420 if (!filteredResponse.isEmpty())
422 final int filterResponseCount = filteredResponse.size();
423 Collection<PDBResponseSummary> reorderedStructuresSet = new LinkedHashSet<PDBResponseSummary>();
424 reorderedStructuresSet.addAll(filteredResponse);
425 reorderedStructuresSet.addAll(discoveredStructuresSet);
426 tbl_summary.setModel(PDBRestResponse.getTableModel(
427 lastPdbRequest, reorderedStructuresSet));
429 // Update table selection model here
430 tbl_summary.addRowSelectionInterval(0, filterResponseCount - 1);
432 mainFrame.setTitle("Structure Chooser - Filter time ("
437 mainFrame.setTitle("Structure Chooser - Filter time ("
439 if (errors.size() > 0)
441 StringBuilder errorMsg = new StringBuilder();
442 for (String error : errors)
444 errorMsg.append(error).append("\n");
446 JOptionPane.showMessageDialog(null, errorMsg.toString(),
447 "PDB Web-service Error", JOptionPane.ERROR_MESSAGE);
451 lbl_loading.setVisible(false);
453 validateSelections();
456 filterThread.start();
460 * Handles action event for btn_pdbFromFile
462 public void pdbFromFile_actionPerformed()
464 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
465 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
466 chooser.setFileView(new jalview.io.JalviewFileView());
467 chooser.setDialogTitle(MessageManager.formatMessage(
468 "label.select_pdb_file_for", new String[]
469 { selectedSequence.getDisplayId(false) }));
470 chooser.setToolTipText(MessageManager.formatMessage(
471 "label.load_pdb_file_associate_with_sequence", new String[]
472 { selectedSequence.getDisplayId(false) }));
474 int value = chooser.showOpenDialog(null);
475 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
477 selectedPdbFileName = chooser.getSelectedFile().getPath();
478 jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedPdbFileName);
479 validateSelections();
484 * Populates the filter combo-box options dynamically depending on discovered
487 protected void populateFilterComboBox()
489 if (isStructuresDiscovered())
491 cmb_filterOption.addItem(new FilterOption("Best Quality",
492 PDBDocField.OVERALL_QUALITY.getCode(), VIEWS_FILTER));
493 cmb_filterOption.addItem(new FilterOption("Best UniProt Coverage",
494 PDBDocField.UNIPROT_COVERAGE.getCode(), VIEWS_FILTER));
495 cmb_filterOption.addItem(new FilterOption("Highest Resolution",
496 PDBDocField.RESOLUTION.getCode(), VIEWS_FILTER));
497 cmb_filterOption.addItem(new FilterOption("Highest Protein Chain",
498 PDBDocField.PROTEIN_CHAIN_COUNT.getCode(), VIEWS_FILTER));
499 cmb_filterOption.addItem(new FilterOption("Highest Bound Molecules",
500 PDBDocField.BOUND_MOLECULE_COUNT.getCode(), VIEWS_FILTER));
501 cmb_filterOption.addItem(new FilterOption("Highest Polymer Residues",
502 PDBDocField.POLYMER_RESIDUE_COUNT.getCode(), VIEWS_FILTER));
504 cmb_filterOption.addItem(new FilterOption("Enter PDB Id", "-",
506 cmb_filterOption.addItem(new FilterOption("From File", "-",
508 cmb_filterOption.addItem(new FilterOption("Cached PDB Entries", "-",
513 * Updates the displayed view based on the selected filter option
515 protected void updateCurrentView()
517 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
519 layout_switchableViews.show(pnl_switchableViews,
520 selectedFilterOpt.getView());
521 String filterTitle = mainFrame.getTitle();
522 mainFrame.setTitle(frameTitle);
523 chk_invertFilter.setVisible(false);
524 if (selectedFilterOpt.getView() == VIEWS_FILTER)
526 mainFrame.setTitle(filterTitle);
527 chk_invertFilter.setVisible(true);
528 filterResultSet(selectedFilterOpt.getValue());
530 else if (selectedFilterOpt.getView() == VIEWS_ENTER_ID
531 || selectedFilterOpt.getView() == VIEWS_FROM_FILE)
533 mainFrame.setTitle(filterTitle);
534 idInputAssSeqPanel.loadCmbAssSeq();
535 fileChooserAssSeqPanel.loadCmbAssSeq();
537 validateSelections();
541 * Validates user selection and activates the view button if all parameters
544 public void validateSelections()
546 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
548 btn_view.setEnabled(false);
549 String currentView = selectedFilterOpt.getView();
550 if (currentView == VIEWS_FILTER)
552 if (tbl_summary.getSelectedRows().length > 0)
554 btn_view.setEnabled(true);
557 else if (currentView == VIEWS_LOCAL_PDB)
559 if (tbl_local_pdb.getSelectedRows().length > 0)
561 btn_view.setEnabled(true);
564 else if (currentView == VIEWS_ENTER_ID)
566 validateAssociationEnterPdb();
568 else if (currentView == VIEWS_FROM_FILE)
570 validateAssociationFromFile();
575 * Validates inputs from the Manual PDB entry panel
577 public void validateAssociationEnterPdb()
579 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel
580 .getCmb_assSeq().getSelectedItem();
581 lbl_pdbManualFetchStatus.setIcon(errorImage);
582 lbl_pdbManualFetchStatus.setToolTipText("");
583 if (txt_search.getText().length() > 0)
585 lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
586 true, "No PDB entry found for \'" + txt_search.getText()
590 if (errorWarning.length() > 0)
592 lbl_pdbManualFetchStatus.setIcon(warningImage);
593 lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
594 true, errorWarning.toString()));
597 if (selectedSequences.length == 1
598 || !assSeqOpt.getName().equalsIgnoreCase(
599 "-Select Associated Seq-"))
601 txt_search.setEnabled(true);
604 btn_view.setEnabled(true);
605 lbl_pdbManualFetchStatus.setToolTipText("");
606 lbl_pdbManualFetchStatus.setIcon(goodImage);
611 txt_search.setEnabled(false);
612 lbl_pdbManualFetchStatus.setIcon(errorImage);
617 * Validates inputs for the manual PDB file selection options
619 public void validateAssociationFromFile()
621 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel
622 .getCmb_assSeq().getSelectedItem();
623 lbl_fromFileStatus.setIcon(errorImage);
624 if (selectedSequences.length == 1
625 || (assSeqOpt != null && !assSeqOpt.getName().equalsIgnoreCase(
626 "-Select Associated Seq-")))
628 btn_pdbFromFile.setEnabled(true);
629 if (selectedPdbFileName != null && selectedPdbFileName.length() > 0)
631 btn_view.setEnabled(true);
632 lbl_fromFileStatus.setIcon(goodImage);
637 btn_pdbFromFile.setEnabled(false);
638 lbl_fromFileStatus.setIcon(errorImage);
643 public void cmbAssSeqStateChanged()
645 validateSelections();
649 * Handles the state change event for the 'filter' combo-box and 'invert'
653 protected void stateChanged(ItemEvent e)
655 if (e.getSource() instanceof JCheckBox)
661 if (e.getStateChange() == ItemEvent.SELECTED)
670 * Handles action event for btn_ok
673 public void ok_ActionPerformed()
675 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
677 String currentView = selectedFilterOpt.getView();
678 if (currentView == VIEWS_FILTER)
680 int pdbIdColIndex = tbl_summary.getColumn(
681 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
682 int refSeqColIndex = tbl_summary.getColumn("Ref Sequence")
684 int[] selectedRows = tbl_summary.getSelectedRows();
685 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
687 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
688 for (int summaryRow : selectedRows)
690 String pdbIdStr = tbl_summary.getValueAt(summaryRow, pdbIdColIndex)
692 SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(
693 summaryRow, refSeqColIndex);
694 selectedSeqsToView.add(selectedSeq);
695 PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase());
696 if (pdbEntry == null)
698 pdbEntry = new PDBEntry();
699 pdbEntry.setId(pdbIdStr);
700 pdbEntry.setType(PDBEntry.Type.PDB);
702 pdbEntriesToView[count++] = pdbEntry;
704 SequenceI[] selectedSeqs = selectedSeqsToView
705 .toArray(new SequenceI[selectedSeqsToView.size()]);
706 launchStructureViewer(ap.getStructureSelectionManager(),
707 pdbEntriesToView, ap, selectedSeqs);
709 else if (currentView == VIEWS_LOCAL_PDB)
711 int[] selectedRows = tbl_local_pdb.getSelectedRows();
712 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
714 int pdbIdColIndex = tbl_local_pdb.getColumn(
715 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
716 int refSeqColIndex = tbl_local_pdb.getColumn("Ref Sequence")
718 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
719 for (int row : selectedRows)
721 String entryKey = tbl_local_pdb.getValueAt(row, pdbIdColIndex)
722 .toString().toLowerCase();
723 pdbEntriesToView[count++] = cachedEntryMap.get(entryKey);
724 SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(row,
726 selectedSeqsToView.add(selectedSeq);
728 SequenceI[] selectedSeqs = selectedSeqsToView
729 .toArray(new SequenceI[selectedSeqsToView.size()]);
730 launchStructureViewer(ap.getStructureSelectionManager(),
731 pdbEntriesToView, ap, selectedSeqs);
733 else if (currentView == VIEWS_ENTER_ID)
735 SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel
736 .getCmb_assSeq().getSelectedItem()).getSequence();
737 if (userSelectedSeq != null)
739 selectedSequence = userSelectedSeq;
742 String pdbIdStr = txt_search.getText();
743 PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase());
744 if (pdbEntry == null)
746 pdbEntry = new PDBEntry();
747 pdbEntry.setId(txt_search.getText());
748 pdbEntry.setType(PDBEntry.Type.PDB);
751 selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
752 PDBEntry[] pdbEntriesToView = new PDBEntry[]
754 launchStructureViewer(ap.getStructureSelectionManager(),
755 pdbEntriesToView, ap, new SequenceI[]
756 { selectedSequence });
758 else if (currentView == VIEWS_FROM_FILE)
760 SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel
761 .getCmb_assSeq().getSelectedItem()).getSequence();
762 if (userSelectedSeq != null)
764 selectedSequence = userSelectedSeq;
766 PDBEntry fileEntry = new AssociatePdbFileWithSeq()
767 .associatePdbWithSeq(selectedPdbFileName,
768 jalview.io.AppletFormatAdapter.FILE,
769 selectedSequence, true, Desktop.instance);
771 launchStructureViewer(ap.getStructureSelectionManager(),
773 { fileEntry }, ap, new SequenceI[]
774 { selectedSequence });
779 private void launchStructureViewer(final StructureSelectionManager ssm,
780 final PDBEntry[] pdbEntriesToView,
781 final AlignmentPanel alignPanel, final SequenceI[] sequences)
783 final StructureViewer sViewer = new StructureViewer(ssm);
784 new Thread(new Runnable()
788 if (pdbEntriesToView.length > 1)
790 ArrayList<SequenceI[]> seqsMap = new ArrayList<SequenceI[]>();
791 for (SequenceI seq : sequences)
793 seqsMap.add(new SequenceI[]
796 SequenceI[][] collatedSeqs = seqsMap.toArray(new SequenceI[0][0]);
797 sViewer.viewStructures(pdbEntriesToView, collatedSeqs, alignPanel);
798 // sViewer.viewStructures(pdbEntriesToView,
799 // alignPanel.av.collateForPDB(pdbEntriesToView),
804 sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
811 * Populates the combo-box used in associating manually fetched structures to
812 * a unique sequence when more than one sequence selection is made.
814 public void populateCmbAssociateSeqOptions(
815 JComboBox<AssociateSeqOptions> cmb_assSeq, JLabel lbl_associateSeq)
817 cmb_assSeq.removeAllItems();
818 cmb_assSeq.addItem(new AssociateSeqOptions("-Select Associated Seq-",
820 // cmb_assSeq.addItem(new AssociateSeqOptions("Auto Detect", null));
821 lbl_associateSeq.setVisible(false);
822 if (selectedSequences.length > 1)
824 for (SequenceI seq : selectedSequences)
826 cmb_assSeq.addItem(new AssociateSeqOptions(seq));
831 String seqName = selectedSequence.getDisplayId(false);
832 seqName = seqName.length() <= 40 ? seqName : seqName.substring(0, 39);
833 lbl_associateSeq.setText(seqName);
834 lbl_associateSeq.setVisible(true);
835 cmb_assSeq.setVisible(false);
839 public boolean isStructuresDiscovered()
841 return structuresDiscovered;
844 public void setStructuresDiscovered(boolean structuresDiscovered)
846 this.structuresDiscovered = structuresDiscovered;
849 public Collection<PDBResponseSummary> getDiscoveredStructuresSet()
851 return discoveredStructuresSet;
855 protected void txt_search_ActionPerformed()
857 errorWarning.setLength(0);
858 isValidPBDEntry = false;
859 if (txt_search.getText().length() > 0)
861 List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
862 wantedFields.add(PDBDocField.PDB_ID);
863 PDBRestRequest pdbRequest = new PDBRestRequest();
864 pdbRequest.setAllowEmptySeq(false);
865 pdbRequest.setResponseSize(1);
866 pdbRequest.setFieldToSearchBy("(pdb_id:");
867 pdbRequest.setWantedFields(wantedFields);
868 pdbRequest.setSearchTerm(txt_search.getText() + ")");
869 pdbRequest.setAssociatedSequence(selectedSequence);
870 pdbRestCleint = new PDBRestClient();
871 PDBRestResponse resultList;
874 resultList = pdbRestCleint.executeRequest(pdbRequest);
875 } catch (Exception e)
877 errorWarning.append(e.getMessage());
881 validateSelections();
883 if (resultList.getSearchSummary() != null
884 && resultList.getSearchSummary().size() > 0)
886 isValidPBDEntry = true;
889 validateSelections();
893 public void tabRefresh()
895 if (selectedSequences != null)
897 Thread refreshThread = new Thread(new Runnable()
902 fetchStructuresMetaData();
903 filterResultSet(((FilterOption) cmb_filterOption
904 .getSelectedItem()).getValue());
907 refreshThread.start();