From: tcofoegbu Date: Fri, 22 May 2015 11:09:09 +0000 (+0100) Subject: JAL-1745 improvement to retreive already downloaded pdb structure file from cache X-Git-Tag: Release_2_10_0~661^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=420f8c90293d60c925ec564aa28fcb3ef0136d28;p=jalview.git JAL-1745 improvement to retreive already downloaded pdb structure file from cache --- diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 142028a..ff7cdcb 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -224,7 +224,7 @@ public class StructureChooser extends GStructureChooser pdbEntry.getType(), pdbEntry.getFile() }; tableModel.addRow(pdbEntryRowData); - cachedEntryMap.put(seq.getDisplayId(false) + pdbEntry.getId(), + cachedEntryMap.put(pdbEntry.getId().toLowerCase(), pdbEntry); } } @@ -644,12 +644,16 @@ public class StructureChooser extends GStructureChooser { String pdbIdStr = tbl_summary.getValueAt(summaryRow, pdbIdCol) .toString(); - PDBEntry pdbEntry = new PDBEntry(); - pdbEntry.setId(pdbIdStr); - pdbEntry.setType(PDBEntry.Type.PDB); + + PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase()); + if (pdbEntry == null) + { + pdbEntry = new PDBEntry(); + pdbEntry.setId(pdbIdStr); + pdbEntry.setType(PDBEntry.Type.PDB); + } pdbEntriesToView[count++] = pdbEntry; } - launchStructureViewer(ap.getStructureSelectionManager(), pdbEntriesToView, ap, selectedSequences); } @@ -659,7 +663,8 @@ public class StructureChooser extends GStructureChooser int count = 0; for (int row : selectedRows) { - String entryKey = tbl_local_pdb.getValueAt(row, 0).toString() + tbl_local_pdb.getValueAt(row, 1).toString(); + String entryKey = tbl_local_pdb.getValueAt(row, 1).toString() + .toLowerCase(); pdbEntriesToView[count++] = cachedEntryMap.get(entryKey); } launchStructureViewer(ap.getStructureSelectionManager(), @@ -673,9 +678,16 @@ public class StructureChooser extends GStructureChooser { selectedSequence = userSelectedSeq; } - PDBEntry pdbEntry = new PDBEntry(); - pdbEntry.setId(txt_search.getText()); - pdbEntry.setType(PDBEntry.Type.PDB); + + String pdbIdStr = txt_search.getText(); + PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase()); + if (pdbEntry == null) + { + pdbEntry = new PDBEntry(); + pdbEntry.setId(txt_search.getText()); + pdbEntry.setType(PDBEntry.Type.PDB); + } + selectedSequence.getDatasetSequence().addPDBId(pdbEntry); PDBEntry[] pdbEntriesToView = new PDBEntry[] { pdbEntry }; @@ -823,4 +835,5 @@ public class StructureChooser extends GStructureChooser } } + }