[Chimera-users] how to save distance to a file

Eric Pettersen pett at cgl.ucsf.edu
Mon May 5 15:57:25 PDT 2014


On May 5, 2014, at 1:34 AM, chang YG <changyg2008 at gmail.com> wrote:

> Hi,
> 
> Thanks for taking time to answer the questions. Could you advise me of how to save distances using a python script.
> 
> Here is what I have:
> 
> from chimera import runCommand as rc
> rc("open 1t4y")
> rc("distance :33 at H :34 at H")
> #how to save distance.

Hi Yonggang,
	There are a few possibilities, but here's what I would do:

rc("open 1t4y")
rc("sel :33 at H :34 at H")
from chimera.selection import currentAtoms
a1, a2 = currentAtoms()
dist = a1.coord().distance(a2.coord())
from OpenSave import osOpen
f = open("~/dists", "w")
print>>f, a1, a2, diet
f.close()

The above will write the distance into a file named "dists" in your home directory.  Now you obviously probably want to do this for a lot of distances and/or files.  You should look at the simple Chimera programming primer for looping through files:

Very Basic Chimera Programming Primer

> Another related question: how to save "rmsd" of two structures using a python script?

The basic answer is by calling Midas.rmsd(atoms1, atoms2) to get the RMSD and saving that.  The issue is how to get the two sets of atoms to send to that command, and that would depend on whether the structures have identical sets of atoms (i.e. they're different conformers), or if you know which atoms to match against which, or whether you need to discover the set of corresponding atoms using MatchMaker.  Instead of explaining each in detail (two of which you won't care about), why don't you say which you need and I'll explain that one…

--Eric

                        Eric Pettersen
                        UCSF Computer Graphics Lab
                        http://www.cgl.ucsf.edu


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20140505/c8b5cd6b/attachment.html>


More information about the Chimera-users mailing list