[Chimera-users] All PDB ca atom pairwise distance

Eric Pettersen pett at cgl.ucsf.edu
Tue Oct 31 12:34:00 PDT 2017

Well, since the code is simple, I’ve included it below.  You should put it in a file whose name in “.py” to indicate it’s Python code, then you can run it in Chimera simply by opening it.  It will create a file named “output” in your home folder.  It assumes you’re doing CA-CA distances, not CA-any.  Probably still very slow.

from chimera import openModels, Molecule
mol = openModels.list(modelTypes=[Molecule])[0]
cas = [ a for a in mol.atoms if a.name == “CA” and a.element.name == “C”]
import os.path
f = open(os.path.expanduser(“~/output”), “w”)
for i, ca1 in enumerate(cas):
	for ca2 in cas[i+1:]:
		print>>f, ca1, ca2, ca1.coord().distance(ca2.coord())

Since my mail client does wonky things to quotation marks, I’ve also attached the above as a file.


> On Oct 31, 2017, at 11:36 AM, Eric Pettersen <pett at cgl.ucsf.edu> wrote:
>> On Oct 31, 2017, at 9:54 AM, Kyle Morris <kylelmorris at berkeley.edu> wrote:
>> Dear chimera dev and users,
>> Is there a way to calculate (using the GUI, commands or using a python script) the pairwise distances for every single c-alpha atom in a set of loaded PDB coordinates and spit this out to a file for further analysis? There are 142,800 atoms in the current loaded assembly.
> Do you mean CA-CA distances, or CA-any-other-atom distances?  Even CA-CA only (assuming CAs are roughly 1/10 of your atoms) will be more than one hundred million distances, and CA-other will be more than a billion.  Is this really what you want?  If so, it would seem more efficient and much faster to write a special purpose program for this in a compiled language, like C, C++ or some such.  It is of course doable in Chimera via Python.  If you really do want to do it that way, I can offer further guidance...
> —Eric
> 	Eric Pettersen
> 	UCSF Computer Graphics Lab
> _______________________________________________
> Chimera-users mailing list: Chimera-users at cgl.ucsf.edu
> Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20171031/306ec3ac/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ca.py
Type: text/x-python-script
Size: 343 bytes
Desc: not available
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20171031/306ec3ac/attachment.bin>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20171031/306ec3ac/attachment-0001.html>

More information about the Chimera-users mailing list