Hi Dirk,
cmd.iterate is actually the most efficient function to access atom properties.
If you want a wrapper which directly gets b and q for one atom, it could look
like this (returns a dictionary):
from pymol import cmd
@cmd.extend
def get_signle_atom_props(selection, props=['b', 'q'], quiet=1):
if isinstance(props, basestring):
props = cmd.safe_list_eval(props)
expr = ','.join((repr(k) + ':' + k) for k in props)
expr = '_r.update({' + expr + '})'
r = {}
n = cmd.iterate(selection, expr, space={'_r': r})
if n > 1:
print ' Warning: selections spans more than one atom'
if not int(quiet):
print r
return r
You can use the "first" operator to limit your selection to one atom:
print get_single_atom_props('first polymer')
Cheers,
Thomas
On 27 Aug 2015, at 06:27, Dirk Kostrewa <[email protected]> wrote:
> Dear PyMOLers,
>
> I have trouble to find out, which command I could use in a python script
> to get the b-factor and occupancy of a single atom.
> In the script library, I only found examples getting b-factors iterating
> over a selection.
> Although, I could iterate over one atom, only, is there a more elegant
> way of getting the b-factor and occupancy of a single atom?
>
> Best regards,
>
> Dirk.
>
> --
>
> *******************************************************
> Dirk Kostrewa
> Gene Center Munich, A5.07
> Department of Biochemistry
> Ludwig-Maximilians-Universität München
> Feodor-Lynen-Str. 25
> D-81377 Munich
> Germany
> Phone: +49-89-2180-76845
> Fax: +49-89-2180-76999
> E-mail: [email protected]
> WWW: www.genzentrum.lmu.de
> *******************************************************
--
Thomas Holder
PyMOL Principal Developer
Schrödinger, Inc.
------------------------------------------------------------------------------
_______________________________________________
PyMOL-users mailing list ([email protected])
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/[email protected]