[chimerax-users] Batch save the image of each chain

Tom Goddard goddard at sonic.net
Fri Dec 11 11:41:19 PST 2020


Hi Yong Liu,

  First start by figuring out the ChimeraX commands to do what you want.  For example, the commands to save an image of chain A shown as atoms could be

	open 2bbv

	show #1/A only
	view
	save ~/Desktop/2bbv_chain_A.png

Now the trick is we want to do that for all chains.  The ChimeraX command language has not looping methods so we have to use some Python.  Also you wanted to create a new command that does the 3 commands above with the right chain id and model number substituted in.  I've attached some Python code chain_images.py that does that makes the command.  If you open that Python file in ChimeraX it will define the command then type

	chainimages #1

to make the images.  I've put this example Python code on the ChimeraX Recipes web site

	https://rbvi.github.io/chimerax-recipes/chain_images/chain_images.html <https://rbvi.github.io/chimerax-recipes/chain_images/chain_images.html>

If you want ChimeraX to define this command each time you start you can put command "open ~/scripts/chain_images.py" in ChimeraX startup preferences.

  Tom




> On Dec 10, 2020, at 10:29 PM, Yong Liu <liuyongbox at gmail.com> wrote:
> 
> Hi All,
> I would like to save the image of each chain in one command. I have wrote following python code, but it is not working. Is anybody know how to fix it?
> 
> 
> # save the image of each chain
> 
> def batchSave(session):
> 	chainID_list = info chains 
> for x in chainID_list:
> 
> chainID = chainID_list.split()
> 
> ID = chainID[-1]
> 
> save "Desktop/ID.png" width 4000 height 4000 transparentBackground true
> 
> 
> def register_command(session):
>  from chimerax.core.commands import CmdDesc, register
>  desc = CmdDesc()
>  register('batchSave', desc, batchSave, logger=session.logger)
> 
> register_command(session)
> 
> Best,
> Yong Liu
> _______________________________________________
> ChimeraX-users mailing list
> ChimeraX-users at cgl.ucsf.edu
> Manage subscription:
> https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20201211/606ffb71/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chain_images.py
Type: text/x-python-script
Size: 820 bytes
Desc: not available
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20201211/606ffb71/attachment.bin>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20201211/606ffb71/attachment-0001.html>


More information about the ChimeraX-users mailing list