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

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@cgl.ucsf.edu http://www.cgl.ucsf.edu/mailman/listinfo/chimera-users

Hi Eric, Thanks for telling me of those routines. I think I would optimize the close contact pseudobond routine I gave to Grant by first grouping the atoms by molecule and only comparing pairs in different molecules. For more speed I would use the _closepoints module to limit the atoms from each molecule to only those within the requested distance range of atoms in all other molecules. With these improvements the code would be 3 times longer but finish in less than a second for anything ribosome size or smaller and a reasonable number of contacts (< 10000). Tom
participants (2)
-
Eric Pettersen
-
Thomas Goddard