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!

--- On Sun, 10/28/12, Krisztina Feher <feher_kriszt...@yahoo.com> wrote:

From: Krisztina Feher <feher_kriszt...@yahoo.com>
Subject: [PyMOL] visualise NOEs
To: pymol-users@lists.sourceforge.net
Date: Sunday, October 28, 2012, 10:14 PM

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

-----Inline Attachment Follows-----

------------------------------------------------------------------------------
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/
-----Inline Attachment Follows-----

_______________________________________________
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
# 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*\((?P<group1>[^\)]+)\)(\s*assign\s*)?\((?P<group2>[^\)]+)\)\s*(?P<dist>\d+(\.\d+)?)""")

    resid_regex = re.compile(r"resid(ue)?\s*(?P<resid>\d+)")
    name_regex = re.compile(r"name\s*(?P<name>[\w\#]+)")
    count = 0

    with open(filename) as f:

        for line in f.readlines():
            print line
            print noe_regex.search(line)
            match = noe_regex.search(line)
            print match
            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)


------------------------------------------------------------------------------
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

Reply via email to