[chimera-dev] Fwd: [Chimera-users] Volume covered by a group of atoms

Eric Pettersen pett at cgl.ucsf.edu
Tue May 11 11:15:37 PDT 2010


On May 11, 2010, at 1:29 AM, Miguel Ortiz Lombardia wrote:
> Ooops, I made a blind reply and my message went to the wrong list.
>
> Never mind, I found that this:
>
> mybonds = [':2.C at CP3-CPG',':2.C at CPG-OPA']
> bondlist = mol.bonds
> mybondlist = []
> for bond in bondlist:
>     if str(bond) in mybonds:
>         mybondlist.append(bond)
>
> selects the bonds I want. Perhaps not the most efficient way but it  
> works. Now I can go for the real stuff.

Hi Miguel,
	I'm glad you found something that worked.  Your first try didn't work  
for a couple of reasons:  (1) Selections are collective containers  
like lists, and (2) OSLSelections don't contain bonds.  Here's what I  
would have done:

a1, a2 = selection.OSLSelection(':2.C at C1,C2').atoms()
bond1 = (set(a1.bonds)|set(a2.bonds)).pop()

Basically, use OSLSelection to get the two atoms, then intersect their  
bond lists.  It should be slightly more efficient than your loop  
(though it probably makes no real difference unless this is going to  
execute hundreds or thousands of times).  The efficiency comes from  
OSLSelection first finding the residues that match, then finding the  
atoms in those that match.

--Eric

>
> Début du message réexpédié :
>
>> De : Miguel Ortiz Lombardia <miguel.ortiz-lombardia at afmb.univ-mrs.fr>
>> Date : 11 mai 2010 03:39:47 HAEC
>> À : chimera-dev at cgl.ucsf.edu
>> Objet : Rép : [Chimera-users] Volume covered by a group of atoms
>>
>> Hi Eric,
>>
>> Thanks a lot for your explanations!
>> In fact, I want to do this not for an amino acid side-chain (that  
>> was an easy-to-see example) but for a group in a small molecule. so  
>> I will need the  BondRotMgr module.
>>
>> First, I need to figure out how to select the bonds explicitly in  
>> the script. I thought that something like
>>
>> bond1 = selection.OSLSelection(':2.C at C1|:2.C at C2')
>> bond2 = selection.OSLSelection(':2.C at C5|:2.C at C7')
>> (...)
>>
>> would work, but it doesn't.
>>
>> So far I have fond in the examples how to go through all the bonds  
>> in a molecule (or a residue) but not how to make a explicit  
>> selection of the bond. Is that possible at all or should I go  
>> through the molecule (or residue) list of bonds and pick the one I  
>> want based on two atom selections?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20100511/04c4d0e3/attachment.html>


More information about the Chimera-dev mailing list