X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fext%2Fedu%2Fucsf%2Frbvi%2Fstrucviz2%2FChimeraManager.java;h=a910a5a6df161cde886d8fc7faf5c235ab55078b;hb=1c0b1e8433ecd71423107bce3514b4d929f75df7;hp=85ae718861cb8b967ee7fac9fe48b0f9bd32b244;hpb=fc9edfca9cec3e0a10d3585bb856e0dcd6cff999;p=jalview.git diff --git a/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java b/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java index 85ae718..a910a5a 100644 --- a/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java +++ b/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java @@ -40,6 +40,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -83,7 +84,7 @@ public class ChimeraManager this.structureManager = structureManager; chimera = null; chimeraListenerThread = null; - currentModelsMap = new HashMap(); + currentModelsMap = new HashMap<>(); } @@ -98,7 +99,7 @@ public class ChimeraManager public List getChimeraModels(String modelName, ModelType modelType) { - List models = new ArrayList(); + List models = new ArrayList<>(); for (ChimeraModel model : currentModelsMap.values()) { if (modelName.equals(model.getModelName()) @@ -112,7 +113,7 @@ public class ChimeraManager public Map> getChimeraModelsMap() { - Map> models = new HashMap>(); + Map> models = new HashMap<>(); for (ChimeraModel model : currentModelsMap.values()) { String modelName = model.getModelName(); @@ -393,7 +394,7 @@ public class ChimeraManager public Map getSelectedModels() { - Map selectedModelsMap = new HashMap(); + Map selectedModelsMap = new HashMap<>(); List chimeraReply = sendChimeraCommand( "list selection level molecule", true); if (chimeraReply != null) @@ -418,7 +419,7 @@ public class ChimeraManager */ public List getSelectedResidueSpecs() { - List selectedResidues = new ArrayList(); + List selectedResidues = new ArrayList<>(); List chimeraReply = sendChimeraCommand( "list selection level residue", true); if (chimeraReply != null) @@ -471,7 +472,7 @@ public class ChimeraManager // TODO: [Optional] Handle smiles names in a better way in Chimera? public List getModelList() { - List modelList = new ArrayList(); + List modelList = new ArrayList<>(); List list = sendChimeraCommand("list models type molecule", true); if (list != null) @@ -494,7 +495,7 @@ public class ChimeraManager */ public List getPresets() { - ArrayList presetList = new ArrayList(); + ArrayList presetList = new ArrayList<>(); List output = sendChimeraCommand("preset list", true); if (output != null) { @@ -550,17 +551,19 @@ public class ChimeraManager // iterate over possible paths for starting Chimera for (String chimeraPath : chimeraPaths) { - File path = new File(chimeraPath); - // uncomment the next line to simulate Chimera not installed - // path = new File(chimeraPath + "x"); - if (!path.canExecute()) - { - error += "File '" + path + "' does not exist.\n"; - continue; - } try { - List args = new ArrayList(); + // ensure symbolic links are resolved + chimeraPath = Paths.get(chimeraPath).toRealPath().toString(); + File path = new File(chimeraPath); + // uncomment the next line to simulate Chimera not installed + // path = new File(chimeraPath + "x"); + if (!path.canExecute()) + { + error += "File '" + path + "' does not exist.\n"; + continue; + } + List args = new ArrayList<>(); args.add(chimeraPath); // shows Chimera output window but suppresses REST responses: // args.add("--debug"); @@ -573,7 +576,7 @@ public class ChimeraManager break; } catch (Exception e) { - // Chimera could not be started + // Chimera could not be started using this path error += e.getMessage(); } } @@ -699,7 +702,7 @@ public class ChimeraManager public List getAttrList() { - List attributes = new ArrayList(); + List attributes = new ArrayList<>(); final List reply = sendChimeraCommand("list resattr", true); if (reply != null) { @@ -718,7 +721,7 @@ public class ChimeraManager public Map getAttrValues(String aCommand, ChimeraModel model) { - Map values = new HashMap(); + Map values = new HashMap<>(); final List reply = sendChimeraCommand("list residue spec " + model.toSpec() + " attribute " + aCommand, true); if (reply != null) @@ -818,10 +821,10 @@ public class ChimeraManager protected List sendRestCommand(String command) { String restUrl = "http://127.0.0.1:" + this.chimeraRestPort + "/run"; - List commands = new ArrayList(1); + List commands = new ArrayList<>(1); commands.add(new BasicNameValuePair("command", command)); - List reply = new ArrayList(); + List reply = new ArrayList<>(); BufferedReader response = null; try {