2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
24 import jalview.datamodel.DBRefEntry;
25 import jalview.datamodel.DBRefSource;
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("(");
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 boolean isPDBRefsFound = false;
238 boolean isUniProtRefsFound = false;
239 StringBuilder queryBuilder = new StringBuilder();
240 HashSet<String> seqRefs = new LinkedHashSet<String>();
242 if (seq.getAllPDBEntries() != null)
244 for (PDBEntry entry : seq.getAllPDBEntries())
246 if (isValidSeqName(entry.getId()))
248 queryBuilder.append(PDBRestClient.PDBDocField.PDB_ID.getCode())
250 .append(entry.getId().toLowerCase())
252 isPDBRefsFound = true;
253 // seqRefs.add(entry.getId());
258 if (seq.getDBRefs() != null && seq.getDBRefs().length != 0)
260 for (DBRefEntry dbRef : seq.getDBRefs())
262 if (isValidSeqName(getDBRefId(dbRef)))
264 if (dbRef.getSource().equalsIgnoreCase(DBRefSource.UNIPROT))
267 .append(PDBRestClient.PDBDocField.UNIPROT_ACCESSION
268 .getCode()).append(":")
269 .append(getDBRefId(dbRef))
272 .append(PDBRestClient.PDBDocField.UNIPROT_ID.getCode())
274 .append(getDBRefId(dbRef)).append(" OR ");
275 isUniProtRefsFound = true;
277 else if (dbRef.getSource().equalsIgnoreCase(DBRefSource.PDB))
280 queryBuilder.append(PDBRestClient.PDBDocField.PDB_ID.getCode())
281 .append(":").append(getDBRefId(dbRef).toLowerCase())
283 isPDBRefsFound = true;
287 seqRefs.add(getDBRefId(dbRef));
293 if (!isPDBRefsFound && !isUniProtRefsFound)
295 String seqName = seq.getName();
296 String[] names = seqName.toLowerCase().split("\\|");
297 for (String name : names)
299 // System.out.println("Found name : " + name);
301 if (isValidSeqName(name))
307 for (String seqRef : seqRefs)
309 queryBuilder.append("text:").append(seqRef).append(" OR ");
313 int endIndex = queryBuilder.lastIndexOf(" OR ");
314 if (queryBuilder.toString().length() < 6)
318 String query = queryBuilder.toString().substring(0, endIndex);
323 * Ensures sequence ref names are not less than 3 characters and does not
324 * contain a database name
329 public static boolean isValidSeqName(String seqName)
331 // System.out.println("seqName : " + seqName);
332 String ignoreList = "pdb,uniprot,swiss-prot";
333 if (seqName.length() < 3)
337 if (seqName.contains(":"))
341 seqName = seqName.toLowerCase();
342 for (String ignoredEntry : ignoreList.split(","))
344 if (seqName.contains(ignoredEntry))
352 public static String getDBRefId(DBRefEntry dbRef)
354 String ref = dbRef.getAccessionId().replaceAll("GO:", "");
359 * Filters a given list of discovered structures based on supplied argument
361 * @param fieldToFilterBy
362 * the field to filter by
364 public void filterResultSet(final String fieldToFilterBy)
366 Thread filterThread = new Thread(new Runnable()
371 long startTime = System.currentTimeMillis();
372 lbl_loading.setVisible(true);
373 Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
374 .getStructureSummaryFields();
375 Collection<PDBResponseSummary> filteredResponse = new HashSet<PDBResponseSummary>();
376 HashSet<String> errors = new HashSet<String>();
377 for (SequenceI seq : selectedSequences)
379 PDBRestRequest pdbRequest = new PDBRestRequest();
380 pdbRequest.setAllowEmptySeq(false);
381 pdbRequest.setResponseSize(1);
382 pdbRequest.setFieldToSearchBy("(");
383 pdbRequest.setFieldToSortBy(fieldToFilterBy,
384 !chk_invertFilter.isSelected());
385 pdbRequest.setSearchTerm(buildQuery(seq) + ")");
386 pdbRequest.setWantedFields(wantedFields);
387 pdbRequest.setAssociatedSequence(seq);
388 pdbRestCleint = new PDBRestClient();
389 PDBRestResponse resultList;
392 resultList = pdbRestCleint.executeRequest(pdbRequest);
393 } catch (Exception e)
396 errors.add(e.getMessage());
399 lastPdbRequest = pdbRequest;
400 if (resultList.getSearchSummary() != null
401 && !resultList.getSearchSummary().isEmpty())
403 filteredResponse.addAll(resultList.getSearchSummary());
407 String totalTime = (System.currentTimeMillis() - startTime)
409 if (!filteredResponse.isEmpty())
411 final int filterResponseCount = filteredResponse.size();
412 Collection<PDBResponseSummary> reorderedStructuresSet = new LinkedHashSet<PDBResponseSummary>();
413 reorderedStructuresSet.addAll(filteredResponse);
414 reorderedStructuresSet.addAll(discoveredStructuresSet);
415 tbl_summary.setModel(PDBRestResponse.getTableModel(
416 lastPdbRequest, reorderedStructuresSet));
418 // Update table selection model here
419 tbl_summary.addRowSelectionInterval(0, filterResponseCount - 1);
420 mainFrame.setTitle(MessageManager.formatMessage(
421 "label.structure_chooser_filter_time", totalTime));
425 mainFrame.setTitle(MessageManager.formatMessage(
426 "label.structure_chooser_filter_time", totalTime));
427 if (errors.size() > 0)
429 StringBuilder errorMsg = new StringBuilder();
430 for (String error : errors)
432 errorMsg.append(error).append("\n");
434 JOptionPane.showMessageDialog(
437 MessageManager.getString("label.pdb_web-service_error"),
438 JOptionPane.ERROR_MESSAGE);
442 lbl_loading.setVisible(false);
444 validateSelections();
447 filterThread.start();
451 * Handles action event for btn_pdbFromFile
454 public void pdbFromFile_actionPerformed()
456 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
457 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
458 chooser.setFileView(new jalview.io.JalviewFileView());
459 chooser.setDialogTitle(MessageManager.formatMessage(
460 "label.select_pdb_file_for",
461 selectedSequence.getDisplayId(false)));
462 chooser.setToolTipText(MessageManager.formatMessage(
463 "label.load_pdb_file_associate_with_sequence",
464 selectedSequence.getDisplayId(false)));
466 int value = chooser.showOpenDialog(null);
467 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
469 selectedPdbFileName = chooser.getSelectedFile().getPath();
470 jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedPdbFileName);
471 validateSelections();
476 * Populates the filter combo-box options dynamically depending on discovered
480 protected void populateFilterComboBox()
482 if (isStructuresDiscovered())
484 cmb_filterOption.addItem(new FilterOption("Best Quality",
485 PDBDocField.OVERALL_QUALITY.getCode(), VIEWS_FILTER));
486 cmb_filterOption.addItem(new FilterOption("Best UniProt Coverage",
487 PDBDocField.UNIPROT_COVERAGE.getCode(), VIEWS_FILTER));
488 cmb_filterOption.addItem(new FilterOption("Highest Resolution",
489 PDBDocField.RESOLUTION.getCode(), VIEWS_FILTER));
490 cmb_filterOption.addItem(new FilterOption("Highest Protein Chain",
491 PDBDocField.PROTEIN_CHAIN_COUNT.getCode(), VIEWS_FILTER));
492 cmb_filterOption.addItem(new FilterOption("Highest Bound Molecules",
493 PDBDocField.BOUND_MOLECULE_COUNT.getCode(), VIEWS_FILTER));
494 cmb_filterOption.addItem(new FilterOption("Highest Polymer Residues",
495 PDBDocField.POLYMER_RESIDUE_COUNT.getCode(), VIEWS_FILTER));
497 cmb_filterOption.addItem(new FilterOption("Enter PDB Id", "-",
499 cmb_filterOption.addItem(new FilterOption("From File", "-",
501 cmb_filterOption.addItem(new FilterOption("Cached PDB Entries", "-",
506 * Updates the displayed view based on the selected filter option
509 protected void updateCurrentView()
511 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
513 layout_switchableViews.show(pnl_switchableViews,
514 selectedFilterOpt.getView());
515 String filterTitle = mainFrame.getTitle();
516 mainFrame.setTitle(frameTitle);
517 chk_invertFilter.setVisible(false);
518 if (selectedFilterOpt.getView() == VIEWS_FILTER)
520 mainFrame.setTitle(filterTitle);
521 chk_invertFilter.setVisible(true);
522 filterResultSet(selectedFilterOpt.getValue());
524 else if (selectedFilterOpt.getView() == VIEWS_ENTER_ID
525 || selectedFilterOpt.getView() == VIEWS_FROM_FILE)
527 mainFrame.setTitle(MessageManager
528 .getString("label.structure_chooser_manual_association"));
529 idInputAssSeqPanel.loadCmbAssSeq();
530 fileChooserAssSeqPanel.loadCmbAssSeq();
532 validateSelections();
536 * Validates user selection and activates the view button if all parameters
540 public void validateSelections()
542 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
544 btn_view.setEnabled(false);
545 String currentView = selectedFilterOpt.getView();
546 if (currentView == VIEWS_FILTER)
548 if (tbl_summary.getSelectedRows().length > 0)
550 btn_view.setEnabled(true);
553 else if (currentView == VIEWS_LOCAL_PDB)
555 if (tbl_local_pdb.getSelectedRows().length > 0)
557 btn_view.setEnabled(true);
560 else if (currentView == VIEWS_ENTER_ID)
562 validateAssociationEnterPdb();
564 else if (currentView == VIEWS_FROM_FILE)
566 validateAssociationFromFile();
571 * Validates inputs from the Manual PDB entry panel
573 public void validateAssociationEnterPdb()
575 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel
576 .getCmb_assSeq().getSelectedItem();
577 lbl_pdbManualFetchStatus.setIcon(errorImage);
578 lbl_pdbManualFetchStatus.setToolTipText("");
579 if (txt_search.getText().length() > 0)
581 lbl_pdbManualFetchStatus
582 .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
583 .formatMessage("info.no_pdb_entry_found_for",
584 txt_search.getText())));
587 if (errorWarning.length() > 0)
589 lbl_pdbManualFetchStatus.setIcon(warningImage);
590 lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(
591 true, errorWarning.toString()));
594 if (selectedSequences.length == 1
595 || !assSeqOpt.getName().equalsIgnoreCase(
596 "-Select Associated Seq-"))
598 txt_search.setEnabled(true);
601 btn_view.setEnabled(true);
602 lbl_pdbManualFetchStatus.setToolTipText("");
603 lbl_pdbManualFetchStatus.setIcon(goodImage);
608 txt_search.setEnabled(false);
609 lbl_pdbManualFetchStatus.setIcon(errorImage);
614 * Validates inputs for the manual PDB file selection options
616 public void validateAssociationFromFile()
618 AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel
619 .getCmb_assSeq().getSelectedItem();
620 lbl_fromFileStatus.setIcon(errorImage);
621 if (selectedSequences.length == 1
622 || (assSeqOpt != null && !assSeqOpt.getName().equalsIgnoreCase(
623 "-Select Associated Seq-")))
625 btn_pdbFromFile.setEnabled(true);
626 if (selectedPdbFileName != null && selectedPdbFileName.length() > 0)
628 btn_view.setEnabled(true);
629 lbl_fromFileStatus.setIcon(goodImage);
634 btn_pdbFromFile.setEnabled(false);
635 lbl_fromFileStatus.setIcon(errorImage);
640 public void cmbAssSeqStateChanged()
642 validateSelections();
646 * Handles the state change event for the 'filter' combo-box and 'invert'
650 protected void stateChanged(ItemEvent e)
652 if (e.getSource() instanceof JCheckBox)
658 if (e.getStateChange() == ItemEvent.SELECTED)
667 * Handles action event for btn_ok
670 public void ok_ActionPerformed()
672 FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
674 String currentView = selectedFilterOpt.getView();
675 if (currentView == VIEWS_FILTER)
677 int pdbIdColIndex = tbl_summary.getColumn(
678 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
679 int refSeqColIndex = tbl_summary.getColumn("Ref Sequence")
681 int[] selectedRows = tbl_summary.getSelectedRows();
682 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
684 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
685 for (int row : selectedRows)
687 String pdbIdStr = tbl_summary.getValueAt(row, pdbIdColIndex)
689 SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(row,
691 selectedSeqsToView.add(selectedSeq);
692 PDBEntry pdbEntry = selectedSeq.getPDBEntry(pdbIdStr);
693 if (pdbEntry == null)
695 pdbEntry = new PDBEntry();
696 pdbEntry.setId(pdbIdStr);
697 pdbEntry.setType(PDBEntry.Type.PDB);
698 selectedSeq.getDatasetSequence().addPDBId(pdbEntry);
700 pdbEntriesToView[count++] = pdbEntry;
702 SequenceI[] selectedSeqs = selectedSeqsToView
703 .toArray(new SequenceI[selectedSeqsToView.size()]);
704 launchStructureViewer(ap.getStructureSelectionManager(),
705 pdbEntriesToView, ap, selectedSeqs);
707 else if (currentView == VIEWS_LOCAL_PDB)
709 int[] selectedRows = tbl_local_pdb.getSelectedRows();
710 PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
712 int pdbIdColIndex = tbl_local_pdb.getColumn(
713 PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex();
714 int refSeqColIndex = tbl_local_pdb.getColumn("Ref Sequence")
716 ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
717 for (int row : selectedRows)
719 PDBEntry pdbEntry = (PDBEntry) tbl_local_pdb.getValueAt(row,
721 pdbEntriesToView[count++] = pdbEntry;
722 SequenceI selectedSeq = (SequenceI) tbl_local_pdb.getValueAt(row,
724 selectedSeqsToView.add(selectedSeq);
726 SequenceI[] selectedSeqs = selectedSeqsToView
727 .toArray(new SequenceI[selectedSeqsToView.size()]);
728 launchStructureViewer(ap.getStructureSelectionManager(),
729 pdbEntriesToView, ap, selectedSeqs);
731 else if (currentView == VIEWS_ENTER_ID)
733 SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel
734 .getCmb_assSeq().getSelectedItem()).getSequence();
735 if (userSelectedSeq != null)
737 selectedSequence = userSelectedSeq;
740 String pdbIdStr = txt_search.getText();
741 PDBEntry pdbEntry = selectedSequence.getPDBEntry(pdbIdStr);
742 if (pdbEntry == null)
744 pdbEntry = new PDBEntry();
745 pdbEntry.setId(pdbIdStr);
746 pdbEntry.setType(PDBEntry.Type.PDB);
747 selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
750 PDBEntry[] pdbEntriesToView = new PDBEntry[] { pdbEntry };
751 launchStructureViewer(ap.getStructureSelectionManager(),
752 pdbEntriesToView, ap, new SequenceI[] { selectedSequence });
754 else if (currentView == VIEWS_FROM_FILE)
756 SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel
757 .getCmb_assSeq().getSelectedItem()).getSequence();
758 if (userSelectedSeq != null)
760 selectedSequence = userSelectedSeq;
762 PDBEntry fileEntry = new AssociatePdbFileWithSeq()
763 .associatePdbWithSeq(selectedPdbFileName,
764 jalview.io.AppletFormatAdapter.FILE,
765 selectedSequence, true, Desktop.instance);
767 launchStructureViewer(ap.getStructureSelectionManager(),
768 new PDBEntry[] { fileEntry }, ap,
769 new SequenceI[] { selectedSequence });
774 private void launchStructureViewer(final StructureSelectionManager ssm,
775 final PDBEntry[] pdbEntriesToView,
776 final AlignmentPanel alignPanel, final SequenceI[] sequences)
778 final StructureViewer sViewer = new StructureViewer(ssm);
780 new jalview.ws.DBRefFetcher(sequences, null, null, null, false)
782 new Thread(new Runnable()
787 if (pdbEntriesToView.length > 1)
789 ArrayList<SequenceI[]> seqsMap = new ArrayList<SequenceI[]>();
790 for (SequenceI seq : sequences)
792 seqsMap.add(new SequenceI[] { seq });
794 SequenceI[][] collatedSeqs = seqsMap.toArray(new SequenceI[0][0]);
795 sViewer.viewStructures(pdbEntriesToView, collatedSeqs, alignPanel);
799 sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
806 * Populates the combo-box used in associating manually fetched structures to
807 * a unique sequence when more than one sequence selection is made.
810 public void populateCmbAssociateSeqOptions(
811 JComboBox<AssociateSeqOptions> cmb_assSeq, JLabel lbl_associateSeq)
813 cmb_assSeq.removeAllItems();
814 cmb_assSeq.addItem(new AssociateSeqOptions("-Select Associated Seq-",
816 lbl_associateSeq.setVisible(false);
817 if (selectedSequences.length > 1)
819 for (SequenceI seq : selectedSequences)
821 cmb_assSeq.addItem(new AssociateSeqOptions(seq));
826 String seqName = selectedSequence.getDisplayId(false);
827 seqName = seqName.length() <= 40 ? seqName : seqName.substring(0, 39);
828 lbl_associateSeq.setText(seqName);
829 lbl_associateSeq.setVisible(true);
830 cmb_assSeq.setVisible(false);
834 public boolean isStructuresDiscovered()
836 return structuresDiscovered;
839 public void setStructuresDiscovered(boolean structuresDiscovered)
841 this.structuresDiscovered = structuresDiscovered;
844 public Collection<PDBResponseSummary> getDiscoveredStructuresSet()
846 return discoveredStructuresSet;
850 protected void txt_search_ActionPerformed()
857 errorWarning.setLength(0);
858 isValidPBDEntry = false;
859 if (txt_search.getText().length() > 0)
861 List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
862 wantedFields.add(PDBDocField.PDB_ID);
863 PDBRestRequest pdbRequest = new PDBRestRequest();
864 pdbRequest.setAllowEmptySeq(false);
865 pdbRequest.setResponseSize(1);
866 pdbRequest.setFieldToSearchBy("(pdb_id:");
867 pdbRequest.setWantedFields(wantedFields);
868 pdbRequest.setSearchTerm(txt_search.getText() + ")");
869 pdbRequest.setAssociatedSequence(selectedSequence);
870 pdbRestCleint = new PDBRestClient();
871 PDBRestResponse resultList;
874 resultList = pdbRestCleint.executeRequest(pdbRequest);
875 } catch (Exception e)
877 errorWarning.append(e.getMessage());
881 validateSelections();
883 if (resultList.getSearchSummary() != null
884 && resultList.getSearchSummary().size() > 0)
886 isValidPBDEntry = true;
889 validateSelections();
895 public void tabRefresh()
897 if (selectedSequences != null)
899 Thread refreshThread = new Thread(new Runnable()
904 fetchStructuresMetaData();
905 filterResultSet(((FilterOption) cmb_filterOption
906 .getSelectedItem()).getValue());
909 refreshThread.start();
913 public class PDBEntryTableModel extends AbstractTableModel
915 String[] columns = { "Ref Sequence", "PDB Id", "Chain", "Type", "File" };
917 private List<CachedPDB> pdbEntries;
919 public PDBEntryTableModel(List<CachedPDB> pdbEntries)
921 this.pdbEntries = new ArrayList<CachedPDB>(pdbEntries);
925 public String getColumnName(int columnIndex)
927 return columns[columnIndex];
931 public int getRowCount()
933 return pdbEntries.size();
937 public int getColumnCount()
939 return columns.length;
943 public boolean isCellEditable(int row, int column)
949 public Object getValueAt(int rowIndex, int columnIndex)
952 CachedPDB entry = pdbEntries.get(rowIndex);
956 value = entry.getSequence();
959 value = entry.getPdbEntry();
962 value = entry.getPdbEntry().getChainCode() == null ? "_" : entry
963 .getPdbEntry().getChainCode();
966 value = entry.getPdbEntry().getType();
969 value = entry.getPdbEntry().getFile();
976 public Class<?> getColumnClass(int columnIndex)
978 return columnIndex == 0 ? SequenceI.class : PDBEntry.class;
981 public CachedPDB getPDBEntryAt(int row)
983 return pdbEntries.get(row);
988 private class CachedPDB
990 private SequenceI sequence;
992 private PDBEntry pdbEntry;
994 public CachedPDB(SequenceI sequence, PDBEntry pdbEntry)
996 this.sequence = sequence;
997 this.pdbEntry = pdbEntry;
1000 public SequenceI getSequence()
1005 public PDBEntry getPdbEntry()