[chimerax-users] Converting Chimera movie script
Elaine Meng
meng at cgl.ucsf.edu
Fri Jun 26 17:24:10 PDT 2020
Hello Vid,
The ChimeraX clip command is different from Chimera's in that
(1) it uses an absolute position, not a change from current position, so (I agree) it can be difficult to put it where you want with just a command
(2) there is no number-of-frames option in the command to repeat the action so that the plane moves gradually
In ChimeraX I can imagine a few different ways to make a script that changes the clipping gradually. What I personally think would be easiest is to move the plane to where you want it to start by hand, then save that view (for example, command "view name v1"), then move it by hand to where you want it to end, then save another view (for example, "view name v2") and then save the sessions so that these positions could easily be restored later. The saved view includes model positions, camera position, zoom, and clip plane positions.
<http://rbvi.ucsf.edu/chimerax/docs/user/commands/view.html#name>
Then in your script for what is shown in the movie, restore the starting position with the "view" command and the name you gave that view, and then use "view" command again with the name of the second view and a number of frames to gradually transition between them. For example, commands;
view v1
view v2 frames 120
There will probably be some trial and error. When I make a movie command script I usually end up playing it through and making adjustments several times before I actually add the commands to record the movie.
Another different way instead of using "view" would be to combine "perframe" and "clip" (see their ChimeraX manual pages) but I think that would be more difficult.
<http://rbvi.ucsf.edu/chimerax/docs/user/index.html#commands>
I hope this helps,
Elaine
-----
Elaine C. Meng, Ph.D.
UCSF Chimera(X) team
Department of Pharmaceutical Chemistry
University of California, San Francisco
> On Jun 26, 2020, at 3:50 PM, Vid Sustar <vid.sustar at abo.fi> wrote:
>
> The following bug report has been submitted:
> Platform: Linux-5.3.0-61-generic-x86_64-with-debian-buster-sid
> ChimeraX Version: 1.0 (2020-06-04 23:15:07 UTC)
> Description
> Hello!
>
> I have tried to adapt the cliping script from
> http://www.rbvi.ucsf.edu/chimera/data/movie-howto-mar2012/scripts/clip.cmd
> to work in ChimeraX (because my structure is too big, to be loaded properly in earlier Chimera)
> I tried to convert the old commands to the ChimeraX, but I get an error in the line "clip front -0.5 120": Expected a keyword
> Please advise me how to change the code to work with ChimeraX to create a movie
> or to simply save a series of images of cliped planes
>
> Best regards,
> Vid Sustar
>
> Log:
> UCSF ChimeraX version: 1.0 (2020-06-04)
> © 2016-2020 Regents of the University of California. All rights reserved.
> How to cite UCSF ChimeraX
>
>> open /home/user/MASTERS/Chimera_files/PythonScripts/clip2.py
>
> Traceback (most recent call last):
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/dialog.py", line 150, in _qt_safe
> if data_format is None else " format " +
> StringArg.unparse(data_format.nicknames[0])))
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/commands/run.py", line 31, in run
> results = command.run(text, log=log)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/commands/cli.py", line 2805, in run
> result = ci.function(session, **kw_args)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/cmd.py", line 101, in cmd_open
> Command(session, registry=registry).run(provider_cmd_text, log=log)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/commands/cli.py", line 2805, in run
> result = ci.function(session, **kw_args)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/cmd.py", line 152, in provider_open
> name or model_name_from_path(fi.file_name)), provider_kw)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/cmd.py", line 365, in collated_open
> return func(*func_args, **func_kw)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core_formats/__init__.py", line 48, in open
> return open_python_script(session, data, file_name)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/scripting.py", line 82, in open_python_script
> _exec_python(session, code, argv)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/scripting.py", line 59, in _exec_python
> exec(code, sandbox.__dict__)
> File "clip2.py", line 3, in <module>
> ModuleNotFoundError: No module named 'chimera'
>
> ModuleNotFoundError: No module named 'chimera'
>
> File "clip2.py", line 3, in
>
> See log for complete Python traceback.
>
>
>> ui tool show Shell
>
> /usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/IPython/core/history.py:226: UserWarning: IPython History requires
> SQLite, your history will not be saved
> warn("IPython History requires SQLite, your history will not be saved")
>
>> select up
>
> Nothing selected
>
>> open /home/user/MASTERS/Chimera_files/PythonScripts/clip2.py
>
> Traceback (most recent call last):
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/dialog.py", line 150, in _qt_safe
> if data_format is None else " format " +
> StringArg.unparse(data_format.nicknames[0])))
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/commands/run.py", line 31, in run
> results = command.run(text, log=log)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/commands/cli.py", line 2805, in run
> result = ci.function(session, **kw_args)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/cmd.py", line 101, in cmd_open
> Command(session, registry=registry).run(provider_cmd_text, log=log)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/commands/cli.py", line 2805, in run
> result = ci.function(session, **kw_args)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/cmd.py", line 152, in provider_open
> name or model_name_from_path(fi.file_name)), provider_kw)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/cmd.py", line 365, in collated_open
> return func(*func_args, **func_kw)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core_formats/__init__.py", line 48, in open
> return open_python_script(session, data, file_name)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/scripting.py", line 82, in open_python_script
> _exec_python(session, code, argv)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/scripting.py", line 59, in _exec_python
> exec(code, sandbox.__dict__)
> File "clip2.py", line 3, in <module>
> ModuleNotFoundError: No module named 'chimera'
>
> ModuleNotFoundError: No module named 'chimera'
>
> File "clip2.py", line 3, in
>
> See log for complete Python traceback.
>
>
>> open /home/user/MASTERS/Chimera_files/PythonScripts/writeMol2.py
>
> Traceback (most recent call last):
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/dialog.py", line 150, in _qt_safe
> if data_format is None else " format " +
> StringArg.unparse(data_format.nicknames[0])))
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/commands/run.py", line 31, in run
> results = command.run(text, log=log)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/commands/cli.py", line 2805, in run
> result = ci.function(session, **kw_args)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/cmd.py", line 101, in cmd_open
> Command(session, registry=registry).run(provider_cmd_text, log=log)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/commands/cli.py", line 2805, in run
> result = ci.function(session, **kw_args)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/cmd.py", line 152, in provider_open
> name or model_name_from_path(fi.file_name)), provider_kw)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/cmd.py", line 365, in collated_open
> return func(*func_args, **func_kw)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core_formats/__init__.py", line 48, in open
> return open_python_script(session, data, file_name)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/scripting.py", line 82, in open_python_script
> _exec_python(session, code, argv)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/scripting.py", line 59, in _exec_python
> exec(code, sandbox.__dict__)
> File "writeMol2.py", line 2, in <module>
> ModuleNotFoundError: No module named 'chimera'
>
> ModuleNotFoundError: No module named 'chimera'
>
> File "writeMol2.py", line 2, in
>
> See log for complete Python traceback.
>
>
>> help help:user
>
>> open /home/user/MASTERS/Chimera_files/PythonScripts/clip2.py
>
> Traceback (most recent call last):
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/dialog.py", line 150, in _qt_safe
> if data_format is None else " format " +
> StringArg.unparse(data_format.nicknames[0])))
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/commands/run.py", line 31, in run
> results = command.run(text, log=log)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/commands/cli.py", line 2805, in run
> result = ci.function(session, **kw_args)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/cmd.py", line 101, in cmd_open
> Command(session, registry=registry).run(provider_cmd_text, log=log)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/commands/cli.py", line 2805, in run
> result = ci.function(session, **kw_args)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/cmd.py", line 152, in provider_open
> name or model_name_from_path(fi.file_name)), provider_kw)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/open_command/cmd.py", line 365, in collated_open
> return func(*func_args, **func_kw)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core_formats/__init__.py", line 48, in open
> return open_python_script(session, data, file_name)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/scripting.py", line 82, in open_python_script
> _exec_python(session, code, argv)
> File "/usr/lib/ucsf-chimerax/lib/python3.7/site-
> packages/chimerax/core/scripting.py", line 59, in _exec_python
> exec(code, sandbox.__dict__)
> File "clip2.py", line 4, in <module>
> ImportError: cannot import name 'runCommand' from 'chimerax' (unknown
> location)
>
> ImportError: cannot import name 'runCommand' from 'chimerax' (unknown
> location)
>
> File "clip2.py", line 4, in
>
> See log for complete Python traceback.
>
>
>> open /home/user/MASTERS/Chimera_files/PythonScripts/clip2.cxc
>
>> open /home/user/MASTERS/Chimera_files/testPDBfiles/Sys1nanopart.pdb
>
>> select :wat
>
> 157584 atoms, 157584 bonds, 1 model selected
>
>> hide sel target a
>
>> select ~sel
>
> 37869 atoms, 34860 bonds, 1 model selected
>
>> surface sel
>
>> color (#!1 & sel) white
>
>> select ::name="OQL"
>
> 2380 atoms, 2520 bonds, 1 model selected
>
>> color (#!1 & sel) red
>
>> select ::name="ONC"
>
> 4200 atoms, 3920 bonds, 1 model selected
>
>> color (#!1 & sel) blue
>
>> select ::name="NP"
>
> 2869 atoms, 1 model selected
>
>> color (#!1 & sel) yellow
>
>> lighting flat
>
>> lighting shadows false
>
>> graphics silhouettes false
>
>> movie record supersample 3
>
>> clip front -0.5
>
>> wait
>
> wait requires a frame count argument unless motion is in progress
>
>> movie encode clip.mp4 bitrate 200
>
> Movie encoding failed because no images were recorded.
>
>> close session
>
>> open /home/user/MASTERS/Chimera_files/PythonScripts/clip2.cxc
>
>> open /home/user/MASTERS/Chimera_files/testPDBfiles/Sys1nanopart.pdb
>
>> select :wat
>
> 157584 atoms, 157584 bonds, 1 model selected
>
>> hide sel target a
>
>> select ~sel
>
> 37869 atoms, 34860 bonds, 1 model selected
>
>> surface sel
>
>> color (#!1 & sel) white
>
>> select ::name="OQL"
>
> 2380 atoms, 2520 bonds, 1 model selected
>
>> color (#!1 & sel) red
>
>> select ::name="ONC"
>
> 4200 atoms, 3920 bonds, 1 model selected
>
>> color (#!1 & sel) blue
>
>> select ::name="NP"
>
> 2869 atoms, 1 model selected
>
>> color (#!1 & sel) yellow
>
>> lighting flat
>
>> lighting shadows false
>
>> graphics silhouettes false
>
>> movie record supersample 3
>
>> clip front -0.5 120
>
> Expected a keyword
>
>> close session
>
>> open /home/user/MASTERS/Chimera_files/PythonScripts/clip2.cxc
>
>> open /home/user/MASTERS/Chimera_files/testPDBfiles/Sys1nanopart.pdb
>
>> select :wat
>
> 157584 atoms, 157584 bonds, 1 model selected
>
>> hide sel target a
>
>> select ~sel
>
> 37869 atoms, 34860 bonds, 1 model selected
>
>> surface sel
>
>> color (#!1 & sel) white
>
>> select ::name="OQL"
>
> 2380 atoms, 2520 bonds, 1 model selected
>
>> color (#!1 & sel) red
>
>> select ::name="ONC"
>
> 4200 atoms, 3920 bonds, 1 model selected
>
>> color (#!1 & sel) blue
>
>> select ::name="NP"
>
> 2869 atoms, 1 model selected
>
>> color (#!1 & sel) yellow
>
>> lighting flat
>
>> lighting shadows false
>
>> graphics silhouettes false
>
>> windowsize 200 150
>
>> copy file clip.jpg
>
> Unknown command: copy file clip.jpg
>
>> copy
>
> Unknown command: copy
>
>> save /home/user/Desktop/image1.png supersample 3
>
>> movie record
>
> Already recording a movie
>
>> open /home/user/Desktop/gbpmovie.cxc
>
> No such file/path: /home/user/Desktop/gbpmovie.cxc
>
>> close session
>
>> open /home/user/MASTERS/Chimera_files/PythonScripts/clip2.cxc
>
>> open /home/user/MASTERS/Chimera_files/testPDBfiles/Sys1nanopart.pdb
>
>> select :wat
>
> 157584 atoms, 157584 bonds, 1 model selected
>
>> hide sel target a
>
>> select ~sel
>
> 37869 atoms, 34860 bonds, 1 model selected
>
>> surface sel
>
>> color (#!1 & sel) white
>
>> select ::name="OQL"
>
> 2380 atoms, 2520 bonds, 1 model selected
>
>> color (#!1 & sel) red
>
>> select ::name="ONC"
>
> 4200 atoms, 3920 bonds, 1 model selected
>
>> color (#!1 & sel) blue
>
>> select ::name="NP"
>
> 2869 atoms, 1 model selected
>
>> color (#!1 & sel) yellow
>
>> lighting flat
>
>> lighting shadows false
>
>> graphics silhouettes false
>
>> movie record supersample 3
>
> Already recording a movie
>
>> movie stop
>
>> movie record supersample 3
>
>> movie stop
>
>> movie stop
>
> Not currently recording
>
>> close session
>
>> open /home/user/MASTERS/Chimera_files/PythonScripts/clip2.cxc
>
>> open /home/user/MASTERS/Chimera_files/testPDBfiles/Sys1nanopart.pdb
>
>> select :wat
>
> 157584 atoms, 157584 bonds, 1 model selected
>
>> hide sel target a
>
>> select ~sel
>
> 37869 atoms, 34860 bonds, 1 model selected
>
>> surface sel
>
>> color (#!1 & sel) white
>
>> select ::name="OQL"
>
> 2380 atoms, 2520 bonds, 1 model selected
>
>> color (#!1 & sel) red
>
>> select ::name="ONC"
>
> 4200 atoms, 3920 bonds, 1 model selected
>
>> color (#!1 & sel) blue
>
>> select ::name="NP"
>
> 2869 atoms, 1 model selected
>
>> color (#!1 & sel) yellow
>
>> lighting flat
>
>> lighting shadows false
>
>> graphics silhouettes false
>
>> movie record supersample 3
>
>> clip front -0.5 120 ; wait 120 ; movie encode clip.mp4 bitrate 200
>
> Expected a keyword
>
>> help help:contact.html
>
>
>
>
> OpenGL version: 3.3.0 NVIDIA 440.100
> OpenGL renderer: GeForce RTX 2060/PCIe/SSE2
> OpenGL vendor: NVIDIA Corporation
> Manufacturer: Micro-Star International Co., Ltd.
> Model: GL63 8SE
> OS: Ubuntu 18.04 bionic
> Architecture: 64bit ELF
> CPU: 12 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
> Cache Size: 9216 KB
> Memory:
> total used free shared buff/cache available
> Mem: 31G 6.1G 18G 662M 6.6G 24G
> Swap: 2.0G 0B 2.0G
>
> Graphics:
> 00:02.0 VGA compatible controller [0300]: Intel Corporation Device [8086:3e9b]
> Subsystem: Micro-Star International Co., Ltd. [MSI] Device [1462:126a]
> Kernel driver in use: i915
> PyQt version: 5.12.3
> Compiled Qt version: 5.12.4
> Runtime Qt version: 5.12.8
> File attachment: clip2.cxc
> <clip2.cxc>_______________________________________________
> ChimeraX-users mailing list
> ChimeraX-users at cgl.ucsf.edu
> Manage subscription:
> https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
More information about the ChimeraX-users
mailing list