Example #1
0
    def cache(action='optimize', scenes='', state=-1, quiet=1, _self=cmd):
        '''
DESCRIPTION

    "cache" manages storage of precomputed results, such as
    molecular surfaces.

USAGE

    cache action [, scenes [, state ]]

ARGUMENTS

    action = string: enable, disable, read_only, clear, or optimize

    scenes = string: a space-separated list of scene names (default: '')

    state = integer: state index (default: -1)

EXAMPLES

    cache enable
    cache optimize
    cache optimize, F1 F2 F5

NOTES

    "cache optimize" will iterate through the list of scenes provided
    (or all defined scenes), compute any missing surfaces, and store
    them in the cache for later reuse.
    
PYMOL API

    cmd.cache(string action, string scenes, int state, int quiet)

    '''

        r = DEFAULT_ERROR
        action = cache_action_dict[cache_action_sc.auto_err(
            str(action), 'action')]
        quiet = int(quiet)
        if action == 0:  # enable
            r = _self.set('cache_mode', 2, quiet=quiet)
        elif action == 1:  # disable
            r = _self.set('cache_mode', 0, quiet=quiet)
        elif action == 2:  # read_only
            r = _self.set('cache_mode', 1, quiet=quiet)
        elif action == 3:  # clear
            r = _self._cache_clear(_self=_self)
        elif action == 4:  # optimize
            r = DEFAULT_SUCCESS
            _self._cache_mark(_self=_self)
            cur_scene = _self.get('scene_current_name')
            cache_max = int(_self.get('cache_max'))
            if cache_max > 0:
                # allow double memory for an optimized cache
                _self.set('cache_max', cache_max * 2)
            scenes = str(scenes)
            scene_list = string.split(scenes)
            cache_mode = int(_self.get('cache_mode'))
            _self.set('cache_mode', 2)
            if not len(scene_list):
                scene_list = _self.get_scene_list()
            for scene in scene_list:
                scene = string.strip(scene)
                if not quiet:
                    print " cache: optimizing scene '%s'." % scene
                cmd.scene(scene, animate=0)
                cmd.rebuild()
                cmd.refresh()
            if len(cur_scene):
                cmd.scene(cur_scene, animate=0)
            else:
                scene_list = _self.get_scene_list()
                if len(scene_list):
                    cmd.scene(scene_list[0], animate=0)
                else:
                    if not quiet:
                        print " cache: no scenes defined -- optimizing current display."
                    cmd.rebuild()
                    cmd.refresh()
            usage = _self._cache_purge(-1, _self=_self)
            if cache_mode:
                _self.set('cache_mode', cache_mode)
            else:
                _self.set('cache_mode', 2)  # hmm... could use 1 here instead.
            _self.set('cache_max', cache_max)  # restore previous limits
            if not quiet:
                print " cache: optimization complete (~%0.1f MB)." % (
                    usage * 4 / 1000000.0)
        try:
            _self.lock(_self)
        finally:
            _self.unlock(r, _self)
        if _self._raising(r, _self): raise QuietException
        return r
Example #2
0
    def mview(action='store', first=0, last=0, power=0.0,
              bias=-1.0, simple=-1, linear=0.0, object='',
              wrap=-1, hand=0, window=5, cycles=1, scene='',
              cut=0.5, quiet=1, auto=-1, state=0, freeze=0,
              _self=cmd):

        '''
DESCRIPTION

    "mview" stores camera and object matrices for use in movie
    interpolation.

USAGE

    mview [action [, first [, last [, power [, bias [, simple
       [, linear [, object [, wrap [, hand [, window [, cycles [,scene
       [, cut [, quiet ]]]]]]]]]]]]]]]

NOTES

    This command is not yet fully supported in PyMOL 1.x.
    
SEE ALSO

    mplay, mset, mdo, mclear, mmatrix
        '''
        
        r = DEFAULT_ERROR
        first = int(first)
        last = int(last)
        auto = int(auto)
        freeze = int(freeze)
        if first<0:
            first = _self.count_frames() + first + 1
            if last == 0:
                last = _self.count_frames()
        if last<0:
            last = _self.count_frames() + last + 1
        action = mview_action_dict[mview_action_sc.auto_err(action,'action')]
        if (scene==None) or (scene=='auto'):
            scene = _self.get("scene_current_name")
        scene = str(scene)
        if (scene!=''):
            cmd.scene(scene,"recall","",animate=0,frame=0)
        try:
            _self.lock(_self)
            r = _cmd.mview(_self._COb,int(action),int(first)-1,int(last)-1,
                           float(power),float(bias),
                           int(simple), float(linear),str(object),
                           int(wrap),int(hand),int(window),int(cycles),
                           str(scene),float(cut),int(quiet),int(state)-1,0)
            if (not freeze and 
                ((auto>0) or ((auto<0) and 
                              (_self.get_setting_int("movie_auto_interpolate")>0)))):
                if action in [0,1,7]: # reinterpolate after store, clear, or toggle
                    _cmd.mview(_self._COb,3,-1,-1,
                               float(power),float(bias),
                               int(simple), float(linear),str(object),
                               int(wrap),int(hand),int(window),int(cycles),
                               str(scene),float(cut),int(quiet),-1,1)                    
        finally:
            _self.unlock(r,_self)
        if _self._raising(r,_self): raise pymol.CmdException
        return r
Example #3
0
    def cache(action='optimize', scenes='',state=-1, quiet=1, _self=cmd):
        '''
DESCRIPTION

    "cache" manages storage of precomputed results, such as
    molecular surfaces.

USAGE

    cache action [, scenes [, state ]]

ARGUMENTS

    action = string: enable, disable, read_only, clear, or optimize

    scenes = string: a space-separated list of scene names (default: '')

    state = integer: state index (default: -1)

EXAMPLES

    cache enable
    cache optimize
    cache optimize, F1 F2 F5

NOTES

    "cache optimize" will iterate through the list of scenes provided
    (or all defined scenes), compute any missing surfaces, and store
    them in the cache for later reuse.
    
PYMOL API

    cmd.cache(string action, string scenes, int state, int quiet)

    '''
        
        r = DEFAULT_ERROR
        action = cache_action_dict[cache_action_sc.auto_err(str(action),'action')]
        quiet = int(quiet)
        if action == 0: # enable
            r = _self.set('cache_mode',2,quiet=quiet)
        elif action == 1: # disable
            r =_self.set('cache_mode',0,quiet=quiet)
        elif action == 2: # read_only
            r =_self.set('cache_mode',1,quiet=quiet)
        elif action == 3: # clear
            r =_self._cache_clear(_self=_self)
        elif action == 4: # optimize
            r = DEFAULT_SUCCESS
            _self._cache_mark(_self=_self)
            cur_scene = _self.get('scene_current_name')
            cache_max = int(_self.get('cache_max'))
            if cache_max>0:
                # allow double memory for an optimized cache
                _self.set('cache_max',cache_max*2) 
            scenes = str(scenes)
            scene_list = string.split(scenes)
            cache_mode = int(_self.get('cache_mode'))
            _self.set('cache_mode',2)
            if not len(scene_list):
                scene_list = _self.get_scene_list()
            for scene in scene_list:
                scene = string.strip(scene)
                if not quiet:
                    print " cache: optimizing scene '%s'."%scene
                cmd.scene(scene,animate=0)
                cmd.rebuild()                
                cmd.refresh()
            if len(cur_scene):
                cmd.scene(cur_scene,animate=0)
            else:
                scene_list = _self.get_scene_list()
                if len(scene_list):
                    cmd.scene(scene_list[0],animate=0)
                else:
                    if not quiet:
                        print " cache: no scenes defined -- optimizing current display."
                    cmd.rebuild() 
                    cmd.refresh()
            usage = _self._cache_purge(-1,_self=_self)
            if cache_mode:
                _self.set('cache_mode',cache_mode)
            else:
                _self.set('cache_mode',2) # hmm... could use 1 here instead.
            _self.set('cache_max',cache_max) # restore previous limits
            if not quiet:            
                print " cache: optimization complete (~%0.1f MB)."%(usage*4/1000000.0)
        try:
            _self.lock(_self)
        finally:
            _self.unlock(r,_self)
        if _self._raising(r,_self): raise QuietException         
        return r
Example #4
0
    def mview(action='store',
              first=0,
              last=0,
              power=0.0,
              bias=-1.0,
              simple=-1,
              linear=0.0,
              object='',
              wrap=-1,
              hand=0,
              window=5,
              cycles=1,
              scene='',
              cut=0.5,
              quiet=1,
              auto=-1,
              state=0,
              freeze=0,
              _self=cmd):
        '''
DESCRIPTION

    "mview" stores camera and object matrices for use in movie
    interpolation.

USAGE

    mview [action [, first [, last [, power [, bias [, simple
       [, linear [, object [, wrap [, hand [, window [, cycles [,scene
       [, cut [, quiet ]]]]]]]]]]]]]]]

NOTES

    This command is not yet fully supported in PyMOL 1.x.
    
SEE ALSO

    mplay, mset, mdo, mclear, mmatrix
        '''

        r = DEFAULT_ERROR
        first = int(first)
        last = int(last)
        auto = int(auto)
        freeze = int(freeze)
        if first < 0:
            first = _self.count_frames() + first + 1
            if last == 0:
                last = _self.count_frames()
        if last < 0:
            last = _self.count_frames() + last + 1
        action = mview_action_dict[mview_action_sc.auto_err(action, 'action')]
        if (scene == None) or (scene == 'auto'):
            scene = _self.get("scene_current_name")
        scene = str(scene)
        if (scene != ''):
            cmd.scene(scene, "recall", "", animate=0, frame=0)
        try:
            _self.lock(_self)
            r = _cmd.mview(_self._COb, int(action),
                           int(first) - 1,
                           int(last) - 1, float(power), float(bias),
                           int(simple), float(linear), str(object), int(wrap),
                           int(hand), int(window), int(cycles), str(scene),
                           float(cut), int(quiet),
                           int(state) - 1, 0)
            if (not freeze and
                ((auto > 0) or
                 ((auto < 0) and
                  (_self.get_setting_int("movie_auto_interpolate") > 0)))):
                if action in [0, 1, 7
                              ]:  # reinterpolate after store, clear, or toggle
                    _cmd.mview(_self._COb, 3, -1, -1, float(power),
                               float(bias), int(simple), float(linear),
                               str(object), int(wrap), int(hand), int(window),
                               int(cycles), str(scene), float(cut), int(quiet),
                               -1, 1)
        finally:
            _self.unlock(r, _self)
        if _self._raising(r, _self): raise pymol.CmdException
        return r