[chimerax-users] no gui mode and redirecting output of some commands
Eric Pettersen
pett at cgl.ucsf.edu
Tue May 10 11:00:16 PDT 2022
Hi Shubham,
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.
Replace:
run(session, "info residue sel")
run(session, "log save aromatic_list.html")
with:
from chimerax.atomic import selected_residues
with open("where-I-want-to-save.txt", "w") as f:
for r in selected_residues(session):
print(r, file=f)
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")
write/append d to a file
--Eric
Eric Pettersen
UCSF Computer Graphics Lab
> On May 10, 2022, at 3:29 AM, Shubham Devesh Ramgoolam via ChimeraX-users <chimerax-users at cgl.ucsf.edu> wrote:
>
> Hi,
> I hope you are doing well.
> I have a python script (myscript.py) as follows:
>
> from chimerax.core.commands import run
> import os
> 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.).
>
> Regards,
> Shubham
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows
>
> _______________________________________________
> ChimeraX-users mailing list
> ChimeraX-users at cgl.ucsf.edu <mailto:ChimeraX-users at cgl.ucsf.edu>
> Manage subscription:
> https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users <https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.rbvi.ucsf.edu/pipermail/chimerax-users/attachments/20220510/62174e59/attachment.html>
More information about the ChimeraX-users
mailing list