}\r
AlignmentI alignment = alignmentv.getAlignment();\r
\r
- for (String cbyseq : JmolCommands.getColourBySequenceCommand(ssm, files, sequence, sr, fr, alignment)) {\r
+ for (jalview.structure.StructureMappingcommandSet cpdbbyseq: JmolCommands.getColourBySequenceCommand(ssm, files, sequence, sr, fr, alignment))\r
+ for (String cbyseq : cpdbbyseq.commands) {\r
evalStateCommand(cbyseq);\r
}\r
}\r
import jalview.datamodel.AlignmentI;\r
import jalview.datamodel.SequenceI;\r
import jalview.structure.StructureMapping;\r
+import jalview.structure.StructureMappingcommandSet;\r
import jalview.structure.StructureSelectionManager;\r
import jalview.util.Comparison;\r
\r
import java.awt.Color;\r
import java.util.ArrayList;\r
-\r
/**\r
* Routines for generating Jmol commands for Jalview/Jmol binding\r
* another cruisecontrol test.\r
\r
/**\r
* Jmol utility which constructs the commands to colour chains by the given alignment\r
+ * @returns Object[] { Object[] { <model being coloured>, \r
* \r
*/\r
- public static String[] getColourBySequenceCommand(StructureSelectionManager ssm, String[] files, SequenceI[][] sequence, SequenceRenderer sr, FeatureRenderer fr, AlignmentI alignment)\r
+ public static StructureMappingcommandSet[] getColourBySequenceCommand(StructureSelectionManager ssm, String[] files, SequenceI[][] sequence, SequenceRenderer sr, FeatureRenderer fr, AlignmentI alignment)\r
{\r
- ArrayList<String> str = new ArrayList<String>();\r
- StringBuffer command = new StringBuffer();\r
- \r
+ \r
+ ArrayList<StructureMappingcommandSet> cset = new ArrayList<StructureMappingcommandSet>();\r
+ \r
for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)\r
{\r
StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]);\r
+ StringBuffer command = new StringBuffer();\r
+ StructureMappingcommandSet smc;\r
+ ArrayList<String> str = new ArrayList<String>();\r
\r
if (mapping == null || mapping.length < 1)\r
continue;\r
- \r
+ \r
int lastPos = -1;\r
for (int s = 0; s < sequence[pdbfnum].length; s++)\r
{\r
}\r
}\r
}\r
+ {\r
+ // add final chunk\r
+ str.add(command.toString());\r
+ command.setLength(0);\r
+ }\r
+ // Finally, add the command set ready to be returned.\r
+ cset.add(new StructureMappingcommandSet(JmolCommands.class,files[pdbfnum], str.toArray(new String[str.size()])));\r
+\r
}\r
- {\r
- // add final chunk\r
- str.add(command.toString());\r
- command.setLength(0);\r
- }\r
- return str.toArray(new String[str.size()]);\r
+ return cset.toArray(new StructureMappingcommandSet[cset.size()]);\r
}\r
\r
public static StringBuffer condenseCommand(StringBuffer command, int pos)\r
package jalview.javascript;\r
\r
import java.awt.Color;\r
+import java.util.ArrayList;\r
+\r
import jalview.api.AlignmentViewPanel;\r
import jalview.api.FeatureRenderer;\r
import jalview.api.SequenceRenderer;\r
import jalview.ext.jmol.JmolCommands;\r
import jalview.structure.StructureListener;\r
import jalview.structure.StructureMapping;\r
+import jalview.structure.StructureMappingcommandSet;\r
import jalview.structure.StructureSelectionManager;\r
\r
/**\r
}\r
;\r
\r
- // Form a colour command for the given alignment panel\r
- final String[] colcommands = JmolCommands.getColourBySequenceCommand(\r
+ \r
+ // Form a colour command from the given alignment panel for each distinct structure \r
+ ArrayList<String[]> ccomands=new ArrayList<String[]>();\r
+ ArrayList<String> pdbfn=new ArrayList<String>();\r
+ StructureMappingcommandSet[] colcommands=JmolCommands.getColourBySequenceCommand(\r
ssm, modelSet, sequence, sr, fr,\r
((AlignmentViewPanel) source).getAlignment());\r
- if (colcommands==null)\r
- {\r
- // \r
+ if (colcommands==null) {\r
return;\r
}\r
+ int sz=0;\r
+ for (jalview.structure.StructureMappingcommandSet ccset: colcommands) {\r
+ sz+=ccset.commands.length;\r
+ ccomands.add(ccset.commands);\r
+ pdbfn.add(ccset.mapping);\r
+ }\r
+ \r
String mclass,mhandle;\r
+ String ccomandset[] = new String[sz];\r
+ sz=0;\r
+ for (String[] ccset: ccomands) {\r
+ System.arraycopy(ccset, 0, ccomandset, sz, ccset.length);\r
+ sz+=ccset.length;\r
+ }\r
if (jvlite.isJsMessageSetChanged(mclass="colourstruct",mhandle=((jalview.appletgui.AlignmentPanel) source).av\r
- .getViewId(), colcommands)) {\r
- jvlite.setJsMessageSet(mclass, mhandle , colcommands);\r
+ .getViewId(), ccomandset)) {\r
+ jvlite.setJsMessageSet(mclass, mhandle , ccomandset);\r
// and notify javascript handler\r
String st[] = new String[]\r
{\r
"colourstruct",\r
""\r
+ ((jalview.appletgui.AlignmentPanel) source).av\r
- .getViewId(), ""+colcommands.length, ""+(colcommands[0]!=null ? colcommands[0].length() : 0)};\r
+ .getViewId(), ""+ccomandset.length, jvlite.arrayToSeparatorList(pdbfn.toArray(new String[pdbfn.size()]))\r
+ };\r
try\r
{\r
executeJavascriptFunction(\r
{\r
System.err.println("Couldn't execute callback with "\r
+ _listenerfn + " using args { " + st[0] + ", "\r
- + st[1] + ", " + st[2] + "," + st[3] + "\n");\r
+ + st[1] + ", " + st[2] + "," + st[3]+"}"); // + ","+st[4]+"\n");\r
ex.printStackTrace();\r
\r
}\r
--- /dev/null
+package jalview.structure;
+
+
+/**
+ * holder for script commands generated for a particular structure mapping
+ * @author jimp
+ *
+ */
+public class StructureMappingcommandSet {
+ /**
+ * structure file for which these commands were generated
+ */
+ public String mapping;
+ /**
+ * set of commands
+ */
+ public String[] commands;
+ /**
+ * some object that indicates what the commands can be parsed by (eg JmolCommands.class implies these are Jmol commands)
+ */
+ public Object handledBy;
+ /**
+ * record the originating command generator, the structure mapping involved, and the set of commands to be passed.
+ * @param handledBy
+ * @param files
+ * @param commands
+ */
+ public StructureMappingcommandSet(Object handledBy, String files, String[] commands)
+ {
+ this.mapping=files;
+ this.handledBy=handledBy;
+ this.commands=commands;
+ }
+}