Re: [PyMOL] visualise NOEs

2012-10-31 Thread Thomas Holder

Hi Krisztina,

check the attached script (strongly modified). It doesn't use a regex 
anymore, but uses a split function which takes parentheses into account. 
Also it doesn't parse name and resi, but passes the selection string 
directly to PyMOL (which understands most of CNS selection syntax!).


Your example selects segidA, since PyMOL will strip off whitespace 
from the segid, you might need something like this to fix it before 
calling plot_noe:


PyMOL alter all, segi=segi.rjust(4)

Hope that helps.

Cheers,
  Thomas

On 10/31/2012 04:36 PM, Krisztina Feher wrote:

Dear All

thanks to Thomas for the modfication on the plot_noe.py. It turns out
that the CNS .tbl file can have different formats, the one I used only
includes residue ID and atom name, but soemtimes it also inlcudes
segment ID as well, see on the attached file. How do I have to modify
the noe_regex pattern so that it is recognised?

Thanks in advance,
regards,
Krisztina


--
Thomas Holder
MPI for Developmental Biology
Spemannstr. 35
D-72076 Tübingen


plot_noe.py
Description: application/chimera
--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

Re: [PyMOL] visualise NOEs

2012-10-29 Thread Thomas Holder

Hi Krisztina,

I slightly modified the script, see attachment. The regular expression 
is modified and I replaced search by match.


The script could be further optimized (exception handling etc.) but with 
your example file it works fine now.


Cheers,
  Thomas

On 10/29/2012 04:06 PM, Krisztina Feher wrote:

Sure, thanks for looking at it!
Krisztina

--- On *Mon, 10/29/12, Thomas Holder wrote:

From: Thomas Holder spel...@users.sourceforge.net
Subject: Re: [PyMOL] visualise NOEs
To: Krisztina Feher feher_kriszt...@yahoo.com
Date: Monday, October 29, 2012, 4:04 PM

Hi Krisztina,

can you send me the restraints file and PDB file as well?

Cheers,
Thomas

On 10/29/2012 04:00 PM, Krisztina Feher wrote:
  Hi Thomas,
 
  thanks a lot for your reply! Now I was running the script from
command
  line and executed it: it did not display anything on the structure. I
  inserted a couple of print statements into the script (attached),
but it
  seems that the noe_regex is not being found in the variable
line by
  the .search method (see the output below: match is None). The pdb
file
  does have residue 433 and all the listed atom names. The
noe_regex looks
  sort of complicated, I have no idea how to fix it. If anyone had
an idea
  how to fix it, I would very much appreciate it.
 
  Thanks,
  Krisztina
 
  ps. If this script works for on your system, please write me too!


--
Thomas Holder
MPI for Developmental Biology
Spemannstr. 35
D-72076 Tübingen


plot_noe.py
Description: application/chimera
--
The Windows 8 Center - In partnership with Sourceforge
Your idea - your app - 30 days.
Get started!
http://windows8center.sourceforge.net/
what-html-developers-need-to-know-about-coding-windows-8-metro-style-apps/___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

[PyMOL] visualise NOEs

2012-10-28 Thread Krisztina Feher
Hi,

I am looking for a script that could show CNS type distance restraints on a pdb 
structure. In fact I have found a script on Justin Lorieau's homepage 
(http://www.lorieau.com/software/biophysics-software/40-plot-xplor-noes-in-pymol.html)
 that seems to intend to do exactly what I want, but it does not seem to work 
(I have Pymol 1.2 version installed with package manager of Ubuntu). I 
installed it as Plugin, but it gives the message:

Exception in plugin 'plot_noe' -- Traceback follows...
Traceback (most recent call last):
  File /usr/lib/python2.7/dist-packages/pmg_tk/PMGApp.py, line 321, in 
initializePlugins
    mod.__init__(self)
TypeError: module.__init__() argument 1 must be string, not instance
Error: unable to initialize plugin 'plot_noe'.

Upon execution with a distance .tbl file nothing happens on the structure. I 
attached the script, I would appreciate any ideas how to make it work.
Thanks a lot!
Krisztina
# plot_noe
#
#   Written by Justin L Lorieau
#   Version 20110923



from pymol import cmd

def plot_noe(filename, line_color='black', line_width='1.0', replace_pound='2'):
A function for plotting XPLOR NOE restraints on a structure using an impressive,
yet highly limited, regex for parsing.

:filename:
The filename of the NOE retraint file in XPLOR NIH format.

:line_color:
The color for the NOE lines. See the standard colors in PyMOL.
Default: 'black'

:line_width:
The thickness of the NOE lines.
Default: '1.0'

:replace_pound:
Replace the '#' character with the following character.
Default: '2'

NOE Restraint Format

assign (residue 5 and name HB#) (residue 21 and name HA) 3.0 0.7 0.7 # long
# assign (residue 3 and name HA) (residue 3 and name HB#) 2.2 0.3 0.3

Usage Notes
---
Commented 'assign' lines are skipped

This function cannot handle nested parentheses well. Please assign these to
one group or another. Also this function does not handle ranges with a ':'.

All atom groups denoted with a '#' are replaced with the replace_pound
character.

Usage Example
-
PyMOL plot_noe noe_short.tbl

from pymol import cmd
import re

noe_regex = re.compile(r\s*[^#]\s*assign\s*\((?Pgroup1[^\)]+)\)(\s*assign\s*)?\((?Pgroup2[^\)]+)\)\s*(?Pdist\d+(\.\d+)?))

resid_regex = re.compile(rresid(ue)?\s*(?Presid\d+))
name_regex = re.compile(rname\s*(?Pname[\w\#]+))
count = 0

with open(filename) as f:

for line in f.readlines():
match = noe_regex.search(line)
if match is None:
continue

# Parse the assignments in each group
# ex: match['group1'] = 'residue 21 and name HB#'
group1 = match.groupdict()['group1']
group2 = match.groupdict()['group2']
dist = match.groupdict()['dist']

# Parse the residue number and atom names
name1 = name_regex.search(group1).groupdict()['name'].replace('#',replace_pound)
name2 = name_regex.search(group2).groupdict()['name'].replace('#',replace_pound)
resid1 = resid_regex.search(group1).groupdict()['resid']
resid2 = resid_regex.search(group2).groupdict()['resid']
#resid1, resid2 = map(float, (resid1, resid2))
count += 1
print group2

# Create the PyMOL restraint
label = NOE_ + str(count)
cmd.do(.join((distance , label, , ,
resid1, /, name1, , ,
resid2, /, name2)))

# Format the line
cmd.do(set dash_color,  + line_color +  ,  + label)
cmd.do(set dash_gap, 0,  + label)
cmd.do(set dash_width,  + line_width + ,  + label)
cmd.do(hide labels) 

cmd.extend(plot_noe,plot_noe)


--
WINDOWS 8 is here. 
Millions of people.  Your app in 30 days.
Visit The Windows 8 Center at Sourceforge for all your go to resources.
http://windows8center.sourceforge.net/
join-generation-app-and-make-money-coding-fast/___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net