* setattr #0/A:3-9,14-20,39-43 res jv_strand 'strand' create true ** * @param attributeName * @param attributeValue * @param atomSpecModel * @return */ @Override protected StructureCommandI setAttribute(String attributeName, String attributeValue, AtomSpecModel atomSpecModel) { StringBuilder sb = new StringBuilder(128); sb.append("setattr ").append(getAtomSpec(atomSpecModel, false)); sb.append(" res ").append(attributeName).append(" '") .append(attributeValue).append("'"); sb.append(" create true"); return new StructureCommand(sb.toString()); } @Override public StructureCommandI openCommandFile(String path) { // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/open.html return new StructureCommand("open " + path); } @Override public StructureCommandI saveSession(String filepath) { // https://www.cgl.ucsf.edu/chimerax/docs/user/commands/save.html // note ChimeraX will append ".cxs" to the filepath! return new StructureCommand("save " + filepath + " format session"); } /** * Returns the range(s) formatted as a ChimeraX atomspec, for example *
* #1/A:2-20,30-40/B:10-20|#2/A:12-30
*
* @return
*/
@Override
public String getAtomSpec(AtomSpecModel atomSpec, boolean alphaOnly)
{
StringBuilder sb = new StringBuilder(128);
boolean firstModel = true;
for (String model : atomSpec.getModels())
{
if (!firstModel)
{
sb.append("|");
}
firstModel = false;
appendModel(sb, model, atomSpec);
if (alphaOnly)
{
// TODO @P if RNA - add nucleotide flag to AtomSpecModel?
sb.append("@CA");
}
// todo: is there ChimeraX syntax to exclude altlocs?
}
return sb.toString();
}
/**
* A helper method to append an atomSpec string for atoms in the given model
*
* @param sb
* @param model
* @param atomSpec
*/
protected void appendModel(StringBuilder sb, String model,
AtomSpecModel atomSpec)
{
sb.append("#").append(model);
for (String chain : atomSpec.getChains(model))
{
boolean firstPositionForChain = true;
sb.append("/").append(chain.trim()).append(":");
List