[Chimera-users] Making chimera selections on the fly

Bala subramanian bala.biophysics at gmail.com
Thu Apr 19 06:09:06 PDT 2018

Dear chimera lovers,

Good day. I wrote a small script (pasted below) to monitor the dipole
vector of water molecules during MD. The script was adopted based available

rc('close #1-500')

m = chimera.openModels.list()[0]

wat = m.residues[2449]

com = Point([a.coord() for a in wat.atoms], [a.element.mass for a in

# dipl = Vector() No working, Use numpy instead

dipl = np.array( [0.0,0.0,0.0] )

for atm in wat.atoms:

     #dipl += atm.charge * atm.coord()

     dipl += atm.charge * np.array( atm.coord().data() )

vend = np.array(com) + 5 * dipl

of = open('current.bild','w')

of.write('.color green\n')

of.write('.cone %f %f %f %f %f %f 0.5 \n' %


rc('open current.bild')

Query 1)

The following syntax given in a example doesnt work. What is the chimera
point object indeed, an array or list ?. How to do math operations on point

dipl += atm.charge * a.coord()


TypeError: unsupported operand type(s) for *: 'float' and '_chimera.Point'

Query 2) In my example, I choose a specific water molecule by residue
index. I am looking for some way to select the water (or get list of water
residues) that satisfy a selection on the fly, lets say that water within 3
A from a prot. residue.

In short, how to handle selections inside python script in chimera
framework. I tried to play with chimera.selections but I didnt succeed. Any
example could be of help.

Query 3) Invoke data calculated out of chimera inside a perframe script.

If I have say 100 frames. I can do the dipole vector calculation outside
chimera and write separate “.bild” files, 1.bild, 2.bild, …..n.bild. Then
inside the perframe script, I can invoke a particular .bild fine
corresponding to the frame no. Please help me with an syntax example if
this is possible.

Thanks in advance,

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

More information about the Chimera-users mailing list