Yes, one more question. How to use all other "functions", like byres, "chain A" or "organic"?
Em seg, 5 de ago de 2019 12:36, Christian "Cole" French < christian.fre...@schrodinger.com> escreveu: > I see now. I updated the code at the link in my previous email to provide > behavior which should allow you to do what you want. Here are your examples > written using the command: > > select_with_filter sele, flag 8, lambda s: len(cmd.get_chains(s)) < 2 > select_with_filter sele, flag 8, lambda s: cmd.get_fastastr(s) < 2 > select_with_filter sele, flag 8 and chain A, lambda s: peplength(s) < 15 > > If you want to write and use your own multi-line function, you can write a > script and cmd.extend('your_function', your_function), then use > your_function in select_with_filter. > > Please let me know if you have any further questions. > > Best, > Cole > > On Mon, Aug 5, 2019 at 8:30 AM Pedro Lacerda <pslace...@gmail.com> wrote: > >> I expressed myself wrong, I'm looking something like: >> >> select peplength < 15 and chain A >> >> Where peplength is an user defined function like: >> >> def peplength(atom): >> return compute_peplength(atom) >> >> I'm looking for the availability of user defined functions on selection >> expressions. How to? >> >> Em sex, 2 de ago de 2019 às 15:44, Christian "Cole" French < >> christian.fre...@schrodinger.com> escreveu: >> >>> Edit: remove the cmd. part when running select_with_filter. (Since it's >>> a custom command, it doesn't belong to the cmd module.) >>> >>> On Fri, Aug 2, 2019 at 2:41 PM Christian "Cole" French < >>> christian.fre...@schrodinger.com> wrote: >>> >>>> Hi Pedro Lacerda, >>>> >>>> Here is a link to a script I wrote which adds a command which does what >>>> you ask: >>>> https://gist.github.com/ColeFrench/6f68fa5f04a67bb6234f10c25debb865. >>>> To use it, download the file to the directory where you run PyMOL from, >>>> then open PyMOL and run run select_with_filter.py. >>>> >>>> For your examples, the commands would be >>>> cmd.select_with_filter(predicate=lambda >>>> s: len(cmd.get_chains(s)) < 2) and cmd.select_with_filter(predicate=lambda >>>> s: cmd.get_fastastr(s) < 2). >>>> >>>> Commands which can be simply run are a convenience which allows you to >>>> type less (e.g., select chain A instead of cmd.select('chain A')). >>>> Some commands require different arguments and can only be run the longer >>>> way, such as the one I wrote which takes a function as an argument. >>>> >>>> Hope this helps, >>>> Cole >>>> >>>> On Fri, Aug 2, 2019 at 11:45 AM Pedro Lacerda <pslace...@gmail.com> >>>> wrote: >>>> >>>>> Hi PyMOL users, >>>>> >>>>> It there any way to enhance the selecion algebra with functions? For >>>>> instance: >>>>> >>>>> select len(get_chains(*)) < 2 >>>>>> >>>>> >>>>> Or even: >>>>> >>>>> select cmd.get_fastastr(*) < 2 >>>>>> >>>>> >>>>> >>>>> By the way, why some commands we can simply run (like get_chains) and >>>>> others are different (like cmd.get_fastastr())? >>>>> >>>>> -- >>>>> Pedro Sousa Lacerda >>>>> >>>>> >>>>> *Laboratório de Bioinformática e Modelagem Molecular* >>>>> *Faculdade de Farmácia / UFBA* >>>>> >>>>> *@pslacerda* >>>>> >>>>> *+55 71 9 9981-1856* >>>>> _______________________________________________ >>>>> PyMOL-users mailing list >>>>> Archives: >>>>> http://www.mail-archive.com/pymol-users@lists.sourceforge.net >>>>> Unsubscribe: >>>>> https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe >>>> >>>> >> >> -- >> Pedro Sousa Lacerda >> >> >> *Laboratório de Bioinformática e Modelagem Molecular* >> *Faculdade de Farmácia / UFBA* >> >> *@pslacerda* >> >> *+55 71 9 9981-1856* >> >
_______________________________________________ PyMOL-users mailing list Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net Unsubscribe: https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe