[Chimera-users] how to save distance to a file
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:
> 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.
There are a few possibilities, but here's what I would do:
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
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…
UCSF Computer Graphics Lab
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Chimera-users