Process All Files In Directory: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Cowsandmilk (talk | contribs) No edit summary |
||
| (One intermediate revision by one other user not shown) | |||
| Line 95: | Line 95: | ||
cmd.select("s2","%s`%d"%b) | cmd.select("s2","%s`%d"%b) | ||
if cmd.select("(s1|s2) and not ?skip"): | if cmd.select("(s1|s2) and not ?skip"): | ||
cmd.iterate("s1|s2","print ' | cmd.iterate("s1|s2","print ' ',chain,resn,resi,name") | ||
',chain,resn,resi,name") | |||
print ' ',round(cmd.dist("tmp","s1","s2"),3) | print ' ',round(cmd.dist("tmp","s1","s2"),3) | ||
cmd.select("skip","s1|s2|?skip") | cmd.select("skip","s1|s2|?skip") | ||
| Line 103: | Line 102: | ||
[[Category:Script_Library|Processing All File in Directory]] | [[Category:Script_Library|Processing All File in Directory]] | ||
[[Category:System_Scripts]] | |||
Latest revision as of 07:54, 2 February 2010
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")