Hi,all

I haven't found any pymol script supports using math expression to select
atoms,
so I spend several hours to write one function to do it.

I write a script(mathexpr.py) containing this function, then run
mathexpr.py,
function 'Select' now can be called. Can anybody tell me how to combine this
function into pymol,
or 'select' command,  so it can be called like 'select x>5'.
Hope it useful for you.

Thank you!

Yours,
Cun Zhang


def Select(expr='x>5',sel='all'):
   """
  A function which supports selection by math expressions.
   example:
         x=Select('x>5 and y<2','name C')
   """
    ATOMS=cmd.get_model(sel)
    vec,index=ATOMS.get_coord_list(),cmd.identify(sel)
    command='[index[vec.index([x,y,z])] for x,y,z in vec if '+expr+']'
    ID=eval(command) #list type
    return ID

-- 
========================================
Cun Zhang
Ph.D. Candidate
LNM,Institute of Mechanics
Chinese Academy of Sciences
Beijing, 100190, China
Tel:86-10-82544204
http://www.edwardpku.com/cun
========================================
------------------------------------------------------------------------------
Oracle to DB2 Conversion Guide: Learn learn about native support for PL/SQL,
new data types, scalar functions, improved concurrency, built-in packages, 
OCI, SQL*Plus, data movement tools, best practices and more.
http://p.sf.net/sfu/oracle-sfdev2dev 
_______________________________________________
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

Reply via email to