Exemplo n.º 1
0
 def testGetType(self):
     cmd.fragment('gly', 'm1')
     self.assertEqual(cmd.get_type('m1'), 'object:molecule')
     cmd.ramp_new('ramp1', 'none')
     self.assertEqual(cmd.get_type('ramp1'), 'object:ramp')
     cmd.select('s1', 'elem C')
     self.assertEqual(cmd.get_type('s1'), 'selection')
Exemplo n.º 2
0
def Refresh_DDL(widget, var, exc, fun):

    try:
        cmd.unpick()
        list = cmd.get_names('all')
    
        # Delete all entries in DDL
        widget['menu'].delete(0, END)

        if len(list) > 0:
            list = [ str(item) for item in list if not re.match(RESERVED_NAMES, item) ]
            
            for item in sorted(list, key=str.lower):
                type = cmd.get_type(str(item))
                
                if (type == 'object:molecule' or type == 'selection') and exc.count(str(item)) == 0:
                    if fun != None:
                        widget['menu'].add_command(label=item, command=lambda temp = item: fun(temp))
                    else:
                        widget['menu'].add_command(label=item, command=lambda temp = item: widget.setvar(widget.cget('textvariable'), value = temp))

                    var.set(item)
                        
        else:            
            # Dummy value
            widget['menu'].add_command(label='', command=lambda temp = '': widget.setvar(widget.cget('textvariable'), value = ''))
            var.set('')

    except:
        pass
Exemplo n.º 3
0
 def fill_map_list(self):
     self.objects_list = cmd.get_names('objects')
     self.maps_list = [
         e for e in self.objects_list if cmd.get_type(e) == 'object:map'
     ]
     self.form.mapselector.clear()
     self.form.mapselector.addItems(self.maps_list)
Exemplo n.º 4
0
 def update_object_list(self):
     """
     update the internal state list
     """
     # purge list of removed objects
     pubObj = self.cmd.get_names("public_objects")
     object_list_copy = self.object_list.copy()
     for x in object_list_copy:
         if x not in pubObj:
             del self.object_list[x]
     # for all VOLUME type objects not known to the list
     for x in self.cmd.get_names("public_objects"):
         if "object:volume"==cmd.get_type(x):
             if x not in self.object_list.keys():                   
                 if self.cmd.get_volume_is_updated(x) == 0:
                     continue 
                 # make a default pair for this volume object
                 tmpMap = VolumeHist(self.cmd.get_volume_histogram(x,self.cmd),nBins=64)
                 tmpRamp = ColorRamp(360,name=x)
                 self.object_list[x] = (tmpRamp,tmpMap)
                 if self.ramp_update.has_key(x) and self.ramp_update[x]:
                     tmpRamp.addColor(0, (0,0,1,0))
                     tmpRamp.addColor(359, (0,0,1,0))
                     for data, alpha, col, kind in self.ramp_update[x]:
                         self.addWithoutGUINow(x, data, alpha, col, kind=kind)
                     self.ramp_update[x] = []
                     tmpRamp.updateRamp()
                     self.cmd.volume_color(x, tmpRamp.getRamp())
                     self.cmd.set_volume_ramp(x, tmpRamp.getRampList())
                 else:
                     ramp_list = self.cmd.get_volume_ramp(x, self.cmd)
                     if ramp_list:
                         while ramp_list:
                             tmpRamp.addColor(ramp_list[0], 
                                 (ramp_list[1], ramp_list[2], ramp_list[3], ramp_list[4]))
                             ramp_list = ramp_list[5:]
                     else:                    
                         tmpRamp.addColor(0, (0,0,1,0))
                         tmpRamp.addColor(359, (0,0,1,0))
                         tmpRamp.addColor(200, (0.0, 0.0, 1.0, 0.0))
                         tmpRamp.addColor(210, (0.0, 0.8, 1.0, 0.2))
                         tmpRamp.addColor(220, (0.0, 0.0, 1.0, 0.0))
             else:
                 # need to regenerate the histogram
                 (tmpRamp,tmpMap) = self.object_list[x]
                 tmpMap = VolumeHist(self.cmd.get_volume_histogram(x,self.cmd),nBins=64)
                 self.object_list[x] = (tmpRamp,tmpMap)                    
     if len(self.object_list.keys())!=0:
         # guaranteed to exist
         k = self.object_list.keys()[0]
         self.active_ramp, self.active_map = self.object_list[k]
         self.active = k
         self.update_transferframe()
Exemplo n.º 5
0
def unmask_Objects(lstexc):
    
    lstobj = cmd.get_names('objects')
    
    for obj in lstobj:
        if lstexc.count(str(obj)) == 0:
            try:
                type = cmd.get_type(str(obj))
                
                if type == 'object:molecule' or type == 'selection':
                    cmd.unmask(str(obj))
            except:
                continue
Exemplo n.º 6
0
def get_isoobjects(state=1, quiet=1):
    '''
    Get a list of (name, isolevel) tuples for all isomesh and isosurface
    objects.
    '''
    state, quiet = int(state), int(quiet)
    r = []
    for name in cmd.get_names():
        t = cmd.get_type(name)
        if t in ('object:mesh', 'object:surface'):
            level = cmd.isolevel(name, 0, state, 1)
            if not quiet:
                print '%-20s %5.2f' % (name, level)
            r.append((name, level))
    return r
Exemplo n.º 7
0
    def testFetch(self):
        with testing.mkdtemp() as fetch_path:
            names = []
            cmd.set('fetch_path', fetch_path)
            cmd.set('fetch_host', 'pdb pdbe')

            cmd.fetch('1avy', '1avy1', type='pdb1')
            names += ['1avy1']
            self.assertItemsEqual(cmd.get_names(), names)
            self.assertEqual(cmd.count_states('1avy1'), 3)

            cmd.fetch('1avy', type='2fofc')
            names += ['1avy_2fofc']
            self.assertItemsEqual(cmd.get_names(), names)
            self.assertEqual(cmd.get_type('1avy_2fofc'), 'object:map')
Exemplo n.º 8
0
def get_isoobjects(state=1, quiet=1):
    '''
    Get a list of (name, isolevel) tuples for all isomesh and isosurface
    objects.
    '''
    state, quiet = int(state), int(quiet)
    r = []
    for name in cmd.get_names():
        t = cmd.get_type(name)
        if t in ('object:mesh', 'object:surface'):
            level = cmd.isolevel(name, 0, state, 1)
            if not quiet:
                print '%-20s %5.2f' % (name, level)
            r.append((name, level))
    return r
Exemplo n.º 9
0
    def testFetch(self):
        with testing.mkdtemp() as fetch_path:
            names = []
            cmd.set('fetch_path', fetch_path)
            cmd.set('fetch_host', 'pdb pdbe')

            cmd.fetch('1avy', '1avy1', type='pdb1')
            names += ['1avy1']
            self.assertItemsEqual(cmd.get_names(), names)
            self.assertEqual(cmd.count_states('1avy1'), 3)

            cmd.fetch('1avy', type='2fofc')
            names += ['1avy_2fofc']
            self.assertItemsEqual(cmd.get_names(), names)
            self.assertEqual(cmd.get_type('1avy_2fofc'), 'object:map')
Exemplo n.º 10
0
 def click(self):
     residueName = self.createSelectionMacro("(sele)")
     # transfer the click selection to a named selection
     cmd.select(residueName, "(sele)")
     # find the name of the object which contains the selection
     new_name = None
     obj_list = cmd.get_names("objects")
     for object in obj_list:
         if cmd.get_type(object) == "object:molecule":
             if cmd.count_atoms("(%s and %s)" % (object, residueName)):
                 pickedObject = object
                 break
     if pickedObject == None:
         print "MtsslWizard: object not found."
     self.cmd.refresh_wizard()
     return residueName, pickedObject
Exemplo n.º 11
0
    def update_object_menu(self):

        # find objects with > 1 state

        self.avail_objects = []

        for a in cmd.get_names('objects'):
            if cmd.get_type(a)=='object:molecule':
                if cmd.count_states(a)>1:
                    self.avail_objects.append(a)

        # now create the object menu

        self.menu['object'] = [[2,'Select Object','']]
        for a in self.avail_objects:
            self.menu['object'].append([ 1,a,'cmd.get_wizard().set_object("%s")'%(a) ])
        self.menu['object'].append([ 1,'None','cmd.get_wizard().set_object(None)'])
Exemplo n.º 12
0
    def __init__(self, mobile, target, match):
        self.autodelete = True
        self.temporary = []

        if match == 'none':
            self.mobile = mobile
            self.target = target
        elif match in ['in', 'like']:
            self.mobile = '(%s) %s (%s)' % (mobile, match, target)
            self.target = '(%s) %s (%s)' % (target, match, mobile)
        elif match in ['align', 'super']:
            self.align(mobile, target, match)
        elif match in cmd.get_names('all') and cmd.get_type(match) in ('object:', 'object:alignment'):
            self.from_alignment(mobile, target, match)
        else:
            print(' Error: unkown match method', match)
            raise CmdException
Exemplo n.º 13
0
    def update_object_menu(self):

        # find objects with > 1 state
        
        self.avail_objects = []
        
        for a in cmd.get_names('objects'):
            if cmd.get_type(a)=='object:molecule':
                if cmd.count_states(a)>1:
                    self.avail_objects.append(a)

        # now create the object menu
        
        self.menu['object'] = [[2,'Select Object','']] 
        for a in self.avail_objects:
            self.menu['object'].append([ 1,a,'cmd.get_wizard().set_object("%s")'%(a) ])
        self.menu['object'].append([ 1,'None','cmd.get_wizard().set_object(None)'])
Exemplo n.º 14
0
    def update_object_menu(self):

        # find objects with > 1 state

        self.avail_objects = []

        for a in cmd.get_names("objects"):
            if cmd.get_type(a) == "object:molecule":
                if cmd.count_states(a) > 1:
                    self.avail_objects.append(a)

        # now create the object menu

        self.menu["object"] = [[2, "Select Object", ""]]
        for a in self.avail_objects:
            self.menu["object"].append([1, a, 'cmd.get_wizard().set_object("%s")' % (a)])
        self.menu["object"].append([1, "None", "cmd.get_wizard().set_object(None)"])
Exemplo n.º 15
0
 def createSelectionMacro(self, selection):
     obj_list = cmd.get_names('objects')
     selectedObject = ""
     for object in obj_list:
         if cmd.get_type(object) == "object:molecule":
             if cmd.count_atoms("(%s and (sele))" % (object)):
                 selectedObject = object
                 break
     my_dict = {"my_list": []}
     cmd.iterate(selection,
                 "my_list.append((segi,chain,resi,resn))",
                 space=my_dict)
     my_list = my_dict['my_list']
     macro = "%s-%s-%s-%s-%s" % (selectedObject, my_list[0][0],
                                 my_list[0][1], my_list[0][2],
                                 my_list[0][3])
     return macro
Exemplo n.º 16
0
    def __init__(self, mobile, target, match):
        self.autodelete = True
        self.temporary = []

        if match == 'none':
            self.mobile = mobile
            self.target = target
        elif match in ['in', 'like']:
            self.mobile = '(%s) %s (%s)' % (mobile, match, target)
            self.target = '(%s) %s (%s)' % (target, match, mobile)
        elif match in ['align', 'super']:
            self.align(mobile, target, match)
        elif match in cmd.get_names('all') and cmd.get_type(match) in ('object:', 'object:alignment'):
            self.from_alignment(mobile, target, match)
        else:
            print(' Error: unkown match method', match)
            raise CmdException
Exemplo n.º 17
0
 def update_is_needed(self):
     # check removed objects
     pubObj = self.cmd.get_names("public_objects")
     if not pubObj:
         # if ModalDraw is set (e.g., a movie is running)
         # then API cannot be accessed and get_names() returns
         # None.  In this case, the volume panel info does not
         # need to be updated
         return False
     for x in self.object_list:
         if x not in pubObj:
             return True
     # check new objects
     for x in self.cmd.get_names("public_objects"):
         if "object:volume" == cmd.get_type(x):
             if x not in self.object_list.keys():
                 return True
     return False
Exemplo n.º 18
0
 def update_is_needed(self):
     # check removed objects
     pubObj = self.cmd.get_names("public_objects")
     if not pubObj:
         # if ModalDraw is set (e.g., a movie is running)
         # then API cannot be accessed and get_names() returns
         # None.  In this case, the volume panel info does not
         # need to be updated
         return False
     for x in self.object_list:
         if x not in pubObj:
             return True
     # check new objects
     for x in self.cmd.get_names("public_objects"):
         if "object:volume"==cmd.get_type(x):
             if x not in self.object_list.keys():
                 return True
     return False
Exemplo n.º 19
0
    def __init__(self, _self=cmd):

        # initialize parent class

        Wizard.__init__(self, _self)

        # restore previous state from global storage

        self.dict = static_dict
        self.object = default_object
        self.browse = default_browse
        self.avail_objects = []
        self.state_dict = {}

        # if we don't have a current object, choose the first multi-state object

        if self.object == None:
            for a in cmd.get_names("objects"):
                if cmd.get_type(a) == "object:molecule":
                    if cmd.count_states(a) > 1:
                        self.object = a
                        break

        # menu for

        self.menu["browse"] = [
            [2, "Browse Mode", ""],
            [1, "Browse All", "cmd.get_wizard().set_browse(1)"],
            [1, "Browse Accepted", "cmd.get_wizard().set_browse(2)"],
            [1, "Browse Rejected", "cmd.get_wizard().set_browse(3)"],
            [1, "Browse Deferred", "cmd.get_wizard().set_browse(4)"],
            [1, "Browse Remaining", "cmd.get_wizard().set_browse(5)"],
        ]

        self.count_object()
        self.load_state_dict()
        self.update_object_menu()
        cmd.set_key("F1", lambda s=self: s.accept())
        cmd.set_key("F2", lambda s=self: s.reject())
        cmd.set_key("F3", lambda s=self: s.defer())
        cmd.set_key("right", lambda s=self: s.forward())
        cmd.set_key("left", lambda s=self: s.backward())
Exemplo n.º 20
0
    def __init__(self, _self=cmd):

        # initialize parent class

        Wizard.__init__(self, _self)

        # restore previous state from global storage

        self.dict = static_dict
        self.object = default_object
        self.browse = default_browse
        self.avail_objects = []
        self.state_dict = {}

        # if we don't have a current object, choose the first multi-state object

        if self.object == None:
            for a in cmd.get_names('objects'):
                if cmd.get_type(a) == 'object:molecule':
                    if cmd.count_states(a) > 1:
                        self.object = a
                        break

        # menu for

        self.menu['browse'] = [
            [2, 'Browse Mode', ''],
            [1, 'Browse All', 'cmd.get_wizard().set_browse(1)'],
            [1, 'Browse Accepted', 'cmd.get_wizard().set_browse(2)'],
            [1, 'Browse Rejected', 'cmd.get_wizard().set_browse(3)'],
            [1, 'Browse Deferred', 'cmd.get_wizard().set_browse(4)'],
            [1, 'Browse Remaining', 'cmd.get_wizard().set_browse(5)'],
        ]

        self.count_object()
        self.load_state_dict()
        self.update_object_menu()
        cmd.set_key('F1', lambda s=self: s.accept())
        cmd.set_key('F2', lambda s=self: s.reject())
        cmd.set_key('F3', lambda s=self: s.defer())
        cmd.set_key('right', lambda s=self: s.forward())
        cmd.set_key('left', lambda s=self: s.backward())
Exemplo n.º 21
0
    def import_pymol_selections_from_main_menu(self):
        """
        Method for importing PyMOL Selections into PyMod. It saves PyMOL objects selected by users
        to file, and loads it into PyMOL using 'open_structure_file()'.
        """
        # Find all structures already loaded into PyMod: items in struct_list are excluded from
        # importable PyMOL object list.
        struct_list = [
            member.get_pymol_selector()
            for member in self.get_pymod_elements_list()
            if member.has_structure()
        ]

        # Importable PyMOL objects.
        scrolledlist_items = [
            str(obj) for obj in cmd.get_names("objects") if
            not obj in struct_list and cmd.get_type(obj) == "object:molecule"
        ]

        if not scrolledlist_items:
            if struct_list:
                self.main_window.show_error_message(
                    "No Importable Object",
                    "All PyMOL objects are already imported into PyMod.")
            else:
                self.main_window.show_error_message(
                    "No Importable Object", "No PyMOL object to import.")
            return

        # Builds a new window.
        self.import_from_pymol_window = Import_from_pymol_window_qt(
            self.main_window,
            title="Import from PyMOL",
            upper_frame_title="Load PyMOL Objects into PyMod",
            submit_command=self.import_selected_pymol_object,
            selections_list=scrolledlist_items)
        self.import_from_pymol_window.show()
Exemplo n.º 22
0
 def testLoadVaspCHGCAR(self):
     cmd.load(self.datafile("vasp.CHGCAR"), 'vasp.CHGCAR')
     self.assertEqual(cmd.get_type('vasp.CHGCAR'), 'object:map')
     extend = cmd.get_extent('vasp.CHGCAR')
     self.assertArrayEqual(extend, [[0.0, 0.0, 0.0], [6.5, 6.5, 7.7]],
                           delta=1e-2)
Exemplo n.º 23
0
    def apply(self):
        cmd = self.cmd
        pymol = cmd._pymol
        if self.status == 1:
            # find the name of the object which contains the selection
            new_name = None
            obj_list = cmd.get_names("objects")
            for a in obj_list:
                if cmd.get_type(a) == "object:molecule":
                    if cmd.count_atoms("(%s and %s)" % (a, src_sele)):
                        new_name = a
                        break
            src_frame = cmd.get_state()
            if new_name == None:
                print " Mutagenesis: object not found."
            else:
                auto_zoom = cmd.get_setting_text("auto_zoom")
                cmd.set("auto_zoom", "0", quiet=1)
                if self.lib_mode != "current":

                    # create copy w/o residue
                    cmd.create(tmp_obj1, "(%s and not %s)" % (new_name, src_sele))

                    # remove existing c-cap in copy (if any)
                    cmd.remove("byres (name N and (%s in (neighbor %s)) and resn nme,nhh)" % (tmp_obj1, src_sele))
                    # remove existing n-cap in copy (if any)
                    cmd.remove("byres (name C and (%s in (neighbor %s)) and resn ace)" % (tmp_obj1, src_sele))

                    # save copy for bonded atom reference
                    cmd.create(tmp_obj3, new_name)
                    # transfer the selection to copy
                    cmd.select(src_sele, "(%s in %s)" % (tmp_obj3, src_sele))
                    # create copy with mutant in correct frame
                    cmd.create(tmp_obj2, obj_name, src_frame, 1)
                    cmd.set_title(tmp_obj2, 1, "")
                    cmd.delete(new_name)

                    # create the merged molecule
                    cmd.create(new_name, "(%s or %s)" % (tmp_obj1, tmp_obj2), 1)  # only one state in merged object...

                    # now connect them
                    cmd.select(mut_sele, "(byres (%s like %s))" % (new_name, src_sele))

                    # bond N+0 to C-1
                    if (cmd.select(tmp_sele1, "(name C and (%s in (neighbor %s)))" % (new_name, src_sele)) == 1) and (
                        cmd.select(tmp_sele2, "((%s in %s) and n;N)" % (mut_sele, tmp_obj2)) == 1
                    ):
                        cmd.bond(tmp_sele1, tmp_sele2)
                        cmd.set_geometry(tmp_sele1, 3, 3)  # make amide planer
                        cmd.set_geometry(tmp_sele2, 3, 3)  # make amide planer
                    # bond C+0 to N+1
                    if (cmd.select(tmp_sele1, "(name N and (%s in (neighbor %s)))" % (new_name, src_sele)) == 1) and (
                        cmd.select(tmp_sele2, "((%s in %s) and n;C)" % (mut_sele, tmp_obj2)) == 1
                    ):
                        cmd.bond(tmp_sele1, tmp_sele2)
                        cmd.set_geometry(tmp_sele1, 3, 3)  # make amide planer
                        cmd.set_geometry(tmp_sele2, 3, 3)  # make amide planer

                    cmd.delete(tmp_sele1)
                    cmd.delete(tmp_sele2)

                    # fix N-H hydrogen position (if any exists)
                    cmd.h_fix("(name N and bound_to (%s in %s and n;H))" % (new_name, tmp_obj2))

                    # now transfer selection back to the modified object
                    cmd.delete(tmp_obj1)
                    cmd.delete(tmp_obj2)
                    cmd.delete(tmp_obj3)
                    self.clear()
                    # and return to frame 1
                    cmd.frame(1)
                    cmd.refresh_wizard()
                else:
                    # create copy with conformation in correct state
                    cmd.create(tmp_obj2, obj_name, src_frame, 1)

                    # remove existing c-cap in copy (if any)
                    cmd.remove("byres (name N and (%s in (neighbor %s)) and resn nme,nhh)" % (new_name, src_sele))
                    cmd.remove("(%s) and name OXT" % src_sele)

                    # remove existing n-cap in copy (if any)
                    cmd.remove("byres (name C and (%s in (neighbor %s)) and resn ace)" % (new_name, src_sele))

                    # save existing conformation on undo stack
                    #               cmd.edit("((%s in %s) and name ca)"%(new_name,src_sele))
                    cmd.push_undo("(" + src_sele + ")")
                    # modify the conformation
                    cmd.update(new_name, tmp_obj2)
                    #               cmd.unpick()
                    cmd.delete(tmp_obj2)
                    self.clear()
                    # and return to frame 1
                    cmd.frame(1)
                    cmd.refresh_wizard()
                cmd.set("auto_zoom", auto_zoom, quiet=1)
Exemplo n.º 24
0
def contactsDialog(root):
	"""Create GUI"""

	PADDING=5

	win = Toplevel(root, width=400, height=600, padx=PADDING, pady=PADDING)
	win.resizable(0,0)
	win.title("Visualize CASP RR contacts")

	#### MAIN CONTROLS ####

	frmMain = Frame(win)
	frmMain.pack(fill=BOTH, expand=1)
	frmMain.columnconfigure(0, weight=2, pad=PADDING)
	frmMain.columnconfigure(1, weight=5, pad=PADDING)
	frmMain.columnconfigure(2, weight=1, pad=PADDING)

	Label(frmMain, text="RR file:").grid(row=0,column=0,sticky=N+E)
	vTarget = StringVar(win)
	txtTarget = Entry(frmMain, textvariable=vTarget)
	txtTarget.grid(row=0, column=1, sticky=W+E)
	
	def browseTarget():
		cf = tkFileDialog.askopenfilename(parent=win, filetypes=[("CASP RR files", ".CASPRR")])
		if cf:
			vTarget.set(cf)

	cmdTarget = Button(frmMain, text="...", command=browseTarget)
	cmdTarget.grid(row=0, column=2, sticky=W+E)
	
	Label(frmMain, text="Target:").grid(row=1,column=0,sticky=N+E)
	lstObject = Listbox(frmMain, selectmode=SINGLE, exportselection=0, height=6)


	objects = []
	molecules = ( n for n in cmd.get_names() if cmd.get_type(n) == "object:molecule")
	for n in molecules:
		for ch in cmd.get_chains(n):
			objects.append((n, ch))
			lstObject.insert(END, "{0}/{1}".format(n,ch))

	if objects: lstObject.selection_set(0)

	lstObject.grid(row=1, column=1, columnspan=2, sticky=N+E+S+W)

	Label(frmMain, text="Min. separation:").grid(row=2,column=0,sticky=E)
	vSeparation = IntVar(win)
	vSeparation.set(23)
	sclSeparation = Scale(frmMain, from_=0, to=100, orient=HORIZONTAL, variable=vSeparation)
	sclSeparation.grid(row=2, column=1, columnspan=2, sticky=W+E)

	Label(frmMain, text="Num. contacts:").grid(row=3,column=0,sticky=E)
	vContacts = IntVar(win)
	vContacts.set(25)
	sclContacts = Scale(frmMain, from_=1, to=500, orient=HORIZONTAL, variable=vContacts)
	sclContacts.grid(row=3, column=1, columnspan=2, sticky=W+E)


	Label(frmMain, text="Use atoms:").grid(row=4,column=0,sticky=E)
	catms = sorted(contact_atoms.keys())
	lstAtomMappings = Listbox(frmMain, selectmode=MULTIPLE, exportselection=0, height=4)
	for n in catms:
		lstAtomMappings.insert(END, n)
	lstAtomMappings.selection_set(1)
	lstAtomMappings.grid(row=4, column=1, columnspan=2, sticky=N+E+S+W)

	#### BUTTONS ROW ####

	frmButtons = Frame(win)
	frmButtons.pack(fill=X, expand=1)

	btnCancel = Button(frmButtons, text="Close", command=lambda: win.destroy())
	btnCancel.pack(side=RIGHT, pady=PADDING)

	def validate():
		if not vTarget.get():
			tkMessageBox.showwarning("No CASP RR file", "Please specify a valid CASP RR file to visualize!")
			return False

		if not lstObject.curselection():
			tkMessageBox.showwarning("No Mapping Target", "Please specify a molecule to map contacts on!")
			return False

		if not lstAtomMappings.curselection():
			tkMessageBox.showwarning("No Atom Selection", "Please specify at least one set of atoms to map contacts on!")
			return False
		
		return True

	def confirm():

		if not validate(): return 

		contactFile = vTarget.get()
		target, chain = objects[int(lstObject.curselection()[0])]
		num_contacts = vContacts.get()
		min_separation = vSeparation.get()

		#atom_mapping = contact_atoms[ vAtomMappings.get() ]

		atom_mapping = [ contact_atoms[catms[int(k)]] for k in lstAtomMappings.curselection() ]

		print atom_mapping

		show_contacts(contactFile, target, chain, num_contacts, min_separation, atom_mapping)


	btnOK = Button(frmButtons, text="Show", command=confirm)
	btnOK.pack(side=RIGHT)

	browseTarget()
Exemplo n.º 25
0
 def testLoadVaspCHGCAR(self):
     cmd.load(self.datafile("vasp.CHGCAR"), 'vasp.CHGCAR')
     self.assertEqual(cmd.get_type('vasp.CHGCAR'), 'object:map')
     extend = cmd.get_extent('vasp.CHGCAR')
     self.assertArrayEqual(extend, [[0.0, 0.0, 0.0], [6.5, 6.5, 7.7]], delta=1e-2)
Exemplo n.º 26
0
 def update_object_list(self):
     """
     update the internal state list
     """
     # purge list of removed objects
     pubObj = self.cmd.get_names("public_objects")
     object_list_copy = self.object_list.copy()
     for x in object_list_copy:
         if x not in pubObj:
             del self.object_list[x]
     # for all VOLUME type objects not known to the list
     for x in self.cmd.get_names("public_objects"):
         if "object:volume" == cmd.get_type(x):
             if x not in self.object_list.keys():
                 if self.cmd.get_volume_is_updated(x) == 0:
                     continue
                 # make a default pair for this volume object
                 tmpMap = VolumeHist(self.cmd.get_volume_histogram(
                     x, self.cmd),
                                     nBins=64)
                 tmpRamp = ColorRamp(360, name=x)
                 self.object_list[x] = (tmpRamp, tmpMap)
                 if self.ramp_update.has_key(x) and self.ramp_update[x]:
                     tmpRamp.addColor(0, (0, 0, 1, 0))
                     tmpRamp.addColor(359, (0, 0, 1, 0))
                     for data, alpha, col, kind in self.ramp_update[x]:
                         self.addWithoutGUINow(x,
                                               data,
                                               alpha,
                                               col,
                                               kind=kind)
                     self.ramp_update[x] = []
                     tmpRamp.updateRamp()
                     self.cmd.volume_color(x, tmpRamp.getRamp())
                     self.cmd.set_volume_ramp(x, tmpRamp.getRampList())
                 else:
                     ramp_list = self.cmd.get_volume_ramp(x, self.cmd)
                     if ramp_list:
                         while ramp_list:
                             tmpRamp.addColor(ramp_list[0],
                                              (ramp_list[1], ramp_list[2],
                                               ramp_list[3], ramp_list[4]))
                             ramp_list = ramp_list[5:]
                     else:
                         tmpRamp.addColor(0, (0, 0, 1, 0))
                         tmpRamp.addColor(359, (0, 0, 1, 0))
                         tmpRamp.addColor(200, (0.0, 0.0, 1.0, 0.0))
                         tmpRamp.addColor(210, (0.0, 0.8, 1.0, 0.2))
                         tmpRamp.addColor(220, (0.0, 0.0, 1.0, 0.0))
             else:
                 # need to regenerate the histogram
                 (tmpRamp, tmpMap) = self.object_list[x]
                 tmpMap = VolumeHist(self.cmd.get_volume_histogram(
                     x, self.cmd),
                                     nBins=64)
                 self.object_list[x] = (tmpRamp, tmpMap)
     if len(self.object_list.keys()) != 0:
         # guaranteed to exist
         k = self.object_list.keys()[0]
         self.active_ramp, self.active_map = self.object_list[k]
         self.active = k
         self.update_transferframe()
Exemplo n.º 27
0
    def apply(self):
        cmd=self.cmd
        pymol=cmd._pymol
        if self.status==1:
            # find the name of the object which contains the selection
            new_name = None
            obj_list = cmd.get_names('objects')
            for a in obj_list:
                if cmd.get_type(a)=="object:molecule":
                    if cmd.count_atoms("(%s and %s)"%(a,src_sele)):
                        new_name = a
                        break
            src_frame = cmd.get_state()
            if new_name==None:
                print " Mutagenesis: object not found."
            else:
                auto_zoom = cmd.get_setting_text('auto_zoom')
                cmd.set('auto_zoom',"0",quiet=1)
                if self.lib_mode!="current":

                    # create copy w/o residue
                    cmd.create(tmp_obj1,"(%s and not %s)"%(new_name,src_sele))

                    # remove existing c-cap in copy (if any)
                    cmd.remove("byres (name N and (%s in (neighbor %s)) and resn nme,nhh)"%
                                (tmp_obj1,src_sele))
                    # remove existing n-cap in copy (if any)
                    cmd.remove("byres (name C and (%s in (neighbor %s)) and resn ace)"%
                                (tmp_obj1,src_sele))
                    
                    # save copy for bonded atom reference
                    cmd.create(tmp_obj3,new_name)
                    # transfer the selection to copy
                    cmd.select(src_sele,"(%s in %s)"%(tmp_obj3,src_sele))
                    # create copy with mutant in correct frame
                    cmd.create(tmp_obj2,obj_name,src_frame,1)
                    cmd.set_title(tmp_obj2,1,'')
                    cmd.delete(new_name)

                    # create the merged molecule
                    cmd.create(new_name,"(%s or %s)"%(tmp_obj1,tmp_obj2),1) # only one state in merged object...

                    # now connect them
                    cmd.select(mut_sele,"(byres (%s like %s))"%(new_name,src_sele))


                    # bond N+0 to C-1
                    if ((cmd.select(tmp_sele1, "(name C and (%s in (neighbor %s)))"%
                                  (new_name,src_sele)) == 1) and
                        (cmd.select(tmp_sele2, "((%s in %s) and n;N)"%
                                    (mut_sele,tmp_obj2)) == 1)):
                        cmd.bond(tmp_sele1,tmp_sele2)
                        cmd.set_geometry(tmp_sele1,3,3) # make amide planer
                        cmd.set_geometry(tmp_sele2,3,3) # make amide planer
                    # bond C+0 to N+1
                    if ((cmd.select(tmp_sele1, "(name N and (%s in (neighbor %s)))"%
                                (new_name,src_sele)) == 1) and
                        (cmd.select(tmp_sele2,"((%s in %s) and n;C)"%
                                    (mut_sele,tmp_obj2)) == 1)):
                        cmd.bond(tmp_sele1,tmp_sele2)
                        cmd.set_geometry(tmp_sele1,3,3) # make amide planer
                        cmd.set_geometry(tmp_sele2,3,3) # make amide planer

                    
                    cmd.delete(tmp_sele1)
                    cmd.delete(tmp_sele2)

                    # fix N-H hydrogen position (if any exists)
                    cmd.h_fix("(name N and bound_to (%s in %s and n;H))"%(new_name,tmp_obj2))

                    
                    # now transfer selection back to the modified object
                    cmd.delete(tmp_obj1)
                    cmd.delete(tmp_obj2)
                    cmd.delete(tmp_obj3)
                    self.clear()
                    # and return to frame 1
                    cmd.frame(1)
                    cmd.refresh_wizard()               
                else:
                    # create copy with conformation in correct state
                    cmd.create(tmp_obj2,obj_name,src_frame,1)

                    # remove existing c-cap in copy (if any)
                    cmd.remove("byres (name N and (%s in (neighbor %s)) and resn nme,nhh)"%
                                (new_name,src_sele))
                    cmd.remove("(%s) and name OXT"%src_sele)
                    
                    # remove existing n-cap in copy (if any)
                    cmd.remove("byres (name C and (%s in (neighbor %s)) and resn ace)"%
                                (new_name,src_sele))

                    # save existing conformation on undo stack
#               cmd.edit("((%s in %s) and name ca)"%(new_name,src_sele))
                    cmd.push_undo("("+src_sele+")")
                    # modify the conformation
                    cmd.update(new_name,tmp_obj2)
#               cmd.unpick()
                    cmd.delete(tmp_obj2)
                    self.clear()
                    # and return to frame 1
                    cmd.frame(1)
                    cmd.refresh_wizard()                              
                cmd.set('auto_zoom',auto_zoom,quiet=1)