RBVI / ChimeraX

Source code for molecular graphics program UCSF ChimeraX
https://www.rbvi.ucsf.edu/chimerax/
Other
135 stars 23 forks source link

Using ChimeraX Without GUI in normal python scripts #43

Open fses91 opened 1 week ago

fses91 commented 1 week ago

Hi,

I am currently using ChimeraX for protein manipulation, following this setup guide. While it works, it requires creating a session and running scripts with runscript script.py.

I found the ChimeraX PyPI package and tried:

from chimerax.core.commands import run
from chimerax.core.session import Session

session = Session()
run(session, 'open protein.pdb')
run(session, "exit")

But this approach did not work. I get the following error:

ModuleNotFoundError: No module named 'chimerax.graphics'

Already the import of the packages does not work.

Is it possible to use ChimeraX like PyMol, integrating directly into Python scripts without the GUI?

Best regards,
Florian

zjp commented 1 week ago

Hi Florian,

The PyPi package does not support run(); you'll want to run your script with ChimeraX in nogui mode.

/path/to/ChimeraX.app --nogui --exit --script "/path/to/your/script [script arguments]"

fses91 commented 1 week ago

Hi, I am currently doing that on my local machine, but is it possible to just install the ChimeraX python libraries e.g. into a conda environment, and use it in a normal python script.

Because I want to put my workflow onto a server machine, where I do not have sudo rights to do a full install of ChimeraX via some package manager, I can only work with python environments there.

Best regards, Florian