2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
24 import jalview.datamodel.DBRefEntry;
25 import jalview.datamodel.PDBEntry;
26 import jalview.datamodel.SequenceI;
27 import jalview.jbgui.GStructureChooser;
28 import jalview.jbgui.PDBDocFieldPreferences;
29 import jalview.structure.StructureSelectionManager;
30 import jalview.util.MessageManager;
31 import jalview.ws.dbsources.PDBRestClient;
32 import jalview.ws.dbsources.PDBRestClient.PDBDocField;
33 import jalview.ws.uimodel.PDBRestRequest;
34 import jalview.ws.uimodel.PDBRestResponse;
35 import jalview.ws.uimodel.PDBRestResponse.PDBResponseSummary;
37 import java.awt.event.ItemEvent;
38 import java.util.ArrayList;
39 import java.util.Collection;
40 import java.util.HashSet;
41 import java.util.LinkedHashSet;
42 import java.util.List;
44 import javax.swing.JCheckBox;
45 import javax.swing.JComboBox;
46 import javax.swing.JLabel;
47 import javax.swing.JOptionPane;
48 import javax.swing.table.AbstractTableModel;
51 * Provides the behaviors for the Structure chooser Panel
56 @SuppressWarnings("serial")
57 public class StructureChooser extends GStructureChooser
59 private boolean structuresDiscovered = false;
61 private SequenceI selectedSequence;
63 private SequenceI[] selectedSequences;
65 private IProgressIndicator progressIndicator;
67 private Collection<PDBResponseSummary> discoveredStructuresSet;
69 private PDBRestRequest lastPdbRequest;
71 private PDBRestClient pdbRestCleint;
73 private String selectedPdbFileName;
75 private boolean isValidPBDEntry;
77 public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
81 this.selectedSequence = selectedSeq;
82 this.selectedSequences = selectedSeqs;
83 this.progressIndicator = (ap == null) ? null : ap.alignFrame;
88 * Initializes parameters used by the Structure Chooser Panel
92 Thread discoverPDBStructuresThread = new Thread(new Runnable()
97 long startTime = System.currentTimeMillis();
98 updateProgressIndicator(MessageManager
99 .getString("status.loading_cached_pdb_entries"), startTime);
100 loadLocalCachedPDBEntries();
101 updateProgressIndicator(null, startTime);
102 updateProgressIndicator(MessageManager
103 .getString("status.searching_for_pdb_structures"),
105 fetchStructuresMetaData();
106 populateFilterComboBox();
107 updateProgressIndicator(null, startTime);
108 mainFrame.setVisible(true);
112 discoverPDBStructuresThread.start();
116 * Updates the progress indicator with the specified message
119 * displayed message for the operation
121 * unique handle for this indicator
123 public void updateProgressIndicator(String message, long id)
125 if (progressIndicator != null)
127 progressIndicator.setProgressBar(message, id);
132 * Retrieve meta-data for all the structure(s) for a given sequence(s) in a
135 public void fetchStructuresMetaData()
137 long startTime = System.currentTimeMillis();
138 Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
139 .getStructureSummaryFields();
141 discoveredStructuresSet = new LinkedHashSet<PDBResponseSummary>();
142 HashSet<String> errors = new HashSet<String>();
143 for (SequenceI seq : selectedSequences)
145 PDBRestRequest pdbRequest = new PDBRestRequest();
146 pdbRequest.setAllowEmptySeq(false);
147 pdbRequest.setResponseSize(500);
148 pdbRequest.setFieldToSearchBy("(text:");
149 pdbRequest.setWantedFields(wantedFields);
150 pdbRequest.setSearchTerm(buildQuery(seq) + ")");
151 pdbRequest.setAssociatedSequence(seq);
152 pdbRestCleint = new PDBRestClient();
153 PDBRestResponse resultList;
156 resultList = pdbRestCleint.executeRequest(pdbRequest);
157 } catch (Exception e)
160 errors.add(e.getMessage());
163 lastPdbRequest = pdbRequest;
164 if (resultList.getSearchSummary() != null
165 && !resultList.getSearchSummary().isEmpty())
167 discoveredStructuresSet.addAll(resultList.getSearchSummary());
171 int noOfStructuresFound = 0;
172 String totalTime = (System.currentTimeMillis() - startTime)
174 if (discoveredStructuresSet != null
175 && !discoveredStructuresSet.isEmpty())
177 tbl_summary.setModel(PDBRestResponse.getTableModel(lastPdbRequest,
178 discoveredStructuresSet));
179 structuresDiscovered = true;
180 noOfStructuresFound = discoveredStructuresSet.size();
181 mainFrame.setTitle(MessageManager.formatMessage(
182 "label.structure_chooser_no_of_structures",
183 noOfStructuresFound, totalTime));
187 mainFrame.setTitle(MessageManager
188 .getString("label.structure_chooser_manual_association"));
189 if (errors.size() > 0)
191 StringBuilder errorMsg = new StringBuilder();
192 for (String error : errors)
194 errorMsg.append(error).append("\n");
196 JOptionPane.showMessageDialog(this, errorMsg.toString(),
197 MessageManager.getString("label.pdb_web-service_error"),
198 JOptionPane.ERROR_MESSAGE);
203 public void loadLocalCachedPDBEntries()
205 ArrayList<CachedPDB> entries = new ArrayList<CachedPDB>();
206 for (SequenceI seq : selectedSequences)
208 if (seq.getDatasetSequence() != null
209 && seq.getDatasetSequence().getAllPDBEntries() != null)
211 for (PDBEntry pdbEntry : seq.getDatasetSequence()
214 if (pdbEntry.getFile() != null)
216 entries.add(new CachedPDB(seq, pdbEntry));
222 PDBEntryTableModel tableModelx = new PDBEntryTableModel(entries);
223 tbl_local_pdb.setModel(tableModelx);
227 * Builds a query string for a given sequences using its DBRef entries
230 * the sequences to build a query for
231 * @return the built query string
234 public static String buildQuery(SequenceI seq)
236 HashSet<String> seqRefs = new LinkedHashSet<String>();
237 String seqName = seq.getName();
238 String[] names = seqName.toLowerCase().split("\\|");
239 for (String name : names)
241 // System.out.println("Found name : " + name);
243 if (isValidSeqName(name))
249 if (seq.getAllPDBEntries() != null)
251 for (PDBEntry entry : seq.getAllPDBEntries())
253 if (isValidSeqName(entry.getId()))
255 seqRefs.add(entry.getId());
260 if (seq.getDBRef() != null && seq.getDBRef().length != 0)
263 for (DBRefEntry dbRef : seq.getDBRef())
265 if (isValidSeqName(getDBRefId(dbRef)))
267 seqRefs.add(getDBRefId(dbRef));
277 StringBuilder queryBuilder = new StringBuilder();
278 for (String seqRef : seqRefs)
280 queryBuilder.append("text:").append(seqRef).append(" OR ");
282 int endIndex = queryBuilder.lastIndexOf(" OR ");
284 if (queryBuilder.toString().length() < 6)
288 String query = queryBuilder.toString().substring(5, endIndex);
293 * Ensures sequence ref names are not less than 3 characters and does not
294 * contain a database name
299 public static boolean isValidSeqName(String seqName)
301 // System.out.println("seqName : " + seqName);
302 String ignoreList = "pdb,uniprot,swiss-prot";
303 if (seqName.length() < 3)
307 if (seqName.contains(":"))
311 seqName = seqName.toLowerCase();
312 for (String ignoredEntry : ignoreList.split(","))
314 if (seqName.contains(ignoredEntry))
322 public static String getDBRefId(DBRefEntry dbRef)
324 String ref = dbRef.getAccessionId().replaceAll("GO:", "");
329 * Filters a given list of discovered structures based on supplied argument
331 * @param fieldToFilterBy
332 * the field to filter by
334 public void filterResultSet(final String fieldToFilterBy)
336 Thread filterThread = new Thread(new Runnable()
341 long startTime = System.currentTimeMillis();
342 lbl_loading.setVisible(true);
343 Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
344 .getStructureSummaryFields();
345 Collection<PDBResponseSummary> filteredResponse = new HashSet<PDBResponseSummary>();
346 HashSet<String> errors = new HashSet<String>();
347 for (SequenceI seq : selectedSequences)
349 PDBRestRequest pdbRequest = new PDBRestRequest();
350 pdbRequest.setAllowEmptySeq(false);
351 pdbRequest.setResponseSize(1);
352 pdbRequest.setFieldToSearchBy("(text:");
353 pdbRequest.setFieldToSortBy(fieldToFilterBy,
354 !chk_invertFilter.isSelected());
355 pdbRequest.setSearchTerm(buildQuery(seq) + ")");
356 pdbRequest.setWantedFields(wantedFields);
357 pdbRequest.setAssociatedSequence(seq);
358 pdbRestCleint = new PDBRestClient();
359 PDBRestResponse resultList;
362 resultList = pdbRestCleint.executeRequest(pdbRequest);
363 } catch (Exception e)
366 errors.add(e.getMessage());
369 lastPdbRequest = pdbRequest;
370 if (resultList.getSearchSummary() != null
371 && !resultList.getSearchSummary().isEmpty())
373 filteredResponse.addAll(resultList.getSearchSummary());
377 String totalTime = (System.currentTimeMillis() - startTime)
379 if (!filteredResponse.isEmpty())
381 final int filterResponseCount = filteredResponse.size();
382 Collection<PDBResponseSummary> reorderedStructuresSet = new LinkedHashSet<PDBResponseSummary>();
383 reorderedStructuresSet.addAll(filteredResponse);
384 reorderedStructuresSet.addAll(discoveredStructuresSet);
385 tbl_summary.setModel(PDBRestResponse.getTableModel(
386 lastPdbRequest, reorderedStructuresSet));
388 // Update table selection model here
389 tbl_summary.addRowSelectionInterval(0, filterResponseCount - 1);
390 mainFrame.setTitle(MessageManager.formatMessage(
391 "label.structure_chooser_filter_time", totalTime));
395 mainFrame.setTitle(MessageManager.formatMessage(
396 "label.structure_chooser_filter_time", totalTime));
397 if (errors.size() > 0)
399 StringBuilder errorMsg = new StringBuilder();
400 for (String error : errors)
402 errorMsg.append(error).append("\n");
404 JOptionPane.showMessageDialog(
407 MessageManager.getString("label.pdb_web-service_error"),
408 JOptionPane.ERROR_MESSAGE);
412 lbl_loading.setVisible(false);
414 validateSelections();
417 filterThread.start();
421 * Handles action event for btn_pdbFromFile
423 public void pdbFromFile_actionPerformed()
425 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
426 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
427 chooser.setFileView(new jalview.io.JalviewFileView());
428 chooser.setDialogTitle(MessageManager.formatMessage(
429 "label.select_pdb_file_for",
430 selectedSequence.getDisplayId(false)));
431 chooser.setToolTipText(MessageManager.formatMessage(
432 "label.load_pdb_file_associate_with_sequence",
433 selectedSequence.getDisplayId(false)));
435 int value = chooser.showOpenDialog(null);
436 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
438 selectedPdbFileName = chooser.getSelectedFile().getPath();
439 jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedPdbFileName);
440 validateSelections();
445 * Populates the filter combo-box options dynamically depending on discovered
448 protected void populateFilterComboBox()
450 if (isStructuresDiscovered())
452 cmb_filterOption.addItem(new FilterOption("Best Quality",
453 PDBDocField.OVERALL_QUALITY.getCode(), VIEWS_FILTER));
454 cmb_filterOption.addItem(new FilterOption("Best UniProt Coverage",
455 PDBDocField.UNIPROT_COVERAGE.getCode(), VIEWS_FILTER));
456 cmb_filterOption.addItem(new FilterOption("Highest Resolution",
457 PDBDocField.RESOLUTION.getCode(), VIEWS_FILTER));
458 cmb_filterOption.addItem(new FilterOption("Highest Protein Chain",
459 PDBDocField.PROTEIN_CHAIN_COUNT.getCode(), VIEWS_FILTER));
460 cmb_filterOption.addItem(new FilterOption("Highest Bound Molecules",
461 PDBDocField.BOUND_MOLECULE_COUNT.getCode(), VIEWS_FILTER));
462 cmb_filterOption.addItem(new FilterOption("Highest Polymer Residues",
463 PDBDocField.POLYMER_RESIDUE_COUNT.getCode(), VIEWS_FILTER));
465 cmb_filterOption.addItem(new FilterOption("Enter PDB Id", "-",
467 cmb_filterOption.addItem(new FilterOption("From File", "-",
469 cmb_filterOption.addItem(new FilterOption("Cached PDB Entries", "-",
474 * Updates the displayed view based on the selected filter option
476 protected void updateCurrentView()
478 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
480 layout_switchableViews.show(pnl_switchableViews,
481 selectedFilterOpt.getView());
482 String filterTitle = mainFrame.getTitle();
483 mainFrame.setTitle(frameTitle);
484 chk_invertFilter.setVisible(false);
485 if (selectedFilterOpt.getView() == VIEWS_FILTER)
487 mainFrame.setTitle(filterTitle);
488 chk_invertFilter.setVisible(true);
489 filterResultSet(selectedFilterOpt.getValue());
491 else if (selectedFilterOpt.getView() == VIEWS_ENTER_ID
492 || selectedFilterOpt.getView() == VIEWS_FROM_FILE)
494 mainFrame.setTitle(MessageManager
495 .getString("label.structure_chooser_manual_association"));
496 idInputAssSeqPanel.loadCmbAssSeq();
497 fileChooserAssSeqPanel.loadCmbAssSeq();
499 validateSelections();
503 * Validates user selection and activates the view button if all parameters
506 public void validateSelections()
508 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
510 btn_view.setEnabled(false);
511 String currentView = selectedFilterOpt.getView();
512 if (currentView == VIEWS_FILTER)
514 if (tbl_summary.getSelectedRows().length > 0)
516 btn_view.setEnabled(true);
519 else if (currentView == VIEWS_LOCAL_PDB)
521 if (tbl_local_pdb.getSelectedRows().length > 0)
523 btn_view.setEnabled(true);
526 else if (currentView == VIEWS_ENTER_ID)
528 validateAssociationEnterPdb();
530 else if (currentView == VIEWS_FROM_FILE)
532 validateAssociationFromFile();
537 * Validates inputs from the Manual PDB entry panel
539 public void validateAssociationEnterPdb()
541 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel
542 .getCmb_assSeq().getSelectedItem();
543 lbl_pdbManualFetchStatus.setIcon(errorImage);
544 lbl_pdbManualFetchStatus.setToolTipText("");
545 if (txt_search.getText().length() > 0)
547 lbl_pdbManualFetchStatus
548 .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
549 .formatMessage("info.no_pdb_entry_found_for",
550 txt_search.getText())));
553 if (errorWarning.length() > 0)
555 lbl_pdbManualFetchStatus.setIcon(warningImage);
556 lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
557 true, errorWarning.toString()));
560 if (selectedSequences.length == 1
561 || !assSeqOpt.getName().equalsIgnoreCase(
562 "-Select Associated Seq-"))
564 txt_search.setEnabled(true);
567 btn_view.setEnabled(true);
568 lbl_pdbManualFetchStatus.setToolTipText("");
569 lbl_pdbManualFetchStatus.setIcon(goodImage);
574 txt_search.setEnabled(false);
575 lbl_pdbManualFetchStatus.setIcon(errorImage);
580 * Validates inputs for the manual PDB file selection options
582 public void validateAssociationFromFile()
584 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel
585 .getCmb_assSeq().getSelectedItem();
586 lbl_fromFileStatus.setIcon(errorImage);
587 if (selectedSequences.length == 1
588 || (assSeqOpt != null && !assSeqOpt.getName().equalsIgnoreCase(
589 "-Select Associated Seq-")))
591 btn_pdbFromFile.setEnabled(true);
592 if (selectedPdbFileName != null && selectedPdbFileName.length() > 0)
594 btn_view.setEnabled(true);
595 lbl_fromFileStatus.setIcon(goodImage);
600 btn_pdbFromFile.setEnabled(false);
601 lbl_fromFileStatus.setIcon(errorImage);
606 public void cmbAssSeqStateChanged()
608 validateSelections();
612 * Handles the state change event for the 'filter' combo-box and 'invert'
616 protected void stateChanged(ItemEvent e)
618 if (e.getSource() instanceof JCheckBox)
624 if (e.getStateChange() == ItemEvent.SELECTED)
633 * Handles action event for btn_ok
636 public void ok_ActionPerformed()
638 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
640 String currentView = selectedFilterOpt.getView();
641 if (currentView == VIEWS_FILTER)
643 int pdbIdColIndex = tbl_summary.getColumn(
644 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
645 int refSeqColIndex = tbl_summary.getColumn("Ref Sequence")
647 int[] selectedRows = tbl_summary.getSelectedRows();
648 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
650 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
651 for (int row : selectedRows)
653 String pdbIdStr = tbl_summary.getValueAt(row, pdbIdColIndex)
655 SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(row,
657 selectedSeqsToView.add(selectedSeq);
658 PDBEntry pdbEntry = selectedSeq.getPDBEntry(pdbIdStr);
659 if (pdbEntry == null)
661 pdbEntry = new PDBEntry();
662 pdbEntry.setId(pdbIdStr);
663 pdbEntry.setType(PDBEntry.Type.PDB);
664 selectedSeq.getDatasetSequence().addPDBId(pdbEntry);
666 pdbEntriesToView[count++] = pdbEntry;
668 SequenceI[] selectedSeqs = selectedSeqsToView
669 .toArray(new SequenceI[selectedSeqsToView.size()]);
670 launchStructureViewer(ap.getStructureSelectionManager(),
671 pdbEntriesToView, ap, selectedSeqs);
673 else if (currentView == VIEWS_LOCAL_PDB)
675 int[] selectedRows = tbl_local_pdb.getSelectedRows();
676 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
678 int pdbIdColIndex = tbl_local_pdb.getColumn(
679 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
680 int refSeqColIndex = tbl_local_pdb.getColumn("Ref Sequence")
682 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
683 for (int row : selectedRows)
685 PDBEntry pdbEntry = (PDBEntry) tbl_local_pdb.getValueAt(row,
687 pdbEntriesToView[count++] = pdbEntry;
688 SequenceI selectedSeq = (SequenceI) tbl_local_pdb.getValueAt(row,
690 selectedSeqsToView.add(selectedSeq);
692 SequenceI[] selectedSeqs = selectedSeqsToView
693 .toArray(new SequenceI[selectedSeqsToView.size()]);
694 launchStructureViewer(ap.getStructureSelectionManager(),
695 pdbEntriesToView, ap, selectedSeqs);
697 else if (currentView == VIEWS_ENTER_ID)
699 SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel
700 .getCmb_assSeq().getSelectedItem()).getSequence();
701 if (userSelectedSeq != null)
703 selectedSequence = userSelectedSeq;
706 String pdbIdStr = txt_search.getText();
707 PDBEntry pdbEntry = selectedSequence.getPDBEntry(pdbIdStr);
708 if (pdbEntry == null)
710 pdbEntry = new PDBEntry();
711 pdbEntry.setId(pdbIdStr);
712 pdbEntry.setType(PDBEntry.Type.PDB);
713 selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
716 PDBEntry[] pdbEntriesToView = new PDBEntry[] { pdbEntry };
717 launchStructureViewer(ap.getStructureSelectionManager(),
718 pdbEntriesToView, ap, new SequenceI[] { selectedSequence });
720 else if (currentView == VIEWS_FROM_FILE)
722 SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel
723 .getCmb_assSeq().getSelectedItem()).getSequence();
724 if (userSelectedSeq != null)
726 selectedSequence = userSelectedSeq;
728 PDBEntry fileEntry = new AssociatePdbFileWithSeq()
729 .associatePdbWithSeq(selectedPdbFileName,
730 jalview.io.AppletFormatAdapter.FILE,
731 selectedSequence, true, Desktop.instance);
733 launchStructureViewer(ap.getStructureSelectionManager(),
734 new PDBEntry[] { fileEntry }, ap,
735 new SequenceI[] { selectedSequence });
740 private void launchStructureViewer(final StructureSelectionManager ssm,
741 final PDBEntry[] pdbEntriesToView,
742 final AlignmentPanel alignPanel, final SequenceI[] sequences)
744 final StructureViewer sViewer = new StructureViewer(ssm);
745 new Thread(new Runnable()
749 if (pdbEntriesToView.length > 1)
751 ArrayList<SequenceI[]> seqsMap = new ArrayList<SequenceI[]>();
752 for (SequenceI seq : sequences)
754 seqsMap.add(new SequenceI[] { seq });
756 SequenceI[][] collatedSeqs = seqsMap.toArray(new SequenceI[0][0]);
757 sViewer.viewStructures(pdbEntriesToView, collatedSeqs, alignPanel);
761 sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
768 * Populates the combo-box used in associating manually fetched structures to
769 * a unique sequence when more than one sequence selection is made.
771 public void populateCmbAssociateSeqOptions(
772 JComboBox<AssociateSeqOptions> cmb_assSeq, JLabel lbl_associateSeq)
774 cmb_assSeq.removeAllItems();
775 cmb_assSeq.addItem(new AssociateSeqOptions("-Select Associated Seq-",
777 lbl_associateSeq.setVisible(false);
778 if (selectedSequences.length > 1)
780 for (SequenceI seq : selectedSequences)
782 cmb_assSeq.addItem(new AssociateSeqOptions(seq));
787 String seqName = selectedSequence.getDisplayId(false);
788 seqName = seqName.length() <= 40 ? seqName : seqName.substring(0, 39);
789 lbl_associateSeq.setText(seqName);
790 lbl_associateSeq.setVisible(true);
791 cmb_assSeq.setVisible(false);
795 public boolean isStructuresDiscovered()
797 return structuresDiscovered;
800 public void setStructuresDiscovered(boolean structuresDiscovered)
802 this.structuresDiscovered = structuresDiscovered;
805 public Collection<PDBResponseSummary> getDiscoveredStructuresSet()
807 return discoveredStructuresSet;
811 protected void txt_search_ActionPerformed()
817 errorWarning.setLength(0);
818 isValidPBDEntry = false;
819 if (txt_search.getText().length() > 0)
821 List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
822 wantedFields.add(PDBDocField.PDB_ID);
823 PDBRestRequest pdbRequest = new PDBRestRequest();
824 pdbRequest.setAllowEmptySeq(false);
825 pdbRequest.setResponseSize(1);
826 pdbRequest.setFieldToSearchBy("(pdb_id:");
827 pdbRequest.setWantedFields(wantedFields);
828 pdbRequest.setSearchTerm(txt_search.getText() + ")");
829 pdbRequest.setAssociatedSequence(selectedSequence);
830 pdbRestCleint = new PDBRestClient();
831 PDBRestResponse resultList;
834 resultList = pdbRestCleint.executeRequest(pdbRequest);
835 } catch (Exception e)
837 errorWarning.append(e.getMessage());
841 validateSelections();
843 if (resultList.getSearchSummary() != null
844 && resultList.getSearchSummary().size() > 0)
846 isValidPBDEntry = true;
849 validateSelections();
855 public void tabRefresh()
857 if (selectedSequences != null)
859 Thread refreshThread = new Thread(new Runnable()
864 fetchStructuresMetaData();
865 filterResultSet(((FilterOption) cmb_filterOption
866 .getSelectedItem()).getValue());
869 refreshThread.start();
873 public class PDBEntryTableModel extends AbstractTableModel
875 String[] columns = { "Ref Sequence", "PDB Id", "Chain", "Type", "File" };
877 private List<CachedPDB> pdbEntries;
879 public PDBEntryTableModel(List<CachedPDB> pdbEntries)
881 this.pdbEntries = new ArrayList<CachedPDB>(pdbEntries);
885 public String getColumnName(int columnIndex)
887 return columns[columnIndex];
891 public int getRowCount()
893 return pdbEntries.size();
897 public int getColumnCount()
899 return columns.length;
903 public boolean isCellEditable(int row, int column)
909 public Object getValueAt(int rowIndex, int columnIndex)
912 CachedPDB entry = pdbEntries.get(rowIndex);
916 value = entry.getSequence();
919 value = entry.getPdbEntry();
922 value = entry.getPdbEntry().getChainCode() == null ? "_" : entry
923 .getPdbEntry().getChainCode();
926 value = entry.getPdbEntry().getType();
929 value = entry.getPdbEntry().getFile();
936 public Class<?> getColumnClass(int columnIndex)
938 return columnIndex == 0 ? SequenceI.class : PDBEntry.class;
941 public CachedPDB getPDBEntryAt(int row)
943 return pdbEntries.get(row);
948 private class CachedPDB
950 private SequenceI sequence;
952 private PDBEntry pdbEntry;
954 public CachedPDB(SequenceI sequence, PDBEntry pdbEntry)
956 this.sequence = sequence;
957 this.pdbEntry = pdbEntry;
960 public SequenceI getSequence()
965 public PDBEntry getPdbEntry()