def add_scenes(names=None, pause=8.0, cut=0.0, loop=1, rock=-1, period=8.0, animate=-1, start=0, _self=cmd): cmd = _self if not start: start = cmd.get_movie_length() + 1 animate = float(animate) pause = float(pause) period = float(period) if period > pause: period = pause rock = int(rock) if animate < 0: animate = float(cmd.get("scene_animation_duration")) if names == None: names = cmd.get_scene_list() elif cmd.is_str(names): names = cmd.safe_alpha_list_eval(names) n_scene = len(names) duration = n_scene * (pause + animate) fps = float(cmd.get('movie_fps')) n_frame = int(round(fps * duration)) if not loop: act_n_frame = int(round(fps * (duration - animate))) else: act_n_frame = n_frame if rock < 0: sweep_mode = int(cmd.get('sweep_mode')) elif rock: sweep_mode = rock - 1 else: sweep_mode = 0 if n_frame > 0: cmd.mset("1 x%d" % act_n_frame, start, freeze=1) cnt = 0 for scene in names: frame = start + int((cnt * n_frame) / n_scene) cmd.mview("store", frame, scene=scene, freeze=1) if rock: cmd.mview("interpolate", cut=cut, wrap=0) sweep_first = frame + 1 sweep_last = start + int(pause * fps + (cnt * n_frame) / n_scene) - 1 if sweep_last > act_n_frame: sweep_last = act_n_frame n_sweep_frame = sweep_last - sweep_first + 1 if n_sweep_frame > 0: if sweep_mode == 1: # x-axis rock _rock(sweep_mode, 'x', sweep_first, sweep_last, period, pause, _self=_self) elif sweep_mode < 3: # y-axis rock _rock(sweep_mode, 'y', sweep_first, sweep_last, period, pause, _self=_self) elif sweep_mode == 3: _nutate(sweep_mode, sweep_first, sweep_last, period, pause, _self=_self) frame = start + int(pause * fps + (cnt * n_frame) / n_scene) if frame <= act_n_frame: if sweep_mode != 3: cmd.mview("store", frame, scene=scene, freeze=1) cnt = cnt + 1 cmd.mview("interpolate", cut=cut, wrap=loop) if rock: cmd.mview("smooth") cmd.frame(start)
def add_scenes(names=None, pause=8.0, cut=0.0, loop=1, rock=-1, period=8.0, animate=-1, start=0, _self=cmd): cmd = _self if not start: start = cmd.get_movie_length()+1 animate = float(animate) pause = float(pause) period = float(period) if period>pause: period = pause rock = int(rock) if animate<0: animate = float(cmd.get("scene_animation_duration")) if names == None: names = cmd.get_scene_list() elif cmd.is_str(names): names = cmd.safe_alpha_list_eval(names) n_scene = len(names) duration = n_scene*(pause+animate) fps = float(cmd.get('movie_fps')) n_frame = int(round(fps * duration)) if not loop: act_n_frame = int(round(fps * (duration - animate))) else: act_n_frame = n_frame if rock<0: sweep_mode = int(cmd.get('sweep_mode')) elif rock: sweep_mode = rock - 1 else: sweep_mode = 0 if n_frame > 0: cmd.mset("1 x%d"%act_n_frame,start,freeze=1) cnt = 0 for scene in names: frame = start+int((cnt*n_frame)/n_scene) cmd.mview("store",frame,scene=scene,freeze=1) if rock: cmd.mview("interpolate",cut=cut,wrap=0) sweep_first = frame + 1 sweep_last = start + int(pause*fps+(cnt*n_frame)/n_scene) - 1 if sweep_last > act_n_frame: sweep_last = act_n_frame n_sweep_frame = sweep_last - sweep_first + 1 if n_sweep_frame > 0: if sweep_mode==1: # x-axis rock _rock(sweep_mode, 'x', sweep_first, sweep_last, period, pause, _self=_self) elif sweep_mode<3: # y-axis rock _rock(sweep_mode, 'y', sweep_first, sweep_last, period, pause, _self=_self) elif sweep_mode == 3: _nutate(sweep_mode, sweep_first, sweep_last, period, pause, _self=_self) frame = start+int(pause*fps+(cnt*n_frame)/n_scene) if frame <= act_n_frame: if sweep_mode!=3: cmd.mview("store",frame,scene=scene,freeze=1) cnt = cnt + 1 cmd.mview("interpolate",cut=cut,wrap=loop) if rock: cmd.mview("smooth") cmd.frame(start)
def ramp_new(name, map_name, range=[-1.0,0.0,1.0], color=['red',[1.0,1.0,1.0],'blue'], state=1, selection='', beyond=2.0, within=6.0, sigma=2.0, zero=1, quiet=1, _self=cmd): ''' DESCRIPTION "ramp_new" creates a color ramp based on a map potential value or based on proximity to a molecular object. USAGE ramp_new name, map_name [, range [, color [, state [, selection [, beyond [, within [, sigma [, zero ]]]]]]]] ARGUMENTS name = string: name of the ramp object map_name = string: name of the map (for potential) or molecular object (for proximity) range = list: values corresponding to slots in the ramp color = list: colors corresponding to slots in the ramp state = integer: state identifier selection = selection: for automatic ranging beyond = number: with automatic ranging, are we excluding values beyond a certain distance from the selection? within = number: with automatic ranging, are we only including valuess within a certain distance from the selection? sigma = number: with automatic ranging, how many standard deviations from the mean do we go? zero = integer: with automatic ranging, do we force the central value to be zero? EXAMPLES ramp_new e_pot_color, e_pot_map, [-10,0,10], [red,white,blue] NOTES Color ramps are extremely powerful but complicated to use. In the simplest case, they can be used to color representations based on the potential values found in a map object at the corresponding positions in space. In another simple case, representations can be colored based on proximity to a target. Note that since ramp targets must themselves be real objects (not merely selections), the "create" command may be needed in order to generate an appropriate target. In more complicated cases, they can be used to color representations on one object based atoms found in another. Ramps can operate recursively. In other words, the output color from one ramp can be used as the input color for another. For example, you could color by map potential within a certain distance of the target object, beyond which, a uniform color is applied. PYMOL API def ramp_new(string name, string map_name, list range, list color, int state, string selection, float beyond, float within, float sigma, int zero, int quiet) SEE ALSO load, color, create, slice, gradient ''' r = DEFAULT_ERROR safe_color = string.strip(str(color)) if(safe_color[0:1]=="["): # looks like a list color = safe_alpha_list_eval(str(safe_color)) else: # looks like a literal color = str(color) new_color = [] # preprocess selection if selection!='': selection = selector.process(selection) # coerce range try: if isinstance(range, str): range = safe_list_eval(range) range = map(float, range) except: raise pymol.CmdException('invalid range') if is_list(color): for a in color: if not is_list(a): new_color.append(list(_self.get_color_tuple(a,4))) # incl negative RGB special colors else: new_color.append(a) elif is_string(color): new_color = ramp_spectrum_dict[ramp_spectrum_sc.auto_err(str(color),'ramp color spectrum')] else: new_color=int(color) try: _self.lock(_self) r = _cmd.ramp_new(_self._COb,str(name),str(map_name),range,new_color, int(state)-1,str(selection),float(beyond),float(within), float(sigma),int(zero),int(quiet)) finally: _self.unlock(r,_self) if _self._raising(r,_self): raise pymol.CmdException return r
def ramp_new(name, map_name, range=[-1.0, 0.0, 1.0], color=['red', [1.0, 1.0, 1.0], 'blue'], state=1, selection='', beyond=2.0, within=6.0, sigma=2.0, zero=1, quiet=1, _self=cmd): ''' DESCRIPTION "ramp_new" creates a color ramp based on a map potential value or based on proximity to a molecular object. USAGE ramp_new name, map_name [, range [, color [, state [, selection [, beyond [, within [, sigma [, zero ]]]]]]]] ARGUMENTS name = string: name of the ramp object map_name = string: name of the map (for potential) or molecular object (for proximity) range = list: values corresponding to slots in the ramp color = list: colors corresponding to slots in the ramp state = integer: state identifier selection = selection: for automatic ranging beyond = number: with automatic ranging, are we excluding values beyond a certain distance from the selection? within = number: with automatic ranging, are we only including valuess within a certain distance from the selection? sigma = number: with automatic ranging, how many standard deviations from the mean do we go? zero = integer: with automatic ranging, do we force the central value to be zero? EXAMPLES ramp_new e_pot_color, e_pot_map, [-10,0,10], [red,white,blue] NOTES Color ramps are extremely powerful but complicated to use. In the simplest case, they can be used to color representations based on the potential values found in a map object at the corresponding positions in space. In another simple case, representations can be colored based on proximity to a target. Note that since ramp targets must themselves be real objects (not merely selections), the "create" command may be needed in order to generate an appropriate target. In more complicated cases, they can be used to color representations on one object based atoms found in another. Ramps can operate recursively. In other words, the output color from one ramp can be used as the input color for another. For example, you could color by map potential within a certain distance of the target object, beyond which, a uniform color is applied. PYMOL API def ramp_new(string name, string map_name, list range, list color, int state, string selection, float beyond, float within, float sigma, int zero, int quiet) SEE ALSO load, color, create, slice, gradient ''' r = DEFAULT_ERROR safe_color = string.strip(str(color)) if (safe_color[0:1] == "["): # looks like a list color = safe_alpha_list_eval(str(safe_color)) else: # looks like a literal color = str(color) new_color = [] # preprocess selection if selection != '': selection = selector.process(selection) # coerce range try: if isinstance(range, str): range = safe_list_eval(range) range = map(float, range) except: raise pymol.CmdException('invalid range') if is_list(color): for a in color: if not is_list(a): new_color.append(list(_self.get_color_tuple( a, 4))) # incl negative RGB special colors else: new_color.append(a) elif is_string(color): new_color = ramp_spectrum_dict[ramp_spectrum_sc.auto_err( str(color), 'ramp color spectrum')] else: new_color = int(color) try: _self.lock(_self) r = _cmd.ramp_new(_self._COb, str(name), str(map_name), range, new_color, int(state) - 1, str(selection), float(beyond), float(within), float(sigma), int(zero), int(quiet)) finally: _self.unlock(r, _self) if _self._raising(r, _self): raise pymol.CmdException return r