Thank you for your reply.
I have implemented the change as requested in my python script but I am still facing the same issue: Script works in gui mode but not in nogui mode(no text file made).
I have tried running the script in the RC build(May 5, 2022), latest production release (Dec 8, 2021), and the daily build (built on May 10, 2022) but to no avail.
from chimerax.core.commands import run
from chimerax.atomic import selected_residues
run(session, "open C:\\Users\\Shubham\\Desktop\\PDB_Script\\1ebt.pdb")
run(session, "sel aromatic & protein")
with open("C:\\Users\\Shubham\\Desktop\\arom_list.txt", "w") as f:
for r in selected_residues(session):
I also faced the same issue when writing the output of the command distance (between two centroids) to a text file: Script works in gui mode but not in nogui mode(no text file made).
Here is my script for that:
from chimerax.core.commands import run
run(session, "open C:\\Users\\Shubham\\Desktop\\PDB_Script\\1ebt.pdb")
run (session, 'define centroid /A:14 & aromatic-ring radius 0.3 color yellow mass false name C1')
run (session, 'define centroid /A:21 & aromatic-ring radius 0.3 color yellow mass false name C2')
file = open('C:\\Users\\Shubham\\Desktop\\distance.txt', 'w+')
dist = run(session, 'distance @c1 @c2')
Sent from
Mail for Windows
It seems like a deficiency of the 'info' command that it can't put the information directly into a file. We will look into rectifying that -- and yes, the problem is that the Log does not exist in nogui mode. However, since you are using a Python script for
this (rather than a Chimera command script), you can save the information directly to a file yourself.
run(session, "info residue sel")
run(session, "log save aromatic_list.html")
from chimerax.atomic import selected_residues
with open("where-I-want-to-save.txt", "w") as f:
for r in selected_residues(session):
You can do similar things with distances and angles because the commands return the distance/angle values, e.g.:
d = run(session, "distance atom1 atom2")
UCSF Computer Graphics Lab
I hope you are doing well.
I have a python script (myscript.py) as follows:
from chimerax.core.commands import run
os.chdir("C:\\Users\\Shubham\\Desktop")
run(session, "open C:\\Users\\Shubham\\Desktop\\PDB_Script\\1ebt.pdb") # location of my pdb file
run(session, "sel aromatic & protein")
run(session, "log clear")
run (session, "info residue sel")
run(session, "log save aromatic_list.html")
I am using the following prompt for calling chimerax from command prompt:
Gui enabled: chimerax --script C:\\Users\\Shubham\\Desktop\\myscript.py
Gui disabled: chimerax --nogui --script C:\\Users\\Shubham\\Desktop\\myscript.py
With gui mode enabled, the html file, aromatic_list.html, is created.
However, when disabling gui, nothing is created.
I suspect this is because I am relying on the log which may not be functional when gui is disabled?
Is there a way of redirecting the output of certain commands (e.g info, distance, angle) to a desired text file when disabling gui?
I tried with sys.stdout but it did not work (empty text files were created.).
Sent from
Mail for Windows