Grepset: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 2: Line 2:


Usefull for newbies and those with not so good memory skills...
Usefull for newbies and those with not so good memory skills...
To use:
# put the script in a file called '''grepset.py'''
# from within PyMOL execute '''run grepset.py'''
# try it out, see examples below.


Example 1: '''grepset light'''
Example 1: '''grepset light'''
Line 27: Line 33:
10 settings matched
10 settings matched
</pre>
</pre>


Example 3: '''grepset ^trans'''
Example 3: '''grepset ^trans'''
Line 37: Line 42:
</pre>
</pre>


 
== The Script itself: grepset.py ==
<source lang="python">
<source lang="python">
from pymol import cmd
from pymol import cmd

Revision as of 10:11, 18 April 2005

Use this little script to explore PyMOL's myriad settings.

Usefull for newbies and those with not so good memory skills...

To use:

  1. put the script in a file called grepset.py
  2. from within PyMOL execute run grepset.py
  3. try it out, see examples below.

Example 1: grepset light

cartoon_highlight_color        default
dot_lighting                   on
light                          [ -0.40000, -0.40000, -1.00000 ]
mesh_lighting                  off
two_sided_lighting             off
5 settings matched

Example 2: grepset trans

cartoon_transparency           0.00000
ray_transparency_contrast      1.00000
ray_transparency_shadows       1
ray_transparency_spec_cut      0.90000
ray_transparency_specular      0.40000
sphere_transparency            0.00000
stick_transparency             0.00000
transparency                   0.00000
transparency_mode              2
transparency_picking_mode      2
10 settings matched

Example 3: grepset ^trans

transparency                   0.00000
transparency_mode              2
transparency_picking_mode      2
3 settings matched

The Script itself: grepset.py

from pymol import cmd
import pymol.setting

def grepset(regexp=''):
   '''
DESCRIPTION
   "grepset" greps through the list of settings using a python
   regular expression as defined in the 're' module.
   It returns a list of settings/values matching the regexp.
   No regexp returns every setting.

USAGE
   grepset [regexp]

EXAMPLE
   grepset line
   grepset ray

SEE ALSO
   Python re module
   '''

   from re import compile

   count=0
   regexp=compile(regexp)
   for a in pymol.setting.get_index_list():
      setting=pymol.setting._get_name(a)
      if regexp.search(setting):
         count = count + 1
         print '%-30s %s' % (setting, cmd.get_setting_text(a,'',-1))

   print '%d settings matched' % count
cmd.extend('grepset',grepset)