Take the 2-minute tour ×
Biology Stack Exchange is a question and answer site for biology researchers, academics, and students. It's 100% free, no registration required.

I'm trying to make a script that will take a MTZ file (reflections), convert it into a CCP4 map, then pare that map down to only encompass a desired area to cut down on the size of my PyMol session files so they're email-able (a.k.a. not 200 MB) and ease the burden on my POS computer.

I currently have a Python script that can fft (CCP4) to create the map and mapmask to fix unit cell tiling issues. What I want to add now is something that can take a PDB file and strip out most of it except, for example, residues within 10 Å of #123.

I've been looking at ProDy, but not quite sure where to start. I would also be open to using something in the CCP4 toolkit.

share|improve this question
    
I'm curious in the PDB format as well. If you already have a PDB file output, you could try removing all information other than the ATOM lines, and further, remove all the ATOM lines that list atoms from residues outside the range of a subset of your structure. If you could view it in PyMol then perhaps that's good enough? –  leonardo Mar 25 '12 at 0:20
    
@leonardo some sort of manual hack like that may work (as mapmask seems to expand a little anyway), but doesn't seem that optimal. I'll beat on this for a while and let you know what I come up with. –  Nick T Mar 25 '12 at 0:37
1  
Is it possible to use a PDB viewing program to select a subregion of a single chain and save a new PDB? If so, you might want to compare the source file to the subregion file and see if it is indeed this simple and then hack yourself a solution. –  leonardo Mar 25 '12 at 0:50
1  
Pymol has a selection operator that matches everthing in a specific distance around an atom, is should be possible to use that for this purpose. –  Mad Scientist Mar 25 '12 at 8:55
    
@MadScientist from within a script running outside of PyMol? –  Nick T Mar 25 '12 at 17:21

2 Answers 2

up vote 5 down vote accepted

ProDy works quite well, especially from within an existing Python script.

The following code takes an existing PDB file, performs some selection query on it, then saves it to another file.

import prody

def pdbsubset(inpdb, outpdb, selection):
    with open(inpdb) as protf:
        prot = prody.parsePDBStream(protf)
    atoms = prot.select(selection)
    prody.writePDB(outpdb, atoms)

An example selection query builder

  • residues is a list e.g. ['A12', 'A39'] with each element in the form <chain><residue number>. They were captured from the command line using argparse with

        parser.add_argument('-i', '--residues', nargs='+')
    
    • so you would specify -i A12 A39 or whatever.
  • pdb and outpdb are file paths
  • radius is the distance in angstroms to expand the selection by.
reslist = ["(chid {0} and resid {1})".format(res[0], res[1:]) for res in residues]
selector = 'within {0} of ({1})'.format(radius, ' or '.join(reslist))

# and running it:
pdbsubset(pdb, outpdb, selector)

The documentation on ProDy selection queries is not the most straightforward, but fairly analogous to PyMol, so doable.

share|improve this answer

With the program RasMol, you can select, as Mad Scientist explained it for PyMol, everything in a specific distance around an atom. RasMol can be run from command line, using a script (with the -script option under UNIX).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.