[Chimera-users] Metal Geometry Analysis - per frame

Eric Pettersen pett at cgl.ucsf.edu
Fri Jan 27 14:05:07 PST 2017

Hi Veronica,
	Unfortunately all the metal-coordination analysis is intimately integrated into the Metal Geometry graphical interface, but it is extractable via Python.  The general approach will be to get a handle on the Metal Geometry dialog and then prod it a lot to force it to tell you what you want. :-)  Probably easiest to make the whole thing a Python script and therefore you would play through the trajectory programmatically rather than using the MD Movie dialog.
	Assuming you have your trajectory open already, the first thing to do in the script would be to bring up the Metal Geometry dialog and get a reference to it:

from chimera import dialogs
from MetalGeom.gui import MetalsDialog
dlg = dialogs.find(MetalsDialog.name, create=True)

	The Metal Geometry dialog (dlg) has a “metalsMenu” attribute, which is the menu near the top of the dialog that shows which metal is currently being analyzed.  That menu has a ‘valueMap’ attribute, which is a dictionary that maps from actual metal atom Python instances to the textual name shown for the atom in the menu.  Therefore:

metals = dlg.metalsMenu.valueMap.keys()

	would produce a list of Python metal atoms in the “metals” variable, which will be handy soon. :-)  But you probably first need to write the code that loops through the coords sets.  The Molecule model that contains the metals will have a ‘coordSets’ instance, which is all the coordinate sets, therefore:

mol = metals[0].molecule
for coordSet in mol.coordSets:
	mol.activeCoordSet = coordSet

	will loop though all the Molecule’s coordinate sets.  Within the loop, you would loop through the metals, setting the metals menu as you go, with:

	for metal in metals:

	I don’t know if your “two atom selections” is all the metals in the trajectory or not.  If not, you’d have to write some code to filter the “metals” list down to just the two you want.
	The coordinating atoms are in a table of the dialog whose attribute name is “coordinationTable”.  The attribute of that table that holds those atoms is named “data”.  Therefore you can get the coordinating atoms for the current metal with:

		coordinators = dlg.coordinationTable.data

	You can compute the distance, RMSD, and best geometry for each coordinator with:

		for coordinator in coordinators:
			dist = metal.coord().distance(coordinator.coord())
			rmsd = dlg._avgError[coordinator]
			geom = dlg._bestGeom[coordinator]

	You probably also want to put output to a file in that loop.  Keep in mind that atoms have a __str__ method, and therefore str(a) is a string representation of atom a.


	Eric Pettersen
	UCSF Computer Graphics Lab

> On Jan 27, 2017, at 1:39 AM, Ilkow, Veronica <veronica.ilkow at kcl.ac.uk> wrote:
> Dear All, 
> Is there a way I could include the metal geometry analysis as a per frame script for a MD movie? Ideally I would like to have an output file which lists the best geometry and essentially prints out the co-ordination table for two atom selections per frame. I am trying to figure out how to use the python or chimera per-frame commands to specifically select an atom and then print an output file. Any hints and suggestions on how to do this will be greatly appreciated. 
> Thank you in advance for your help. 
> -Veronica 
> _______________________________________________
> Chimera-users mailing list: Chimera-users at cgl.ucsf.edu
> Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20170127/c13acad8/attachment.html>

More information about the Chimera-users mailing list