Chimera batch surface exporter
Hi Everyone, I'm pretty new to Chimera, but I'm working on an animation project that requires quite a few proteins and molecules. To speed up the process, I'd like to create a batch converter/exporter script to do the following: Open a PDB file Generate a multiscale model at a specified resolution Export the model out as a VRML or OBJ file I think I can do this using a Chimera command file, but I was hoping someone could point me in the right direction for some of the relevant command line syntax. Is it possible to control the multiscale model tool via command line (I know I can launch the dialog, but can I change the parameters and execute)? Is there a reference somewhere for the command line parameters for the multiscale models tool? What is the command line export command? Where can I find an OBJ exporter (there are references to it in the mailing list archive)? Any help would be greatly appreciated. Thanks, Trent BTW - I have a suggestion for improvement of Chimera. Add a command history window (or modify the existing one) that echoes out the command line text that is equivalent to any command executed via the Chimera user interface. Maya has this functionality and it is wonderful for anyone who is trying to figure out how to script a process that they know how to execute via the various menus.
Hi Trent, Unfortunately many Chimera capabilities do not have equivalent commands, though we are working on adding more commands. The multiscale tool and scene export as vrml cannot be done with Chimera commands. But all the capabilities are available with Python scripts. Attached is a Python script to export a batch of PDB files in a directory as VRML or OBJ. For OBJ format you'll need to download the Export OBJ plug-in that I just added to the Chimera experimental features web page: http://www.cgl.ucsf.edu/chimera/experimental/experimental.html To use the script, edit the line near the bottom to set directory for the PDB files. Then use Chimera File / Open... to open it. It will create the vrml or obj files in the same directory. I tried in with the latest Chimera production release 1.2470. Tom # ----------------------------------------------------------------------------- # Open PDB file, make multiscale model, and export 3d scene. # # Allowed export formats are POV-Ray, RenderMan, X3D, VRML, and OBJ. # OBJ format requires installing the separate ExportOBJ Chimera plug-in # from the Chimera experimental features web page. # def export_pdb_as_multiscale(pdb_path, resolution, export_format, export_path): # Open PDB from chimera import openModels as om mlist = om.open(pdb_path) # Create multiscale model from MultiScale import multiscale_model_dialog d = multiscale_model_dialog(create = True) d.surface_resolution.set('%g' % resolution) # For copies of molecule: d.multimer_none, d.multimer_unitcell d.multimer_type.set(d.multimer_biounit) d.make_multimers(mlist) # Export scene. if export_format == 'OBJ': import ExportOBJ ExportOBJ.write_surfaces_as_wavefront_obj(export_path) else: from chimera import exports exports.doExportCommand(export_format, export_path) # Close files from chimera import closeSession closeSession() # ----------------------------------------------------------------------------- # Export multiscale surface models for all PDB files in a directory. # def export_pdbs(dir, resolution, export_format, export_suffix): from os import listdir filenames = [n for n in listdir(dir) if n.endswith('.pdb')] from os.path import join for f in filenames: pdb_path = join(dir, f) export_path = join(dir, f.rstrip('.pdb') + export_suffix) export_pdb_as_multiscale(pdb_path, resolution, export_format, export_path) # ----------------------------------------------------------------------------- # Formats: 'VRML', 'OBJ', 'POV-Ray', 'RenderMan', 'X3D' # export_pdbs(dir = '/tmp/pdbfiles', # location of PDB files resolution = 3, export_format = 'VRML', export_suffix = '.vrml')
participants (2)
-
Thomas Goddard
-
Trent Grover