[Chimera-users] python script

Eric Pettersen pett at cgl.ucsf.edu
Fri Jun 8 16:27:23 PDT 2018

Hi Hernando,
	Perhaps runCommand should return a value but it doesn’t.  The reasoning there was that the argument to runCommand could be anything, including several commands separated by semi-colons, so in some cases it’s confusing what the return value should be.  In any case that ship has sailed and you have to do something else to get the value.  In most cases it calling the underlying function that performs the command and using it’s return value, but looking at the code that implements the “measure center” command I can see that it doesn’t return anything either.
	So in the particular case of the example you provided, I can see two options for getting the value:

Option 1)
	atoms = chimera.selection.OSLSelection(“#0:.A at CA”).vertices()
	center = chimera.Point([a.coord() for a in atoms])
	x, y, z = center.data()

Option 2)
	rc(“sel #0:.A at CA”)
	center = chimera.Point([a.coord() for a in chimera.selection.currentAtoms()])
	x, y, z = center.data()

I hope this helps.


	Eric Pettersen
	UCSF Computer Graphics Lab

> On Jun 8, 2018, at 11:10 AM, Hernando J Sosa <hernando.sosa at einstein.yu.edu> wrote:
> Dear Chimera,
> Is it possible to assign the result of running a chimera command in python to a string or something else?  E.g doing something like:
> from chimera import runCommand as rc
> myresult  = rc('measure center  #0:.A at CA')
> And then using the  myresults somewhere else in the script after parsing for the relevant values?
> Maybe there is a n easier way to accomplish this?
> Thanks
> Hernando
> _______________________________________________
> Chimera-users mailing list: Chimera-users at cgl.ucsf.edu <mailto:Chimera-users at cgl.ucsf.edu>
> Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users <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/20180608/b0a9a45e/attachment.html>

More information about the Chimera-users mailing list