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.LinkedHashSet;
43 import java.util.List;
45 import javax.swing.JCheckBox;
46 import javax.swing.JComboBox;
47 import javax.swing.JLabel;
48 import javax.swing.JOptionPane;
49 import javax.swing.table.AbstractTableModel;
52 * Provides the behaviors for the Structure chooser Panel
57 @SuppressWarnings("serial")
58 public class StructureChooser extends GStructureChooser
60 private boolean structuresDiscovered = false;
62 private SequenceI selectedSequence;
64 private SequenceI[] selectedSequences;
66 private IProgressIndicator progressIndicator;
68 private Collection<PDBResponseSummary> discoveredStructuresSet;
70 private PDBRestRequest lastPdbRequest;
72 private PDBRestClient pdbRestCleint;
74 private String selectedPdbFileName;
76 private boolean isValidPBDEntry;
78 public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
82 this.selectedSequence = selectedSeq;
83 this.selectedSequences = selectedSeqs;
84 this.progressIndicator = (ap == null) ? null : ap.alignFrame;
89 * Initializes parameters used by the Structure Chooser Panel
93 Thread discoverPDBStructuresThread = new Thread(new Runnable()
98 long startTime = System.currentTimeMillis();
99 updateProgressIndicator(MessageManager
100 .getString("status.loading_cached_pdb_entries"), startTime);
101 loadLocalCachedPDBEntries();
102 updateProgressIndicator(null, startTime);
103 updateProgressIndicator(MessageManager
104 .getString("status.searching_for_pdb_structures"),
106 fetchStructuresMetaData();
107 populateFilterComboBox();
108 updateProgressIndicator(null, startTime);
109 mainFrame.setVisible(true);
113 discoverPDBStructuresThread.start();
117 * Updates the progress indicator with the specified message
120 * displayed message for the operation
122 * unique handle for this indicator
124 public void updateProgressIndicator(String message, long id)
126 if (progressIndicator != null)
128 progressIndicator.setProgressBar(message, id);
133 * Retrieve meta-data for all the structure(s) for a given sequence(s) in a
136 public void fetchStructuresMetaData()
138 long startTime = System.currentTimeMillis();
139 Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
140 .getStructureSummaryFields();
142 discoveredStructuresSet = new LinkedHashSet<PDBResponseSummary>();
143 HashSet<String> errors = new HashSet<String>();
144 for (SequenceI seq : selectedSequences)
146 PDBRestRequest pdbRequest = new PDBRestRequest();
147 pdbRequest.setAllowEmptySeq(false);
148 pdbRequest.setResponseSize(500);
149 pdbRequest.setFieldToSearchBy("(text:");
150 pdbRequest.setWantedFields(wantedFields);
151 pdbRequest.setSearchTerm(buildQuery(seq) + ")");
152 pdbRequest.setAssociatedSequence(seq);
153 pdbRestCleint = new PDBRestClient();
154 PDBRestResponse resultList;
157 resultList = pdbRestCleint.executeRequest(pdbRequest);
158 } catch (Exception e)
161 errors.add(e.getMessage());
164 lastPdbRequest = pdbRequest;
165 if (resultList.getSearchSummary() != null
166 && !resultList.getSearchSummary().isEmpty())
168 discoveredStructuresSet.addAll(resultList.getSearchSummary());
172 int noOfStructuresFound = 0;
173 String totalTime = (System.currentTimeMillis() - startTime)
175 if (discoveredStructuresSet != null
176 && !discoveredStructuresSet.isEmpty())
178 tbl_summary.setModel(PDBRestResponse.getTableModel(lastPdbRequest,
179 discoveredStructuresSet));
180 structuresDiscovered = true;
181 noOfStructuresFound = discoveredStructuresSet.size();
182 mainFrame.setTitle(MessageManager.formatMessage(
183 "label.structure_chooser_no_of_structures",
184 noOfStructuresFound, totalTime));
188 mainFrame.setTitle(MessageManager
189 .getString("label.structure_chooser_manual_association"));
190 if (errors.size() > 0)
192 StringBuilder errorMsg = new StringBuilder();
193 for (String error : errors)
195 errorMsg.append(error).append("\n");
197 JOptionPane.showMessageDialog(this, errorMsg.toString(),
198 MessageManager.getString("label.pdb_web-service_error"),
199 JOptionPane.ERROR_MESSAGE);
204 public void loadLocalCachedPDBEntries()
206 ArrayList<CachedPDB> entries = new ArrayList<CachedPDB>();
207 for (SequenceI seq : selectedSequences)
209 if (seq.getDatasetSequence() != null
210 && seq.getDatasetSequence().getAllPDBEntries() != null)
212 for (PDBEntry pdbEntry : seq.getDatasetSequence()
215 if (pdbEntry.getFile() != null)
217 entries.add(new CachedPDB(seq, pdbEntry));
223 PDBEntryTableModel tableModelx = new PDBEntryTableModel(entries);
224 tbl_local_pdb.setModel(tableModelx);
228 * Builds a query string for a given sequences using its DBRef entries
231 * the sequences to build a query for
232 * @return the built query string
235 public static String buildQuery(SequenceI seq)
237 HashSet<String> seqRefs = new LinkedHashSet<String>();
238 String seqName = seq.getName();
239 String[] names = seqName.toLowerCase().split("\\|");
240 for (String name : names)
242 // System.out.println("Found name : " + name);
244 if (isValidSeqName(name))
250 if (seq.getAllPDBEntries() != null)
252 for (PDBEntry entry : seq.getAllPDBEntries())
254 if (isValidSeqName(entry.getId()))
256 seqRefs.add(entry.getId());
261 if (seq.getDBRef() != null && seq.getDBRef().length != 0)
264 for (DBRefEntry dbRef : seq.getDBRef())
266 if (isValidSeqName(getDBRefId(dbRef)))
268 seqRefs.add(getDBRefId(dbRef));
278 StringBuilder queryBuilder = new StringBuilder();
279 for (String seqRef : seqRefs)
281 queryBuilder.append("text:").append(seqRef).append(" OR ");
283 int endIndex = queryBuilder.lastIndexOf(" OR ");
285 if (queryBuilder.toString().length() < 6)
289 String query = queryBuilder.toString().substring(5, endIndex);
294 * Ensures sequence ref names are not less than 3 characters and does not
295 * contain a database name
300 public static boolean isValidSeqName(String seqName)
302 // System.out.println("seqName : " + seqName);
303 String ignoreList = "pdb,uniprot,swiss-prot";
304 if (seqName.length() < 3)
308 if (seqName.contains(":"))
312 seqName = seqName.toLowerCase();
313 for (String ignoredEntry : ignoreList.split(","))
315 if (seqName.contains(ignoredEntry))
323 public static String getDBRefId(DBRefEntry dbRef)
325 String ref = dbRef.getAccessionId().replaceAll("GO:", "");
330 * Filters a given list of discovered structures based on supplied argument
332 * @param fieldToFilterBy
333 * the field to filter by
335 public void filterResultSet(final String fieldToFilterBy)
337 Thread filterThread = new Thread(new Runnable()
342 long startTime = System.currentTimeMillis();
343 lbl_loading.setVisible(true);
344 Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
345 .getStructureSummaryFields();
346 Collection<PDBResponseSummary> filteredResponse = new HashSet<PDBResponseSummary>();
347 HashSet<String> errors = new HashSet<String>();
348 for (SequenceI seq : selectedSequences)
350 PDBRestRequest pdbRequest = new PDBRestRequest();
351 pdbRequest.setAllowEmptySeq(false);
352 pdbRequest.setResponseSize(1);
353 pdbRequest.setFieldToSearchBy("(text:");
354 pdbRequest.setFieldToSortBy(fieldToFilterBy,
355 !chk_invertFilter.isSelected());
356 pdbRequest.setSearchTerm(buildQuery(seq) + ")");
357 pdbRequest.setWantedFields(wantedFields);
358 pdbRequest.setAssociatedSequence(seq);
359 pdbRestCleint = new PDBRestClient();
360 PDBRestResponse resultList;
363 resultList = pdbRestCleint.executeRequest(pdbRequest);
364 } catch (Exception e)
367 errors.add(e.getMessage());
370 lastPdbRequest = pdbRequest;
371 if (resultList.getSearchSummary() != null
372 && !resultList.getSearchSummary().isEmpty())
374 filteredResponse.addAll(resultList.getSearchSummary());
378 String totalTime = (System.currentTimeMillis() - startTime)
380 if (!filteredResponse.isEmpty())
382 final int filterResponseCount = filteredResponse.size();
383 Collection<PDBResponseSummary> reorderedStructuresSet = new LinkedHashSet<PDBResponseSummary>();
384 reorderedStructuresSet.addAll(filteredResponse);
385 reorderedStructuresSet.addAll(discoveredStructuresSet);
386 tbl_summary.setModel(PDBRestResponse.getTableModel(
387 lastPdbRequest, reorderedStructuresSet));
389 // Update table selection model here
390 tbl_summary.addRowSelectionInterval(0, filterResponseCount - 1);
391 mainFrame.setTitle(MessageManager.formatMessage(
392 "label.structure_chooser_filter_time", totalTime));
396 mainFrame.setTitle(MessageManager.formatMessage(
397 "label.structure_chooser_filter_time", totalTime));
398 if (errors.size() > 0)
400 StringBuilder errorMsg = new StringBuilder();
401 for (String error : errors)
403 errorMsg.append(error).append("\n");
405 JOptionPane.showMessageDialog(
408 MessageManager.getString("label.pdb_web-service_error"),
409 JOptionPane.ERROR_MESSAGE);
413 lbl_loading.setVisible(false);
415 validateSelections();
418 filterThread.start();
422 * Handles action event for btn_pdbFromFile
424 public void pdbFromFile_actionPerformed()
426 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
427 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
428 chooser.setFileView(new jalview.io.JalviewFileView());
429 chooser.setDialogTitle(MessageManager.formatMessage(
430 "label.select_pdb_file_for",
431 selectedSequence.getDisplayId(false)));
432 chooser.setToolTipText(MessageManager.formatMessage(
433 "label.load_pdb_file_associate_with_sequence",
434 selectedSequence.getDisplayId(false)));
436 int value = chooser.showOpenDialog(null);
437 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
439 selectedPdbFileName = chooser.getSelectedFile().getPath();
440 jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedPdbFileName);
441 validateSelections();
446 * Populates the filter combo-box options dynamically depending on discovered
449 protected void populateFilterComboBox()
451 if (isStructuresDiscovered())
453 cmb_filterOption.addItem(new FilterOption("Best Quality",
454 PDBDocField.OVERALL_QUALITY.getCode(), VIEWS_FILTER));
455 cmb_filterOption.addItem(new FilterOption("Best UniProt Coverage",
456 PDBDocField.UNIPROT_COVERAGE.getCode(), VIEWS_FILTER));
457 cmb_filterOption.addItem(new FilterOption("Highest Resolution",
458 PDBDocField.RESOLUTION.getCode(), VIEWS_FILTER));
459 cmb_filterOption.addItem(new FilterOption("Highest Protein Chain",
460 PDBDocField.PROTEIN_CHAIN_COUNT.getCode(), VIEWS_FILTER));
461 cmb_filterOption.addItem(new FilterOption("Highest Bound Molecules",
462 PDBDocField.BOUND_MOLECULE_COUNT.getCode(), VIEWS_FILTER));
463 cmb_filterOption.addItem(new FilterOption("Highest Polymer Residues",
464 PDBDocField.POLYMER_RESIDUE_COUNT.getCode(), VIEWS_FILTER));
466 cmb_filterOption.addItem(new FilterOption("Enter PDB Id", "-",
468 cmb_filterOption.addItem(new FilterOption("From File", "-",
470 cmb_filterOption.addItem(new FilterOption("Cached PDB Entries", "-",
475 * Updates the displayed view based on the selected filter option
477 protected void updateCurrentView()
479 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
481 layout_switchableViews.show(pnl_switchableViews,
482 selectedFilterOpt.getView());
483 String filterTitle = mainFrame.getTitle();
484 mainFrame.setTitle(frameTitle);
485 chk_invertFilter.setVisible(false);
486 if (selectedFilterOpt.getView() == VIEWS_FILTER)
488 mainFrame.setTitle(filterTitle);
489 chk_invertFilter.setVisible(true);
490 filterResultSet(selectedFilterOpt.getValue());
492 else if (selectedFilterOpt.getView() == VIEWS_ENTER_ID
493 || selectedFilterOpt.getView() == VIEWS_FROM_FILE)
495 mainFrame.setTitle(MessageManager
496 .getString("label.structure_chooser_manual_association"));
497 idInputAssSeqPanel.loadCmbAssSeq();
498 fileChooserAssSeqPanel.loadCmbAssSeq();
500 validateSelections();
504 * Validates user selection and activates the view button if all parameters
507 public void validateSelections()
509 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
511 btn_view.setEnabled(false);
512 String currentView = selectedFilterOpt.getView();
513 if (currentView == VIEWS_FILTER)
515 if (tbl_summary.getSelectedRows().length > 0)
517 btn_view.setEnabled(true);
520 else if (currentView == VIEWS_LOCAL_PDB)
522 if (tbl_local_pdb.getSelectedRows().length > 0)
524 btn_view.setEnabled(true);
527 else if (currentView == VIEWS_ENTER_ID)
529 validateAssociationEnterPdb();
531 else if (currentView == VIEWS_FROM_FILE)
533 validateAssociationFromFile();
538 * Validates inputs from the Manual PDB entry panel
540 public void validateAssociationEnterPdb()
542 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel
543 .getCmb_assSeq().getSelectedItem();
544 lbl_pdbManualFetchStatus.setIcon(errorImage);
545 lbl_pdbManualFetchStatus.setToolTipText("");
546 if (txt_search.getText().length() > 0)
548 lbl_pdbManualFetchStatus
549 .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
550 .formatMessage("info.no_pdb_entry_found_for",
551 txt_search.getText())));
554 if (errorWarning.length() > 0)
556 lbl_pdbManualFetchStatus.setIcon(warningImage);
557 lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
558 true, errorWarning.toString()));
561 if (selectedSequences.length == 1
562 || !assSeqOpt.getName().equalsIgnoreCase(
563 "-Select Associated Seq-"))
565 txt_search.setEnabled(true);
568 btn_view.setEnabled(true);
569 lbl_pdbManualFetchStatus.setToolTipText("");
570 lbl_pdbManualFetchStatus.setIcon(goodImage);
575 txt_search.setEnabled(false);
576 lbl_pdbManualFetchStatus.setIcon(errorImage);
581 * Validates inputs for the manual PDB file selection options
583 public void validateAssociationFromFile()
585 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel
586 .getCmb_assSeq().getSelectedItem();
587 lbl_fromFileStatus.setIcon(errorImage);
588 if (selectedSequences.length == 1
589 || (assSeqOpt != null && !assSeqOpt.getName().equalsIgnoreCase(
590 "-Select Associated Seq-")))
592 btn_pdbFromFile.setEnabled(true);
593 if (selectedPdbFileName != null && selectedPdbFileName.length() > 0)
595 btn_view.setEnabled(true);
596 lbl_fromFileStatus.setIcon(goodImage);
601 btn_pdbFromFile.setEnabled(false);
602 lbl_fromFileStatus.setIcon(errorImage);
607 public void cmbAssSeqStateChanged()
609 validateSelections();
613 * Handles the state change event for the 'filter' combo-box and 'invert'
617 protected void stateChanged(ItemEvent e)
619 if (e.getSource() instanceof JCheckBox)
625 if (e.getStateChange() == ItemEvent.SELECTED)
634 * Handles action event for btn_ok
637 public void ok_ActionPerformed()
639 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
641 String currentView = selectedFilterOpt.getView();
642 if (currentView == VIEWS_FILTER)
644 int pdbIdColIndex = tbl_summary.getColumn(
645 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
646 int refSeqColIndex = tbl_summary.getColumn("Ref Sequence")
648 int[] selectedRows = tbl_summary.getSelectedRows();
649 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
651 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
652 for (int row : selectedRows)
654 String pdbIdStr = tbl_summary.getValueAt(row, pdbIdColIndex)
656 SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(row,
658 selectedSeqsToView.add(selectedSeq);
659 PDBEntry pdbEntry = selectedSeq.getPDBEntry(pdbIdStr);
660 if (pdbEntry == null)
662 pdbEntry = new PDBEntry();
663 pdbEntry.setId(pdbIdStr);
664 pdbEntry.setType(PDBEntry.Type.PDB);
665 selectedSeq.getDatasetSequence().addPDBId(pdbEntry);
667 pdbEntriesToView[count++] = pdbEntry;
669 SequenceI[] selectedSeqs = selectedSeqsToView
670 .toArray(new SequenceI[selectedSeqsToView.size()]);
671 launchStructureViewer(ap.getStructureSelectionManager(),
672 pdbEntriesToView, ap, selectedSeqs);
674 else if (currentView == VIEWS_LOCAL_PDB)
676 int[] selectedRows = tbl_local_pdb.getSelectedRows();
677 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
679 int pdbIdColIndex = tbl_local_pdb.getColumn(
680 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
681 int refSeqColIndex = tbl_local_pdb.getColumn("Ref Sequence")
683 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
684 for (int row : selectedRows)
686 PDBEntry pdbEntry = (PDBEntry) tbl_local_pdb.getValueAt(row,
688 pdbEntriesToView[count++] = pdbEntry;
689 SequenceI selectedSeq = (SequenceI) tbl_local_pdb.getValueAt(row,
691 selectedSeqsToView.add(selectedSeq);
693 SequenceI[] selectedSeqs = selectedSeqsToView
694 .toArray(new SequenceI[selectedSeqsToView.size()]);
695 launchStructureViewer(ap.getStructureSelectionManager(),
696 pdbEntriesToView, ap, selectedSeqs);
698 else if (currentView == VIEWS_ENTER_ID)
700 SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel
701 .getCmb_assSeq().getSelectedItem()).getSequence();
702 if (userSelectedSeq != null)
704 selectedSequence = userSelectedSeq;
707 String pdbIdStr = txt_search.getText();
708 PDBEntry pdbEntry = selectedSequence.getPDBEntry(pdbIdStr);
709 if (pdbEntry == null)
711 pdbEntry = new PDBEntry();
712 pdbEntry.setId(pdbIdStr);
713 pdbEntry.setType(PDBEntry.Type.PDB);
714 selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
717 PDBEntry[] pdbEntriesToView = new PDBEntry[] { pdbEntry };
718 launchStructureViewer(ap.getStructureSelectionManager(),
719 pdbEntriesToView, ap, new SequenceI[] { selectedSequence });
721 else if (currentView == VIEWS_FROM_FILE)
723 SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel
724 .getCmb_assSeq().getSelectedItem()).getSequence();
725 if (userSelectedSeq != null)
727 selectedSequence = userSelectedSeq;
729 PDBEntry fileEntry = new AssociatePdbFileWithSeq()
730 .associatePdbWithSeq(selectedPdbFileName,
731 jalview.io.AppletFormatAdapter.FILE,
732 selectedSequence, true, Desktop.instance);
734 launchStructureViewer(ap.getStructureSelectionManager(),
735 new PDBEntry[] { fileEntry }, ap,
736 new SequenceI[] { selectedSequence });
741 private void launchStructureViewer(final StructureSelectionManager ssm,
742 final PDBEntry[] pdbEntriesToView,
743 final AlignmentPanel alignPanel, final SequenceI[] sequences)
745 final StructureViewer sViewer = new StructureViewer(ssm);
746 new Thread(new Runnable()
750 if (pdbEntriesToView.length > 1)
752 ArrayList<SequenceI[]> seqsMap = new ArrayList<SequenceI[]>();
753 for (SequenceI seq : sequences)
755 seqsMap.add(new SequenceI[] { seq });
757 SequenceI[][] collatedSeqs = seqsMap.toArray(new SequenceI[0][0]);
758 sViewer.viewStructures(pdbEntriesToView, collatedSeqs, alignPanel);
762 sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
769 * Populates the combo-box used in associating manually fetched structures to
770 * a unique sequence when more than one sequence selection is made.
772 public void populateCmbAssociateSeqOptions(
773 JComboBox<AssociateSeqOptions> cmb_assSeq, JLabel lbl_associateSeq)
775 cmb_assSeq.removeAllItems();
776 cmb_assSeq.addItem(new AssociateSeqOptions("-Select Associated Seq-",
778 lbl_associateSeq.setVisible(false);
779 if (selectedSequences.length > 1)
781 for (SequenceI seq : selectedSequences)
783 cmb_assSeq.addItem(new AssociateSeqOptions(seq));
788 String seqName = selectedSequence.getDisplayId(false);
789 seqName = seqName.length() <= 40 ? seqName : seqName.substring(0, 39);
790 lbl_associateSeq.setText(seqName);
791 lbl_associateSeq.setVisible(true);
792 cmb_assSeq.setVisible(false);
796 public boolean isStructuresDiscovered()
798 return structuresDiscovered;
801 public void setStructuresDiscovered(boolean structuresDiscovered)
803 this.structuresDiscovered = structuresDiscovered;
806 public Collection<PDBResponseSummary> getDiscoveredStructuresSet()
808 return discoveredStructuresSet;
812 protected void txt_search_ActionPerformed()
818 errorWarning.setLength(0);
819 isValidPBDEntry = false;
820 if (txt_search.getText().length() > 0)
822 List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
823 wantedFields.add(PDBDocField.PDB_ID);
824 PDBRestRequest pdbRequest = new PDBRestRequest();
825 pdbRequest.setAllowEmptySeq(false);
826 pdbRequest.setResponseSize(1);
827 pdbRequest.setFieldToSearchBy("(pdb_id:");
828 pdbRequest.setWantedFields(wantedFields);
829 pdbRequest.setSearchTerm(txt_search.getText() + ")");
830 pdbRequest.setAssociatedSequence(selectedSequence);
831 pdbRestCleint = new PDBRestClient();
832 PDBRestResponse resultList;
835 resultList = pdbRestCleint.executeRequest(pdbRequest);
836 } catch (Exception e)
838 errorWarning.append(e.getMessage());
842 validateSelections();
844 if (resultList.getSearchSummary() != null
845 && resultList.getSearchSummary().size() > 0)
847 isValidPBDEntry = true;
850 validateSelections();
856 public void tabRefresh()
858 if (selectedSequences != null)
860 Thread refreshThread = new Thread(new Runnable()
865 fetchStructuresMetaData();
866 filterResultSet(((FilterOption) cmb_filterOption
867 .getSelectedItem()).getValue());
870 refreshThread.start();
874 public class PDBEntryTableModel extends AbstractTableModel
876 String[] columns = { "Ref Sequence", "PDB Id", "Chain", "Type", "File" };
878 private List<CachedPDB> pdbEntries;
880 public PDBEntryTableModel(List<CachedPDB> pdbEntries)
882 this.pdbEntries = new ArrayList<CachedPDB>(pdbEntries);
886 public String getColumnName(int columnIndex)
888 return columns[columnIndex];
892 public int getRowCount()
894 return pdbEntries.size();
898 public int getColumnCount()
900 return columns.length;
904 public boolean isCellEditable(int row, int column)
910 public Object getValueAt(int rowIndex, int columnIndex)
913 CachedPDB entry = pdbEntries.get(rowIndex);
917 value = entry.getSequence();
920 value = entry.getPdbEntry();
923 value = entry.getPdbEntry().getChainCode() == null ? "_" : entry
924 .getPdbEntry().getChainCode();
927 value = entry.getPdbEntry().getType();
930 value = entry.getPdbEntry().getFile();
937 public Class<?> getColumnClass(int columnIndex)
939 return columnIndex == 0 ? SequenceI.class : PDBEntry.class;
942 public CachedPDB getPDBEntryAt(int row)
944 return pdbEntries.get(row);
949 private class CachedPDB
951 private SequenceI sequence;
953 private PDBEntry pdbEntry;
955 public CachedPDB(SequenceI sequence, PDBEntry pdbEntry)
957 this.sequence = sequence;
958 this.pdbEntry = pdbEntry;
961 public SequenceI getSequence()
966 public PDBEntry getPdbEntry()