def view_model(self, tool='chimera', savefig=None, cmd=None, center_of_mass=False, gyradius=False, color='index', **kwargs): """ Visualize a selected model in the three dimensions. (either with Chimera or through matplotlib). :param model_num: model to visualize :param 'chimera' tool: path to the external tool used to visualize the model. Can also be 'plot', to use matplotlib. :param None savefig: path to a file where to save the image OR movie generated (depending on the extension; accepted formats are png, mov and webm). if set to None, the image or movie will be shown using the default GUI. :param 'index' color: can be: * a string as: * '**index**' to color particles according to their position in the model (:func:`pytadbit.utils.extraviews.color_residues`) * '**tad**' to color particles according to the TAD they belong to (:func:`pytadbit.utils.extraviews.tad_coloring`) * '**border**' to color particles marking borders. Color according to their score (:func:`pytadbit.utils.extraviews.tad_border_coloring`) coloring function like. * a function, that takes as argument a model and any other parameter passed through the kwargs. * a list of (r, g, b) tuples (as long as the number of particles). Each r, g, b between 0 and 1. :param False center_of_mass: draws a dot representing the center of mass of the model :param False gyradius: draws the center of mass of the model as a sphere with radius equal to the radius of gyration of the model :param None cmd: list of commands to be passed to the viewer. The chimera list is: :: focus set bg_color white windowsize 800 600 bonddisplay never #0 represent wire shape tube #0 radius 5 bandLength 100 segmentSubdivisions 1 followBonds on clip yon -500 ~label set subdivision 1 set depth_cue set dc_color black set dc_start 0.5 set dc_end 1 scale 0.8 Followed by the movie command to record movies: :: movie record supersample 1 turn y 3 120 wait 120 movie stop movie encode output SAVEFIG Or the copy command for images: :: copy file SAVEFIG png Passing as the following list as 'cmd' parameter: :: cmd = ['focus', 'set bg_color white', 'windowsize 800 600', 'bonddisplay never #0', 'shape tube #0 radius 10 bandLength 200 segmentSubdivisions 100 followBonds on', 'clip yon -500', '~label', 'set subdivision 1', 'set depth_cue', 'set dc_color black', 'set dc_start 0.5', 'set dc_end 1', 'scale 0.8'] will return the default image (other commands can be passed to modified the final image/movie). :param kwargs: see :func:`pytadbit.utils.extraviews.plot_3d_model` or :func:`pytadbit.utils.extraviews.chimera_view` for other arguments to pass to this function """ if gyradius: gyradius = self.radius_of_gyration() center_of_mass = True if tool == 'plot': x, y, z = self['x'], self['y'], self['z'] plot_3d_model(x, y, z, color=color, **kwargs) return self.write_cmm('/tmp/', color=color, **kwargs) chimera_view(['/tmp/model.%s.cmm' % (self['rand_init'])], savefig=savefig, chimera_bin=tool, chimera_cmd=cmd, center_of_mass=center_of_mass, gyradius=gyradius)