Пример #1
0
    def id_atom(selection, mode=0, quiet=1, _self=cmd):
        '''
DESCRIPTION

    "id_atom" returns the original source id of a single atom, or
    raises and exception if the atom does not exist or if the selection
    corresponds to multiple atoms.

PYMOL API

    list = cmd.id_atom(string selection)
        '''
        r = DEFAULT_ERROR
        selection = str(selection)
        l = apply(identify, (selection, mode, 1))
        ll = len(l)
        if not ll:
            if _feedback(fb_module.cmd, fb_mask.errors, _self):
                print "cmd-Error: atom %s not found by id_atom." % selection
            if _self._raising(_self=_self): raise pymol.CmdException
        elif ll > 1:
            if _feedback(fb_module.cmd, fb_mask.errors, _self):
                print "cmd-Error: multiple atoms %s found by id_atom." % selection
            if _self._raising(_self=_self): raise pymol.CmdException
        else:
            r = l[0]
            if not quiet:
                if mode:
                    print " cmd.id_atom: (%s and id %d)" % (r[0], r[1])
                else:
                    print " cmd.id_atom: (id %d)" % r
        if _raising(r, _self): raise pymol.CmdException
        return r
Пример #2
0
    def id_atom(selection,mode=0,quiet=1,_self=cmd):
        '''
DESCRIPTION

    "id_atom" returns the original source id of a single atom, or
    raises and exception if the atom does not exist or if the selection
    corresponds to multiple atoms.

PYMOL API

    list = cmd.id_atom(string selection)
        '''
        r = DEFAULT_ERROR
        selection = str(selection)
        l = apply(identify,(selection,mode,1))
        ll = len(l)
        if not ll:
            if _feedback(fb_module.cmd,fb_mask.errors,_self):
                print "cmd-Error: atom %s not found by id_atom." % selection
            if _self._raising(_self=_self): raise pymol.CmdException
        elif ll>1:
            if _feedback(fb_module.cmd,fb_mask.errors,_self):
                print "cmd-Error: multiple atoms %s found by id_atom." % selection
            if _self._raising(_self=_self): raise pymol.CmdException
        else:
            r = l[0]
            if not quiet:
                if mode:
                    print " cmd.id_atom: (%s and id %d)"%(r[0],r[1])
                else:
                    print " cmd.id_atom: (id %d)"%r
        if _raising(r,_self): raise pymol.CmdException
        return r
Пример #3
0
    def get_version(quiet=1,_self=cmd):
	'''
DESCRIPTION
 
    "get_version" returns a tuple of length three containing text,
    floating point, and integer representations of the current PyMOL
    version number.
   
PYMOL API

    cmd.get_version(int quiet)

	'''
        r = DEFAULT_ERROR
        try:
            _self.lock(_self)   
            r = _cmd.get_version(_self._COb)
        finally:
            _self.unlock(r,_self)
        if _raising(r,_self):
            raise pymol.CmdException
        else:
            if not quiet:
                if _feedback(fb_module.cmd,fb_mask.results,_self):
                    print " version: %s (%8.6f) %d"%r
        return r
Пример #4
0
    def phi_psi(selection="(byres pk1)", quiet=1, _self=cmd):
        '''
DESCRIPTION

    "phi_psi" return the phi and psi angles for a protein atom
    selection.
    
USAGE
        '''
        
        r = cmd.get_phipsi(selection)
        if r!=None:
            kees = r.keys()
            kees.sort()
            if not quiet:
                _self.feedback('push')
                _self.feedback('disable','executive','actions')
                for a in kees:
                    _self.iterate("(%s`%d)"%a,"print ' %-9s "+
                                ("( %6.1f, %6.1f )"%r[a])+
                                "'%(resn+'-'+resi+':')")
                _self.feedback('pop')
        elif _feedback(fb_module.cmd,fb_mask.errors,_self):      
            print "cmd-Error: can't compute phi_psi"
        if _raising(r,_self): raise pymol.CmdException
        return r
Пример #5
0
    def get_version(quiet=1,_self=cmd):
	'''
DESCRIPTION
 
    "get_version" returns a tuple of length six containing text,
    floating point, and integer representations of the current PyMOL
    version number, build date as unix timestamp, GIT SHA and SVN
    code revision so far available.
   
PYMOL API

    cmd.get_version(int quiet)

	'''
        r = DEFAULT_ERROR
        try:
            _self.lock(_self)   
            r = _cmd.get_version(_self._COb)
        finally:
            _self.unlock(r,_self)
        if _raising(r,_self):
            raise pymol.CmdException
        else:
            quiet = int(quiet)
            if quiet < 1 and _feedback(fb_module.cmd, fb_mask.results, _self):
                print " version: %s (%2.3f) %d," % r[:3],
                print "Incentive Product" if pymol.invocation.options.incentive_product else "Open-Source"
                if quiet < 0:
                    if r[3]:
                        print ' build date:', time.strftime('%c %Z', time.localtime(r[3]))
                    if r[4]:
                        print ' git sha:', r[4]
                    if r[5]:
                        print ' svn rev:', r[5]
        return r
Пример #6
0
    def get_version(quiet=1, _self=cmd):
        '''
DESCRIPTION
 
    "get_version" returns a tuple of length three containing text,
    floating point, and integer representations of the current PyMOL
    version number.
   
PYMOL API

    cmd.get_version(int quiet)

	'''
        r = DEFAULT_ERROR
        try:
            _self.lock(_self)
            r = _cmd.get_version(_self._COb)
        finally:
            _self.unlock(r, _self)
        if _raising(r, _self):
            raise pymol.CmdException
        else:
            if not quiet:
                if _feedback(fb_module.cmd, fb_mask.results, _self):
                    print " version: %s (%2.3f) %d" % r
        return r
Пример #7
0
    def phi_psi(selection="(byres pk1)", quiet=1, _self=cmd):
        '''
DESCRIPTION

    "phi_psi" return the phi and psi angles for a protein atom
    selection.
    
USAGE
        '''

        r = cmd.get_phipsi(selection)
        if r != None:
            kees = r.keys()
            kees.sort()
            if not quiet:
                _self.feedback('push')
                _self.feedback('disable', 'executive', 'actions')
                for a in kees:
                    _self.iterate(
                        "(%s`%d)" % a, "print ' %-9s " +
                        ("( %6.1f, %6.1f )" % r[a]) + "'%(resn+'-'+resi+':')")
                _self.feedback('pop')
        elif _feedback(fb_module.cmd, fb_mask.errors, _self):
            print "cmd-Error: can't compute phi_psi"
        if _raising(r, _self): raise pymol.CmdException
        return r
Пример #8
0
    def get_version(quiet=1,_self=cmd):
	'''
DESCRIPTION
 
    "get_version" returns a tuple of length six containing text,
    floating point, and integer representations of the current PyMOL
    version number, build date as unix timestamp, GIT SHA and SVN
    code revision so far available.
   
PYMOL API

    cmd.get_version(int quiet)

	'''
        # get_version doesn't need the _COb and doesn't require a lock
        r = _cmd.get_version()
        if _raising(r,_self):
            raise pymol.CmdException
        else:
            quiet = int(quiet)
            if quiet < 1 and _feedback(fb_module.cmd, fb_mask.results, _self):
                import re
                p = pymol.get_version_message(r)
                print re.sub(r'^', ' ', p, re.M)
                if quiet < 0:
                    if r[3]:
                        print ' build date:', time.strftime('%c %Z', time.localtime(r[3]))
                    if r[4]:
                        print ' git sha:', r[4]
        return r
Пример #9
0
 def get_color_tuple(name,mode=0,_self=cmd):
     name=str(name)
     r = DEFAULT_ERROR
     try:
         _self.lock(_self)
         r = _cmd.get_color(_self._COb,name,mode)
         if r==None:
             if _feedback(fb_module.cmd,fb_mask.errors,_self):         
                 print "cmd-Error: Unknown color '%s'."%name
     finally:
         _self.unlock(r,_self)
     if _raising(r,_self): raise pymol.CmdException
     return r
Пример #10
0
 def get_color_tuple(name, mode=0, _self=cmd):
     name = str(name)
     r = DEFAULT_ERROR
     try:
         _self.lock(_self)
         r = _cmd.get_color(_self._COb, name, mode)
         if r == None:
             if _feedback(fb_module.cmd, fb_mask.errors, _self):
                 print "cmd-Error: Unknown color '%s'." % name
     finally:
         _self.unlock(r, _self)
     if _raising(r, _self): raise pymol.CmdException
     return r
Пример #11
0
    def get_type(name,quiet=1,_self=cmd):
        '''
DESCRIPTION

    "get_type" returns a string describing the named object or
     selection or the string "nonexistent" if the name in unknown.

PYMOL API

    cmd.get_type(string object-name)

NOTES

    Possible return values are

    "object:molecule"
    "object:map"
    "object:mesh"
    "object:slice"
    "object:surface"
    "object:measurement"
    "object:cgo"
    "object:group"
    "object:volume"
    "selection"

SEE ALSO

    get_names
        '''
        r = DEFAULT_ERROR
        try:
            _self.lock(_self)
            r = _cmd.get_type(_self._COb,str(name))
        finally:
            _self.unlock(r,_self)
        if is_error(r):
            if not quiet and _feedback(fb_module.cmd,fb_mask.errors,_self):      
                print "Cmd-Error: unrecognized name."
        elif not quiet:
            print r
        if _raising(r,_self): raise pymol.CmdException
        return r
Пример #12
0
    def get_type(name, quiet=1, _self=cmd):
        '''
DESCRIPTION

    "get_type" returns a string describing the named object or
     selection or the string "nonexistent" if the name in unknown.

PYMOL API

    cmd.get_type(string object-name)

NOTES

    Possible return values are

    "object:molecule"
    "object:map"
    "object:mesh"
    "object:slice"
    "object:surface"
    "object:measurement"
    "object:cgo"
    "object:group"
    "object:volume"
    "selection"

SEE ALSO

    get_names
        '''
        r = DEFAULT_ERROR
        try:
            _self.lock(_self)
            r = _cmd.get_type(_self._COb, str(name))
        finally:
            _self.unlock(r, _self)
        if is_error(r):
            if not quiet and _feedback(fb_module.cmd, fb_mask.errors, _self):
                print "Cmd-Error: unrecognized name."
        elif not quiet:
            print r
        if _raising(r, _self): raise pymol.CmdException
        return r
Пример #13
0
    def distance(name=None, selection1="(pk1)", selection2="(pk2)", 
		 cutoff=None, mode=None, zoom=0, width=None, length=None,
                 gap=None, label=1, quiet=1, reset=0, state=0, _self=cmd):
	
        '''
DESCRIPTION

    "distance" creates a new distance object between two selections.

USAGE
    
    distance [name [, selection1 [, selection2 [, cutoff [, mode ]]]]]

ARGUMENTS

    name = string: name of the distance object to create

    selection1 = string: first atom selection

    selection2 = string: second atom selection

    cutoff = float: longest distance to show 
    
    mode = 0: all interatomic distances

    mode = 1: only bond distances

    mode = 2: only show polar contact distances

EXAMPLES

    distance mydist, 14/CA, 29/CA

    distance hbonds, all, all, 3.2, mode=2

NOTES

    The distance wizard makes measuring distances easier than using
    the "dist" command for real-time operations.

    "dist" alone will show distances between selections (pk1) and (pk1),
    which can be set using the PkAt mouse action (usually CTRL-middle-click).

PYMOL API

    cmd.distance(string name, string selection1, string selection2,
                 string cutoff, string mode )

    '''
        # handle unnamed distance
        r = DEFAULT_SUCCESS
        if name!=None:
            if len(name):
                if name[0]=='(' or ' ' in name or '/' in name: # we're one argument off...
                    if cutoff!=None:
                        mode = cutoff
                    if selection2!="(pk2)":
                        cutoff = selection2
                    if selection1!="(pk1)":
                        selection2 = selection1
                    selection1=name
                    name = None

        if selection1=="(pk1)":
            if "pk1" not in _self.get_names('selections'):
                if _feedback(fb_module.cmd,fb_mask.errors,_self):
                    print "cmd-Error: The 'pk1' selection is undefined."
                r = DEFAULT_ERROR
        if selection2=="(pk2)":
            if "pk2" not in _self.get_names('selections'):
                if _feedback(fb_module.cmd,fb_mask.errors,_self):         
                    print "cmd-Error: The 'pk2' selection is undefined."
                r = DEFAULT_ERROR
        if is_ok(r):
            r = DEFAULT_ERROR

            # if unlabeled, then get next name in series

            if name!=None:
                nam=name
            else:
                try:
                    _self.lock(_self)
                    cnt = _cmd.get(_self._COb,"dist_counter") + 1.0
                    r = _cmd.legacy_set(_self._COb,"dist_counter","%1.0f" % cnt)
                    nam = "dist%02.0f" % cnt
                finally:
                    _self.unlock(r,_self)

            # defaults
            if mode == None:
                mode = 0
            if cutoff == None:
                cutoff = -1.0
            # preprocess selections
            selection1 = selector.process(selection1)
            selection2 = selector.process(selection2)
            # now do the deed
            try:
                _self.lock(_self)
                if selection2!="same":
                    selection2 = "("+selection2+")"
                r = _cmd.dist(_self._COb,str(nam),"("+str(selection1)+")",
                              str(selection2),int(mode),float(cutoff),
                              int(label),int(quiet),int(reset),
                              int(state)-1,int(zoom))
                if width!=None:
                    _self.set("dash_width",width,nam)
                if length!=None:
                    _self.set("dash_length",length,nam)
                if gap!=None:
                    _self.set("dash_gap",gap,nam)
            finally:
                _self.unlock(r,_self)
        if (r<0.0) and (not quiet):
            # a negative value is an warning signal from PyMOL...
            r = DEFAULT_ERROR
        if _raising(r,_self): raise pymol.CmdException
        return r
Пример #14
0
    def dihedral(name=None, selection1="(pk1)", selection2="(pk2)",
		 selection3="(pk3)", selection4="(pk4)", mode=None,
		 label=1, reset=0, zoom=0, state=0, quiet=1, _self=cmd):
        '''
DESCRIPTION

    "dihedral" shows dihedral angles formed between any four atoms.

USAGE

    dihedral [ name [, selection1 [, selection2 [, selection3 [, selection4 ]]]]]


NOTES

    "dihedral" alone will show the dihedral angle formed by selections
    (pk1), (pk2), (pk3), and (pk4), which can be set using the "PkAt"
    mouse action (typically, Ctrl-middle-click)

PYMOL API

    cmd.dihedral(string name, string selection1, string selection2,
                 string selection3, string selection4)

SEE ALSO

    distance, angle
    '''
        r = DEFAULT_SUCCESS      
        if selection1=="(pk1)":
            if "pk1" not in _self.get_names('selections'):
                if _feedback(fb_module.cmd,fb_mask.errors,_self):
                    print "cmd-Error: The 'pk1' selection is undefined."
                r = DEFAULT_ERROR
        if selection2=="(pk2)":
            if "pk2" not in _self.get_names('selections'):
                if _feedback(fb_module.cmd,fb_mask.errors,_self):         
                    print "cmd-Error: The 'pk2' selection is undefined."
                r = DEFAULT_ERROR
        if selection3=="(pk3)":
            if "pk3" not in _self.get_names('selections'):
                if _feedback(fb_module.cmd,fb_mask.errors,_self):         
                    print "cmd-Error: The 'pk3' selection is undefined."
                r = DEFAULT_ERROR
        if selection3=="(pk4)":
            if "pk4" not in _self.get_names('selections'):
                if _feedback(fb_module.cmd,fb_mask.errors,_self):         
                    print "cmd-Error: The 'pk4' selection is undefined."
                r = DEFAULT_ERROR
        if is_ok(r):
            r = DEFAULT_ERROR
            # if unlabeled, then get next name in series

            if name!=None:
                nam=name
            else:
                try:
                    _self.lock(_self)
                    cnt = _cmd.get(_self._COb,"dist_counter") + 1.0
                    r = _cmd.legacy_set(_self._COb,"dist_counter","%1.0f" % cnt)
                    nam = "dihedral%02.0f" % cnt
                finally:
                    _self.unlock(r,_self)

            # defaults
            if mode == None:
                mode = 0
            # preprocess selections
            selection1 = selector.process(selection1)
            selection2 = selector.process(selection2)
            selection3 = selector.process(selection3)
            selection4 = selector.process(selection4)
            # now do the deed
            try:
                _self.lock(_self)
                if selection2!="same":
                    selection2 = "("+selection2+")"
                if selection3!="same":
                    selection3 = "("+selection3+")"
                if selection4!="same":
                    selection4 = "("+selection4+")"
                r = _cmd.dihedral(_self._COb,str(nam),"("+str(selection1)+")",
                                  str(selection2),
                                  str(selection3),
                                  str(selection4),
                                  int(mode),int(label),
                                  int(reset),int(zoom),
                                  int(quiet),int(state)-1)
            finally:
                _self.unlock(r,_self)
        if _raising(r,_self): raise pymol.CmdException
        return r
Пример #15
0
    def distance(name=None,
                 selection1="(pk1)",
                 selection2="(pk2)",
                 cutoff=None,
                 mode=None,
                 zoom=0,
                 width=None,
                 length=None,
                 gap=None,
                 label=1,
                 quiet=1,
                 reset=0,
                 state=0,
                 _self=cmd):
        '''
DESCRIPTION

    "distance" creates a new distance object between two selections.

USAGE
    
    distance [name [, selection1 [, selection2 [, cutoff [, mode ]]]]]

ARGUMENTS

    name = string: name of the distance object to create

    selection1 = string: first atom selection

    selection2 = string: second atom selection

    cutoff = float: longest distance to show 
    
    mode = 0: all interatomic distances

    mode = 1: only bond distances

    mode = 2: only show polar contact distances

EXAMPLES

    distance mydist, 14/CA, 29/CA

    distance hbonds, all, all, 3.2, mode=2

NOTES

    The distance wizard makes measuring distances easier than using
    the "dist" command for real-time operations.

    "dist" alone will show distances between selections (pk1) and (pk1),
    which can be set using the PkAt mouse action (usually CTRL-middle-click).

PYMOL API

    cmd.distance(string name, string selection1, string selection2,
                 string cutoff, string mode )

    '''
        # handle unnamed distance
        r = DEFAULT_SUCCESS
        if name != None:
            if len(name):
                if name[0] == '(' or ' ' in name or '/' in name:  # we're one argument off...
                    if cutoff != None:
                        mode = cutoff
                    if selection2 != "(pk2)":
                        cutoff = selection2
                    if selection1 != "(pk1)":
                        selection2 = selection1
                    selection1 = name
                    name = None

        if selection1 == "(pk1)":
            if "pk1" not in _self.get_names('selections'):
                if _feedback(fb_module.cmd, fb_mask.errors, _self):
                    print "cmd-Error: The 'pk1' selection is undefined."
                r = DEFAULT_ERROR
        if selection2 == "(pk2)":
            if "pk2" not in _self.get_names('selections'):
                if _feedback(fb_module.cmd, fb_mask.errors, _self):
                    print "cmd-Error: The 'pk2' selection is undefined."
                r = DEFAULT_ERROR
        if is_ok(r):
            r = DEFAULT_ERROR

            # if unlabeled, then get next name in series

            if name != None:
                nam = name
            else:
                try:
                    _self.lock(_self)
                    cnt = _cmd.get(_self._COb, "dist_counter") + 1.0
                    r = _cmd.legacy_set(_self._COb, "dist_counter",
                                        "%1.0f" % cnt)
                    nam = "dist%02.0f" % cnt
                finally:
                    _self.unlock(r, _self)

            # defaults
            if mode == None:
                mode = 0
            if cutoff == None:
                cutoff = -1.0
            # preprocess selections
            selection1 = selector.process(selection1)
            selection2 = selector.process(selection2)
            # now do the deed
            try:
                _self.lock(_self)
                if selection2 != "same":
                    selection2 = "(" + selection2 + ")"
                r = _cmd.dist(_self._COb, str(nam),
                              "(" + str(selection1) + ")", str(selection2),
                              int(mode), float(cutoff), int(label), int(quiet),
                              int(reset),
                              int(state) - 1, int(zoom))
                if width != None:
                    _self.set("dash_width", width, nam)
                if length != None:
                    _self.set("dash_length", length, nam)
                if gap != None:
                    _self.set("dash_gap", gap, nam)
            finally:
                _self.unlock(r, _self)
        if (r < 0.0) and (not quiet):
            # a negative value is an warning signal from PyMOL...
            r = DEFAULT_ERROR
        if _raising(r, _self): raise pymol.CmdException
        return r
Пример #16
0
    def dihedral(name=None,
                 selection1="(pk1)",
                 selection2="(pk2)",
                 selection3="(pk3)",
                 selection4="(pk4)",
                 mode=None,
                 label=1,
                 reset=0,
                 zoom=0,
                 state=0,
                 quiet=1,
                 _self=cmd):
        '''
DESCRIPTION

    "dihedral" shows dihedral angles formed between any four atoms.

USAGE

    dihedral [ name [, selection1 [, selection2 [, selection3 [, selection4 ]]]]]


NOTES

    "dihedral" alone will show the dihedral angle formed by selections
    (pk1), (pk2), (pk3), and (pk4), which can be set using the "PkAt"
    mouse action (typically, Ctrl-middle-click)

PYMOL API

    cmd.dihedral(string name, string selection1, string selection2,
                 string selection3, string selection4)

SEE ALSO

    distance, angle
    '''
        r = DEFAULT_SUCCESS
        if selection1 == "(pk1)":
            if "pk1" not in _self.get_names('selections'):
                if _feedback(fb_module.cmd, fb_mask.errors, _self):
                    print "cmd-Error: The 'pk1' selection is undefined."
                r = DEFAULT_ERROR
        if selection2 == "(pk2)":
            if "pk2" not in _self.get_names('selections'):
                if _feedback(fb_module.cmd, fb_mask.errors, _self):
                    print "cmd-Error: The 'pk2' selection is undefined."
                r = DEFAULT_ERROR
        if selection3 == "(pk3)":
            if "pk3" not in _self.get_names('selections'):
                if _feedback(fb_module.cmd, fb_mask.errors, _self):
                    print "cmd-Error: The 'pk3' selection is undefined."
                r = DEFAULT_ERROR
        if selection3 == "(pk4)":
            if "pk4" not in _self.get_names('selections'):
                if _feedback(fb_module.cmd, fb_mask.errors, _self):
                    print "cmd-Error: The 'pk4' selection is undefined."
                r = DEFAULT_ERROR
        if is_ok(r):
            r = DEFAULT_ERROR
            # if unlabeled, then get next name in series

            if name != None:
                nam = name
            else:
                try:
                    _self.lock(_self)
                    cnt = _cmd.get(_self._COb, "dist_counter") + 1.0
                    r = _cmd.legacy_set(_self._COb, "dist_counter",
                                        "%1.0f" % cnt)
                    nam = "dihedral%02.0f" % cnt
                finally:
                    _self.unlock(r, _self)

            # defaults
            if mode == None:
                mode = 0
            # preprocess selections
            selection1 = selector.process(selection1)
            selection2 = selector.process(selection2)
            selection3 = selector.process(selection3)
            selection4 = selector.process(selection4)
            # now do the deed
            try:
                _self.lock(_self)
                if selection2 != "same":
                    selection2 = "(" + selection2 + ")"
                if selection3 != "same":
                    selection3 = "(" + selection3 + ")"
                if selection4 != "same":
                    selection4 = "(" + selection4 + ")"
                r = _cmd.dihedral(_self._COb,
                                  str(nam), "(" + str(selection1) + ")",
                                  str(selection2), str(selection3),
                                  str(selection4), int(mode), int(label),
                                  int(reset), int(zoom), int(quiet),
                                  int(state) - 1)
            finally:
                _self.unlock(r, _self)
        if _raising(r, _self): raise pymol.CmdException
        return r