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;
79 public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
83 this.selectedSequence = selectedSeq;
84 this.selectedSequences = selectedSeqs;
85 this.progressIndicator = (ap == null) ? null : ap.alignFrame;
90 * Initializes parameters used by the Structure Chooser Panel
94 Thread discoverPDBStructuresThread = new Thread(new Runnable()
99 long startTime = System.currentTimeMillis();
100 updateProgressIndicator(MessageManager
101 .getString("status.loading_cached_pdb_entries"), startTime);
102 loadLocalCachedPDBEntries();
103 updateProgressIndicator(null, startTime);
104 updateProgressIndicator(MessageManager
105 .getString("status.searching_for_pdb_structures"),
107 fetchStructuresMetaData();
108 populateFilterComboBox();
109 updateProgressIndicator(null, startTime);
110 mainFrame.setVisible(true);
114 discoverPDBStructuresThread.start();
118 * Updates the progress indicator with the specified message
121 * displayed message for the operation
123 * unique handle for this indicator
125 public void updateProgressIndicator(String message, long id)
127 if (progressIndicator != null)
129 progressIndicator.setProgressBar(message, id);
134 * Retrieve meta-data for all the structure(s) for a given sequence(s) in a
137 public void fetchStructuresMetaData()
139 long startTime = System.currentTimeMillis();
140 Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
141 .getStructureSummaryFields();
143 discoveredStructuresSet = new LinkedHashSet<PDBResponseSummary>();
144 HashSet<String> errors = new HashSet<String>();
145 for (SequenceI seq : selectedSequences)
147 PDBRestRequest pdbRequest = new PDBRestRequest();
148 pdbRequest.setAllowEmptySeq(false);
149 pdbRequest.setResponseSize(500);
150 pdbRequest.setFieldToSearchBy("(text:");
151 pdbRequest.setWantedFields(wantedFields);
152 pdbRequest.setSearchTerm(buildQuery(seq) + ")");
153 pdbRequest.setAssociatedSequence(seq);
154 pdbRestCleint = new PDBRestClient();
155 PDBRestResponse resultList;
158 resultList = pdbRestCleint.executeRequest(pdbRequest);
159 } catch (Exception e)
162 errors.add(e.getMessage());
165 lastPdbRequest = pdbRequest;
166 if (resultList.getSearchSummary() != null
167 && !resultList.getSearchSummary().isEmpty())
169 discoveredStructuresSet.addAll(resultList.getSearchSummary());
173 int noOfStructuresFound = 0;
174 String totalTime = (System.currentTimeMillis() - startTime)
176 if (discoveredStructuresSet != null
177 && !discoveredStructuresSet.isEmpty())
179 tbl_summary.setModel(PDBRestResponse.getTableModel(lastPdbRequest,
180 discoveredStructuresSet));
181 structuresDiscovered = true;
182 noOfStructuresFound = discoveredStructuresSet.size();
183 mainFrame.setTitle("Structure Chooser - " + noOfStructuresFound
184 + " Found (" + totalTime + ")");
188 mainFrame.setTitle("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 "PDB Web-service Error", JOptionPane.ERROR_MESSAGE);
202 public void loadLocalCachedPDBEntries()
204 ArrayList<CachedPDB> entries = new ArrayList<CachedPDB>();
205 for (SequenceI seq : selectedSequences)
207 if (seq.getDatasetSequence() != null
208 && seq.getDatasetSequence().getAllPDBEntries() != null)
210 for (PDBEntry pdbEntry : seq.getDatasetSequence().getAllPDBEntries())
212 if (pdbEntry.getFile() != null)
214 entries.add(new CachedPDB(seq, pdbEntry));
220 PDBEntryTableModel tableModelx = new PDBEntryTableModel(entries);
221 tbl_local_pdb.setModel(tableModelx);
226 * Builds a query string for a given sequences using its DBRef entries
229 * the sequences to build a query for
230 * @return the built query string
233 public static String buildQuery(SequenceI seq)
235 HashSet<String> seqRefs = new LinkedHashSet<String>();
236 String seqName = seq.getName();
237 String[] names = seqName.toLowerCase().split("\\|");
238 for (String name : names)
240 // System.out.println("Found name : " + name);
242 if (isValidSeqName(name))
248 if (seq.getAllPDBEntries() != null)
250 for (PDBEntry entry : seq.getAllPDBEntries())
252 if (isValidSeqName(entry.getId()))
254 seqRefs.add(entry.getId());
259 if (seq.getDBRef() != null && seq.getDBRef().length != 0)
262 for (DBRefEntry dbRef : seq.getDBRef())
264 if (isValidSeqName(getDBRefId(dbRef)))
266 seqRefs.add(getDBRefId(dbRef));
276 StringBuilder queryBuilder = new StringBuilder();
277 for (String seqRef : seqRefs)
279 queryBuilder.append("text:").append(seqRef).append(" OR ");
281 int endIndex = queryBuilder.lastIndexOf(" OR ");
282 String query = queryBuilder.toString().substring(5, endIndex);
287 * Ensures sequence ref names are not less than 3 characters and does not
288 * contain a database name
293 public static boolean isValidSeqName(String seqName)
295 // System.out.println("seqName : " + seqName);
296 String ignoreList = "pdb,uniprot,swiss-prot";
297 if (seqName.length() < 3)
301 if (seqName.contains(":"))
305 seqName = seqName.toLowerCase();
306 for (String ignoredEntry : ignoreList.split(","))
308 if (seqName.contains(ignoredEntry))
316 public static String getDBRefId(DBRefEntry dbRef)
318 String ref = dbRef.getAccessionId().replaceAll("GO:", "");
323 * Filters a given list of discovered structures based on supplied argument
325 * @param fieldToFilterBy
326 * the field to filter by
328 public void filterResultSet(final String fieldToFilterBy)
330 Thread filterThread = new Thread(new Runnable()
335 long startTime = System.currentTimeMillis();
336 lbl_loading.setVisible(true);
337 Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
338 .getStructureSummaryFields();
339 Collection<PDBResponseSummary> filteredResponse = new HashSet<PDBResponseSummary>();
340 HashSet<String> errors = new HashSet<String>();
341 for (SequenceI seq : selectedSequences)
343 PDBRestRequest pdbRequest = new PDBRestRequest();
344 pdbRequest.setAllowEmptySeq(false);
345 pdbRequest.setResponseSize(1);
346 pdbRequest.setFieldToSearchBy("(text:");
347 pdbRequest.setFieldToSortBy(fieldToFilterBy,
348 !chk_invertFilter.isSelected());
349 pdbRequest.setSearchTerm(buildQuery(seq) + ")");
350 pdbRequest.setWantedFields(wantedFields);
351 pdbRequest.setAssociatedSequence(seq);
352 pdbRestCleint = new PDBRestClient();
353 PDBRestResponse resultList;
356 resultList = pdbRestCleint.executeRequest(pdbRequest);
357 } catch (Exception e)
360 errors.add(e.getMessage());
363 lastPdbRequest = pdbRequest;
364 if (resultList.getSearchSummary() != null
365 && !resultList.getSearchSummary().isEmpty())
367 filteredResponse.addAll(resultList.getSearchSummary());
371 String totalTime = (System.currentTimeMillis() - startTime)
373 if (!filteredResponse.isEmpty())
375 final int filterResponseCount = filteredResponse.size();
376 Collection<PDBResponseSummary> reorderedStructuresSet = new LinkedHashSet<PDBResponseSummary>();
377 reorderedStructuresSet.addAll(filteredResponse);
378 reorderedStructuresSet.addAll(discoveredStructuresSet);
379 tbl_summary.setModel(PDBRestResponse.getTableModel(
380 lastPdbRequest, reorderedStructuresSet));
382 // Update table selection model here
383 tbl_summary.addRowSelectionInterval(0, filterResponseCount - 1);
385 mainFrame.setTitle("Structure Chooser - Filter time ("
390 mainFrame.setTitle("Structure Chooser - Filter time ("
392 if (errors.size() > 0)
394 StringBuilder errorMsg = new StringBuilder();
395 for (String error : errors)
397 errorMsg.append(error).append("\n");
399 JOptionPane.showMessageDialog(null, errorMsg.toString(),
400 "PDB Web-service Error", JOptionPane.ERROR_MESSAGE);
404 lbl_loading.setVisible(false);
406 validateSelections();
409 filterThread.start();
413 * Handles action event for btn_pdbFromFile
415 public void pdbFromFile_actionPerformed()
417 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
418 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
419 chooser.setFileView(new jalview.io.JalviewFileView());
420 chooser.setDialogTitle(MessageManager.formatMessage(
421 "label.select_pdb_file_for", new String[]
422 { selectedSequence.getDisplayId(false) }));
423 chooser.setToolTipText(MessageManager.formatMessage(
424 "label.load_pdb_file_associate_with_sequence", new String[]
425 { selectedSequence.getDisplayId(false) }));
427 int value = chooser.showOpenDialog(null);
428 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
430 selectedPdbFileName = chooser.getSelectedFile().getPath();
431 jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedPdbFileName);
432 validateSelections();
437 * Populates the filter combo-box options dynamically depending on discovered
440 protected void populateFilterComboBox()
442 if (isStructuresDiscovered())
444 cmb_filterOption.addItem(new FilterOption("Best Quality",
445 PDBDocField.OVERALL_QUALITY.getCode(), VIEWS_FILTER));
446 cmb_filterOption.addItem(new FilterOption("Best UniProt Coverage",
447 PDBDocField.UNIPROT_COVERAGE.getCode(), VIEWS_FILTER));
448 cmb_filterOption.addItem(new FilterOption("Highest Resolution",
449 PDBDocField.RESOLUTION.getCode(), VIEWS_FILTER));
450 cmb_filterOption.addItem(new FilterOption("Highest Protein Chain",
451 PDBDocField.PROTEIN_CHAIN_COUNT.getCode(), VIEWS_FILTER));
452 cmb_filterOption.addItem(new FilterOption("Highest Bound Molecules",
453 PDBDocField.BOUND_MOLECULE_COUNT.getCode(), VIEWS_FILTER));
454 cmb_filterOption.addItem(new FilterOption("Highest Polymer Residues",
455 PDBDocField.POLYMER_RESIDUE_COUNT.getCode(), VIEWS_FILTER));
457 cmb_filterOption.addItem(new FilterOption("Enter PDB Id", "-",
459 cmb_filterOption.addItem(new FilterOption("From File", "-",
461 cmb_filterOption.addItem(new FilterOption("Cached PDB Entries", "-",
466 * Updates the displayed view based on the selected filter option
468 protected void updateCurrentView()
470 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
472 layout_switchableViews.show(pnl_switchableViews,
473 selectedFilterOpt.getView());
474 String filterTitle = mainFrame.getTitle();
475 mainFrame.setTitle(frameTitle);
476 chk_invertFilter.setVisible(false);
477 if (selectedFilterOpt.getView() == VIEWS_FILTER)
479 mainFrame.setTitle(filterTitle);
480 chk_invertFilter.setVisible(true);
481 filterResultSet(selectedFilterOpt.getValue());
483 else if (selectedFilterOpt.getView() == VIEWS_ENTER_ID
484 || selectedFilterOpt.getView() == VIEWS_FROM_FILE)
486 mainFrame.setTitle(filterTitle);
487 idInputAssSeqPanel.loadCmbAssSeq();
488 fileChooserAssSeqPanel.loadCmbAssSeq();
490 validateSelections();
494 * Validates user selection and activates the view button if all parameters
497 public void validateSelections()
499 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
501 btn_view.setEnabled(false);
502 String currentView = selectedFilterOpt.getView();
503 if (currentView == VIEWS_FILTER)
505 if (tbl_summary.getSelectedRows().length > 0)
507 btn_view.setEnabled(true);
510 else if (currentView == VIEWS_LOCAL_PDB)
512 if (tbl_local_pdb.getSelectedRows().length > 0)
514 btn_view.setEnabled(true);
517 else if (currentView == VIEWS_ENTER_ID)
519 validateAssociationEnterPdb();
521 else if (currentView == VIEWS_FROM_FILE)
523 validateAssociationFromFile();
528 * Validates inputs from the Manual PDB entry panel
530 public void validateAssociationEnterPdb()
532 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel
533 .getCmb_assSeq().getSelectedItem();
534 lbl_pdbManualFetchStatus.setIcon(errorImage);
535 lbl_pdbManualFetchStatus.setToolTipText("");
536 if (txt_search.getText().length() > 0)
538 lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
539 true, "No PDB entry found for \'" + txt_search.getText()
543 if (errorWarning.length() > 0)
545 lbl_pdbManualFetchStatus.setIcon(warningImage);
546 lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
547 true, errorWarning.toString()));
550 if (selectedSequences.length == 1
551 || !assSeqOpt.getName().equalsIgnoreCase(
552 "-Select Associated Seq-"))
554 txt_search.setEnabled(true);
557 btn_view.setEnabled(true);
558 lbl_pdbManualFetchStatus.setToolTipText("");
559 lbl_pdbManualFetchStatus.setIcon(goodImage);
564 txt_search.setEnabled(false);
565 lbl_pdbManualFetchStatus.setIcon(errorImage);
570 * Validates inputs for the manual PDB file selection options
572 public void validateAssociationFromFile()
574 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel
575 .getCmb_assSeq().getSelectedItem();
576 lbl_fromFileStatus.setIcon(errorImage);
577 if (selectedSequences.length == 1
578 || (assSeqOpt != null && !assSeqOpt.getName().equalsIgnoreCase(
579 "-Select Associated Seq-")))
581 btn_pdbFromFile.setEnabled(true);
582 if (selectedPdbFileName != null && selectedPdbFileName.length() > 0)
584 btn_view.setEnabled(true);
585 lbl_fromFileStatus.setIcon(goodImage);
590 btn_pdbFromFile.setEnabled(false);
591 lbl_fromFileStatus.setIcon(errorImage);
596 public void cmbAssSeqStateChanged()
598 validateSelections();
602 * Handles the state change event for the 'filter' combo-box and 'invert'
606 protected void stateChanged(ItemEvent e)
608 if (e.getSource() instanceof JCheckBox)
614 if (e.getStateChange() == ItemEvent.SELECTED)
623 * Handles action event for btn_ok
626 public void ok_ActionPerformed()
628 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
630 String currentView = selectedFilterOpt.getView();
631 if (currentView == VIEWS_FILTER)
633 int pdbIdColIndex = tbl_summary.getColumn(
634 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
635 int refSeqColIndex = tbl_summary.getColumn("Ref Sequence")
637 int[] selectedRows = tbl_summary.getSelectedRows();
638 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
640 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
641 for (int row : selectedRows)
643 String pdbIdStr = tbl_summary.getValueAt(row, pdbIdColIndex)
645 SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(row,
647 selectedSeqsToView.add(selectedSeq);
648 PDBEntry pdbEntry = selectedSeq.getPDBEntry(pdbIdStr);
649 if (pdbEntry == null)
651 pdbEntry = new PDBEntry();
652 pdbEntry.setId(pdbIdStr);
653 pdbEntry.setType(PDBEntry.Type.PDB);
654 selectedSeq.getDatasetSequence().addPDBId(pdbEntry);
656 pdbEntriesToView[count++] = pdbEntry;
658 SequenceI[] selectedSeqs = selectedSeqsToView
659 .toArray(new SequenceI[selectedSeqsToView.size()]);
660 launchStructureViewer(ap.getStructureSelectionManager(),
661 pdbEntriesToView, ap, selectedSeqs);
663 else if (currentView == VIEWS_LOCAL_PDB)
665 int[] selectedRows = tbl_local_pdb.getSelectedRows();
666 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
668 int pdbIdColIndex = tbl_local_pdb.getColumn(
669 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
670 int refSeqColIndex = tbl_local_pdb.getColumn("Ref Sequence")
672 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
673 for (int row : selectedRows)
675 PDBEntry pdbEntry = (PDBEntry) tbl_local_pdb.getValueAt(row,
677 pdbEntriesToView[count++] = pdbEntry;
678 SequenceI selectedSeq = (SequenceI) tbl_local_pdb.getValueAt(row,
680 selectedSeqsToView.add(selectedSeq);
682 SequenceI[] selectedSeqs = selectedSeqsToView
683 .toArray(new SequenceI[selectedSeqsToView.size()]);
684 launchStructureViewer(ap.getStructureSelectionManager(),
685 pdbEntriesToView, ap, selectedSeqs);
687 else if (currentView == VIEWS_ENTER_ID)
689 SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel
690 .getCmb_assSeq().getSelectedItem()).getSequence();
691 if (userSelectedSeq != null)
693 selectedSequence = userSelectedSeq;
696 String pdbIdStr = txt_search.getText();
697 PDBEntry pdbEntry = selectedSequence.getPDBEntry(pdbIdStr);
698 if (pdbEntry == null)
700 pdbEntry = new PDBEntry();
701 pdbEntry.setId(pdbIdStr);
702 pdbEntry.setType(PDBEntry.Type.PDB);
703 selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
706 PDBEntry[] pdbEntriesToView = new PDBEntry[]
708 launchStructureViewer(ap.getStructureSelectionManager(),
709 pdbEntriesToView, ap, new SequenceI[]
710 { selectedSequence });
712 else if (currentView == VIEWS_FROM_FILE)
714 SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel
715 .getCmb_assSeq().getSelectedItem()).getSequence();
716 if (userSelectedSeq != null)
718 selectedSequence = userSelectedSeq;
720 PDBEntry fileEntry = new AssociatePdbFileWithSeq()
721 .associatePdbWithSeq(selectedPdbFileName,
722 jalview.io.AppletFormatAdapter.FILE,
723 selectedSequence, true, Desktop.instance);
725 launchStructureViewer(ap.getStructureSelectionManager(),
727 { fileEntry }, ap, new SequenceI[]
728 { selectedSequence });
733 private void launchStructureViewer(final StructureSelectionManager ssm,
734 final PDBEntry[] pdbEntriesToView,
735 final AlignmentPanel alignPanel, final SequenceI[] sequences)
737 final StructureViewer sViewer = new StructureViewer(ssm);
738 new Thread(new Runnable()
742 if (pdbEntriesToView.length > 1)
744 ArrayList<SequenceI[]> seqsMap = new ArrayList<SequenceI[]>();
745 for (SequenceI seq : sequences)
747 seqsMap.add(new SequenceI[]
750 SequenceI[][] collatedSeqs = seqsMap.toArray(new SequenceI[0][0]);
751 sViewer.viewStructures(pdbEntriesToView, collatedSeqs, alignPanel);
755 sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
762 * Populates the combo-box used in associating manually fetched structures to
763 * a unique sequence when more than one sequence selection is made.
765 public void populateCmbAssociateSeqOptions(
766 JComboBox<AssociateSeqOptions> cmb_assSeq, JLabel lbl_associateSeq)
768 cmb_assSeq.removeAllItems();
769 cmb_assSeq.addItem(new AssociateSeqOptions("-Select Associated Seq-",
771 lbl_associateSeq.setVisible(false);
772 if (selectedSequences.length > 1)
774 for (SequenceI seq : selectedSequences)
776 cmb_assSeq.addItem(new AssociateSeqOptions(seq));
781 String seqName = selectedSequence.getDisplayId(false);
782 seqName = seqName.length() <= 40 ? seqName : seqName.substring(0, 39);
783 lbl_associateSeq.setText(seqName);
784 lbl_associateSeq.setVisible(true);
785 cmb_assSeq.setVisible(false);
789 public boolean isStructuresDiscovered()
791 return structuresDiscovered;
794 public void setStructuresDiscovered(boolean structuresDiscovered)
796 this.structuresDiscovered = structuresDiscovered;
799 public Collection<PDBResponseSummary> getDiscoveredStructuresSet()
801 return discoveredStructuresSet;
805 protected void txt_search_ActionPerformed()
807 errorWarning.setLength(0);
808 isValidPBDEntry = false;
809 if (txt_search.getText().length() > 0)
811 List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
812 wantedFields.add(PDBDocField.PDB_ID);
813 PDBRestRequest pdbRequest = new PDBRestRequest();
814 pdbRequest.setAllowEmptySeq(false);
815 pdbRequest.setResponseSize(1);
816 pdbRequest.setFieldToSearchBy("(pdb_id:");
817 pdbRequest.setWantedFields(wantedFields);
818 pdbRequest.setSearchTerm(txt_search.getText() + ")");
819 pdbRequest.setAssociatedSequence(selectedSequence);
820 pdbRestCleint = new PDBRestClient();
821 PDBRestResponse resultList;
824 resultList = pdbRestCleint.executeRequest(pdbRequest);
825 } catch (Exception e)
827 errorWarning.append(e.getMessage());
831 validateSelections();
833 if (resultList.getSearchSummary() != null
834 && resultList.getSearchSummary().size() > 0)
836 isValidPBDEntry = true;
839 validateSelections();
843 public void tabRefresh()
845 if (selectedSequences != null)
847 Thread refreshThread = new Thread(new Runnable()
852 fetchStructuresMetaData();
853 filterResultSet(((FilterOption) cmb_filterOption
854 .getSelectedItem()).getValue());
857 refreshThread.start();
861 public class PDBEntryTableModel extends AbstractTableModel
864 { "Ref Sequence", "PDB Id", "Chain", "Type", "File" };
866 private List<CachedPDB> pdbEntries;
868 public PDBEntryTableModel(List<CachedPDB> pdbEntries)
870 this.pdbEntries = new ArrayList<CachedPDB>(pdbEntries);
874 public String getColumnName(int columnIndex)
876 return columns[columnIndex];
880 public int getRowCount()
882 return pdbEntries.size();
886 public int getColumnCount()
888 return columns.length;
892 public boolean isCellEditable(int row, int column)
898 public Object getValueAt(int rowIndex, int columnIndex)
901 CachedPDB entry = pdbEntries.get(rowIndex);
905 value = entry.getSequence();
908 value = entry.getPdbEntry();
911 value = entry.getPdbEntry().getChainCode() == null ? "_" : entry
912 .getPdbEntry().getChainCode();
915 value = entry.getPdbEntry().getType();
918 value = entry.getPdbEntry().getFile();
925 public Class<?> getColumnClass(int columnIndex)
927 return columnIndex == 0 ? SequenceI.class : PDBEntry.class;
930 public CachedPDB getPDBEntryAt(int row)
932 return pdbEntries.get(row);
937 private class CachedPDB
939 private SequenceI sequence;
941 private PDBEntry pdbEntry;
943 public CachedPDB(SequenceI sequence, PDBEntry pdbEntry)
945 this.sequence = sequence;
946 this.pdbEntry = pdbEntry;
949 public SequenceI getSequence()
954 public PDBEntry getPdbEntry()