This is a read-only mirror of pymolwiki.org

Process All Files In Directory

From PyMOL Wiki
Revision as of 03:08, 28 March 2014 by Bell (talk | contribs) (4 revisions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Explanation

For a given directory with PDB files in it, the following code will output, for each PDB, the bound disulfide bond lengths like this:

1alk.pdb
  A CYS 168 SG
  A CYS 178 SG
    1.975
  A CYS 286 SG
  A CYS 336 SG
    1.995
  B CYS 168 SG
  B CYS 178 SG
    1.996
  B CYS 286 SG
  B CYS 336 SG
    2.032
1btu.pdb
   CYS 42 SG
   CYS 58 SG
    2.039
   CYS 136 SG
   CYS 201 SG
    2.031
   CYS 168 SG
   CYS 182 SG
    2.001
   CYS 191 SG
   CYS 220 SG
    2.019
...

Bound Disulfides

from pymol import cmd
from glob import glob

for file in glob("*.pdb"):
    print file
    cmd.load(file,'prot')
    for a in cmd.index("elem s and bound_to elem s"):
        if cmd.select("s1","%s`%d"%a) and \
           cmd.select("s2","elem s and bound_to %s`%d"%a):
            if cmd.select("(s1|s2) and not ?skip"):
                cmd.iterate("s1|s2","print ' ',chain,resn,resi,name")
                print '   ',round(cmd.dist("tmp","s1","s2"),3)
                cmd.select("skip","s1|s2|?skip")
    cmd.delete("all")

All Sulfur Distances

Note that the above is for bonded sulfurs in disulfides. For all intra-cysteine gamma sulfur distances, you'd want to do something more like:

1alk.pdb
  A CYS 168 SG
  A CYS 178 SG
    1.975
  A CYS 168 SG
  A CYS 286 SG
    35.845
  A CYS 168 SG
  A CYS 336 SG
    35.029
  A CYS 168 SG
  B CYS 168 SG
    63.64
  A CYS 168 SG
  B CYS 178 SG
    63.775
  A CYS 168 SG
  B CYS 286 SG
    39.02
  A CYS 168 SG
  B CYS 336 SG
    39.314
1btu.pdb
   CYS 42 SG
   CYS 58 SG
    2.039
   CYS 42 SG
   CYS 136 SG
from pymol import cmd
from glob import glob

for file in glob("*.pdb"):
    print file
    cmd.load(file,'prot')
    for a in cmd.index("CYS/SG"):
        for b in cmd.index("CYS/SG"):
            if a[1]<b[1]:
                cmd.select("s1","%s`%d"%a)
                cmd.select("s2","%s`%d"%b)
                if cmd.select("(s1|s2) and not ?skip"):
                    cmd.iterate("s1|s2","print ' ',chain,resn,resi,name")
                    print '   ',round(cmd.dist("tmp","s1","s2"),3)
                    cmd.select("skip","s1|s2|?skip")
    cmd.delete("all")