<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Bala!<br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div></div></div><div><blockquote type="cite" class=""><div class="">On Apr 19, 2018, at 6:09 AM, Bala subramanian <<a href="mailto:bala.biophysics@gmail.com" class="">bala.biophysics@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class="">


        
        <span class=""></span><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="2" class="">Dear
chimera lovers,</font></p><font size="2" class="">
</font><div style="margin-bottom: 0in; line-height: 100%;" class="">

<br class="webkit-block-placeholder"></div><font size="2" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="2" class="">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 example.</font></p><div style="margin-bottom: 0in; line-height: 100%;" class="">

<br class="webkit-block-placeholder"></div><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">rc('close
#1-500')</font></p><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">m =
chimera.openModels.list()[0]</font></p><font size="1" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">wat
= m.residues[2449]</font></p><font size="1" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">com
= Point([a.coord() for a in wat.atoms], [a.element.mass for a in
wat.atoms])</font></p><font size="1" class="">
</font><div style="margin-bottom: 0in; line-height: 100%;" class="">

<br class="webkit-block-placeholder"></div><font size="1" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">#
dipl = Vector()   No working, Use numpy instead</font></p><font size="1" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">dipl
= np.array( [0.0,0.0,0.0] )</font></p><font size="1" class="">
</font><div style="margin-bottom: 0in; line-height: 100%;" class="">

<br class="webkit-block-placeholder"></div><font size="1" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">for
atm in wat.atoms: <br class=""></font></p><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">     #dipl
+= atm.charge * atm.coord()</font></p><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">     dipl
  += atm.charge * np.array( atm.coord().data() )</font></p><font size="1" class="">
</font><div style="margin-bottom: 0in; line-height: 100%;" class=""><font size="1" class=""></font>

<br class="webkit-block-placeholder"></div><font size="1" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">vend
= np.array(com) + 5 * dipl</font></p><font size="1" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">of =
open('current.bild','w')</font></p><font size="1" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">of.write('.color
green\n')</font></p><font size="1" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">of.write('.cone
%f %f %f  %f %f %f 0.5 \n' %
(com.x,com.y,com.z,vend[0],vend[1],vend[2]))</font></p><font size="1" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">of.close()</font></p><font size="1" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="1" class="">rc('open
current.bild')</font></p><div style="margin-bottom: 0in; line-height: 100%;" class="">

<br class="webkit-block-placeholder"></div><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="2" class="">Query
1)</font></p><font size="2" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="2" class="">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 object.</font></p><font size="2" class="">
</font><div style="margin-bottom: 0in; line-height: 100%;" class=""><font size="2" class=""></font>

<br class="webkit-block-placeholder"></div><font size="2" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="2" class=""> 
dipl += atm.charge * a.coord() 
</font></p><font size="2" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="2" class="">Error:</font></p><font size="2" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="2" class="">TypeError:
unsupported operand type(s) for *: 'float' and '_chimera.Point'</font></p><div class=""><br class=""></div></div></div></div></div></blockquote><div><br class=""></div>Well, Chimera has Point and Vector classes and is kind of pedantic about the allowed operations on them.  So you can multiply a Vector but not a Point.  You can add a Point and a Vector, but not a Point and a Point.  Therefore, for the above to work you would need to convert the Point (what .coord() returns) to a Vector, e.g.:</div><div><br class=""></div><div>dial += atm.charge * a.coord().toVector()</div><div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class=""><font size="2" class="">
</font><div style="margin-bottom: 0in; line-height: 100%;" class=""><span style="font-size: small;" class="">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.</span><font size="2" class=""></font></div><font size="2" class="">
</font><div style="margin-bottom: 0in; line-height: 100%;" class=""><font size="2" class=""></font>

<br class="webkit-block-placeholder"></div><font size="2" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="2" class="">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.</font></p><div class=""><br class=""></div></div></div></div></blockquote><div><br class=""></div>If you select the atoms (by whatever code/commands desired), then you can get a list of them from chimera.selection.currentAtoms()</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class=""><font size="2" class="">
</font><div style="margin-bottom: 0in; line-height: 100%;" class=""><span style="font-size: small;" class="">Query
3) Invoke data calculated out of chimera inside a perframe script.</span><font size="2" class=""></font></div><font size="2" class="">
</font><div style="margin-bottom: 0in; line-height: 100%;" class=""><font size="2" class=""></font>

<br class="webkit-block-placeholder"></div><font size="2" class="">
</font><p style="margin-bottom:0in;line-height:100%" align="justify" class=""><font size="2" class="">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.</font></p></div></div></div></blockquote><br class=""></div><div>We’re talking about MD Movie’s per-frame scripting dialog, right?  In that dialog, make sure â€œInterpret script as” is set to â€œChimera commands”, then your script could be:</div><div><br class=""></div><div>close #25</div><div>open 25 folder_your_bild_files_are_in/<FRAME>.bild</div><div><br class=""></div><div>Literally the string â€œ<FRAME>”.  Chimera will substitute in the actual frame number there.  If you don’t have the frame number to have leading zeroes (e.g. 001 vs. 1) then uncheck the â€œUse leading zeroes…” box near the top of the dialog.  The above first closes any model #25 that is open, then opens your BILD file as model #25.</div><div><br class=""></div><div>—Eric</div><br class=""><div class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>Eric Pettersen</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">  </span>UCSF Computer Graphics Lab</div><div class=""><br class=""></div></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline"></div></div></body></html>