Question: Problem in compiling a modified Pymol plugin
gravatar for mayankb3192
4.7 years ago by
mayankb31920 wrote:

I am trying to use a part of the plugin available here. uses a trick to try and align structures that are very different from one another. It does this by temporarily modifying the resname of one structure to match the other and then aligning these structures with same name. 
I am using the same trick to generate two structures with same resname. I upload the plugin and try to proceed normally, however, I get two errors-one is while parsing the file and other while saving it. 
I am posting the plugin along with the errors,

from pymol import cmd

def alter(obj1,select1,obj2,select2):
    list_m = []
    list_n = []

    calpha = 'name ca'
    select1 = '%s & %s' % (selection1,calpha)
    select2 = '%s & %s' % (selection2,calpha)
    m=cmd.get_model("%s & %s" % (obj1,select1))
    n=cmd.get_model("%s & %s" % (obj2,select2))
    for at in m.atom:,at.chain,at.resn,at.resi,,at.segi, at.alt))
    for at in n.atom:,at.chain,at.resn,at.resi,,at.segi, at.alt))

    if len(m.atom) <= len(n.atom):
        total = len(m.atom)
        total = len(n.atom)

    for i in range(total):"alter %s & id %s, chain='%s'" % (obj1,list_m[i][0],list_n[i][1]))"alter %s & id %s, resn='%s'" % (obj1,list_m[i][0],list_n[i][2]))"alter %s & id %s, resi=%s" % (obj1,list_m[i][0],list_n[i][3]))"alter %s & id %s, alt='%s'" % (obj1,list_m[i][0],list_n[i][6])), obj1, 0, pdb), obj2, 0, pdb)



Parsing-Error: missing required argument in function  alter  : select1

Traceback (most recent call last):

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymol/", line 256, in parse[0],layer.args,layer.kw_args)

  File "/Users/reload/.pymol/startup/", line 28, in alter, obj1, 0, pdb)

NameError: global name 'pdb' is not defined

ADD COMMENTlink written 4.7 years ago by mayankb31920

Your code does not compile when I try to run it. Please check in the lines starting with `list_m.append`; you're missing brackets here.

The NameError at the end is thrown because you do not define `pdb` anywhere in your script.

What about the select1 and select2 arguments parsed to the function? Why are they required but then redefined without the user's input being used?

ADD REPLYlink written 4.6 years ago by Felix_Sim250
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 715 users visited in the last hour