[chimera-dev] Linking Chimera with Tetr

Tom Goddard goddard at sonic.net
Wed Feb 8 10:02:16 PST 2017


Hi Gordon,

  The from_atoms and to_atoms arguments of molecule_copy() are lists of Atom objects, not Molecule objects.

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

So use

	molecule_copy(m0.atoms, m1.atoms)

If the two structures don't have the same number of atoms it will still work but will only copy attributes for atoms with the same atom name, residue number, residue name, chain identifier, as described in the mcopy command documentation:

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

  Tom

  
> On Feb 8, 2017, at 5:57 AM, Gordon Gibb <gordon.gibb at ed.ac.uk> wrote:
> 
> Hi Tom,
> 
> Thanks for your help. Unfortunately I can’t seem to pass the models/molecules into the function:
> 
> For example, if I have two models open such that:
> 
> mollist=chimera.openModels.list()
> m0=mollist[0]
> m1=mollist[1]
> 
> MoleculeCopy.molecule_copy(m0,m1)
> 
> I get the error:
> 
> Traceback (most recent call last):
>   File "<pyshell#42>", line 1, in <module>
>     MoleculeCopy.molecule_copy(m1,m2)
>   File "/Applications/Chimera.app/Contents/Resources/share/MoleculeCopy/mcopy.py", line 18, in molecule_copy
>     matchResidues)
>   File "/Applications/Chimera.app/Contents/Resources/share/MoleculeCopy/mcopy.py", line 42, in match_objects
>     fms = set([a.molecule for a in from_atoms])
> TypeError: '_molecule.Molecule' object is not iterable
> 
> I guess I’m passing in the wrong kind of object into this function. What should I be passing into it?
> 
> Additionally, would I be right in thinking that this copies the visualisation settings atom-for-atom, so I could run into problems if the first molecule has fewer or more atoms in it than the second molecule?
> 
> Thanks,
> 
> Gordon
> 
> 
> -----------------------------------------------
> Dr Gordon P S Gibb
> EPCC, The University of Edinburgh
> 
> 
> 
>> On 7 Feb 2017, at 17:29, Tom Goddard <goddard at sonic.net <mailto:goddard at sonic.net>> wrote:
>> 
>> 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 <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 <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 at cgl.ucsf.edu <mailto:Chimera-dev at cgl.ucsf.edu>
>>> http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev <http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev>
>> 
> 
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20170208/158f3b59/attachment.html>


More information about the Chimera-dev mailing list