From: gmungoc Date: Fri, 13 Dec 2019 16:12:31 +0000 (+0000) Subject: JAL-2422 write Jalview features to ChimeraX via command file X-Git-Tag: Release_2_11_2_0~37^2~44 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0d103d35395f8b6de4fd993f34539a66554d7c6c;p=jalview.git JAL-2422 write Jalview features to ChimeraX via command file --- diff --git a/src/jalview/ext/rbvi/chimera/ChimeraCommands.java b/src/jalview/ext/rbvi/chimera/ChimeraCommands.java index 01458a8..b35faa8 100644 --- a/src/jalview/ext/rbvi/chimera/ChimeraCommands.java +++ b/src/jalview/ext/rbvi/chimera/ChimeraCommands.java @@ -350,7 +350,7 @@ public class ChimeraCommands AlignmentViewPanel viewPanel, boolean isChimeraX) { Map> featureMap = buildFeaturesMap( - ssm, files, seqs, viewPanel); + ssm, files, seqs, viewPanel, isChimeraX); List commands = buildSetAttributeCommands(featureMap, isChimeraX); @@ -372,11 +372,12 @@ public class ChimeraCommands * @param files * @param seqs * @param viewPanel + * @param isChimeraX * @return */ protected static Map> buildFeaturesMap( StructureSelectionManager ssm, String[] files, SequenceI[][] seqs, - AlignmentViewPanel viewPanel) + AlignmentViewPanel viewPanel, boolean isChimeraX) { Map> theMap = new LinkedHashMap<>(); @@ -414,6 +415,7 @@ public class ChimeraCommands AlignmentI alignment = viewPanel.getAlignment(); for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { + final int modelNumber = pdbfnum + (isChimeraX ? 1 : 0); StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]); if (mapping == null || mapping.length < 1) @@ -437,12 +439,12 @@ public class ChimeraCommands if (!visibleFeatures.isEmpty()) { scanSequenceFeatures(visibleFeatures, structureMapping, seq, - theMap, pdbfnum); + theMap, modelNumber); } if (showLinkedFeatures) { scanComplementFeatures(complementRenderer, structureMapping, - seq, theMap, pdbfnum); + seq, theMap, modelNumber); } } } @@ -626,14 +628,25 @@ public class ChimeraCommands * add a command to set the attribute on the mapped residues * Put values in single quotes, encoding any embedded single quotes */ + AtomSpecModel atomSpecModel = values.get(value); StringBuilder sb = new StringBuilder(128); + sb.append("setattr "); + if (isChimeraX) + { + sb.append(atomSpecModel.getAtomSpecX()); + } String featureValue = value.toString(); featureValue = featureValue.replaceAll("\\'", "'"); - sb.append("setattr r ").append(attributeName).append(" '") + sb.append(" res ").append(attributeName).append(" '") .append(featureValue).append("' "); - AtomSpecModel atomSpecModel = values.get(value); - sb.append(isChimeraX ? atomSpecModel.getAtomSpecX() - : atomSpecModel.getAtomSpec()); + if (isChimeraX) + { + sb.append(" create true"); + } + else + { + sb.append(atomSpecModel.getAtomSpec()); + } commands.add(sb.toString()); } } diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index 47ada53..c16ce13 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -1154,9 +1154,10 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel */ protected void sendCommandsByFile(String[] commands) { + boolean toChimeraX = viewer.isChimeraX(); try { - File tmp = File.createTempFile("chim", ".com"); + File tmp = File.createTempFile("chim", toChimeraX ? ".cxc" : ".com"); tmp.deleteOnExit(); PrintWriter out = new PrintWriter(new FileOutputStream(tmp)); for (String command : commands) @@ -1166,7 +1167,8 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel out.flush(); out.close(); String path = tmp.getAbsolutePath(); - sendAsynchronousCommand("open cmd:" + path, null); + String command = "open " + (toChimeraX ? "" : "cmd:") + path; + sendAsynchronousCommand(command, null); } catch (IOException e) { System.err.println("Sending commands to Chimera via file failed with "