RBVI / ChimeraX

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

Using ChimeraX Without GUI in normal python scripts #43

Closed fses91 closed 4 months ago

fses91 commented 5 months 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 5 months 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 5 months 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

fses91 commented 4 months ago

I built it myself, that worked.

s1752729916 commented 4 months ago

ChimeraX PyPI 包

hi, can you share some guidances on how to build chimerax as a regular python package?

tomgoddard commented 4 months ago

The code that builds the ChimeraX wheel for PyPi is here

https://github.com/RBVI/ChimeraX/tree/develop/wheel

But since the PyPi ChimeraX package is currently broken, the Makefile in that directory may not work. Here is the bug report requesting to fix the ChimeraX PyPi package so you can see its status

https://www.rbvi.ucsf.edu/trac/ChimeraX/ticket/15650
s1752729916 commented 4 months ago

The code that builds the ChimeraX wheel for PyPi is here

https://github.com/RBVI/ChimeraX/tree/develop/wheel

But since the PyPi ChimeraX package is currently broken, the Makefile in that directory may not work. Here is the bug report requesting to fix the ChimeraX PyPi package so you can see its status

https://www.rbvi.ucsf.edu/trac/ChimeraX/ticket/15650

Thanks for your reply! What do i need to modify in https://github.com/RBVI/ChimeraX/tree/develop/wheel? I noticed that you mentioned that there may be issues with v1.7.1, so I run python setup.py install in the release/v1.6 branch

but i got following errors:

error: Multiple top-level modules discovered in a flat-layout: ['filter_deps', 'filter_modules', 'make_init'].

To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.

If you are trying to create a single distribution with multiple modules
on purpose, you should not rely on automatic discovery.
Instead, consider the following options:

1. set up custom discovery (`find` directive with `include` or `exclude`)
2. use a `src-layout`
3. explicitly set `py_modules` or `packages` with a list of names

To find more information, look for "package discovery" on setuptools docs.
tomgoddard commented 4 months ago

First you should try to build the ChimeraX application. It has about 100 dependencies so it may take you a week to get it to build and run on Linux. There is some info online about how to compile it

https://www.cgl.ucsf.edu/chimerax/docs/devel/building.html

Unless you are a very knowledgable software developer in C++ and Python with lots of time to spend you are probably not going to get a ChimeraX wheel built. You should probably discuss what you are trying to do with Zach Pearson who is the ChimeraX developer who made the ChimeraX PyPi package.