[chimera-dev] Re: [Chimera-users] Zones to create inspector list of "contacts"

Eric Pettersen pett at cgl.ucsf.edu
Wed Mar 23 14:57:38 PST 2005


Tom,
	Wanted to alert you to a couple of functions in chimera.misc that will  
be in the next _production_ release:

	getAtoms(atomContainer)
		returns a list of atoms from various things (or lists of things) that  
can contain atoms, such as residues, sequences, molecules

	atomSearchTree(atomContainer, sepVal=5.0)
		returns a adaptive search tree of the atoms in the atomContainer (ala  
arg to getAtoms()).  CGLutil.AdaptiveTree has docs for these trees.   
Typically searched with the 'searchTree' method.

--Eric

On Mar 23, 2005, at 11:37 AM, Thomas Goddard wrote:

> Hi Grant,
>
>   Below is some Python code that will create pseudobonds between all
> pairs of selected atoms from different molecules that are within 3  
> angstroms.
> It is quite slow for large sets of selected atoms.  It could be made  
> much
> faster but I chose to keep it simple.
>
>        Tom
>
> #  
> ----------------------------------------------------------------------- 
> -----
> # Check all pairwise distances between selected atoms and connect those
> # atom pairs that are close by a pseudobond if the atoms belong to  
> different
> # molecules.
> #
> # To run this use Tools / Programming / Idle to show the Python shell  
> and
> # type
> #
> #    >>> execfile('path-to-this-file.py')
> #
> # For large selected sets of atoms this will be slow.
> #
>
> #  
> ----------------------------------------------------------------------- 
> -----
> #
> def connect_close(dist):
>
>     from chimera import selection, distance
>     atoms = selection.currentAtoms()
>     atom_pairs = []
>     n = len(atoms)
>     for i1 in range(n):
>         a1 = atoms[i1]
>         for i2 in range(i1+1, n):
>             a2 = atoms[i2]
>             if a1.molecule != a2.molecule:
>                 if distance(a1.xformCoord().xyz, a2.xformCoord().xyz)  
> <= dist:
>                     atom_pairs.append((a1,a2))
>     print len(atom_pairs), 'atom pairs'
>
>     from chimera import PseudoBondGroup, PseudoBondMgr_mgr, PseudoBond
>     pg = PseudoBondMgr_mgr().newPseudoBondGroup('close contacts')
>     bonds = []
>     for a1, a2 in atom_pairs:
>         bonds.append(pg.newPseudoBond(a1, a2))
>
>     import chimera
>     chimera.openModels.add([pg])
>
>     selection.setCurrent(bonds)
>
> #  
> ----------------------------------------------------------------------- 
> -----
> #
> connect_close(3)
> _______________________________________________
> Chimera-users mailing list
> Chimera-users at cgl.ucsf.edu
> http://www.cgl.ucsf.edu/mailman/listinfo/chimera-users



More information about the Chimera-dev mailing list