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

Yong Liu liuyongbox at gmail.com
Fri Dec 11 21:09:06 PST 2020


Dear Tom, 

Many thanks. It is working very well.

I am wondering if it is fine to add two more arguments for this command which are chains of list and color.  For example: chainimages #1/X,Y,Z Blue

Kind regards,
Yong Liu
> On Dec 11, 2020, at 22:29, Tom Goddard <goddard at sonic.net> wrote:
> 
> Here is what the saved images look like for 2bbv.
> 
> 	Tom
> 
> <2bbv.jpg>
> 
>> On Dec 11, 2020, at 11:41 AM, Tom Goddard <goddard at sonic.net <mailto:goddard at sonic.net>> wrote:
>> 
>> 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
>> 
>> <chain_images.py>
>> 
>> 
>>> On Dec 10, 2020, at 10:29 PM, Yong Liu <liuyongbox at gmail.com <mailto: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 <mailto:ChimeraX-users at cgl.ucsf.edu>
>>> Manage subscription:
>>> https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users <https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users>
>>> 
>> 
>> _______________________________________________
>> ChimeraX-users mailing list
>> ChimeraX-users at cgl.ucsf.edu <mailto: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/20201212/119c9fdb/attachment.html>


More information about the ChimeraX-users mailing list