<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Eric,<div><br></div><div>Thanks so much for the help. I was able to quickly get the basic functionality </div><div>I wanted, and I would not have gotten there without your guidance. In the process</div><div>I ran into a few small issues that come simply from not yet understanding the overall </div><div>structure of the data and its representation, and its interaction in the python interface. </div><div>But that is coming together. Notably, I needed to find other ways to select the</div><div>bonds that would have be affected by the fading and also how to control element colors</div><div>in the context of applying this to C-C bonds in a simple hydrocarbon. Evidentially, an arbitrary color </div><div>gets applied to the model as a whole when it comes up, and then when fading the bonds </div><div>they would sometimes fade to reveal that underlying solid color. But I have sorted those things out.</div><div>The Python interface is very cool.</div><div><br></div><div>Thanks again.</div><div><br></div><div>Cheers</div><div>Kersey</div><div><br></div><div><div>On May 29, 2012, at 3:08 PM, Eric Pettersen wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On May 29, 2012, at 12:29 PM, Kersey Black wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi,<br><br>Very recent to Chimera. Trying to set the transparency of a bond<br>to be a function of bond length in each frame of a trajectory. <br>I have figured out how to define a transparent color, and <br>now I am imaging the solution might use something like range color<br>to vary the blending of the opaque version of the color and the <br>fully transparent version based on distance, with the distance being <br>determined as a per frame attribute of those atoms, but someplace around <br>here I am lost. Any hints, links or suggestions would be very much <br>appreciated. </div></blockquote><br></div><div>Hi Kersey,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>This is doable but you have to resort to Python, and even then it's tricky. The issues are:</div><div><br></div><div>1) By default, bonds are colored in "halfbond" mode, where each half of the bond is colored the same as the corresponding endpoint atom.</div><div>2) There is no command to set only the transparency of a bond. There is a 'bondcolor' command which sets the red, green, and blue components as well (and also takes the bond out of halfbond mode). The 'transparency' command works on atoms, not bonds (but bonds in halfbond mode "inherit" the transparency changes of their endpoint atoms).</div><div>3) In Python, changing the transparency component of a color object will affect every atom/bond/molecule using that color object, so the bonds you want to vary the transparency of will have to have unique color objects assigned to them.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>So, as best I can determine the general plan of action would be:</div><div><br></div><div>1) Select the bond or bonds you want to do this for using whatever means you like.</div><div>2) Store a list of the selected bonds in the Python layer and create color objects for them.</div><div>3) Each frame, assign distance-dependent transparency values</div><div><br></div><div>You do both steps 2 and 3 with Python scripts in the Per-Frame dialog of the MD Movie tool. For step 2 you input the script, click Apply and execute 1 step of your trajectory. Then back up the trajectory and input the script for step 3, click OK, and run the trajectory. Here are the scripts:</div><div><br></div><div>(step 2)</div><div><div>bonds = mdInfo['mol'].ghostBonds = chimera.selection.currentBonds()</div><div>for b in bonds:</div><div> b.halfbond = False</div><div> b.color = chimera.MaterialColor(*b.molecule.color.rgba())</div><div><br></div><div><br></div><div>(step 3)</div><div><div>for b in mdInfo['mol'].ghostBonds:</div><div> dist = b.length()</div><div> if dist <= 2.0:</div><div> opacity = 1.0</div><div> elif dist >= 5.0:</div><div> opacity = 0.0</div><div> else:</div><div> opacity = 1.0 - (dist - 2.0) / 3.0</div><div> b.color.opacity = opacity</div></div><div><br></div><div>For the step 3 script, change the distance cutoff values and interpolation formula as you like to fit your needs. I've attached the scripts as files so that you can save some typing and use the 'insert from file' button on the Per-Frame dialog.</div><div><br></div><div>--Eric</div><div><br></div></div><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; font-family: Helvetica; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="5" style="font: 16.0px Helvetica"><span class="Apple-converted-space"> <span class="Apple-converted-space"> </span></span>Eric Pettersen</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="5" style="font: 16.0px Helvetica"><span class="Apple-converted-space"> <span class="Apple-converted-space"> </span></span>UCSF Computer Graphics Lab</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="5" style="font: 16.0px Helvetica"><span class="Apple-converted-space"> </span><a href="http://www.cgl.ucsf.edu/">http://www.cgl.ucsf.edu</a></font></div><br class="Apple-interchange-newline"></div></span> </div></div><span><saveBonds.py></span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "></div><span><byDist.py></span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "></div></blockquote></div><br></body></html>