5c86ce26e6fcaded633fe0b8d24aebfc1be452a5
[jalview.git] / src / jalview / gui / StructureChooser.java
1 /*
2
3  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
4  * Copyright (C) 2014 The Jalview Authors
5  * 
6  * This file is part of Jalview.
7  * 
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.
12  *  
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.
17  * 
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.
21  */
22
23 package jalview.gui;
24
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;
37
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.Hashtable;
43 import java.util.LinkedHashSet;
44 import java.util.List;
45
46 import javax.swing.JCheckBox;
47 import javax.swing.JComboBox;
48 import javax.swing.JLabel;
49 import javax.swing.table.DefaultTableModel;
50
51
52 /**
53  * Provides the behaviors for the Structure chooser Panel
54  * 
55  * @author tcnofoegbu
56  *
57  */
58 @SuppressWarnings("serial")
59 public class StructureChooser extends GStructureChooser
60 {
61   private boolean structuresDiscovered = false;
62
63   private SequenceI selectedSequence;
64
65   private SequenceI[] selectedSequences;
66
67   private IProgressIndicator progressIndicator;
68
69   private Collection<PDBResponseSummary> discoveredStructuresSet;
70
71   private PDBRestRequest lastPdbRequest;
72
73   private PDBRestClient pdbRestCleint;
74
75   private String selectedPdbFileName;
76
77   private boolean isValidPBDEntry;
78
79   private static Hashtable<String, PDBEntry> cachedEntryMap;
80
81   public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
82           AlignmentPanel ap)
83   {
84     this.ap = ap;
85     this.selectedSequence = selectedSeq;
86     this.selectedSequences = selectedSeqs;
87     this.progressIndicator = (ap == null) ? null : ap.alignFrame;
88     init();
89   }
90
91   /**
92    * Initializes parameters used by the Structure Chooser Panel
93    */
94   public void init()
95   {
96     Thread discoverPDBStructuresThread = new Thread(new Runnable()
97     {
98       @Override
99       public void run()
100       {
101         long startTime = System.currentTimeMillis();
102         String msg = MessageManager.getString("status.fetching_db_refs");
103         updateProgressIndicator(msg, startTime);
104         loadLocalCachedPDBEntries();
105         fetchStructuresMetaData();
106         populateFilterComboBox();
107         updateProgressIndicator(null, startTime);
108         mainFrame.setVisible(true);
109         updateCurrentView();
110       }
111     });
112     discoverPDBStructuresThread.start();
113   }
114
115   /**
116    * Updates the progress indicator with the specified message
117    * 
118    * @param message
119    *          displayed message for the operation
120    * @param id
121    *          unique handle for this indicator
122    */
123   public void updateProgressIndicator(String message, long id)
124   {
125     if (progressIndicator != null)
126     {
127       progressIndicator.setProgressBar(message, id);
128     }
129   }
130
131   /**
132    * Retrieve meta-data for all the structure(s) for a given sequence(s) in a
133    * selection group
134    */
135   public void fetchStructuresMetaData()
136   {
137     long startTime = System.currentTimeMillis();
138     Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
139             .getStructureSummaryFields();
140
141     discoveredStructuresSet = new LinkedHashSet<PDBResponseSummary>();
142     for (SequenceI seq : selectedSequences)
143     {
144       PDBRestRequest pdbRequest = new PDBRestRequest();
145       pdbRequest.setAllowEmptySeq(false);
146       pdbRequest.setResponseSize(500);
147       pdbRequest.setFieldToSearchBy("(text:");
148       pdbRequest.setWantedFields(wantedFields);
149       pdbRequest.setSearchTerm(buildQuery(seq) + ")");
150       pdbRequest.setAssociatedSequence(seq.getName());
151       pdbRestCleint = new PDBRestClient();
152       PDBRestResponse resultList = pdbRestCleint.executeRequest(pdbRequest);
153       lastPdbRequest = pdbRequest;
154       if (resultList.getSearchSummary() != null
155               && !resultList.getSearchSummary().isEmpty())
156       {
157         discoveredStructuresSet.addAll(resultList.getSearchSummary());
158         updateSequenceDbRef(seq, resultList.getSearchSummary());
159       }
160     }
161
162     int noOfStructuresFound = 0;
163     if (discoveredStructuresSet != null
164             && !discoveredStructuresSet.isEmpty())
165     {
166       tbl_summary.setModel(PDBRestResponse.getTableModel(lastPdbRequest,
167               discoveredStructuresSet));
168       structuresDiscovered = true;
169       noOfStructuresFound = discoveredStructuresSet.size();
170     }
171     String totalTime = (System.currentTimeMillis() - startTime)
172             + " milli secs";
173     mainFrame.setTitle("Structure Chooser - " + noOfStructuresFound
174             + " Found (" + totalTime + ")");
175   }
176
177   public void loadLocalCachedPDBEntries()
178   {
179     DefaultTableModel tableModel = new DefaultTableModel();
180     tableModel.addColumn("Sequence");
181     tableModel.addColumn("PDB Id");
182     tableModel.addColumn("Type");
183     tableModel.addColumn("File");
184     cachedEntryMap = new Hashtable<String, PDBEntry>();
185     for (SequenceI seq : selectedSequences)
186     {
187       if (seq.getDatasetSequence() != null
188               && seq.getDatasetSequence().getPDBId() != null)
189       {
190         for (PDBEntry pdbEntry : seq.getDatasetSequence().getPDBId())
191         {
192           String[] pdbEntryRowData = new String[]
193           { seq.getDisplayId(false), pdbEntry.getId(), pdbEntry.getType(),
194               pdbEntry.getFile() };
195           tableModel.addRow(pdbEntryRowData);
196           cachedEntryMap.put(seq.getDisplayId(false) + pdbEntry.getId(),
197                   pdbEntry);
198         }
199       }
200     }
201     tbl_local_pdb.setModel(tableModel);
202   }
203
204   /**
205    * Update the DBRef entry for a given sequence with values retrieved from
206    * PDBResponseSummary
207    * 
208    * @param seq
209    *          the Sequence to update its DBRef entry
210    * @param responseSummaries
211    *          a collection of PDBResponseSummary
212    */
213   public void updateSequenceDbRef(SequenceI seq,
214           Collection<PDBResponseSummary> responseSummaries)
215   {
216     for (PDBResponseSummary response : responseSummaries)
217     {
218       PDBEntry newEntry = new PDBEntry();
219       newEntry.setId(response.getPdbId());
220       newEntry.setType("PDB");
221       seq.getDatasetSequence().addPDBId(newEntry);
222     }
223   }
224
225   /**
226    * Builds a query string for a given sequences using its DBRef entries
227    * 
228    * @param seq
229    *          the sequences to build a query for
230    * @return the built query string
231    */
232
233   public static String buildQuery(SequenceI seq)
234   {
235     String query = seq.getName();
236     StringBuilder queryBuilder = new StringBuilder();
237     int count = 0;
238
239     if (seq.getPDBId() != null)
240     {
241       for (PDBEntry entry : seq.getPDBId())
242       {
243         queryBuilder.append("text:").append(entry.getId()).append(" OR ");
244       }
245     }
246
247     if (seq.getDBRef() != null && seq.getDBRef().length != 0)
248     {
249       for (DBRefEntry dbRef : seq.getDBRef())
250       {
251         queryBuilder.append("text:")
252                 .append(dbRef.getAccessionId().replaceAll("GO:", ""))
253                 .append(" OR ");
254         ++count;
255         if (count > 10)
256         {
257           break;
258         }
259       }
260       int endIndex = queryBuilder.lastIndexOf(" OR ");
261       query = queryBuilder.toString().substring(5, endIndex);
262     }
263     return query;
264   }
265
266   /**
267    * Filters a given list of discovered structures based on supplied argument
268    * 
269    * @param fieldToFilterBy
270    *          the field to filter by
271    */
272   public void filterResultSet(final String fieldToFilterBy)
273   {
274     Thread filterThread = new Thread(new Runnable()
275     {
276       @Override
277       public void run()
278       {
279         long startTime = System.currentTimeMillis();
280         try
281         {
282           lbl_loading.setVisible(true);
283
284           Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
285                   .getStructureSummaryFields();
286           Collection<PDBResponseSummary> filteredResponse = new HashSet<PDBResponseSummary>();
287           for (SequenceI seq : selectedSequences)
288           {
289             PDBRestRequest pdbRequest = new PDBRestRequest();
290             pdbRequest.setAllowEmptySeq(false);
291             pdbRequest.setResponseSize(1);
292             pdbRequest.setFieldToSearchBy("(text:");
293             pdbRequest.setFieldToSortBy(fieldToFilterBy,
294                     !chk_invertFilter.isSelected());
295             pdbRequest.setSearchTerm(buildQuery(seq) + ")");
296             pdbRequest.setWantedFields(wantedFields);
297             pdbRequest.setAssociatedSequence(seq.getName());
298             pdbRestCleint = new PDBRestClient();
299             PDBRestResponse resultList = pdbRestCleint
300                     .executeRequest(pdbRequest);
301             lastPdbRequest = pdbRequest;
302             if (resultList.getSearchSummary() != null
303                     && !resultList.getSearchSummary().isEmpty())
304             {
305               filteredResponse.addAll(resultList.getSearchSummary());
306             }
307           }
308
309           if (!filteredResponse.isEmpty())
310           {
311             final int filterResponseCount = filteredResponse.size();
312             Collection<PDBResponseSummary> reorderedStructuresSet = new LinkedHashSet<PDBResponseSummary>();
313             reorderedStructuresSet.addAll(filteredResponse);
314             reorderedStructuresSet.addAll(discoveredStructuresSet);
315             tbl_summary.setModel(PDBRestResponse.getTableModel(
316                     lastPdbRequest, reorderedStructuresSet));
317
318             // Update table selection model here
319             tbl_summary.addRowSelectionInterval(0, filterResponseCount - 1);
320
321           }
322
323           lbl_loading.setVisible(false);
324           String totalTime = (System.currentTimeMillis() - startTime)
325                   + " milli secs";
326           mainFrame.setTitle("Structure Chooser - Filter time ("
327                   + totalTime + ")");
328
329           validateSelections();
330         } catch (Exception e)
331         {
332           e.printStackTrace();
333         }
334       }
335     });
336     filterThread.start();
337   }
338
339
340   /**
341    * Handles action event for btn_pdbFromFile
342    */
343   public void pdbFromFile_actionPerformed()
344   {
345     jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
346             jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
347     chooser.setFileView(new jalview.io.JalviewFileView());
348     chooser.setDialogTitle(MessageManager.formatMessage(
349             "label.select_pdb_file_for", new String[]
350             { selectedSequence.getDisplayId(false) }));
351     chooser.setToolTipText(MessageManager.formatMessage(
352             "label.load_pdb_file_associate_with_sequence", new String[]
353             { selectedSequence.getDisplayId(false) }));
354
355     int value = chooser.showOpenDialog(null);
356     if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
357     {
358       selectedPdbFileName = chooser.getSelectedFile().getPath();
359       jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedPdbFileName);
360       validateSelections();
361     }
362   }
363
364   /**
365    * Populates the filter combo-box options dynamically depending on discovered
366    * structures
367    */
368   protected void populateFilterComboBox()
369   {
370     if (isStructuresDiscovered())
371     {
372       cmb_filterOption.addItem(new FilterOption("Best Quality",
373               PDBDocField.OVERALL_QUALITY.getCode(), VIEWS_FILTER));
374       cmb_filterOption.addItem(new FilterOption("Best UniProt Coverage",
375               PDBDocField.UNIPROT_COVERAGE.getCode(), VIEWS_FILTER));
376       cmb_filterOption.addItem(new FilterOption("Highest Resolution",
377               PDBDocField.RESOLUTION.getCode(), VIEWS_FILTER));
378       cmb_filterOption.addItem(new FilterOption("Highest Protein Chain",
379               PDBDocField.PROTEIN_CHAIN_COUNT.getCode(), VIEWS_FILTER));
380       cmb_filterOption.addItem(new FilterOption("Highest Bound Molecules",
381               PDBDocField.BOUND_MOLECULE_COUNT.getCode(), VIEWS_FILTER));
382       cmb_filterOption.addItem(new FilterOption("Highest Polymer Residues",
383               PDBDocField.POLYMER_RESIDUE_COUNT.getCode(), VIEWS_FILTER));
384     }
385     cmb_filterOption.addItem(new FilterOption("Enter PDB Id", "-",
386             VIEWS_ENTER_ID));
387     cmb_filterOption.addItem(new FilterOption("From File", "-",
388             VIEWS_FROM_FILE));
389     cmb_filterOption.addItem(new FilterOption("Cached PDB Entries", "-",
390             VIEWS_LOCAL_PDB));
391   }
392
393   /**
394    * Updates the displayed view based on the selected filter option
395    */
396   protected void updateCurrentView()
397   {
398     FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
399             .getSelectedItem());
400     layout_switchableViews.show(pnl_switchableViews,
401             selectedFilterOpt.getView());
402     String filterTitle = mainFrame.getTitle();
403     mainFrame.setTitle(frameTitle);
404     chk_invertFilter.setVisible(false);
405     if (selectedFilterOpt.getView() == VIEWS_FILTER)
406     {
407       mainFrame.setTitle(filterTitle);
408       chk_invertFilter.setVisible(true);
409       filterResultSet(selectedFilterOpt.getValue());
410     }
411     else if (selectedFilterOpt.getView() == VIEWS_ENTER_ID
412             || selectedFilterOpt.getView() == VIEWS_FROM_FILE)
413     {
414       idInputAssSeqPanel.loadCmbAssSeq();
415       fileChooserAssSeqPanel.loadCmbAssSeq();
416     }
417     validateSelections();
418   }
419
420   /**
421    * Validates user selection and activates the view button if all parameters
422    * are correct
423    */
424   public void validateSelections()
425   {
426     FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
427             .getSelectedItem());
428     btn_view.setEnabled(false);
429     String currentView = selectedFilterOpt.getView();
430     if (currentView == VIEWS_FILTER)
431     {
432       if (tbl_summary.getSelectedRows().length > 0)
433       {
434         btn_view.setEnabled(true);
435       }
436     }
437     else if (currentView == VIEWS_LOCAL_PDB)
438     {
439       if (tbl_local_pdb.getSelectedRows().length > 0)
440       {
441         btn_view.setEnabled(true);
442       }
443     }
444     else if (currentView == VIEWS_ENTER_ID)
445     {
446       validateAssociationEnterPdb();
447     }
448     else if (currentView == VIEWS_FROM_FILE)
449     {
450       validateAssociationFromFile();
451     }
452   }
453
454   /**
455    * Validates inputs from the Manual PDB entry panel
456    */
457   public void validateAssociationEnterPdb()
458   {
459     AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel
460             .getCmb_assSeq().getSelectedItem();
461     lbl_pdbManualFetchStatus.setIcon(errorImage);
462     if (selectedSequences.length == 1
463             || !assSeqOpt.getName().equalsIgnoreCase(
464                     "-Select Associated Seq-"))
465     {
466       txt_search.setEnabled(true);
467       if (isValidPBDEntry)
468       {
469         btn_view.setEnabled(true);
470         lbl_pdbManualFetchStatus.setIcon(goodImage);
471       }
472     }
473     else
474     {
475       txt_search.setEnabled(false);
476       lbl_pdbManualFetchStatus.setIcon(errorImage);
477     }
478   }
479
480   /**
481    * Validates inputs for the manual PDB file selection options
482    */
483   public void validateAssociationFromFile()
484   {
485     AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel
486             .getCmb_assSeq().getSelectedItem();
487     lbl_fromFileStatus.setIcon(errorImage);
488     if (selectedSequences.length == 1
489             || (assSeqOpt != null
490             && !assSeqOpt.getName().equalsIgnoreCase(
491                     "-Select Associated Seq-")))
492     {
493       btn_pdbFromFile.setEnabled(true);
494       if (selectedPdbFileName != null && selectedPdbFileName.length() > 0)
495       {
496         btn_view.setEnabled(true);
497         lbl_fromFileStatus.setIcon(goodImage);
498       }
499     }
500     else
501     {
502       btn_pdbFromFile.setEnabled(false);
503       lbl_fromFileStatus.setIcon(errorImage);
504     }
505   }
506
507   @Override
508   public void cmbAssSeqStateChanged()
509   {
510     validateSelections();
511   }
512
513   /**
514    * Handles the state change event for the 'filter' combo-box and 'invert'
515    * check-box
516    */
517   @Override
518   protected void stateChanged(ItemEvent e)
519   {
520     if (e.getSource() instanceof JCheckBox)
521     {
522       updateCurrentView();
523     }
524     else
525     {
526       if (e.getStateChange() == ItemEvent.SELECTED)
527       {
528         updateCurrentView();
529       }
530     }
531
532   }
533
534   /**
535    * Handles action event for btn_ok
536    */
537   @Override
538   public void ok_ActionPerformed()
539   {
540     FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
541             .getSelectedItem());
542     String currentView = selectedFilterOpt.getView();
543     if (currentView == VIEWS_FILTER)
544     {
545       int pdbIdCol = PDBRestClient.getPDBIdColumIndex(
546               lastPdbRequest.getWantedFields(), true);
547       int[] selectedRows = tbl_summary.getSelectedRows();
548       PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
549       int count = 0;
550       for (int summaryRow : selectedRows)
551       {
552         String pdbIdStr = tbl_summary.getValueAt(summaryRow, pdbIdCol)
553                 .toString();
554         PDBEntry pdbEntry = new PDBEntry();
555         pdbEntry.setId(pdbIdStr);
556         pdbEntry.setType("PDB");
557         pdbEntriesToView[count++] = pdbEntry;
558       }
559
560       launchStructureViewer(ap.getStructureSelectionManager(),
561               pdbEntriesToView, ap, selectedSequences);
562     }
563     else if(currentView == VIEWS_LOCAL_PDB){
564       int[] selectedRows = tbl_local_pdb.getSelectedRows();
565       PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
566       int count = 0;
567       for (int row : selectedRows)
568       {
569          String entryKey = tbl_local_pdb.getValueAt(row, 0).toString() + tbl_local_pdb.getValueAt(row, 1).toString();
570         pdbEntriesToView[count++] = cachedEntryMap.get(entryKey);
571       }
572       launchStructureViewer(ap.getStructureSelectionManager(),
573               pdbEntriesToView, ap, selectedSequences);
574     }
575     else if (currentView == VIEWS_ENTER_ID)
576     {
577       SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel
578               .getCmb_assSeq().getSelectedItem()).getSequence();
579       if (userSelectedSeq != null)
580       {
581         selectedSequence = userSelectedSeq;
582       }
583       PDBEntry pdbEntry = new PDBEntry();
584       pdbEntry.setId(txt_search.getText());
585       pdbEntry.setType("PDB");
586       selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
587       PDBEntry[] pdbEntriesToView = new PDBEntry[]
588       { pdbEntry };
589       launchStructureViewer(ap.getStructureSelectionManager(),
590               pdbEntriesToView, ap, new SequenceI[]
591               { selectedSequence });
592     }
593     else if (currentView == VIEWS_FROM_FILE)
594     {
595       SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel
596               .getCmb_assSeq().getSelectedItem()).getSequence();
597       if (userSelectedSeq != null)
598       {
599         selectedSequence = userSelectedSeq;
600       }
601       PDBEntry fileEntry = new AssociatePdbFileWithSeq()
602               .associatePdbWithSeq(
603               selectedPdbFileName, jalview.io.AppletFormatAdapter.FILE,
604               selectedSequence, true, Desktop.instance);
605
606       launchStructureViewer(ap.getStructureSelectionManager(),
607               new PDBEntry[]
608               { fileEntry }, ap, new SequenceI[]
609               { selectedSequence });
610     }
611     mainFrame.dispose();
612   }
613
614   private void launchStructureViewer(StructureSelectionManager ssm,
615           PDBEntry[] pdbEntriesToView, AlignmentPanel alignPanel,
616           SequenceI[] selectedSequences)
617   {
618     StructureViewer sViewer = new StructureViewer(ssm);
619     if (pdbEntriesToView.length > 1)
620     {
621       sViewer.viewStructures(alignPanel, pdbEntriesToView,
622               alignPanel.av.collateForPDB(pdbEntriesToView));
623     }
624     else
625     {
626       sViewer.viewStructures(pdbEntriesToView[0], selectedSequences, null,
627               alignPanel);
628     }
629   }
630
631   /**
632    * Populates the combo-box used in associating manually fetched structures to
633    * a unique sequence when more than one sequence selection is made.
634    */
635   public void populateCmbAssociateSeqOptions(
636           JComboBox<AssociateSeqOptions> cmb_assSeq, JLabel lbl_associateSeq)
637   {
638     cmb_assSeq.removeAllItems();
639     cmb_assSeq.addItem(new AssociateSeqOptions("-Select Associated Seq-",
640             null));
641     // cmb_assSeq.addItem(new AssociateSeqOptions("Auto Detect", null));
642     lbl_associateSeq.setVisible(false);
643     if (selectedSequences.length > 1)
644     {
645       for (SequenceI seq : selectedSequences)
646       {
647         cmb_assSeq.addItem(new AssociateSeqOptions(seq));
648       }
649     }
650     else
651     {
652       String seqName = selectedSequence.getDisplayId(false);
653       seqName = seqName.length() <= 40 ? seqName : seqName.substring(0, 39);
654       lbl_associateSeq.setText(seqName);
655       lbl_associateSeq.setVisible(true);
656       cmb_assSeq.setVisible(false);
657     }
658   }
659
660   public boolean isStructuresDiscovered()
661   {
662     return structuresDiscovered;
663   }
664
665   public void setStructuresDiscovered(boolean structuresDiscovered)
666   {
667     this.structuresDiscovered = structuresDiscovered;
668   }
669
670   public Collection<PDBResponseSummary> getDiscoveredStructuresSet()
671   {
672     return discoveredStructuresSet;
673   }
674
675   @Override
676   protected void txt_search_ActionPerformed()
677   {
678     isValidPBDEntry = false;
679     if (txt_search.getText().length() > 0)
680     {
681       List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
682       wantedFields.add(PDBDocField.PDB_ID);
683       PDBRestRequest pdbRequest = new PDBRestRequest();
684       pdbRequest.setAllowEmptySeq(false);
685       pdbRequest.setResponseSize(1);
686       pdbRequest.setFieldToSearchBy("(pdb_id:");
687       pdbRequest.setWantedFields(wantedFields);
688       pdbRequest.setSearchTerm(txt_search.getText() + ")");
689       pdbRequest.setAssociatedSequence(selectedSequence.getName());
690       pdbRestCleint = new PDBRestClient();
691       PDBRestResponse resultList = pdbRestCleint.executeRequest(pdbRequest);
692       if (resultList.getSearchSummary() != null
693               && resultList.getSearchSummary().size() > 0)
694       {
695         isValidPBDEntry = true;
696       }
697     }
698     validateSelections();
699   }
700
701   @Override
702   public void tabRefresh()
703   {
704     if (selectedSequences != null)
705     {
706       Thread refreshThread = new Thread(new Runnable()
707       {
708         @Override
709         public void run()
710         {
711           fetchStructuresMetaData();
712           filterResultSet(((FilterOption) cmb_filterOption
713                   .getSelectedItem()).getValue());
714         }
715       });
716       refreshThread.start();
717     }
718   }
719
720 }