Skip to content

Commit

Permalink
Added update script
Browse files Browse the repository at this point in the history
(c) 2011-09-23 by Justin L Lorieau
(c) 2012-10-31 by Thomas Holder
  • Loading branch information
jlec committed Nov 2, 2012
1 parent 400ec57 commit 5725f42
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions plot_noe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
'''
plot_noe.py
(c) 2011-09-23 by Justin L Lorieau
(c) 2012-10-31 by Thomas Holder
'''

from pymol import cmd, CmdException

def plot_noe(filename, selection='', line_color='gray20', line_width='1.0', single=0, quiet=1):
"""
DESCRIPTION
A function for plotting XPLOR NOE restraints on a structure
ARGUMENTS
filename = string: The filename of the NOE retraint file in XPLOR NIH format.
selection = string: atom selection {default: all}
line_color = string: The color for the NOE lines. {default: black}
line_width = float: The thickness of the NOE lines. {default: 1.0}
NOE Restraint Format Example
assign (residue 5 and name HB#) (residue 21 and name HA) 3.0 0.7 0.7
EXAMPLE
PyMOL> plot_noe noe_short.tbl
"""
from pymol.parsing import split

single, quiet = int(single), int(quiet)

count = 0

for line in open(filename):
line = line.replace('(', ' (').replace(')', ') ').replace('#', '*')

a = filter(None, split(line, ' \t'))
if len(a) < 4 or not a[0].startswith('assi'):
continue

try:
float(a[3])
except ValueError:
continue

sele1, sele2 = a[1:3]

if selection:
sele1 = '(%s) and (%s)' % (selection, sele1)
sele2 = '(%s) and (%s)' % (selection, sele2)

label = single and "NOE" or ("NOE_%d" % (count + 1))

try:
cmd.distance(label, sele1, sele2, quiet=quiet)
except CmdException:
print 'FAILED: %s - %s' % (sele1, sele2)
continue

cmd.set("dash_color", line_color, label)
cmd.set("dash_gap", 0, label)
cmd.set("dash_width", line_width, label)

count += 1

if not quiet:
print ' Info: Created distance objects for %d restraints' % (count)

cmd.hide("labels", "NOE*")

cmd.extend("plot_noe", plot_noe)

0 comments on commit 5725f42

Please sign in to comment.