-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(c) 2011-09-23 by Justin L Lorieau (c) 2012-10-31 by Thomas Holder
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|