[Chimera-users] Chimera-users Digest, Vol 56, Issue 14

Jonathan Hilmer jkhilmer at gmail.com
Mon Dec 17 12:35:25 PST 2007


Ryan,

Try this as a way to figure out what you can do with an object:

dir(chimera.selection.currentResidues()[0])

In the above command I've indexed the list of selections to return
just one object, and the dir() function will return a list of names
defined by the currentResidues module.  It should contain something
like the following:

...  'addAtom', 'atomNames', 'atoms', 'atomsMap', 'bondedTo', 'count',
'findAtom', 'findRangeAtoms', 'getDefaultRibbonStyle', 'hasRibbon',
'id', 'isHelix', 'isHet', 'isSheet', 'isStrand', 'isTurn',
'kdHydrophobicity', 'label', 'labelColor', 'labelOffset', 'molecule',
'numAtoms', 'oslChildren', 'oslIdent', 'oslLevel', 'oslParents',
'oslTestAbbr', 'removeAtom', 'ribbonBinormals', 'ribbonCenters',
'ribbonColor', 'ribbonData', 'ribbonDisplay', 'ribbonDrawMode',
'ribbonFindStyle', 'ribbonFindStyleType', 'ribbonFindXSection',
'ribbonNormals', 'ribbonResidueClass', 'ribbonStyle',
'ribbonXSection', 'selLevel', 'type'

If you try:

chimera.selection.currentResidues()[0].type

it will return a string with the 3-letter aa code, and the other
options displayed by dir() will output useful things such as more
strings, lists, or other objects that can be likewise explored.

Try this combination:

mySel = chimera.selection.currentResidues()[0]
print "%s, %s" % (mySel.oslIdent(), mySel.type)

On my test structure it returns '#0:127.A, ARG'.  The second line is
equivalent to 'print str(mySel.oslIdent() + ", " + mySel.type)', but
the formatting I used in the above example helps to keep things clean
if you have a complicated output that needs to have a specific format.
 There are some more advanced features of that approach detailed here:
http://www.python.org/doc/1.5/tut/node45.html

Jonathan


> Date: Fri, 14 Dec 2007 19:55:39 -0500
> From: Ryan <pavlovicz.7 at osu.edu>
> Subject: Re: [Chimera-users] printing "zone" search
> To: chimera-users at cgl.ucsf.edu
> Message-ID: <17bf4817f850.17f85017bf48 at osu.edu>
> Content-Type: text/plain; charset=us-ascii
>
> Hi Eric, thanks for your help.  I'm getting closer to achieving the results i'd like.
>
> So i've been able to properly select the residues within a specified radius of my ligand, but am a little confused as to how Chimera handles the selection list.  If i try:
>
>   print chimera.selection.currentResidues()
>
> i get a list like this:
>
>   > [<_chimera.Residue object at 0x578d2020>, <_chimera.Residue object at 0x578cbfb0>, ... ]
>
> but if i try:
>
>   for x in chimera.selection.currentResidues():
>     print x
>
> i get output that is much closer to what i'm looking for:
>
>   > #0:499
>   > #0:496
>   > ...
>
> What is the reason for the difference between these two forms of output that seem to be accessing the same list?  Also, is there a way i can get more detailed output with residue names and numbers, such as ['#0:TYR499','#0:TRP496',...]?
>
> Sorry if these questions are answered elsewhere, but i could not find the answers online.  Is there a document out there that can teach me how to better master the Chimera Python modules for scripting?  I'm no Python expert -- i've so far only been learning things as i need them.  Thanks again,
>
> ryan



More information about the Chimera-users mailing list