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(MessageManager.formatMessage(
184 "label.structure_chooser_no_of_structures",
185 noOfStructuresFound, totalTime));
189 mainFrame.setTitle(MessageManager
190 .getString("label.structure_chooser_manual_association"));
191 if (errors.size() > 0)
193 StringBuilder errorMsg = new StringBuilder();
194 for (String error : errors)
196 errorMsg.append(error).append("\n");
198 JOptionPane.showMessageDialog(this, errorMsg.toString(),
199 MessageManager.getString("label.pdb_web-service_error"),
200 JOptionPane.ERROR_MESSAGE);
205 public void loadLocalCachedPDBEntries()
207 ArrayList<CachedPDB> entries = new ArrayList<CachedPDB>();
208 for (SequenceI seq : selectedSequences)
210 if (seq.getDatasetSequence() != null
211 && seq.getDatasetSequence().getAllPDBEntries() != null)
213 for (PDBEntry pdbEntry : seq.getDatasetSequence().getAllPDBEntries())
215 if (pdbEntry.getFile() != null)
217 entries.add(new CachedPDB(seq, pdbEntry));
223 PDBEntryTableModel tableModelx = new PDBEntryTableModel(entries);
224 tbl_local_pdb.setModel(tableModelx);
229 * Builds a query string for a given sequences using its DBRef entries
232 * the sequences to build a query for
233 * @return the built query string
236 public static String buildQuery(SequenceI seq)
238 HashSet<String> seqRefs = new LinkedHashSet<String>();
239 String seqName = seq.getName();
240 String[] names = seqName.toLowerCase().split("\\|");
241 for (String name : names)
243 // System.out.println("Found name : " + name);
245 if (isValidSeqName(name))
251 if (seq.getAllPDBEntries() != null)
253 for (PDBEntry entry : seq.getAllPDBEntries())
255 if (isValidSeqName(entry.getId()))
257 seqRefs.add(entry.getId());
262 if (seq.getDBRef() != null && seq.getDBRef().length != 0)
265 for (DBRefEntry dbRef : seq.getDBRef())
267 if (isValidSeqName(getDBRefId(dbRef)))
269 seqRefs.add(getDBRefId(dbRef));
279 StringBuilder queryBuilder = new StringBuilder();
280 for (String seqRef : seqRefs)
282 queryBuilder.append("text:").append(seqRef).append(" OR ");
284 int endIndex = queryBuilder.lastIndexOf(" OR ");
286 if (queryBuilder.toString().length() < 6)
290 String query = queryBuilder.toString().substring(5, endIndex);
295 * Ensures sequence ref names are not less than 3 characters and does not
296 * contain a database name
301 public static boolean isValidSeqName(String seqName)
303 // System.out.println("seqName : " + seqName);
304 String ignoreList = "pdb,uniprot,swiss-prot";
305 if (seqName.length() < 3)
309 if (seqName.contains(":"))
313 seqName = seqName.toLowerCase();
314 for (String ignoredEntry : ignoreList.split(","))
316 if (seqName.contains(ignoredEntry))
324 public static String getDBRefId(DBRefEntry dbRef)
326 String ref = dbRef.getAccessionId().replaceAll("GO:", "");
331 * Filters a given list of discovered structures based on supplied argument
333 * @param fieldToFilterBy
334 * the field to filter by
336 public void filterResultSet(final String fieldToFilterBy)
338 Thread filterThread = new Thread(new Runnable()
343 long startTime = System.currentTimeMillis();
344 lbl_loading.setVisible(true);
345 Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
346 .getStructureSummaryFields();
347 Collection<PDBResponseSummary> filteredResponse = new HashSet<PDBResponseSummary>();
348 HashSet<String> errors = new HashSet<String>();
349 for (SequenceI seq : selectedSequences)
351 PDBRestRequest pdbRequest = new PDBRestRequest();
352 pdbRequest.setAllowEmptySeq(false);
353 pdbRequest.setResponseSize(1);
354 pdbRequest.setFieldToSearchBy("(text:");
355 pdbRequest.setFieldToSortBy(fieldToFilterBy,
356 !chk_invertFilter.isSelected());
357 pdbRequest.setSearchTerm(buildQuery(seq) + ")");
358 pdbRequest.setWantedFields(wantedFields);
359 pdbRequest.setAssociatedSequence(seq);
360 pdbRestCleint = new PDBRestClient();
361 PDBRestResponse resultList;
364 resultList = pdbRestCleint.executeRequest(pdbRequest);
365 } catch (Exception e)
368 errors.add(e.getMessage());
371 lastPdbRequest = pdbRequest;
372 if (resultList.getSearchSummary() != null
373 && !resultList.getSearchSummary().isEmpty())
375 filteredResponse.addAll(resultList.getSearchSummary());
379 String totalTime = (System.currentTimeMillis() - startTime)
381 if (!filteredResponse.isEmpty())
383 final int filterResponseCount = filteredResponse.size();
384 Collection<PDBResponseSummary> reorderedStructuresSet = new LinkedHashSet<PDBResponseSummary>();
385 reorderedStructuresSet.addAll(filteredResponse);
386 reorderedStructuresSet.addAll(discoveredStructuresSet);
387 tbl_summary.setModel(PDBRestResponse.getTableModel(
388 lastPdbRequest, reorderedStructuresSet));
390 // Update table selection model here
391 tbl_summary.addRowSelectionInterval(0, filterResponseCount - 1);
392 mainFrame.setTitle(MessageManager.formatMessage(
393 "label.structure_chooser_filter_time",
398 mainFrame.setTitle(MessageManager.formatMessage(
399 "label.structure_chooser_filter_time",
401 if (errors.size() > 0)
403 StringBuilder errorMsg = new StringBuilder();
404 for (String error : errors)
406 errorMsg.append(error).append("\n");
408 JOptionPane.showMessageDialog(null, errorMsg.toString(),
409 MessageManager.getString("label.pdb_web-service_error"),
410 JOptionPane.ERROR_MESSAGE);
414 lbl_loading.setVisible(false);
416 validateSelections();
419 filterThread.start();
423 * Handles action event for btn_pdbFromFile
425 public void pdbFromFile_actionPerformed()
427 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
428 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
429 chooser.setFileView(new jalview.io.JalviewFileView());
430 chooser.setDialogTitle(MessageManager.formatMessage(
431 "label.select_pdb_file_for",
432 selectedSequence.getDisplayId(false)));
433 chooser.setToolTipText(MessageManager.formatMessage(
434 "label.load_pdb_file_associate_with_sequence",
435 selectedSequence.getDisplayId(false)));
437 int value = chooser.showOpenDialog(null);
438 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
440 selectedPdbFileName = chooser.getSelectedFile().getPath();
441 jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedPdbFileName);
442 validateSelections();
447 * Populates the filter combo-box options dynamically depending on discovered
450 protected void populateFilterComboBox()
452 if (isStructuresDiscovered())
454 cmb_filterOption.addItem(new FilterOption("Best Quality",
455 PDBDocField.OVERALL_QUALITY.getCode(), VIEWS_FILTER));
456 cmb_filterOption.addItem(new FilterOption("Best UniProt Coverage",
457 PDBDocField.UNIPROT_COVERAGE.getCode(), VIEWS_FILTER));
458 cmb_filterOption.addItem(new FilterOption("Highest Resolution",
459 PDBDocField.RESOLUTION.getCode(), VIEWS_FILTER));
460 cmb_filterOption.addItem(new FilterOption("Highest Protein Chain",
461 PDBDocField.PROTEIN_CHAIN_COUNT.getCode(), VIEWS_FILTER));
462 cmb_filterOption.addItem(new FilterOption("Highest Bound Molecules",
463 PDBDocField.BOUND_MOLECULE_COUNT.getCode(), VIEWS_FILTER));
464 cmb_filterOption.addItem(new FilterOption("Highest Polymer Residues",
465 PDBDocField.POLYMER_RESIDUE_COUNT.getCode(), VIEWS_FILTER));
467 cmb_filterOption.addItem(new FilterOption("Enter PDB Id", "-",
469 cmb_filterOption.addItem(new FilterOption("From File", "-",
471 cmb_filterOption.addItem(new FilterOption("Cached PDB Entries", "-",
476 * Updates the displayed view based on the selected filter option
478 protected void updateCurrentView()
480 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
482 layout_switchableViews.show(pnl_switchableViews,
483 selectedFilterOpt.getView());
484 String filterTitle = mainFrame.getTitle();
485 mainFrame.setTitle(frameTitle);
486 chk_invertFilter.setVisible(false);
487 if (selectedFilterOpt.getView() == VIEWS_FILTER)
489 mainFrame.setTitle(filterTitle);
490 chk_invertFilter.setVisible(true);
491 filterResultSet(selectedFilterOpt.getValue());
493 else if (selectedFilterOpt.getView() == VIEWS_ENTER_ID
494 || selectedFilterOpt.getView() == VIEWS_FROM_FILE)
496 mainFrame.setTitle(MessageManager
497 .getString("label.structure_chooser_manual_association"));
498 idInputAssSeqPanel.loadCmbAssSeq();
499 fileChooserAssSeqPanel.loadCmbAssSeq();
501 validateSelections();
505 * Validates user selection and activates the view button if all parameters
508 public void validateSelections()
510 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
512 btn_view.setEnabled(false);
513 String currentView = selectedFilterOpt.getView();
514 if (currentView == VIEWS_FILTER)
516 if (tbl_summary.getSelectedRows().length > 0)
518 btn_view.setEnabled(true);
521 else if (currentView == VIEWS_LOCAL_PDB)
523 if (tbl_local_pdb.getSelectedRows().length > 0)
525 btn_view.setEnabled(true);
528 else if (currentView == VIEWS_ENTER_ID)
530 validateAssociationEnterPdb();
532 else if (currentView == VIEWS_FROM_FILE)
534 validateAssociationFromFile();
539 * Validates inputs from the Manual PDB entry panel
541 public void validateAssociationEnterPdb()
543 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel
544 .getCmb_assSeq().getSelectedItem();
545 lbl_pdbManualFetchStatus.setIcon(errorImage);
546 lbl_pdbManualFetchStatus.setToolTipText("");
547 if (txt_search.getText().length() > 0)
549 lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
550 true, MessageManager.formatMessage(
551 "info.no_pdb_entry_found_for",
552 txt_search.getText())));
555 if (errorWarning.length() > 0)
557 lbl_pdbManualFetchStatus.setIcon(warningImage);
558 lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
559 true, errorWarning.toString()));
562 if (selectedSequences.length == 1
563 || !assSeqOpt.getName().equalsIgnoreCase(
564 "-Select Associated Seq-"))
566 txt_search.setEnabled(true);
569 btn_view.setEnabled(true);
570 lbl_pdbManualFetchStatus.setToolTipText("");
571 lbl_pdbManualFetchStatus.setIcon(goodImage);
576 txt_search.setEnabled(false);
577 lbl_pdbManualFetchStatus.setIcon(errorImage);
582 * Validates inputs for the manual PDB file selection options
584 public void validateAssociationFromFile()
586 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel
587 .getCmb_assSeq().getSelectedItem();
588 lbl_fromFileStatus.setIcon(errorImage);
589 if (selectedSequences.length == 1
590 || (assSeqOpt != null && !assSeqOpt.getName().equalsIgnoreCase(
591 "-Select Associated Seq-")))
593 btn_pdbFromFile.setEnabled(true);
594 if (selectedPdbFileName != null && selectedPdbFileName.length() > 0)
596 btn_view.setEnabled(true);
597 lbl_fromFileStatus.setIcon(goodImage);
602 btn_pdbFromFile.setEnabled(false);
603 lbl_fromFileStatus.setIcon(errorImage);
608 public void cmbAssSeqStateChanged()
610 validateSelections();
614 * Handles the state change event for the 'filter' combo-box and 'invert'
618 protected void stateChanged(ItemEvent e)
620 if (e.getSource() instanceof JCheckBox)
626 if (e.getStateChange() == ItemEvent.SELECTED)
635 * Handles action event for btn_ok
638 public void ok_ActionPerformed()
640 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
642 String currentView = selectedFilterOpt.getView();
643 if (currentView == VIEWS_FILTER)
645 int pdbIdColIndex = tbl_summary.getColumn(
646 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
647 int refSeqColIndex = tbl_summary.getColumn("Ref Sequence")
649 int[] selectedRows = tbl_summary.getSelectedRows();
650 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
652 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
653 for (int row : selectedRows)
655 String pdbIdStr = tbl_summary.getValueAt(row, pdbIdColIndex)
657 SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(row,
659 selectedSeqsToView.add(selectedSeq);
660 PDBEntry pdbEntry = selectedSeq.getPDBEntry(pdbIdStr);
661 if (pdbEntry == null)
663 pdbEntry = new PDBEntry();
664 pdbEntry.setId(pdbIdStr);
665 pdbEntry.setType(PDBEntry.Type.PDB);
666 selectedSeq.getDatasetSequence().addPDBId(pdbEntry);
668 pdbEntriesToView[count++] = pdbEntry;
670 SequenceI[] selectedSeqs = selectedSeqsToView
671 .toArray(new SequenceI[selectedSeqsToView.size()]);
672 launchStructureViewer(ap.getStructureSelectionManager(),
673 pdbEntriesToView, ap, selectedSeqs);
675 else if (currentView == VIEWS_LOCAL_PDB)
677 int[] selectedRows = tbl_local_pdb.getSelectedRows();
678 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
680 int pdbIdColIndex = tbl_local_pdb.getColumn(
681 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
682 int refSeqColIndex = tbl_local_pdb.getColumn("Ref Sequence")
684 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
685 for (int row : selectedRows)
687 PDBEntry pdbEntry = (PDBEntry) tbl_local_pdb.getValueAt(row,
689 pdbEntriesToView[count++] = pdbEntry;
690 SequenceI selectedSeq = (SequenceI) tbl_local_pdb.getValueAt(row,
692 selectedSeqsToView.add(selectedSeq);
694 SequenceI[] selectedSeqs = selectedSeqsToView
695 .toArray(new SequenceI[selectedSeqsToView.size()]);
696 launchStructureViewer(ap.getStructureSelectionManager(),
697 pdbEntriesToView, ap, selectedSeqs);
699 else if (currentView == VIEWS_ENTER_ID)
701 SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel
702 .getCmb_assSeq().getSelectedItem()).getSequence();
703 if (userSelectedSeq != null)
705 selectedSequence = userSelectedSeq;
708 String pdbIdStr = txt_search.getText();
709 PDBEntry pdbEntry = selectedSequence.getPDBEntry(pdbIdStr);
710 if (pdbEntry == null)
712 pdbEntry = new PDBEntry();
713 pdbEntry.setId(pdbIdStr);
714 pdbEntry.setType(PDBEntry.Type.PDB);
715 selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
718 PDBEntry[] pdbEntriesToView = new PDBEntry[]
720 launchStructureViewer(ap.getStructureSelectionManager(),
721 pdbEntriesToView, ap, new SequenceI[]
722 { selectedSequence });
724 else if (currentView == VIEWS_FROM_FILE)
726 SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel
727 .getCmb_assSeq().getSelectedItem()).getSequence();
728 if (userSelectedSeq != null)
730 selectedSequence = userSelectedSeq;
732 PDBEntry fileEntry = new AssociatePdbFileWithSeq()
733 .associatePdbWithSeq(selectedPdbFileName,
734 jalview.io.AppletFormatAdapter.FILE,
735 selectedSequence, true, Desktop.instance);
737 launchStructureViewer(ap.getStructureSelectionManager(),
739 { fileEntry }, ap, new SequenceI[]
740 { selectedSequence });
745 private void launchStructureViewer(final StructureSelectionManager ssm,
746 final PDBEntry[] pdbEntriesToView,
747 final AlignmentPanel alignPanel, final SequenceI[] sequences)
749 final StructureViewer sViewer = new StructureViewer(ssm);
750 new Thread(new Runnable()
754 if (pdbEntriesToView.length > 1)
756 ArrayList<SequenceI[]> seqsMap = new ArrayList<SequenceI[]>();
757 for (SequenceI seq : sequences)
759 seqsMap.add(new SequenceI[]
762 SequenceI[][] collatedSeqs = seqsMap.toArray(new SequenceI[0][0]);
763 sViewer.viewStructures(pdbEntriesToView, collatedSeqs, alignPanel);
767 sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
774 * Populates the combo-box used in associating manually fetched structures to
775 * a unique sequence when more than one sequence selection is made.
777 public void populateCmbAssociateSeqOptions(
778 JComboBox<AssociateSeqOptions> cmb_assSeq, JLabel lbl_associateSeq)
780 cmb_assSeq.removeAllItems();
781 cmb_assSeq.addItem(new AssociateSeqOptions("-Select Associated Seq-",
783 lbl_associateSeq.setVisible(false);
784 if (selectedSequences.length > 1)
786 for (SequenceI seq : selectedSequences)
788 cmb_assSeq.addItem(new AssociateSeqOptions(seq));
793 String seqName = selectedSequence.getDisplayId(false);
794 seqName = seqName.length() <= 40 ? seqName : seqName.substring(0, 39);
795 lbl_associateSeq.setText(seqName);
796 lbl_associateSeq.setVisible(true);
797 cmb_assSeq.setVisible(false);
801 public boolean isStructuresDiscovered()
803 return structuresDiscovered;
806 public void setStructuresDiscovered(boolean structuresDiscovered)
808 this.structuresDiscovered = structuresDiscovered;
811 public Collection<PDBResponseSummary> getDiscoveredStructuresSet()
813 return discoveredStructuresSet;
817 protected void txt_search_ActionPerformed()
823 errorWarning.setLength(0);
824 isValidPBDEntry = false;
825 if (txt_search.getText().length() > 0)
827 List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
828 wantedFields.add(PDBDocField.PDB_ID);
829 PDBRestRequest pdbRequest = new PDBRestRequest();
830 pdbRequest.setAllowEmptySeq(false);
831 pdbRequest.setResponseSize(1);
832 pdbRequest.setFieldToSearchBy("(pdb_id:");
833 pdbRequest.setWantedFields(wantedFields);
834 pdbRequest.setSearchTerm(txt_search.getText() + ")");
835 pdbRequest.setAssociatedSequence(selectedSequence);
836 pdbRestCleint = new PDBRestClient();
837 PDBRestResponse resultList;
840 resultList = pdbRestCleint.executeRequest(pdbRequest);
841 } catch (Exception e)
843 errorWarning.append(e.getMessage());
847 validateSelections();
849 if (resultList.getSearchSummary() != null
850 && resultList.getSearchSummary().size() > 0)
852 isValidPBDEntry = true;
855 validateSelections();
861 public void tabRefresh()
863 if (selectedSequences != null)
865 Thread refreshThread = new Thread(new Runnable()
870 fetchStructuresMetaData();
871 filterResultSet(((FilterOption) cmb_filterOption
872 .getSelectedItem()).getValue());
875 refreshThread.start();
879 public class PDBEntryTableModel extends AbstractTableModel
882 { "Ref Sequence", "PDB Id", "Chain", "Type", "File" };
884 private List<CachedPDB> pdbEntries;
886 public PDBEntryTableModel(List<CachedPDB> pdbEntries)
888 this.pdbEntries = new ArrayList<CachedPDB>(pdbEntries);
892 public String getColumnName(int columnIndex)
894 return columns[columnIndex];
898 public int getRowCount()
900 return pdbEntries.size();
904 public int getColumnCount()
906 return columns.length;
910 public boolean isCellEditable(int row, int column)
916 public Object getValueAt(int rowIndex, int columnIndex)
919 CachedPDB entry = pdbEntries.get(rowIndex);
923 value = entry.getSequence();
926 value = entry.getPdbEntry();
929 value = entry.getPdbEntry().getChainCode() == null ? "_" : entry
930 .getPdbEntry().getChainCode();
933 value = entry.getPdbEntry().getType();
936 value = entry.getPdbEntry().getFile();
943 public Class<?> getColumnClass(int columnIndex)
945 return columnIndex == 0 ? SequenceI.class : PDBEntry.class;
948 public CachedPDB getPDBEntryAt(int row)
950 return pdbEntries.get(row);
955 private class CachedPDB
957 private SequenceI sequence;
959 private PDBEntry pdbEntry;
961 public CachedPDB(SequenceI sequence, PDBEntry pdbEntry)
963 this.sequence = sequence;
964 this.pdbEntry = pdbEntry;
967 public SequenceI getSequence()
972 public PDBEntry getPdbEntry()