X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fgui%2FStructureChooser.java;h=2e3b37ab56bc29b704a629cf60a22b4d5cb97583;hb=fd1c6fd67abdd50ff0d77410d3da9be66be315ce;hp=ff7cdcbad268252d8a60de858c57822ed92db626;hpb=420f8c90293d60c925ec564aa28fcb3ef0136d28;p=jalview.git diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index ff7cdcb..2e3b37a 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -22,19 +22,6 @@ package jalview.gui; -import jalview.datamodel.DBRefEntry; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.SequenceI; -import jalview.jbgui.GStructureChooser; -import jalview.jbgui.PDBDocFieldPreferences; -import jalview.structure.StructureSelectionManager; -import jalview.util.MessageManager; -import jalview.ws.dbsources.PDBRestClient; -import jalview.ws.dbsources.PDBRestClient.PDBDocField; -import jalview.ws.uimodel.PDBRestRequest; -import jalview.ws.uimodel.PDBRestResponse; -import jalview.ws.uimodel.PDBRestResponse.PDBResponseSummary; - import java.awt.event.ItemEvent; import java.util.ArrayList; import java.util.Collection; @@ -49,6 +36,19 @@ import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; +import jalview.datamodel.DBRefEntry; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.SequenceI; +import jalview.jbgui.GStructureChooser; +import jalview.jbgui.PDBDocFieldPreferences; +import jalview.structure.StructureSelectionManager; +import jalview.util.MessageManager; +import jalview.ws.dbsources.PDBRestClient; +import jalview.ws.dbsources.PDBRestClient.PDBDocField; +import jalview.ws.uimodel.PDBRestRequest; +import jalview.ws.uimodel.PDBRestResponse; +import jalview.ws.uimodel.PDBRestResponse.PDBResponseSummary; + /** * Provides the behaviors for the Structure chooser Panel @@ -100,9 +100,13 @@ public class StructureChooser extends GStructureChooser public void run() { long startTime = System.currentTimeMillis(); - String msg = MessageManager.getString("status.fetching_db_refs"); - updateProgressIndicator(msg, startTime); + updateProgressIndicator(MessageManager + .getString("status.loading_cached_pdb_entries"), startTime); loadLocalCachedPDBEntries(); + updateProgressIndicator(null, startTime); + updateProgressIndicator(MessageManager + .getString("status.searching_for_pdb_structures"), + startTime); fetchStructuresMetaData(); populateFilterComboBox(); updateProgressIndicator(null, startTime); @@ -165,7 +169,7 @@ public class StructureChooser extends GStructureChooser && !resultList.getSearchSummary().isEmpty()) { discoveredStructuresSet.addAll(resultList.getSearchSummary()); - updateSequenceDbRef(seq, resultList.getSearchSummary()); + updateSequencePDBEntries(seq, resultList.getSearchSummary()); } } @@ -188,8 +192,8 @@ public class StructureChooser extends GStructureChooser .setTitle("Structure Chooser - Manual association"); if (errors.size() > 0) { - StringBuilder errorMsg = new StringBuilder( - "Operation was unsucessful due to the following: \n"); + StringBuilder errorMsg = new StringBuilder(); + // "Operation was unsucessful due to the following: \n"); for (String error : errors) { errorMsg.append(error).append("\n"); @@ -216,6 +220,7 @@ public class StructureChooser extends GStructureChooser { for (PDBEntry pdbEntry : seq.getDatasetSequence().getPDBId()) { + String chain = pdbEntry.getChainCode() == null ? "_" : pdbEntry .getChainCode(); String[] pdbEntryRowData = new String[] @@ -223,7 +228,10 @@ public class StructureChooser extends GStructureChooser chain, pdbEntry.getType(), pdbEntry.getFile() }; - tableModel.addRow(pdbEntryRowData); + if (pdbEntry.getFile() != null) + { + tableModel.addRow(pdbEntryRowData); + } cachedEntryMap.put(pdbEntry.getId().toLowerCase(), pdbEntry); } @@ -233,7 +241,7 @@ public class StructureChooser extends GStructureChooser } /** - * Update the DBRef entry for a given sequence with values retrieved from + * Update the PDBEntry for a given sequence with values retrieved from * PDBResponseSummary * * @param seq @@ -241,15 +249,20 @@ public class StructureChooser extends GStructureChooser * @param responseSummaries * a collection of PDBResponseSummary */ - public void updateSequenceDbRef(SequenceI seq, + public void updateSequencePDBEntries(SequenceI seq, Collection responseSummaries) { for (PDBResponseSummary response : responseSummaries) { - PDBEntry newEntry = new PDBEntry(); - newEntry.setId(response.getPdbId()); - newEntry.setType(PDBEntry.Type.PDB); - seq.getDatasetSequence().addPDBId(newEntry); + String pdbIdStr = response.getPdbId(); + PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase()); + if (pdbEntry == null) + { + pdbEntry = new PDBEntry(); + pdbEntry.setId(pdbIdStr); + pdbEntry.setType(PDBEntry.Type.PDB); + } + seq.getDatasetSequence().addPDBId(pdbEntry); } } @@ -409,8 +422,7 @@ public class StructureChooser extends GStructureChooser + totalTime + ")"); if (errors.size() > 0) { - StringBuilder errorMsg = new StringBuilder( - "Operation unsucessful due to the following: \n"); + StringBuilder errorMsg = new StringBuilder(); for (String error : errors) { errorMsg.append(error).append("\n"); @@ -552,6 +564,21 @@ public class StructureChooser extends GStructureChooser AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel .getCmb_assSeq().getSelectedItem(); lbl_pdbManualFetchStatus.setIcon(errorImage); + lbl_pdbManualFetchStatus.setToolTipText(""); + if (txt_search.getText().length() > 0) + { + lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip( + true, "No PDB entry found for \'" + txt_search.getText() + + "\'")); + } + + if (errorWarning.length() > 0) + { + lbl_pdbManualFetchStatus.setIcon(warningImage); + lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip( + true, errorWarning.toString())); + } + if (selectedSequences.length == 1 || !assSeqOpt.getName().equalsIgnoreCase( "-Select Associated Seq-")) @@ -560,6 +587,7 @@ public class StructureChooser extends GStructureChooser if (isValidPBDEntry) { btn_view.setEnabled(true); + lbl_pdbManualFetchStatus.setToolTipText(""); lbl_pdbManualFetchStatus.setIcon(goodImage); } } @@ -718,17 +746,17 @@ public class StructureChooser extends GStructureChooser private void launchStructureViewer(StructureSelectionManager ssm, PDBEntry[] pdbEntriesToView, AlignmentPanel alignPanel, - SequenceI[] selectedSequences) + SequenceI[] sequences) { StructureViewer sViewer = new StructureViewer(ssm); if (pdbEntriesToView.length > 1) { - sViewer.viewStructures(alignPanel, pdbEntriesToView, - alignPanel.av.collateForPDB(pdbEntriesToView)); + sViewer.viewStructures(pdbEntriesToView, alignPanel.av.collateForPDB(pdbEntriesToView), + alignPanel); } else { - sViewer.viewStructures(pdbEntriesToView[0], selectedSequences, null, + sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel); } } @@ -780,6 +808,7 @@ public class StructureChooser extends GStructureChooser @Override protected void txt_search_ActionPerformed() { + errorWarning.setLength(0); isValidPBDEntry = false; if (txt_search.getText().length() > 0) { @@ -799,12 +828,10 @@ public class StructureChooser extends GStructureChooser resultList = pdbRestCleint.executeRequest(pdbRequest); } catch (Exception e) { - JOptionPane.showMessageDialog(this, e.getMessage(), - "PDB Web-service Error", JOptionPane.ERROR_MESSAGE); + errorWarning.append(e.getMessage()); return; } finally { - System.out.println(">>>>> executing finally block"); validateSelections(); } if (resultList.getSearchSummary() != null @@ -835,5 +862,4 @@ public class StructureChooser extends GStructureChooser } } - }