[PyMOL] A selection function supporting math expression
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 x5'. Hope it useful for you. Thank you! Yours, Cun Zhang def Select(expr='x5',sel='all'): A function which supports selection by math expressions. example: x=Select('x5 and y2','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
Re: [PyMOL] A selection function supporting math expression
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: PyMOLrun 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 tsje...@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): x10 and y5) 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 apzc2...@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 x5'. Hope it useful for you. Thank you! Yours, Cun Zhang def Select(expr='x5',sel='all'): A function which supports selection by math expressions. example: x=Select('x5 and y2','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 -- 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
Re: [PyMOL] A selection function supporting math expression
On Mon, Dec 13, 2010 at 7:34 PM, Cun Zhang apzc2...@gmail.com wrote: Get it. Thank you! Cheers, Cun Zhang On Mon, Dec 13, 2010 at 7:17 PM, Tsjerk Wassenaar tsje...@gmail.comwrote: 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 apzc2...@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: PyMOLrun 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 tsje...@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): x10 and y5) 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 apzc2...@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 x5'. Hope it useful for you. Thank you! Yours, Cun Zhang def Select(expr='x5',sel='all'): A function which supports selection by math expressions. example: x=Select('x5 and y2','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
Re: [PyMOL] cd in windows
cd test space A nice way is,To Push down the TAB key(maybe need several times) after inputing test,the left will try complete all. cd test push down TAB key Cheers Message: 1 Date: Mon, 20 Sep 2010 11:20:10 -0400 From: David A. Horita dhor...@wfubmc.edu Subject: [PyMOL] cd in windows To: pymol-users@lists.sourceforge.net Message-ID: 4ccfaf32fb7b2c449a189c82198e42653ce9b...@exchvs1.medctr.ad.wfubmc.edu Content-Type: text/plain; charset=us-ascii Hi, How does one change directories in Windows when the directory name has a space in it? I've tried double and single quotes as well as backslash space (I'd like to run a script that's in such a directory). Thanks David - David A. Horita, Ph.D. Department of Biochemistry Wake Forest University School of Medicine Winston-Salem, NC 27157-1016 Tel: 336 713-4194 Fax: 336 716-7671 email: dhor...@wfubmc.edu web: http://www1.wfubmc.edu/biochem/faculty/Horita.htm http://www1.wfubmc.edu/biochem/faculty/Horita.htm/ -- Blog: http://www.edwardpku.com/cun -- Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-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
[PyMOL] How to get the coordinates of the center of a group of atoms?
hi, I have a pdb file with serveral frames, I hope to get the trajectory of the center of a selected group of atoms. I use the following commands, but return the same coord. cmd.load(a.pdb) coord=[] for i in range(cmd.count_frames()): cmd.frame(i+1) cmd.center('id 1-24') coord.append(cmd.get_position()) What should I do? Thank you! Zhang Cun -- Blog: http://www.edwardpku.com/cun -- ___ 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
Re: [PyMOL] How to get the coordinates of the center of a group of atoms?
Dear Jason, Thank you for you quick reply! And This problem is solved! Yours, Zhang Cun On Thu, Apr 29, 2010 at 9:31 PM, Jason Vertrees jason.vertr...@schrodinger.com wrote: Hi Cun, That's a good start. Just a couple things needs to be changed. First, frames don't track coordinates, states do. Frames are for movies; states are for coordinates. Next, instead of using center, use the origin command with the state parameter specified. Here's example code for 1NMR a multi-state protein, adjust his for your application: python cmd.fetch(1nmr, async=0) coord=[] for i in range(1,cmd.count_states()+1): cmd.origin(i. 1-24, state=i) coord.append(cmd.get_position()) print coord python end Cheers, -- Jason On Thu, Apr 29, 2010 at 8:58 AM, Cun Zhang apzc2...@gmail.com wrote: hi, I have a pdb file with serveral frames, I hope to get the trajectory of the center of a selected group of atoms. I use the following commands, but return the same coord. cmd.load(a.pdb) coord=[] for i in range(cmd.count_frames()): cmd.frame(i+1) cmd.center('id 1-24') coord.append(cmd.get_position()) What should I do? Thank you! Zhang Cun -- Blog: http://www.edwardpku.com/cun -- ___ 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 -- Jason Vertrees, PhD PyMOL Product Manager Schrodinger, LLC (e) jason.vertr...@schrodinger.com (o) +1 (603) 374-7120 -- Blog: http://blog.4message.net -- ___ 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
[PyMOL] How to create pdb file within pymol?
Hi,pymolers: I want to create a pdb file for the structure of graphite. But my method is a bit complex. I create the xyz file,then call pymol to translate it into pdb format with the command: os.system('pymol -cd load graphite.xyz;save graphite.pdb') Is there any easy way to create pdb file with the information of atoms' coordinates in pymol? Thank you! Cun Zhang Ph.D.Candidate LNM, Institude of Mechanics Chinese Academy of Sciences Beijing 100190, China Tel:86-10-82544204 -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ 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
Re: [PyMOL] How to create pdb file within pymol?
David, thank you for your reply. I like writing a python script to do this. And I just got the code what I want from http://www.rubor.de/bioinf/tips_python.html#chempy. Model building becomes so easy when using chempy. But I can't get the manual about chempy. So pity! And Here is the partial code: 1 #!/usr/bin/python 2 import __main__ 3 __main__.pymol_argv = ['pymol','-qc'] 4 5 import sys 6 import pymol 7 from scipy import * 8 from chempy.models import Indexed 9 from chempy import Atom 10 from pymol import cmd 11 12 pymol.finish_launching() 47 ATOM=L*array(ATOM) 48 model = Indexed() 49 for i in ATOM: 50 at=Atom() 51 at.name = C 52 at.coord = list(i) 53 at.symbol = C 54 model.atom.append(at) 55 cmd.load_model(model,CNT) 56 cmd.label(CNT,name) 57 cmd.save(Test.pdb) On Wed, Mar 10, 2010 at 10:20 AM, David Hall li...@cowsandmilk.net wrote: What are you using to create the xyz file (and why can that software not write a pdb)? The command you have below is pretty simple. An alternative is also the xyzpdb program that comes as part of tinker. ( eg: xyzpdb graphite.xyz charmm22.prm gives you graphite.pdb ) -David On Tue, Mar 9, 2010 at 7:46 PM, Cun Zhang apzc2...@gmail.com wrote: Hi,pymolers: I want to create a pdb file for the structure of graphite. But my method is a bit complex. I create the xyz file,then call pymol to translate it into pdb format with the command: os.system('pymol -cd load graphite.xyz;save graphite.pdb') Is there any easy way to create pdb file with the information of atoms' coordinates in pymol? Thank you! Cun Zhang Ph.D.Candidate LNM, Institude of Mechanics Chinese Academy of Sciences Beijing 100190, China Tel:86-10-82544204 -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ 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 -- Blog: http://blog.4message.net -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ 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
Re: [PyMOL] PyMOL-users Digest, Vol 43, Issue 7
hi, Joel. I think there are several ways to fix it( I do it under Debian): 1. Install mesa driver. it's the old way and always works well. http://www.centos.org/modules/newbb/viewtopic.php?topic_id=16139 2. Download the driver from nvidia home,and install it. It's the easiest way if you aren't familiar with CentOS. http://www.nvidia.com/Download/index.aspx?lang=en-us 3. Maybe Centos have made the rpm packages for nvidia drivers. So search it with "rpm" cmmand, then install it. Hope help! Cun Zhang Message: 3 Date: Wed, 16 Dec 2009 12:34:59 +1300 From: Joel Tyndall joel.tynd...@otago.ac.nz Subject: [PyMOL] FW: Slightly off topic To: "pymol-users@lists.sourceforge.net" pymol-users@lists.sourceforge.net Message-ID: 4528f8d469bacc498077d350651a72852e581cb...@mail2.registry.otago.ac.nz Content-Type: text/plain; charset="us-ascii" Thanks folks, will start with FC11 J From: Joel Tyndall [mailto:joel.tynd...@otago.ac.nz] Sent: Tuesday, 15 December 2009 4:33 p.m. To: pymol-users@lists.sourceforge.net Subject: [PyMOL] Slightly off topic Hi folks, Sorry for the off topic post. I have just got a new whizz bang laptop and I'm wondering whether I have gone too high spec. It is 64 bit LED ASUS ul50v series. I am running linux centos 5.4 but can't get the nvidia driver going (LED screen perhaps) and I just had an initial problem with pymol. (I want to run modeler, sybyl and gold also ) This is not to mention the fact that the kernel doesn't have wireless or Ethernet drivers. Should I "downgrade" or persist. Many thanks for comments _ Joel Tyndall, PhD Senior Lecturer in Medicinal Chemistry National School of Pharmacy University of Otago PO Box 56 Dunedin 9054 New Zealand http://www.researcherid.com/rid/C-2803-2008 Pukeka Matua Te Kura Taiwhanga Putaiao Te Whare Wananga o Otago Pouaka Poutapeta 56 Otepoti 9054 Aotearoa Ph / Waea +64 3 4797293 Fax / Waeawhakaahua +64 3 4797034 -- next part -- An HTML attachment was scrubbed... -- next part -- An embedded and charset-unspecified text was scrubbed... Name: ATT1.txt -- next part -- An embedded and charset-unspecified text was scrubbed... Name: ATT2.txt -- This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev ___ 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
Re: [PyMOL] PyMOL-users Digest, Vol 43, Issue 7
hi, Joel. I think there are several ways to fix it( I do it under Debian): 1. Install mesa driver. it's the old way and always works well. http://www.centos.org/modules/newbb/viewtopic.php?topic_id=16139 2. Download the driver from nvidia home,and install it. It's the easiest way if you aren't familiar with CentOS. http://www.nvidia.com/Download/index.aspx?lang=en-us 3. Maybe Centos have made the rpm packages for nvidia drivers. So search it with "rpm" cmmand, then install it. Hope help! Cun Zhang Message: 3 Date: Wed, 16 Dec 2009 12:34:59 +1300 From: Joel Tyndall joel.tynd...@otago.ac.nz Subject: [PyMOL] FW: Slightly off topic To: "pymol-users@lists.sourceforge.net" pymol-users@lists.sourceforge.net Message-ID: 4528f8d469bacc498077d350651a72852e581cb...@mail2.registry.otago.ac.nz Content-Type: text/plain; charset="us-ascii" Thanks folks, will start with FC11 J From: Joel Tyndall [mailto:joel.tynd...@otago.ac.nz] Sent: Tuesday, 15 December 2009 4:33 p.m. To: pymol-users@lists.sourceforge.net Subject: [PyMOL] Slightly off topic Hi folks, Sorry for the off topic post. I have just got a new whizz bang laptop and I'm wondering whether I have gone too high spec. It is 64 bit LED ASUS ul50v series. I am running linux centos 5.4 but can't get the nvidia driver going (LED screen perhaps) and I just had an initial problem with pymol. (I want to run modeler, sybyl and gold also ) This is not to mention the fact that the kernel doesn't have wireless or Ethernet drivers. Should I "downgrade" or persist. Many thanks for comments _ Joel Tyndall, PhD Senior Lecturer in Medicinal Chemistry National School of Pharmacy University of Otago PO Box 56 Dunedin 9054 New Zealand http://www.researcherid.com/rid/C-2803-2008 Pukeka Matua Te Kura Taiwhanga Putaiao Te Whare Wananga o Otago Pouaka Poutapeta 56 Otepoti 9054 Aotearoa Ph / Waea +64 3 4797293 Fax / Waeawhakaahua +64 3 4797034 -- next part -- An HTML attachment was scrubbed... -- next part -- An embedded and charset-unspecified text was scrubbed... Name: ATT1.txt -- next part -- An embedded and charset-unspecified text was scrubbed... Name: ATT2.txt -- This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev ___ 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
[PyMOL] why losing information about simulation box size in pdb file after edit it?
Hi, pymol users. I'm a pymol newbie .I have serval question. I have a pdb file which include the information about box size, like TITLE God Rules Over Mankind, Animals, Cosmos and Such REMARKTHIS IS A SIMULATION BOX CRYST1 39.000 39.000 56.140 90.00 90.00 90.00 P 1 1 MODEL1 HETATM1 C UNK 1 25.851 19.500 0.710 1.00 0.00 I run pymol, and load it, then delete some molecules and save it. Now the information about box size is losing. 2. Is there any way to get the information about bonds, angles and dihedrals ? I found the following command can display the bonds information, but can't be assigned to a variable. cmd.select('all') atoms=cmd.get_model('sele') print atoms.list() 3. Is there any way to learn these python api commands of pymol ? Thank you! Blog: http://blog.4message.net -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july___ 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