
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

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@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@cgl.ucsf.edu <mailto:Chimera-dev@cgl.ucsf.edu> https://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev <https://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev>

Thanks very much for your help Tom, really appreciated. Dan Prof Daniel Rigden (He/Him) Department of Biochemistry and Systems Biology Institute of Systems, Molecular and Integrative Biology Room 101, Biosciences Building University of Liverpool Crown St., Liverpool, L69 7ZB (+44) 151 795 4467 www.liverpool.ac.uk/integrative-biology/staff/daniel-rigden/ ________________________________ From: Tom Goddard <goddard@sonic.net> Sent: 17 November 2021 08:03:00 To: Elliott, Luc Cc: chimera-dev@cgl.ucsf.edu; Rigden, Dan Subject: Re: [chimera-dev] Chimera assistance 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@cgl.ucsf.edu<mailto:chimera-dev@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@cgl.ucsf.edu<mailto:Chimera-dev@cgl.ucsf.edu> https://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev
participants (3)
-
Elliott, Luc
-
Rigden, Dan
-
Tom Goddard