Hi Gordon,

  The Chimera mcopy command copies molecule colors, styles, visibility, position, atom coordinates...

https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/mcopy.html

and the equivalent Python function

from MoleculeCopy import molecule_copy
molecule_copy(from_atoms, to_atoms, settings = 'csv', matchResidues = True)

with code in

chimera/share/MoleculeCopy/mcopy.py

To use this in your Python script I suggest opening the new Tetr model before closing the old one.  (You can open it with the same model id.)  Then use molecule_copy() to copy the display attributes from the old molecule to the new one.  The close the old molecule.

Tom



On Feb 7, 2017, at 8:24 AM, Gordon Gibb wrote:

Dear developers,

I have been working on integrating Tetr (a command line tool to construct/modify molecular systems for use in computational chemistry codes such as CASTEP and CP2K - http://nms.kcl.ac.uk/lev.kantorovitch/codes/lev00/index.html) with Chimera. 

To do this we have written a plugin to Chimera that runs an instance of Tetr in a console, with the user being able to type commands into Tetr. The aim is to have Chimera visualise the system being constructed in Tetr, and to update the visualisation based to changes made in Tetr. 

At present whenever a command is send to Tetr (which in response to this command may re-write a file containing the molecular system), the plugin looks to see if this file has changed, and if so gets Chimera to reload this file and visualise it. As far as I can tell, there isn’t a ‘reload’ option in Chimera, so instead I close the model (saving its xform matrix first), then open the modified file, and set its xform matrix to restore the old viewing angle etc. For example:

#save xform matrix and close model
xf=model.openState.xform
chimera.openModels.close(model)

#open updated file into model number baseId
chimera.openModels.open(filename,baseId=baseId)

#retrieve model from the list of open models
modlist=chimera.openModels.list()
for mod in modlist:
    if mod.id == baseId:
        model=mod
        break

#set the xform matrix
model.openState.xform=xf

What I was wondering was 1) if this is a sensible way to go about things, and 2) if there is a way to retrieve and store visualisation information such as displaying the molecule as ball and stick, wireframe etc such that this can be re-applied to the newly opened model, since at present any visualisation information is not retained when re-opening a file.

Thanks in advance,

Gordon

 
-----------------------------------------------
Dr Gordon P S Gibb
EPCC, The University of Edinburgh



The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
_______________________________________________
Chimera-dev mailing list
Chimera-dev@cgl.ucsf.edu
http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev