[chimera-dev] Chimera assistance

Tom Goddard goddard at sonic.net
Wed Nov 17 00:03:00 PST 2021


Hi Luc,

  The Chimera Segger tool does not have an equivalent command for its menu entry File / Save Each Region to .mrc File.  So it would require some Python code to do that without using the GUI.  

  I can show you how to do that in ChimeraX.  All our development effort has been on ChimeraX and not the old Chimera program for several years now.    Maybe you could adapt my example code to work in Chimera if you are familiar with the Python language.

  I looked in my ChimeraX distribution in (on Mac) for the Segger code for that menu entry which I found in

	ChimeraX.app/Contents/lib/python3.9/site-packages/chimerax/segger/segment_dialog.py

and just copied some of that code to the attached Python mrcregion.py which looks like this

# From Segment Map menu entry "Save each region to .mrc file..."
# which calls VolumeSegmentationDialog.WriteEachReginMRCFile() in Segger/segment_dialog.py
#
from chimerax.segger.segment_dialog import volume_segmentation_dialog
vsd = volume_segmentation_dialog(session)
smod = vsd.CurrentSegmentation()
dmap = vsd.SegmentationMap()
path = '/Users/goddard/Desktop/test/test_region_%d.mrc'
for region in smod.regions:
    vsd.SaveRegsToMRC([region], dmap, path % region.rid)

After opening or creating your segmentation you can just open my attached Python script in ChimeraX to write the MRC files.  The path is coded in the file so you would need to change it to where you want the MRC files to be written.  This could be improved to register a ChimeraX command where you could specify the path to write the files.

	Tom



> On Nov 16, 2021, at 6:46 AM, Elliott, Luc via Chimera-dev <chimera-dev at cgl.ucsf.edu> wrote:
> 
> Hello,
> 
> I'm a first year PhD student with the University of Liverpool and I have a query regarding chimera.
> 
> I'm trying to write some code which selects all the regions of a segmented map (.seg) and saves each region to its own .mrc file, similarly to how it works in the program but without needing to interact with the GUI. Would there be a way to make this happen?
> 
> Thank you for your time.
> 
> Kind regards,
> Luc Elliott
> _______________________________________________
> Chimera-dev mailing list
> Chimera-dev at cgl.ucsf.edu <mailto:Chimera-dev at cgl.ucsf.edu>
> https://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev <https://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20211117/2e3076a6/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mrcregions.py
Type: text/x-python-script
Size: 473 bytes
Desc: not available
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20211117/2e3076a6/attachment-0001.bin>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20211117/2e3076a6/attachment-0003.html>


More information about the Chimera-dev mailing list