ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
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

 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