JAL-3949 - refactor logging from jalview.bin.Cache to jalview.bin.Console
[jalview.git] / src / jalview / gui / PymolBindingModel.java
index 538b101..9ef45fb 100644 (file)
@@ -6,7 +6,7 @@ import java.util.List;
 import java.util.Map;
 
 import jalview.api.AlignmentViewPanel;
-import jalview.bin.Cache;
+import jalview.bin.Console;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
 import jalview.ext.pymol.PymolCommands;
@@ -156,7 +156,7 @@ public class PymolBindingModel extends AAStructureBindingModel
     }
     else
     {
-      Cache.log.error("Failed to launch PyMOL!");
+      Console.error("Failed to launch PyMOL!");
     }
     return pymol != null;
   }
@@ -171,6 +171,21 @@ public class PymolBindingModel extends AAStructureBindingModel
      * a second parameter sets the pdbid as the loaded PyMOL object name
      */
     String pdbId = pe.getId();
+    try {
+      String safePDBId = java.net.URLEncoder.encode(pdbId,"UTF-8");
+      pdbId = safePDBId.replace('%', '_');
+      pdbId = pdbId.replace("-", "__");
+      char fc = pdbId.charAt(0);
+      // put an 's' before any numerics
+      if (fc>='0' && fc<='9')
+      {
+        pdbId = 's'+pdbId;
+      }
+//      pdbId.replace('-', 0)
+    } catch (Exception x)
+    {
+      Console.error("Unxpected encoding exception for '"+pdbId+"'",x);
+    }
     cmd.addParameter(pdbId);
 
     executeCommand(cmd, false);