Begin forwarded message:

From: chimerax-users-owner@cgl.ucsf.edu
From: Yue Bao <nkby@outlook.com>
Subject: Question about automating with ChimeraX in Visual Studio Code
Date: July 15, 2024 at 11:54:25 PM PDT
To: "chimerax-users@cgl.ucsf.edu" <chimerax-users@cgl.ucsf.edu>


Hi, 

I am using ChimeraX to visualize a list of protein structures, including hiding/showing/coloring specific chains (sometimes amino acids specific). Because I have a long list, I wanted to get it done not with the ChimeraX console but with Visual Studio Code, since you provided python APIs. 

N.B. I can do run(session, 'open 6qzp') in the Qt console in ChimeraX, as session has been loaded. It is good, just not as efficient as running in VS code. 

However, in VS code it is not working. Here are my code and error messages. Is it because I didn't setup the standalone environment correctly? If possible, could you help me with a piece of sample code and the documentation?

best,
Yue
---

interpreter I used
/Applications/ChimeraX-1.7.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11

I have a script basically to open a PDB structure and get some visualizations done
from chimerax.core.session import Session
from chimerax.core.commands import run

def main():
   session = Session('chimerax')
   run(session, 'open 6qzp')
   run(session, 'hide atom')
   run(session, 'show cartoon')
   run(session, 'select #1') # select all proteins
   run(session, 'color #AAAAAA All')
   run(session, 'select #0')

main()

when I run it in VS code, it  gives me some error
    run(session, 'open 6qzp')  
  File
"/Applications/ChimeraX-1.7.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-
packages/chimerax/core/commands/run.py", line 49, in run  
    results = command.run(text, log=log, return_json=return_json)  
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
  File
"/Applications/ChimeraX-1.7.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-
packages/chimerax/core/commands/cli.py", line 2849, in run  
    _compute_available_commands(session)  
  File
"/Applications/ChimeraX-1.7.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-
packages/chimerax/core/commands/cli.py", line 2431, in
_compute_available_commands  
    ts.register_available_commands(session.logger)  
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
AttributeError: 'NoneType' object has no attribute
'register_available_commands'  
  

BUG: AttributeError: 'NoneType' object has no attribute
'register_available_commands'  
  
File
"/Applications/ChimeraX-1.7.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-
packages/chimerax/core/commands/cli.py", line 2431, in
_compute_available_commands  
ts.register_available_commands(session.logger)  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
  
 _See log for complete Python traceback._