
Friends, I wrote a small script to calculate the distance between two atoms in a list of pdb files. I would like to know how i can redirect the message that appears in replyobj to a text file. Some chimera commands like findhbon has option to save the result in file. But distance command dosent have the same. import glob from chimera import runCommand as rc filenames=[ fn for fn in glob.glob('*.pdb.*')] for fn in filenames: rc("open " + fn) * rc("distance :1@CA :166@CA") # I have to write this distance to a file.* rc("close all") Thank you, Bala

On Jun 10, 2010, at 4:36 AM, Bala subramanian wrote:
Friends, I wrote a small script to calculate the distance between two atoms in a list of pdb files. I would like to know how i can redirect the message that appears in replyobj to a text file. Some chimera commands like findhbon has option to save the result in file. But distance command dosent have the same.
import glob from chimera import runCommand as rc
filenames=[ fn for fn in glob.glob('*.pdb.*')]
for fn in filenames: rc("open " + fn) rc("distance :1@CA :166@CA") # I have to write this distance to a file. rc("close all")
Hi Bala, Since you are using a Python script, you can use the saveReplyLog method in the chimera.tkgui module to save the contents of the reply log to a file, e.g.: for fn in filenames: rc("open " + fn) rc("distance :1@ca :166@ca") rc("close all") from chimera.tkgui import saveReplyLog saveReplyLog("distances") In tomorrow's build there will also be a clearReplyLog method, so you would be able to save a distance file for each structure with: from chimera.tkgui import saveReplyLog, clearReplyLog for fn in filenames: rc("open " + fn) clearReplyLog() rc("distance :1@ca :166@ca") saveReplyLog(fn[:-3] + "distance") rc("close all") --Eric Eric Pettersen UCSF Computer Graphics Lab http://www.cgl.ucsf.edu
participants (2)
-
Bala subramanian
-
Eric Pettersen