Re: [ccp4bb] programmatic symmetry mate generation
James Stroud wrote: Hello All, I want to programmatically generate the symmetry mates for a molecule and write out the files containing the symmetry related molecules. I'm resisting the urge to reinvent the wheel. What is the best way to do this? I'd prefer to do it within a python program using an open source library, but I'd settle for scripting an external program if that is the only option. James Well - pdbset will do it.. E
Re: [ccp4bb] programmatic symmetry mate generation
Hi James, The symmetry copies of a molecule asymmetric unit can be saved to a new PDB file using the saveunitcell.py Python script with Chimera. http://plato.cgl.ucsf.edu/trac/chimera/wiki/Scripts It uses the CRYST1 record in the PDB file to determine the symmetry group. Unfortunately as mentioned in the script you need to use Chimera as the Python interpreter, which you may not be willing to do -- but you can just call out to the command-line version of Chimera (also documented in the script) via os.system() or whatnot. There is also a sym command in Chimera which can generate symmetry mates from a wide spectrum of possible criteria. A Python script to call sym is just: from chimera import runCommand runCommand(sym options you want) --Eric Eric Pettersen UCSF Computer Graphics Lab http://www.cgl.ucsf.edu
Re: [ccp4bb] programmatic symmetry mate generation
cctbx is cool in principle, but I would be very happy to know how to use it with a pre-existing python like most other packages are capable of. I'm starting to lose patience reverse-engineering the install scripts to figure out how to do it. I can't seem to find instructions on the web page. What am I missing? Is it that I must migrate my entire python environment to cctbx.python? Isn't it better to add cctbx to a current environment rather than the other way around? If every package required the user's migrating his python environment to the package's environment, then we wouldn't be able to use more than one package with a given python install. It seems ridiculous. It doesn't make sense, so I must be missing something fundamental. I think this is the reason I have never used cctbx before. I last tried about 4 years and I thought that it was because the package was immature. James On Apr 24, 2010, at 7:16 PM, Peter Zwart wrote: cctbx? 2010/4/24 James Stroud xtald...@gmail.com: Hello All, I want to programmatically generate the symmetry mates for a molecule and write out the files containing the symmetry related molecules. I'm resisting the urge to reinvent the wheel. What is the best way to do this? I'd prefer to do it within a python program using an open source library, but I'd settle for scripting an external program if that is the only option. James -- - P.H. Zwart Beamline Scientist Berkeley Center for Structural Biology Lawrence Berkeley National Laboratories 1 Cyclotron Road, Berkeley, CA-94703, USA Cell: 510 289 9246 BCSB: http://bcsb.als.lbl.gov PHENIX: http://www.phenix-online.org CCTBX: http://cctbx.sf.net -
Re: [ccp4bb] programmatic symmetry mate generation
Hi James, On Sun, 25 Apr 2010 15:41:32 -0700, James Stroud xtald...@gmail.com wrote: cctbx is cool in principle, but I would be very happy to know how to use it with a pre-existing python like most other packages are capable of. I'm starting to lose patience reverse-engineering the install scripts to figure out how to do it. I can't seem to find instructions on the web page. What am I missing? Is it that I must migrate my entire python environment to cctbx.python? Isn't it better to add cctbx to a current environment rather than the other way around? If every package required the user's migrating his python environment to the package's environment, then we wouldn't be able to use more than one package with a given python install. It seems ridiculous. I don't have a problem doing this (at least with Linux). I simply download the Self-extracting cctbx sources for Unix and put it somewhere appropriate and run the installation command perl cctbx_bundle.selfx. After it finishes installing I modify my login shell script according to the installers instructions. Actually I modify a large setup script that allows me and all the users to set up any particular program. This will add the cctbx/cctbx_build/bin directory to the beginning of the PATH variable. In order for cctbx to work with any python script then I simply add a link in the cctbx/cctbx_build/bin directory so that python points at cctbx.python: i.e. cd cctbx_build/bin ln -s cctbx.python python Any other python scripts that call cctbx then start with #! /usr/bin/env python rather than #! /usr/bin/python In order to have cctbx play nice with PyMOL, then I also install PyMOL from the SVN sources (also not too difficult). Then I make sure that my PyMOL start up script uses python and not /usr/bin/python and then I can use both PyMOL and cctbx with the system's python. Perhaps this still sounds ridiculous to you, but I don't have a problem with it. Once the initial set up is done there isn't much to it. Of course I have left myself little instruction files in my installation directories to remind myself what I need to do. It doesn't make sense, so I must be missing something fundamental. I think this is the reason I have never used cctbx before. I last tried about 4 years and I thought that it was because the package was immature. There is also a new PyMOL script in the PyMOL wiki called supercell http://pymolwiki.org/index.php/Supercell that will build a unit cell, or a block of multiple unit cells. I think this should work in a script to PyMOL, hence not needing the graphics nor any interactive work. I haven't tried it that way, though. Cheers, Rob -- Robert L. Campbell, Ph.D. Senior Research Associate/Adjunct Assistant Professor Botterell Hall Rm 644 Department of Biochemistry, Queen's University, Kingston, ON K7L 3N6 Canada Tel: 613-533-6821Fax: 613-533-2497 robert.campb...@queensu.cahttp://pldserver1.biochem.queensu.ca/~rlc
[ccp4bb] programmatic symmetry mate generation
Hello All, I want to programmatically generate the symmetry mates for a molecule and write out the files containing the symmetry related molecules. I'm resisting the urge to reinvent the wheel. What is the best way to do this? I'd prefer to do it within a python program using an open source library, but I'd settle for scripting an external program if that is the only option. James
Re: [ccp4bb] programmatic symmetry mate generation
On Sat, Apr 24, 2010 at 5:25 PM, James Stroud xtald...@gmail.com wrote: I want to programmatically generate the symmetry mates for a molecule and write out the files containing the symmetry related molecules. I'm resisting the urge to reinvent the wheel. What is the best way to do this? I'd prefer to do it within a python program using an open source library, but I'd settle for scripting an external program if that is the only option. Either PyMOL or CCTBX can do this, but it may take some experimenting and fine-tuning to get exactly what you want, which isn't entirely clear from your question. PyMOL just generates symmetry-related molecules within a specified radius of the original object, which is okay for interactive use (or if you just want to see crystal packing), but less useful if you want just the molecules related by the symmetry operators of the space group, or just the unit cell. (I'm assuming you can use PyMOL as a module to do this instead of running the full program, but I haven't tried this before.) Within CCTBX, it is very easy (although not at all intuitive) to apply the symmetry operators; a very rough example is appended below. However, these won't necessarily pack together or fill the unit cell. It is possible I am doing something completely wrong, because I never really understood symmetry very well, but the new chains all align perfectly with symmetry mates created by PyMOL, so I think the operators are being used correctly. An example in P212121 is shown here: http://cci.lbl.gov/~nat/img/symops.png I suspect there is an easy way to fill the unit cell instead, but I'm too tired to figure it out right now. If I can get my simple script working satisfactorily I'll add it to CCTBX. On the non-Python side, Gerard Kleywegt's program XPAND appears to be designed for this - haven't tried that either, but I suspect it will give you something closer to what you want. Not sure whether CCP4 exposes similar functionality anywhere. -Nat # usage: cctbx.python script_name pdb_file # the PDB file must contain a CRYST1 record. from iotbx.file_reader import any_file import scitbx.matrix from scitbx.array_family import flex import sys, os def run (args) : pdb_file = args[0] pdb_inp = any_file(pdb_file, force_type=pdb).file_object symm = pdb_inp.crystal_symmetry() sg = symm.space_group() uc = symm.unit_cell() symops = sg.all_ops() out = open(unit_cell.pdb, w) for symop in symops : r = symop.r() t = symop.t() rt = scitbx.matrix.rt((r.as_double(), t.as_double())) pdb_hierarchy = pdb_inp.construct_hierarchy().deep_copy() atoms = pdb_hierarchy.atoms() sites_frac = uc.fractionalize(sites_cart=atoms.extract_xyz()) new_sites = sites_frac * r.as_double() + t.as_double() atoms.set_xyz(uc.orthogonalize(sites_frac=new_sites)) out.write(pdb_hierarchy.as_pdb_string()) out.close() if __name__ == __main__ : run(sys.argv[1:])
Re: [ccp4bb] programmatic symmetry mate generation
James Stroud wrote: Hello All, I want to programmatically generate the symmetry mates for a molecule and write out the files containing the symmetry related molecules. I'm resisting the urge to reinvent the wheel. What is the best way to do this? I'd prefer to do it within a python program using an open source library, but I'd settle for scripting an external program if that is the only option. James If I could dare to mention a CCP4 program on this BB: PDBSET. The database is a text file called $SYMOP. To be able to control which other ASU get created, copy the symops from there into the script. You also need a CELL line if the .pdb lacks CRYST1 Depending what you're going to do, it may help to rename the new chains. For P212121: #!/bin/csh -f # # Make Cell contents # pdbset xyzin asu.pdb xyzout unitcell.pdb eof-1 symgen X,Y,Z symgen 1/2-X,-Y,1/2+Z symgen -X,1/2+Y,1/2-Z symgen 1/2+X,1/2-Y,-Z ! Rename chains in other ASU chain symmetry 2 A C chain symmetry 2 B D chain symmetry 3 A E chain symmetry 3 B F chain symmetry 4 A G chain symmetry 4 B H eof-1 then you have the problem Nat mentioned that the result probably will not be the best approximation to filling one unit cell (that is a hopeless goal anyway as molecules will always cross cell boundaries) But you can get a lot closer by adding unit cell translations to the symops and seeing where it puts the molecules. substitute Y with 1+y or -1+y (Y-1?) substitute 1/2+y with -1/2+y, 3/2+y etc and so on If you want the results in different files, one for each asu, include only one of the symops each time you run.