- File outFile = File.createTempFile("jalviewdefattr", ".xml");
- outFile.deleteOnExit();
- defAttrPath = outFile.getPath();
- fos = new FileOutputStream(outFile);
- fos.write("attribute: jalviewclr\n".getBytes());
- } catch (IOException e1)
+ Color colour = (Color) key;
+ String colourCode = ColorUtils.toTkCode(colour);
+ sb.append("; ");
+ sb.append("color ").append(colourCode).append(" ");
+ final AtomSpecModel colourData = colourMap.get(colour);
+ sb.append(getAtomSpec(colourData, binding));
+ }
+ commands.add(sb.toString());
+ return commands;
+ }
+
+ /**
+ * Constructs and returns Chimera commands to set attributes on residues
+ * corresponding to features in Jalview. Attribute names are the Jalview feature
+ * type, with a "jv_" prefix.
+ *
+ * @param ssm
+ * @param files
+ * @param seqs
+ * @param viewPanel
+ * @param binding
+ * @return
+ */
+ public static StructureMappingcommandSet getSetAttributeCommandsForFeatures(
+ AlignmentViewPanel viewPanel, AAStructureBindingModel binding)
+ {
+ StructureSelectionManager ssm = binding.getSsm();
+ String[] files = binding.getStructureFiles();
+ SequenceI[][] seqs = binding.getSequence();
+
+ Map<String, Map<Object, AtomSpecModel>> featureMap = buildFeaturesMap(
+ ssm, files, seqs, viewPanel);
+
+ List<String> commands = buildSetAttributeCommands(featureMap, binding);
+
+ StructureMappingcommandSet cs = new StructureMappingcommandSet(
+ ChimeraCommands.class, null,
+ commands.toArray(new String[commands.size()]));
+
+ return cs;
+ }
+
+ /**
+ * <pre>
+ * Helper method to build a map of
+ * { featureType, { feature value, AtomSpecModel } }
+ * </pre>
+ *
+ * @param ssm
+ * @param files
+ * @param seqs
+ * @param viewPanel
+ * @return
+ */
+ protected static Map<String, Map<Object, AtomSpecModel>> buildFeaturesMap(
+ StructureSelectionManager ssm, String[] files, SequenceI[][] seqs,
+ AlignmentViewPanel viewPanel)
+ {
+ Map<String, Map<Object, AtomSpecModel>> theMap = new LinkedHashMap<>();
+
+ FeatureRenderer fr = viewPanel.getFeatureRenderer();
+ if (fr == null)