JAL-1745 improvement to retreive already downloaded pdb structure file from cache
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 22 May 2015 11:09:09 +0000 (12:09 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 22 May 2015 11:09:09 +0000 (12:09 +0100)
src/jalview/gui/StructureChooser.java

index 142028a..ff7cdcb 100644 (file)
@@ -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
     }
   }
 
+
 }