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')
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
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)
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()
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
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
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')
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
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)'])
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
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)"])
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
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
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
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())
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())
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()
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)
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)
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()
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()
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)