From 420f8c90293d60c925ec564aa28fcb3ef0136d28 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Fri, 22 May 2015 12:09:09 +0100 Subject: [PATCH] JAL-1745 improvement to retreive already downloaded pdb structure file from cache --- src/jalview/gui/StructureChooser.java | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) 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 } } + } -- 1.7.10.2