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 ");
283 if (queryBuilder.toString().length() < 6)
287 String query = queryBuilder.toString().substring(5, endIndex);
292 * Ensures sequence ref names are not less than 3 characters and does not
293 * contain a database name
298 public static boolean isValidSeqName(String seqName)
300 // System.out.println("seqName : " + seqName);
301 String ignoreList = "pdb,uniprot,swiss-prot";
302 if (seqName.length() < 3)
306 if (seqName.contains(":"))
310 seqName = seqName.toLowerCase();
311 for (String ignoredEntry : ignoreList.split(","))
313 if (seqName.contains(ignoredEntry))
321 public static String getDBRefId(DBRefEntry dbRef)
323 String ref = dbRef.getAccessionId().replaceAll("GO:", "");
328 * Filters a given list of discovered structures based on supplied argument
330 * @param fieldToFilterBy
331 * the field to filter by
333 public void filterResultSet(final String fieldToFilterBy)
335 Thread filterThread = new Thread(new Runnable()
340 long startTime = System.currentTimeMillis();
341 lbl_loading.setVisible(true);
342 Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
343 .getStructureSummaryFields();
344 Collection<PDBResponseSummary> filteredResponse = new HashSet<PDBResponseSummary>();
345 HashSet<String> errors = new HashSet<String>();
346 for (SequenceI seq : selectedSequences)
348 PDBRestRequest pdbRequest = new PDBRestRequest();
349 pdbRequest.setAllowEmptySeq(false);
350 pdbRequest.setResponseSize(1);
351 pdbRequest.setFieldToSearchBy("(text:");
352 pdbRequest.setFieldToSortBy(fieldToFilterBy,
353 !chk_invertFilter.isSelected());
354 pdbRequest.setSearchTerm(buildQuery(seq) + ")");
355 pdbRequest.setWantedFields(wantedFields);
356 pdbRequest.setAssociatedSequence(seq);
357 pdbRestCleint = new PDBRestClient();
358 PDBRestResponse resultList;
361 resultList = pdbRestCleint.executeRequest(pdbRequest);
362 } catch (Exception e)
365 errors.add(e.getMessage());
368 lastPdbRequest = pdbRequest;
369 if (resultList.getSearchSummary() != null
370 && !resultList.getSearchSummary().isEmpty())
372 filteredResponse.addAll(resultList.getSearchSummary());
376 String totalTime = (System.currentTimeMillis() - startTime)
378 if (!filteredResponse.isEmpty())
380 final int filterResponseCount = filteredResponse.size();
381 Collection<PDBResponseSummary> reorderedStructuresSet = new LinkedHashSet<PDBResponseSummary>();
382 reorderedStructuresSet.addAll(filteredResponse);
383 reorderedStructuresSet.addAll(discoveredStructuresSet);
384 tbl_summary.setModel(PDBRestResponse.getTableModel(
385 lastPdbRequest, reorderedStructuresSet));
387 // Update table selection model here
388 tbl_summary.addRowSelectionInterval(0, filterResponseCount - 1);
390 mainFrame.setTitle("Structure Chooser - Filter time ("
395 mainFrame.setTitle("Structure Chooser - Filter time ("
397 if (errors.size() > 0)
399 StringBuilder errorMsg = new StringBuilder();
400 for (String error : errors)
402 errorMsg.append(error).append("\n");
404 JOptionPane.showMessageDialog(null, errorMsg.toString(),
405 "PDB Web-service Error", JOptionPane.ERROR_MESSAGE);
409 lbl_loading.setVisible(false);
411 validateSelections();
414 filterThread.start();
418 * Handles action event for btn_pdbFromFile
420 public void pdbFromFile_actionPerformed()
422 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
423 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
424 chooser.setFileView(new jalview.io.JalviewFileView());
425 chooser.setDialogTitle(MessageManager.formatMessage(
426 "label.select_pdb_file_for", new String[]
427 { selectedSequence.getDisplayId(false) }));
428 chooser.setToolTipText(MessageManager.formatMessage(
429 "label.load_pdb_file_associate_with_sequence", new String[]
430 { selectedSequence.getDisplayId(false) }));
432 int value = chooser.showOpenDialog(null);
433 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
435 selectedPdbFileName = chooser.getSelectedFile().getPath();
436 jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedPdbFileName);
437 validateSelections();
442 * Populates the filter combo-box options dynamically depending on discovered
445 protected void populateFilterComboBox()
447 if (isStructuresDiscovered())
449 cmb_filterOption.addItem(new FilterOption("Best Quality",
450 PDBDocField.OVERALL_QUALITY.getCode(), VIEWS_FILTER));
451 cmb_filterOption.addItem(new FilterOption("Best UniProt Coverage",
452 PDBDocField.UNIPROT_COVERAGE.getCode(), VIEWS_FILTER));
453 cmb_filterOption.addItem(new FilterOption("Highest Resolution",
454 PDBDocField.RESOLUTION.getCode(), VIEWS_FILTER));
455 cmb_filterOption.addItem(new FilterOption("Highest Protein Chain",
456 PDBDocField.PROTEIN_CHAIN_COUNT.getCode(), VIEWS_FILTER));
457 cmb_filterOption.addItem(new FilterOption("Highest Bound Molecules",
458 PDBDocField.BOUND_MOLECULE_COUNT.getCode(), VIEWS_FILTER));
459 cmb_filterOption.addItem(new FilterOption("Highest Polymer Residues",
460 PDBDocField.POLYMER_RESIDUE_COUNT.getCode(), VIEWS_FILTER));
462 cmb_filterOption.addItem(new FilterOption("Enter PDB Id", "-",
464 cmb_filterOption.addItem(new FilterOption("From File", "-",
466 cmb_filterOption.addItem(new FilterOption("Cached PDB Entries", "-",
471 * Updates the displayed view based on the selected filter option
473 protected void updateCurrentView()
475 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
477 layout_switchableViews.show(pnl_switchableViews,
478 selectedFilterOpt.getView());
479 String filterTitle = mainFrame.getTitle();
480 mainFrame.setTitle(frameTitle);
481 chk_invertFilter.setVisible(false);
482 if (selectedFilterOpt.getView() == VIEWS_FILTER)
484 mainFrame.setTitle(filterTitle);
485 chk_invertFilter.setVisible(true);
486 filterResultSet(selectedFilterOpt.getValue());
488 else if (selectedFilterOpt.getView() == VIEWS_ENTER_ID
489 || selectedFilterOpt.getView() == VIEWS_FROM_FILE)
491 mainFrame.setTitle(filterTitle);
492 idInputAssSeqPanel.loadCmbAssSeq();
493 fileChooserAssSeqPanel.loadCmbAssSeq();
495 validateSelections();
499 * Validates user selection and activates the view button if all parameters
502 public void validateSelections()
504 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
506 btn_view.setEnabled(false);
507 String currentView = selectedFilterOpt.getView();
508 if (currentView == VIEWS_FILTER)
510 if (tbl_summary.getSelectedRows().length > 0)
512 btn_view.setEnabled(true);
515 else if (currentView == VIEWS_LOCAL_PDB)
517 if (tbl_local_pdb.getSelectedRows().length > 0)
519 btn_view.setEnabled(true);
522 else if (currentView == VIEWS_ENTER_ID)
524 validateAssociationEnterPdb();
526 else if (currentView == VIEWS_FROM_FILE)
528 validateAssociationFromFile();
533 * Validates inputs from the Manual PDB entry panel
535 public void validateAssociationEnterPdb()
537 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel
538 .getCmb_assSeq().getSelectedItem();
539 lbl_pdbManualFetchStatus.setIcon(errorImage);
540 lbl_pdbManualFetchStatus.setToolTipText("");
541 if (txt_search.getText().length() > 0)
543 lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
544 true, "No PDB entry found for \'" + txt_search.getText()
548 if (errorWarning.length() > 0)
550 lbl_pdbManualFetchStatus.setIcon(warningImage);
551 lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
552 true, errorWarning.toString()));
555 if (selectedSequences.length == 1
556 || !assSeqOpt.getName().equalsIgnoreCase(
557 "-Select Associated Seq-"))
559 txt_search.setEnabled(true);
562 btn_view.setEnabled(true);
563 lbl_pdbManualFetchStatus.setToolTipText("");
564 lbl_pdbManualFetchStatus.setIcon(goodImage);
569 txt_search.setEnabled(false);
570 lbl_pdbManualFetchStatus.setIcon(errorImage);
575 * Validates inputs for the manual PDB file selection options
577 public void validateAssociationFromFile()
579 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel
580 .getCmb_assSeq().getSelectedItem();
581 lbl_fromFileStatus.setIcon(errorImage);
582 if (selectedSequences.length == 1
583 || (assSeqOpt != null && !assSeqOpt.getName().equalsIgnoreCase(
584 "-Select Associated Seq-")))
586 btn_pdbFromFile.setEnabled(true);
587 if (selectedPdbFileName != null && selectedPdbFileName.length() > 0)
589 btn_view.setEnabled(true);
590 lbl_fromFileStatus.setIcon(goodImage);
595 btn_pdbFromFile.setEnabled(false);
596 lbl_fromFileStatus.setIcon(errorImage);
601 public void cmbAssSeqStateChanged()
603 validateSelections();
607 * Handles the state change event for the 'filter' combo-box and 'invert'
611 protected void stateChanged(ItemEvent e)
613 if (e.getSource() instanceof JCheckBox)
619 if (e.getStateChange() == ItemEvent.SELECTED)
628 * Handles action event for btn_ok
631 public void ok_ActionPerformed()
633 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
635 String currentView = selectedFilterOpt.getView();
636 if (currentView == VIEWS_FILTER)
638 int pdbIdColIndex = tbl_summary.getColumn(
639 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
640 int refSeqColIndex = tbl_summary.getColumn("Ref Sequence")
642 int[] selectedRows = tbl_summary.getSelectedRows();
643 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
645 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
646 for (int row : selectedRows)
648 String pdbIdStr = tbl_summary.getValueAt(row, pdbIdColIndex)
650 SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(row,
652 selectedSeqsToView.add(selectedSeq);
653 PDBEntry pdbEntry = selectedSeq.getPDBEntry(pdbIdStr);
654 if (pdbEntry == null)
656 pdbEntry = new PDBEntry();
657 pdbEntry.setId(pdbIdStr);
658 pdbEntry.setType(PDBEntry.Type.PDB);
659 selectedSeq.getDatasetSequence().addPDBId(pdbEntry);
661 pdbEntriesToView[count++] = pdbEntry;
663 SequenceI[] selectedSeqs = selectedSeqsToView
664 .toArray(new SequenceI[selectedSeqsToView.size()]);
665 launchStructureViewer(ap.getStructureSelectionManager(),
666 pdbEntriesToView, ap, selectedSeqs);
668 else if (currentView == VIEWS_LOCAL_PDB)
670 int[] selectedRows = tbl_local_pdb.getSelectedRows();
671 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
673 int pdbIdColIndex = tbl_local_pdb.getColumn(
674 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
675 int refSeqColIndex = tbl_local_pdb.getColumn("Ref Sequence")
677 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
678 for (int row : selectedRows)
680 PDBEntry pdbEntry = (PDBEntry) tbl_local_pdb.getValueAt(row,
682 pdbEntriesToView[count++] = pdbEntry;
683 SequenceI selectedSeq = (SequenceI) tbl_local_pdb.getValueAt(row,
685 selectedSeqsToView.add(selectedSeq);
687 SequenceI[] selectedSeqs = selectedSeqsToView
688 .toArray(new SequenceI[selectedSeqsToView.size()]);
689 launchStructureViewer(ap.getStructureSelectionManager(),
690 pdbEntriesToView, ap, selectedSeqs);
692 else if (currentView == VIEWS_ENTER_ID)
694 SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel
695 .getCmb_assSeq().getSelectedItem()).getSequence();
696 if (userSelectedSeq != null)
698 selectedSequence = userSelectedSeq;
701 String pdbIdStr = txt_search.getText();
702 PDBEntry pdbEntry = selectedSequence.getPDBEntry(pdbIdStr);
703 if (pdbEntry == null)
705 pdbEntry = new PDBEntry();
706 pdbEntry.setId(pdbIdStr);
707 pdbEntry.setType(PDBEntry.Type.PDB);
708 selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
711 PDBEntry[] pdbEntriesToView = new PDBEntry[]
713 launchStructureViewer(ap.getStructureSelectionManager(),
714 pdbEntriesToView, ap, new SequenceI[]
715 { selectedSequence });
717 else if (currentView == VIEWS_FROM_FILE)
719 SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel
720 .getCmb_assSeq().getSelectedItem()).getSequence();
721 if (userSelectedSeq != null)
723 selectedSequence = userSelectedSeq;
725 PDBEntry fileEntry = new AssociatePdbFileWithSeq()
726 .associatePdbWithSeq(selectedPdbFileName,
727 jalview.io.AppletFormatAdapter.FILE,
728 selectedSequence, true, Desktop.instance);
730 launchStructureViewer(ap.getStructureSelectionManager(),
732 { fileEntry }, ap, new SequenceI[]
733 { selectedSequence });
738 private void launchStructureViewer(final StructureSelectionManager ssm,
739 final PDBEntry[] pdbEntriesToView,
740 final AlignmentPanel alignPanel, final SequenceI[] sequences)
742 final StructureViewer sViewer = new StructureViewer(ssm);
743 new Thread(new Runnable()
747 if (pdbEntriesToView.length > 1)
749 ArrayList<SequenceI[]> seqsMap = new ArrayList<SequenceI[]>();
750 for (SequenceI seq : sequences)
752 seqsMap.add(new SequenceI[]
755 SequenceI[][] collatedSeqs = seqsMap.toArray(new SequenceI[0][0]);
756 sViewer.viewStructures(pdbEntriesToView, collatedSeqs, alignPanel);
760 sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
767 * Populates the combo-box used in associating manually fetched structures to
768 * a unique sequence when more than one sequence selection is made.
770 public void populateCmbAssociateSeqOptions(
771 JComboBox<AssociateSeqOptions> cmb_assSeq, JLabel lbl_associateSeq)
773 cmb_assSeq.removeAllItems();
774 cmb_assSeq.addItem(new AssociateSeqOptions("-Select Associated Seq-",
776 lbl_associateSeq.setVisible(false);
777 if (selectedSequences.length > 1)
779 for (SequenceI seq : selectedSequences)
781 cmb_assSeq.addItem(new AssociateSeqOptions(seq));
786 String seqName = selectedSequence.getDisplayId(false);
787 seqName = seqName.length() <= 40 ? seqName : seqName.substring(0, 39);
788 lbl_associateSeq.setText(seqName);
789 lbl_associateSeq.setVisible(true);
790 cmb_assSeq.setVisible(false);
794 public boolean isStructuresDiscovered()
796 return structuresDiscovered;
799 public void setStructuresDiscovered(boolean structuresDiscovered)
801 this.structuresDiscovered = structuresDiscovered;
804 public Collection<PDBResponseSummary> getDiscoveredStructuresSet()
806 return discoveredStructuresSet;
810 protected void txt_search_ActionPerformed()
812 errorWarning.setLength(0);
813 isValidPBDEntry = false;
814 if (txt_search.getText().length() > 0)
816 List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
817 wantedFields.add(PDBDocField.PDB_ID);
818 PDBRestRequest pdbRequest = new PDBRestRequest();
819 pdbRequest.setAllowEmptySeq(false);
820 pdbRequest.setResponseSize(1);
821 pdbRequest.setFieldToSearchBy("(pdb_id:");
822 pdbRequest.setWantedFields(wantedFields);
823 pdbRequest.setSearchTerm(txt_search.getText() + ")");
824 pdbRequest.setAssociatedSequence(selectedSequence);
825 pdbRestCleint = new PDBRestClient();
826 PDBRestResponse resultList;
829 resultList = pdbRestCleint.executeRequest(pdbRequest);
830 } catch (Exception e)
832 errorWarning.append(e.getMessage());
836 validateSelections();
838 if (resultList.getSearchSummary() != null
839 && resultList.getSearchSummary().size() > 0)
841 isValidPBDEntry = true;
844 validateSelections();
848 public void tabRefresh()
850 if (selectedSequences != null)
852 Thread refreshThread = new Thread(new Runnable()
857 fetchStructuresMetaData();
858 filterResultSet(((FilterOption) cmb_filterOption
859 .getSelectedItem()).getValue());
862 refreshThread.start();
866 public class PDBEntryTableModel extends AbstractTableModel
869 { "Ref Sequence", "PDB Id", "Chain", "Type", "File" };
871 private List<CachedPDB> pdbEntries;
873 public PDBEntryTableModel(List<CachedPDB> pdbEntries)
875 this.pdbEntries = new ArrayList<CachedPDB>(pdbEntries);
879 public String getColumnName(int columnIndex)
881 return columns[columnIndex];
885 public int getRowCount()
887 return pdbEntries.size();
891 public int getColumnCount()
893 return columns.length;
897 public boolean isCellEditable(int row, int column)
903 public Object getValueAt(int rowIndex, int columnIndex)
906 CachedPDB entry = pdbEntries.get(rowIndex);
910 value = entry.getSequence();
913 value = entry.getPdbEntry();
916 value = entry.getPdbEntry().getChainCode() == null ? "_" : entry
917 .getPdbEntry().getChainCode();
920 value = entry.getPdbEntry().getType();
923 value = entry.getPdbEntry().getFile();
930 public Class<?> getColumnClass(int columnIndex)
932 return columnIndex == 0 ? SequenceI.class : PDBEntry.class;
935 public CachedPDB getPDBEntryAt(int row)
937 return pdbEntries.get(row);
942 private class CachedPDB
944 private SequenceI sequence;
946 private PDBEntry pdbEntry;
948 public CachedPDB(SequenceI sequence, PDBEntry pdbEntry)
950 this.sequence = sequence;
951 this.pdbEntry = pdbEntry;
954 public SequenceI getSequence()
959 public PDBEntry getPdbEntry()