[chimerax-users] python script for measuring distance
Rangarajan, Amith
Amith.Rangarajan at ucsf.edu
Sat Feb 12 06:26:12 PST 2022
Hello everyone,
Please see my script below:
import os
import sys
from chimerax.core.commands import run as rc
target_folder = '/wynton/home/jacobson/avranga1008/Documents/0-combo'
os.chdir(target_folder)
home =os.getcwd()
all = os.listdir()
xp_distance_file = os.path.join(home,'xp-distance.log')
print_to_screen = sys.stdout
mae_files =[]
for f in all:
if f.endswith('.mae'):
mae_files.append(f)
print(f'working on {f}')
sys.stdout = open(xp_distance_file,'a')
rc(session,"open " + f)
rc(session,"measure center #1.1 & ligand mark true")
rc(session,"measure center #1.1 :310,335,728,759 mark true")
rc(session,"distance #2 #3")
rc(session,"close")
sys.stdout = print_to_screen
print(f'completed writing xp-distance values to {xp_distance_file} ; now moving to next loop')
for f in mae_files:
line = f + '\n'
open('file_list.txt','a').write(line)
print("loop is complete")
exit()
I am curently using stdout to write the distance values to a file .I am currently running it on command line
[cid:68afa919-1a35-470f-808c-242e97c85957]
it seems like a round about way to do it. The output file has lot of special characters and it takes a bit of effort using regex to extract the values.
I think there might be some logger in chimerax which can do this or some other better way to write results to a file , but i am not able to find it.
#############
please let me know your suggestions on improving this code.
thanks,
amith
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.rbvi.ucsf.edu/pipermail/chimerax-users/attachments/20220212/42c05d91/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 3867 bytes
Desc: image.png
URL: <http://www.rbvi.ucsf.edu/pipermail/chimerax-users/attachments/20220212/42c05d91/attachment-0001.png>
More information about the ChimeraX-users
mailing list