On Mon, Dec 13, 2010 at 7:34 PM, Cun Zhang <apzc2529@gmail.com> wrote:
Get it. Thank you!

Cheers,

Cun Zhang


On Mon, Dec 13, 2010 at 7:17 PM, Tsjerk Wassenaar <tsjerkw@gmail.com> wrote:
Hi Cun Zhang,

The problem there is in turning the list of IDs into a selection. In
version 1.2 there's a command listed as 'in development'
(cmd.select_list), that seems to help out:

ids = cselect('all',lambda (x,y,z): True)
cmd.select_list('test',"->object_name<-",ids)
show sticks, test

Do mind to fill in the proper object name in cmd.select_list. It takes
a list of IDs specific to the object given and turns that in to a
selection object.

Maybe Jason can comment on the status of the cmd.select_list or
suggest an alternative route to create selections from ChemPy models?

Cheers,

Tsjerk

On Mon, Dec 13, 2010 at 11:50 AM, Cun Zhang <apzc2529@gmail.com> wrote:
> Tsjerk, 你好 (ni hao)
> Thank you for your reply. Nice work! So cute codes. I like it.
>
> But when the selection by "id %s"%",".join([str(i) for i in ids]) too long,
> it returns "Segmentation fault" error,and quit. Is it a bug?
>
> I use pymol 1.2r2 under Debian Sid.
>
> The error it returns:
>
> PyMOL>run mathexpr.py
> Selector-Error: Word too long. Truncated:
> Selector-Error: 17,19,.....(long list,about 400 numbers)
> Segmentation fault
>
>
> On Mon, Dec 13, 2010 at 6:00 PM, Tsjerk Wassenaar <tsjerkw@gmail.com> wrote:
>>
>> Ni Hao Cun Zhang
>>
>> The real 'problem' is that Pymol does not allow selection based on
>> coordinates. Probably this should be on the wish list (and easy to
>> implement). Expressions are allowed, for instance selecting based on
>> b-factor or occupancy.
>>
>> In your script, you can use some shortcuts. Maybe something like:
>>
>> def cselect(selection="all",expression=lambda (x,y,z): True):
>>    return [i.id for i in cmd.get_model(selection).atom if
>> expression(i.coord)]
>>
>> The expression can be a predefined function, or a lambda function,
>> like here. You could then say:
>>
>> ids = cselect("n. ca",lambda (x,y,z): x<10 and y>5)
>> cmd.show("spheres","id %s"%",".join([str(i) for i in ids]))
>>
>> Hope it helps :)
>>
>> Cheers,
>>
>> Tsjerk
>>
>>
>>
>> On Mon, Dec 13, 2010 at 9:44 AM, Cun Zhang <apzc2529@gmail.com> wrote:
>> > 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
>> >
>>
>>
>>
>> --
>> Tsjerk A. Wassenaar, Ph.D.
>>
>> post-doctoral researcher
>> Molecular Dynamics Group
>> * Groningen Institute for Biomolecular Research and Biotechnology
>> * Zernike Institute for Advanced Materials
>> University of Groningen
>> The Netherlands
>
>
>
> --
> ========================================
> 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
> ========================================
>



--
Tsjerk A. Wassenaar, Ph.D.

post-doctoral researcher
Molecular Dynamics Group
* Groningen Institute for Biomolecular Research and Biotechnology
* Zernike Institute for Advanced Materials
University of Groningen
The Netherlands



--
========================================
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
========================================



--
========================================
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
========================================