[chimerax-users] Automate calculation and saving of residues' structural attributes

Christian Tüting christian.tueting at biochemtech.uni-halle.de
Fri Jan 21 04:56:27 PST 2022


Hi André,

i am pretty sure, that my solution is very crude and that there are
better ways of doing it (like importing chimerax in the python code
directly). I guess, you'll get more anwsers soon.

I quickly wrote a script, which performs a chimerax task independently,
by just running python code.

First: a chimerax script file with the desired commands:

script.cxc:
open 7ott
surface #1
mearuse area #1
exit

Note: the exit command is needed, otherwise the subprocress will idle in
the chimerax cmd line.


Second: a python script, which execute this script in chimerax and
fetches the output:

test.py:

import subprocess
import os

cwd = os.getcwd()

chimerax = "/Applications/ChimeraX_Daily.app/Contents/MacOS/ChimeraX"
scriptfile = f"{cwd}/script.cxc"

cmd = [chimerax, "--nogui",scriptfile]
p = subprocess.run(" ".join(cmd),shell = True,capture_output=True)

stdout_as_str = p.stdout.decode("utf-8")
print(stdout_as_str)

This just runs a subprocess and fetches the output to a string, which
you can than further analyse. 


Best
Christian



Dr. rer. nat. Christian Tüting

Kastritis Laboratory for Biomolecular Research
Cryo-Electron Microscopy & Computational Structural Biology  
________________________________________________
Martin-Luther-Universität Halle-Wittenberg
Biozentrum, Room A.2.19
IWE ZIK HALOmem NWG III
"Kryo-Elektronenmikroskopie an Membranproteinkomplexen"
Weinbergweg 22, 06120 Halle
tel: +49 345 5524985
web (Lab): https://blogs.urz.uni-halle.de/kastritislab/
web (HALOmem): https://www.halomem.de/en/
>>> André via ChimeraX-users <chimerax-users at cgl.ucsf.edu> 01/21/22 1:29
PM >>>
Hello!

I'm working on an automated pipeline (in Python) for the structural
analysis of proteins. In particular, I'm using Chimera to calculate and
save to .txt files some structural properties of residues (namely:
areaSAS,
areaSES, relSESA, bfactor, kdhydro, phi, psi). These files are the
inputs
of the pipeline.
However, currently the files are exported manually, and, for the purpose
of
building a fully automated pipeline, it would be great to also automate
this step of calculating the attributes and exporting their respective
files.

I searched a lot, and tried some ways to achieve such an automation
(using
Chimera), but nothing worked.
And I also considered using ChimeraX. In particular, I went through
ChimeraX Programming Manual (
https://www.cgl.ucsf.edu/chimerax/docs/devel/index.html#), but, if I
understood correctly, I'd only be able to import chimerax and use its
functions in the Python interpreter within ChimeraX (Tools >> General >>
Shell).
At first, I'd like to import chimerax as a module in a Python
interpreter
outside of ChimeraX, so that manually opening ChimeraX wouldn't be
necessary in order to save the files with the residues' attributes. But,
from some other threads in the mailing list, I found that it wouldn't be
possible (right?)

But I also found out that I could write a .py script which calculates
and
exports the files with the residues' properties, and then run it with
ChimeraX application from the command-line, something like: *chimerax
--nogui myscript.py*
If that works, I think that my automation problem would be solved! The
only
problem is that I really couldn't figure out the Python code to
calculate
and export the aforementioned residues' properties (I took a look in
ChimeraX Recipes (https://rbvi.github.io/chimerax-recipes/), but I
couldn't
find what I need, nor more detailed documentation).

Given that, I'd like to know if anyone has done something like this,
and/or
have any guidance on how I could proceed.

I really appreciate any help you can provide!
(And thanks to Tom Goddard for suggesting moving the discussion here to
the
ChimeraX mailing list).

Thank you so much,
André.



More information about the ChimeraX-users mailing list