def __init__(self, parent, W, H): wx.Panel.__init__(self, parent, id=-1, pos=(0, 0), size=(350, H-265), name="ProtocolsPanel") self.W = W self.H = H self.parent = parent self.SetBackgroundColour("#333333") self.Show() if (platform.system() == "Windows"): self.label = wx.StaticText(self, -1, "Protocols", (5, 5), (340, 25), wx.ALIGN_CENTRE) self.label.SetFont(wx.Font(12, wx.DEFAULT, wx.ITALIC, wx.BOLD)) elif (platform.system() == "Darwin"): self.label = wx.StaticBitmap(self, -1, wx.Image(self.parent.scriptdir + "/images/osx/protocols/lblProtocols.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap(), pos=(5, 5), size=(340, 25)) else: self.label = wx.StaticText(self, -1, "Protocols", style=wx.ALIGN_CENTRE) self.label.SetFont(wx.Font(12, wx.DEFAULT, wx.ITALIC, wx.BOLD)) resizeTextControlForUNIX(self.label, 0, self.GetSize()[0]) self.label.SetForegroundColour("#FFFFFF") if (platform.system() == "Darwin"): self.protMenu = wx.ComboBox(self, pos=(5, 30), size=(230, 25), choices=[], style=wx.CB_READONLY) else: self.protMenu = wx.ComboBox(self, pos=(5, 30), size=(230, 25), choices=[], style=wx.CB_READONLY | wx.CB_SORT) self.protMenu.SetToolTipString("List of currently available protocols") self.default_protocols = ["Antibody Modeling", "Biological Tools", "Docking", "Energy Minimization", "Ensemble Browser", "Ensemble Generation", "Flexible Peptide Docking", "Loop Modeling (KIC)", "Module Manager", "Molecular Surfaces", "Point Mutant Scan", "Point Mutations", "Protein Design (Fixbb)", "Protein Design (MSD)", "Residue/Ligand Creator", "Structure Prediction (Comparative Modeling)", "Superimposition"] self.readModules() self.protMenu.SetSelection(self.protocols.index("Superimposition")) if (platform.system() == "Darwin"): self.GoBtn = wx.BitmapButton(self, id=-1, bitmap=wx.Image(self.parent.scriptdir + "/images/osx/protocols/GoBtn.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap(), pos=(240, 30), size=(100, 25)) else: self.GoBtn = wx.Button(self, id=-1, label="Go!", pos=(240, 30), size=(100, 25)) self.GoBtn.SetForegroundColour("#000000") self.GoBtn.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)) self.GoBtn.Bind(wx.EVT_BUTTON, self.changeProtocol) self.GoBtn.SetToolTipString("Change to the selected protocol") self.currentProtocol = "Superimposition" self.protPanel = SuperimpositionPanel(self, W, H)
class ProtocolsPanel(wx.Panel): def __init__(self, parent, W, H): wx.Panel.__init__(self, parent, id=-1, pos=(0, 0), size=(350, H-265), name="ProtocolsPanel") self.W = W self.H = H self.parent = parent self.SetBackgroundColour("#333333") self.Show() if (platform.system() == "Windows"): self.label = wx.StaticText(self, -1, "Protocols", (5, 5), (340, 25), wx.ALIGN_CENTRE) self.label.SetFont(wx.Font(12, wx.DEFAULT, wx.ITALIC, wx.BOLD)) elif (platform.system() == "Darwin"): self.label = wx.StaticBitmap(self, -1, wx.Image(self.parent.scriptdir + "/images/osx/lblProtocols.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap(), pos=(5, 5), size=(340, 25)) else: self.label = wx.StaticText(self, -1, "Protocols", style=wx.ALIGN_CENTRE) self.label.SetFont(wx.Font(12, wx.DEFAULT, wx.ITALIC, wx.BOLD)) resizeTextControlForUNIX(self.label, 0, self.GetSize()[0]) self.label.SetForegroundColour("#FFFFFF") if (platform.system() == "Darwin"): self.protMenu = wx.ComboBox(self, pos=(5, 30), size=(230, 25), choices=[], style=wx.CB_READONLY) else: self.protMenu = wx.ComboBox(self, pos=(5, 30), size=(230, 25), choices=[], style=wx.CB_READONLY | wx.CB_SORT) self.protMenu.SetToolTipString("List of currently available protocols") self.default_protocols = ["Antibody Modeling", "Docking", "Energy Minimization", "Ensemble Browser", "Ensemble Generation", "Flexible Peptide Docking", "Loop Modeling (KIC)", "Module Manager", "Molecular Surfaces", "Point Mutant Scan", "Point Mutations", "Protein Design (Fixbb)", "Protein Design (MSD)", "Residue/Ligand Creator", "Structure Prediction (Comparative Modeling)", "Superimposition"] self.readModules() self.protMenu.SetSelection(self.protocols.index("Superimposition")) if (platform.system() == "Darwin"): self.GoBtn = wx.BitmapButton(self, id=-1, bitmap=wx.Image(self.parent.scriptdir + "/images/osx/GoBtn.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap(), pos=(240, 30), size=(100, 25)) else: self.GoBtn = wx.Button(self, id=-1, label="Go!", pos=(240, 30), size=(100, 25)) self.GoBtn.SetForegroundColour("#000000") self.GoBtn.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)) self.GoBtn.Bind(wx.EVT_BUTTON, self.changeProtocol) self.GoBtn.SetToolTipString("Change to the selected protocol") self.currentProtocol = "Superimposition" self.protPanel = SuperimpositionPanel(self, W, H) def readModules(self): self.protocols = self.default_protocols[:] # Let's see if there are any custom modules to import # Everything needs to be in a try/except block to prevent corrupted modules from # crashing the whole program # Ignore anything that does not import properly and write a message out to the terminal olddir = os.getcwd() goToSandbox("modules") sys.path.append(os.getcwd()) moduledirs = glob.glob("*") self.modules = {} for moduledir in moduledirs: # Ignore the template if (moduledir == "template"): continue try: module = __import__(moduledir) except: print "Failed to import " + moduledir + ", does " + moduledir + "/__init__.py exist?" continue try: # Does the panel exist? module.ModulePanel except: print "Failed to import " + moduledir + ", could not find the class \"ModulePanel\"" continue # Look for the name of the protocol in the comments of the module's script # If the name does not exist, just use the directory name modulename = moduledir fin = open(moduledir + "/__init__.py", "r") for aline in fin: if (aline.startswith("### PROTOCOL NAME:")): modulename = aline.split("### PROTOCOL NAME:")[1].strip() break fin.close() # Does this name exist already nameTaken = False for name in self.protocols: if (name.strip() == modulename.strip()): nameTaken = True break if (nameTaken): i = 2 while (True): nameTaken = False for name in self.protocols: if (name.strip() == modulename.strip() + " (" + str(i) + ")"): nameTaken = True break if (not(nameTaken)): modulename = modulename.strip() + " (" + str(i) + ")" break i += 1 # Add it into the list of protocols addedIn = False for i in range(0, len(self.protocols)): if (modulename < self.protocols[i]): addedIn = True self.protocols.insert(i, modulename) break if (not(addedIn)): self.protocols.append(modulename) self.modules[modulename] = module os.chdir(olddir) self.protMenu.Clear() self.protMenu.AppendItems(self.protocols) def changeProtocol(self, event): logInfo("Go button clicked") selectedProtocol = self.protMenu.GetStringSelection() if (selectedProtocol != self.currentProtocol and selectedProtocol != ""): # Destroy the old panel so we can free memory up and create the new protocol panel if (self.currentProtocol == "Superimposition"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Energy Minimization"): # Check to see if the user has accepted the minimization # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your minimization and the results will be lost if you proceed. Proceed anyway?", "Minimization Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted minimization") dlg.Destroy() return dlg.Destroy() logInfo("Minimization job rejected") # Try to delete the minimized model if the user doesn't want to accept it try: self.cmd.remove("minimized_view") self.cmd.delete("minimized_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Ensemble Browser"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Module Manager"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Ensemble Generation"): # Check to see if the user has accepted the design # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Cancel!"): dlg = wx.MessageDialog(self, "Your ensemble is not finished and the results will be lost if you proceed. Proceed anyway?", "Design Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unfinished ensemblegen job") dlg.Destroy() return logInfo("Ensemblegen job rejected") dlg.Destroy() self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Protein Design (Fixbb)"): # Check to see if the user has accepted the design # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your design and the results will be lost if you proceed. Proceed anyway?", "Design Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted fixbb job") dlg.Destroy() return logInfo("Fixbb job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("designed_view") self.cmd.delete("designed_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Residue/Ligand Creator"): try: self.cmd.remove("params") self.cmd.delete("params") except: pass self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Point Mutations"): try: self.cmd.remove("rotamer_view") self.cmd.delete("rotamer_view") except: pass self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Point Mutant Scan"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Loop Modeling (KIC)"): # Check to see if the user has accepted the loop model # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your loop model and the results will be lost if you proceed. Proceed anyway?", "KIC Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted KIC job") dlg.Destroy() return logInfo("KIC job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("kic_view") self.cmd.delete("kic_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Docking"): # Check to see if the user has accepted the docking model # If not, ask if they really want to proceed if (self.protPanel.buttonState != "Dock!"): dlg = wx.MessageDialog(self, "You have not accepted your docking model and the results will be lost if you proceed. Proceed anyway?", "Docking Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted docking job") dlg.Destroy() return logInfo("Docking job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("dock_view") self.cmd.delete("dock_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Structure Prediction (Comparative Modeling)"): # Check to see if the user has accepted the docking model # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your comparative modeling structure and the results will be lost if you proceed. Proceed anyway?", "Docking Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted comparative modeling job") dlg.Destroy() return logInfo("Comparative modeling job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("thread_view") self.cmd.delete("thread_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Protein Design (MSD)"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Antibody Modeling"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Molecular Surfaces"): try: self.cmd.delete("curr_surf_recp") except: pass try: self.cmd.delete("curr_surf_lig") except: pass self.cmd.hide("surface", "all") if (self.parent.Selection.showSurf): self.currentProtocol = "n/a" self.parent.Selection.displaySurfaces() self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Flexible Peptide Docking"): self.protPanel.Destroy() del self.protPanel else: # Must be a custom module self.protPanel.Destroy() del self.protPanel self.currentProtocol = selectedProtocol self.seqWin.cannotDelete = False # Restart the Rosetta daemon to clear its memory up self.parent.restartDaemon() logInfo("Changed protocol to " + selectedProtocol) if (selectedProtocol == "Superimposition"): self.protPanel = SuperimpositionPanel(self, self.W, self.H) elif (selectedProtocol == "Energy Minimization"): self.protPanel = MinimizationPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Ensemble Browser"): self.protPanel = EnsembleBrowserPanel(self, self.W, self.H) elif (selectedProtocol == "Module Manager"): self.protPanel = ModuleManagerPanel(self, self.W, self.H) elif (selectedProtocol == "Ensemble Generation"): self.protPanel = EnsembleGenPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Protein Design (Fixbb)"): self.protPanel = FixbbPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Residue/Ligand Creator"): self.protPanel = ResidueCreatorPanel(self, self.W, self.H) elif (selectedProtocol == "Point Mutations"): self.protPanel = PointMutationsPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Point Mutant Scan"): self.protPanel = PointMutantScanPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Loop Modeling (KIC)"): self.protPanel = KICPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Docking"): self.protPanel = DockingPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Structure Prediction (Comparative Modeling)"): self.protPanel = CompModelPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Protein Design (MSD)"): self.protPanel = MSDPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Antibody Modeling"): self.protPanel = AntibodyPanel(self, self.W, self.H) elif (selectedProtocol == "Molecular Surfaces"): self.protPanel = SurfacesPanel(self, self.W, self.H) self.cmd.hide("surface", "all") elif (selectedProtocol == "Flexible Peptide Docking"): self.protPanel = FlexPepDockPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) else: # Custom module # Custom modules are aware of PyMOL, the Sequence Window, and the SelectionPanel # They also know about the Protocols Window through the parent variable # They also will receive activation events self.protPanel = self.modules[selectedProtocol].ModulePanel(self, self.modules[selectedProtocol].__file__, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) self.protPanel.setSeqWin(self.seqWin) self.protPanel.setPyMOL(self.pymol) self.protPanel.activate() self.seqWin.setProtocolPanel(self.protPanel) def setSeqWin(self, seqWin): self.seqWin = seqWin self.protPanel.setSeqWin(seqWin) self.seqWin.setProtocolPanel(self.protPanel) def setPyMOL(self, pymol): self.pymol = pymol self.cmd = pymol.cmd self.stored = pymol.stored self.protPanel.setPyMOL(pymol) def setSelectWin(self, selectWin): self.selectWin = selectWin def activate(self): self.cmd.enable("seqsele") try: self.protPanel.activate() except: # Probably a custom module that does not have the activate function implemented print "WARNING: Could not activate the ProtocolPanel for " + self.currentProtocol
def changeProtocol(self, event): logInfo("Go button clicked") selectedProtocol = self.protMenu.GetStringSelection() if (selectedProtocol != self.currentProtocol and selectedProtocol != ""): # Destroy the old panel so we can free memory up and create the new protocol panel if (self.currentProtocol == "Superimposition"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Energy Minimization"): # Check to see if the user has accepted the minimization # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your minimization and the results will be lost if you proceed. Proceed anyway?", "Minimization Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted minimization") dlg.Destroy() return dlg.Destroy() logInfo("Minimization job rejected") # Try to delete the minimized model if the user doesn't want to accept it try: self.cmd.remove("minimized_view") self.cmd.delete("minimized_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Ensemble Browser"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Module Manager"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Ensemble Generation"): # Check to see if the user has accepted the design # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Cancel!"): dlg = wx.MessageDialog(self, "Your ensemble is not finished and the results will be lost if you proceed. Proceed anyway?", "Design Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unfinished ensemblegen job") dlg.Destroy() return logInfo("Ensemblegen job rejected") dlg.Destroy() self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Protein Design (Fixbb)"): # Check to see if the user has accepted the design # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your design and the results will be lost if you proceed. Proceed anyway?", "Design Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted fixbb job") dlg.Destroy() return logInfo("Fixbb job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("designed_view") self.cmd.delete("designed_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Residue/Ligand Creator"): try: self.cmd.remove("params") self.cmd.delete("params") except: pass self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Point Mutations"): try: self.cmd.remove("rotamer_view") self.cmd.delete("rotamer_view") except: pass self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Point Mutant Scan"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Loop Modeling (KIC)"): # Check to see if the user has accepted the loop model # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your loop model and the results will be lost if you proceed. Proceed anyway?", "KIC Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted KIC job") dlg.Destroy() return logInfo("KIC job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("kic_view") self.cmd.delete("kic_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Docking"): # Check to see if the user has accepted the docking model # If not, ask if they really want to proceed if (self.protPanel.buttonState != "Dock!"): dlg = wx.MessageDialog(self, "You have not accepted your docking model and the results will be lost if you proceed. Proceed anyway?", "Docking Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted docking job") dlg.Destroy() return logInfo("Docking job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("dock_view") self.cmd.delete("dock_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Structure Prediction (Comparative Modeling)"): # Check to see if the user has accepted the docking model # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your comparative modeling structure and the results will be lost if you proceed. Proceed anyway?", "Docking Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted comparative modeling job") dlg.Destroy() return logInfo("Comparative modeling job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("thread_view") self.cmd.delete("thread_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Protein Design (MSD)"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Antibody Modeling"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Molecular Surfaces"): try: self.cmd.delete("curr_surf_recp") except: pass try: self.cmd.delete("curr_surf_lig") except: pass self.cmd.hide("surface", "all") if (self.parent.Selection.showSurf): self.currentProtocol = "n/a" self.parent.Selection.displaySurfaces() self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Flexible Peptide Docking"): self.protPanel.Destroy() del self.protPanel else: # Must be a custom module self.protPanel.Destroy() del self.protPanel self.currentProtocol = selectedProtocol self.seqWin.cannotDelete = False # Restart the Rosetta daemon to clear its memory up self.parent.restartDaemon() logInfo("Changed protocol to " + selectedProtocol) if (selectedProtocol == "Superimposition"): self.protPanel = SuperimpositionPanel(self, self.W, self.H) elif (selectedProtocol == "Energy Minimization"): self.protPanel = MinimizationPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Ensemble Browser"): self.protPanel = EnsembleBrowserPanel(self, self.W, self.H) elif (selectedProtocol == "Module Manager"): self.protPanel = ModuleManagerPanel(self, self.W, self.H) elif (selectedProtocol == "Ensemble Generation"): self.protPanel = EnsembleGenPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Protein Design (Fixbb)"): self.protPanel = FixbbPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Residue/Ligand Creator"): self.protPanel = ResidueCreatorPanel(self, self.W, self.H) elif (selectedProtocol == "Point Mutations"): self.protPanel = PointMutationsPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Point Mutant Scan"): self.protPanel = PointMutantScanPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Loop Modeling (KIC)"): self.protPanel = KICPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Docking"): self.protPanel = DockingPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Structure Prediction (Comparative Modeling)"): self.protPanel = CompModelPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Protein Design (MSD)"): self.protPanel = MSDPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Antibody Modeling"): self.protPanel = AntibodyPanel(self, self.W, self.H) elif (selectedProtocol == "Molecular Surfaces"): self.protPanel = SurfacesPanel(self, self.W, self.H) self.cmd.hide("surface", "all") elif (selectedProtocol == "Flexible Peptide Docking"): self.protPanel = FlexPepDockPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) else: # Custom module # Custom modules are aware of PyMOL, the Sequence Window, and the SelectionPanel # They also know about the Protocols Window through the parent variable # They also will receive activation events self.protPanel = self.modules[selectedProtocol].ModulePanel(self, self.modules[selectedProtocol].__file__, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) self.protPanel.setSeqWin(self.seqWin) self.protPanel.setPyMOL(self.pymol) self.protPanel.activate() self.seqWin.setProtocolPanel(self.protPanel)
def changeProtocol(self, event): logInfo("Go button clicked") selectedProtocol = self.protMenu.GetStringSelection() if (selectedProtocol != self.currentProtocol and selectedProtocol != ""): # Destroy the old panel so we can free memory up and create the new protocol panel if (self.protPanel is not None): if (self.currentProtocol == "Superimposition"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Energy Minimization"): # Check to see if the user has accepted the minimization # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your minimization and the results will be lost if you proceed. Proceed anyway?", "Minimization Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted minimization") dlg.Destroy() return dlg.Destroy() logInfo("Minimization job rejected") # Try to delete the minimized model if the user doesn't want to accept it try: self.cmd.remove("minimized_view") self.cmd.delete("minimized_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Ensemble Browser"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Biological Tools"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Module Manager"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Ensemble Generation"): # Check to see if the user has accepted the design # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Cancel!"): dlg = wx.MessageDialog(self, "Your ensemble is not finished and the results will be lost if you proceed. Proceed anyway?", "Design Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unfinished ensemblegen job") dlg.Destroy() return logInfo("Ensemblegen job rejected") dlg.Destroy() self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Protein Design (Fixbb)"): # Check to see if the user has accepted the design # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your design and the results will be lost if you proceed. Proceed anyway?", "Design Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted fixbb job") dlg.Destroy() return logInfo("Fixbb job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("designed_view") self.cmd.delete("designed_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Residue/Ligand Creator"): try: self.cmd.remove("params") self.cmd.delete("params") except: pass self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Point Mutations"): try: self.cmd.remove("rotamer_view") self.cmd.delete("rotamer_view") except: pass self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Point Mutant Scan"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Loop Modeling (KIC)"): # Check to see if the user has accepted the loop model # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your loop model and the results will be lost if you proceed. Proceed anyway?", "KIC Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted KIC job") dlg.Destroy() return logInfo("KIC job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("kic_view") self.cmd.delete("kic_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Docking"): # Check to see if the user has accepted the docking model # If not, ask if they really want to proceed if (self.protPanel.buttonState != "Dock!"): dlg = wx.MessageDialog(self, "You have not accepted your docking model and the results will be lost if you proceed. Proceed anyway?", "Docking Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted docking job") dlg.Destroy() return logInfo("Docking job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("dock_view") self.cmd.delete("dock_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Structure Prediction (Comparative Modeling)"): # Check to see if the user has accepted the docking model # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your comparative modeling structure and the results will be lost if you proceed. Proceed anyway?", "Docking Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted comparative modeling job") dlg.Destroy() return logInfo("Comparative modeling job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("thread_view") self.cmd.delete("thread_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Protein Design (MSD)"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Antibody Modeling"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Molecular Surfaces"): try: self.cmd.delete("curr_surf_recp") except: pass try: self.cmd.delete("curr_surf_lig") except: pass self.cmd.hide("surface", "all") if (self.parent.Selection.showSurf): self.currentProtocol = "n/a" self.parent.Selection.displaySurfaces() self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Flexible Peptide Docking"): self.protPanel.Destroy() del self.protPanel else: # Must be a custom module self.protPanel.Destroy() del self.protPanel self.currentProtocol = selectedProtocol self.seqWin.cannotDelete = False # Restart the Rosetta daemon to clear its memory up self.parent.restartDaemon() logInfo("Changed protocol to " + selectedProtocol) try: if (selectedProtocol == "Superimposition"): self.protPanel = SuperimpositionPanel(self, self.W, self.H) elif (selectedProtocol == "Energy Minimization"): self.protPanel = MinimizationPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Ensemble Browser"): self.protPanel = EnsembleBrowserPanel(self, self.W, self.H) elif (selectedProtocol == "Biological Tools"): self.protPanel = BioToolsPanel(self, self.W, self.H) elif (selectedProtocol == "Module Manager"): self.protPanel = ModuleManagerPanel(self, self.W, self.H) elif (selectedProtocol == "Ensemble Generation"): self.protPanel = EnsembleGenPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Protein Design (Fixbb)"): self.protPanel = FixbbPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Residue/Ligand Creator"): self.protPanel = ResidueCreatorPanel(self, self.W, self.H) elif (selectedProtocol == "Point Mutations"): self.protPanel = PointMutationsPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Point Mutant Scan"): self.protPanel = PointMutantScanPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Loop Modeling (KIC)"): self.protPanel = KICPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Docking"): self.protPanel = DockingPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Structure Prediction (Comparative Modeling)"): self.protPanel = CompModelPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Protein Design (MSD)"): self.protPanel = MSDPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Antibody Modeling"): self.protPanel = AntibodyPanel(self, self.W, self.H) elif (selectedProtocol == "Molecular Surfaces"): self.protPanel = SurfacesPanel(self, self.W, self.H) self.cmd.hide("surface", "all") elif (selectedProtocol == "Flexible Peptide Docking"): self.protPanel = FlexPepDockPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif selectedProtocol == "Pathway Visualization (GeoFold)": self.protPanel = DagViewPanel(self,self.W,self.H) else: # Custom module # Custom modules are aware of PyMOL, the Sequence Window, and the SelectionPanel # They also know about the Protocols Window through the parent variable # They also will receive activation events self.protPanel = self.modules[selectedProtocol].ModulePanel(self, self.modules[selectedProtocol].__file__, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) self.protPanel.setSeqWin(self.seqWin) self.protPanel.setPyMOL(self.pymol) self.protPanel.activate() self.seqWin.setProtocolPanel(self.protPanel) except: self.protPanel = None
class ProtocolsPanel(wx.Panel): def __init__(self, parent, W, H): wx.Panel.__init__(self, parent, id=-1, pos=(0, 0), size=(350, H-265), name="ProtocolsPanel") self.W = W self.H = H self.parent = parent self.SetBackgroundColour("#333333") self.Show() if (platform.system() == "Windows"): self.label = wx.StaticText(self, -1, "Protocols", (5, 5), (340, 25), wx.ALIGN_CENTRE) self.label.SetFont(wx.Font(12, wx.DEFAULT, wx.ITALIC, wx.BOLD)) elif (platform.system() == "Darwin"): self.label = wx.StaticBitmap(self, -1, wx.Image(self.parent.scriptdir + "/images/osx/protocols/lblProtocols.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap(), pos=(5, 5), size=(340, 25)) else: self.label = wx.StaticText(self, -1, "Protocols", style=wx.ALIGN_CENTRE) self.label.SetFont(wx.Font(12, wx.DEFAULT, wx.ITALIC, wx.BOLD)) resizeTextControlForUNIX(self.label, 0, self.GetSize()[0]) self.label.SetForegroundColour("#FFFFFF") if (platform.system() == "Darwin"): self.protMenu = wx.ComboBox(self, pos=(5, 30), size=(230, 25), choices=[], style=wx.CB_READONLY) else: self.protMenu = wx.ComboBox(self, pos=(5, 30), size=(230, 25), choices=[], style=wx.CB_READONLY | wx.CB_SORT) self.protMenu.SetToolTipString("List of currently available protocols") self.default_protocols = ["Antibody Modeling", "Biological Tools", "Docking", "Energy Minimization", "Ensemble Browser", "Ensemble Generation", "Flexible Peptide Docking", "Loop Modeling (KIC)", "Module Manager", "Molecular Surfaces", "Point Mutant Scan", "Point Mutations", "Protein Design (Fixbb)", "Protein Design (MSD)", "Residue/Ligand Creator", "Structure Prediction (Comparative Modeling)", "Superimposition"] self.readModules() self.protMenu.SetSelection(self.protocols.index("Superimposition")) if (platform.system() == "Darwin"): self.GoBtn = wx.BitmapButton(self, id=-1, bitmap=wx.Image(self.parent.scriptdir + "/images/osx/protocols/GoBtn.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap(), pos=(240, 30), size=(100, 25)) else: self.GoBtn = wx.Button(self, id=-1, label="Go!", pos=(240, 30), size=(100, 25)) self.GoBtn.SetForegroundColour("#000000") self.GoBtn.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)) self.GoBtn.Bind(wx.EVT_BUTTON, self.changeProtocol) self.GoBtn.SetToolTipString("Change to the selected protocol") self.currentProtocol = "Superimposition" self.protPanel = SuperimpositionPanel(self, W, H) def readModules(self): self.protocols = self.default_protocols[:] # Let's see if there are any custom modules to import # Everything needs to be in a try/except block to prevent corrupted modules from # crashing the whole program # Ignore anything that does not import properly and write a message out to the terminal olddir = os.getcwd() goToSandbox("modules") sys.path.append(os.getcwd()) moduledirs = glob.glob("*") self.modules = {} for moduledir in moduledirs: # Ignore the template if (moduledir == "template"): continue try: module = __import__(moduledir) except: print "Failed to import " + moduledir + ", does " + moduledir + "/__init__.py exist?" continue try: # Does the panel exist? module.ModulePanel except: print "Failed to import " + moduledir + ", could not find the class \"ModulePanel\"" continue # Look for the name of the protocol in the comments of the module's script # If the name does not exist, just use the directory name modulename = moduledir fin = open(moduledir + "/__init__.py", "r") for aline in fin: if (aline.startswith("### PROTOCOL NAME:")): modulename = aline.split("### PROTOCOL NAME:")[1].strip() break fin.close() # Does this name exist already nameTaken = False for name in self.protocols: if (name.strip() == modulename.strip()): nameTaken = True break if (nameTaken): i = 2 while (True): nameTaken = False for name in self.protocols: if (name.strip() == modulename.strip() + " (" + str(i) + ")"): nameTaken = True break if (not(nameTaken)): modulename = modulename.strip() + " (" + str(i) + ")" break i += 1 # Add it into the list of protocols addedIn = False for i in range(0, len(self.protocols)): if (modulename < self.protocols[i]): addedIn = True self.protocols.insert(i, modulename) break if (not(addedIn)): self.protocols.append(modulename) self.modules[modulename] = module os.chdir(olddir) self.protMenu.Clear() self.protMenu.AppendItems(self.protocols) def changeProtocol(self, event): logInfo("Go button clicked") selectedProtocol = self.protMenu.GetStringSelection() if (selectedProtocol != self.currentProtocol and selectedProtocol != ""): # Destroy the old panel so we can free memory up and create the new protocol panel if (self.protPanel is not None): if (self.currentProtocol == "Superimposition"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Energy Minimization"): # Check to see if the user has accepted the minimization # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your minimization and the results will be lost if you proceed. Proceed anyway?", "Minimization Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted minimization") dlg.Destroy() return dlg.Destroy() logInfo("Minimization job rejected") # Try to delete the minimized model if the user doesn't want to accept it try: self.cmd.remove("minimized_view") self.cmd.delete("minimized_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Ensemble Browser"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Biological Tools"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Module Manager"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Ensemble Generation"): # Check to see if the user has accepted the design # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Cancel!"): dlg = wx.MessageDialog(self, "Your ensemble is not finished and the results will be lost if you proceed. Proceed anyway?", "Design Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unfinished ensemblegen job") dlg.Destroy() return logInfo("Ensemblegen job rejected") dlg.Destroy() self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Protein Design (Fixbb)"): # Check to see if the user has accepted the design # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your design and the results will be lost if you proceed. Proceed anyway?", "Design Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted fixbb job") dlg.Destroy() return logInfo("Fixbb job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("designed_view") self.cmd.delete("designed_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Residue/Ligand Creator"): try: self.cmd.remove("params") self.cmd.delete("params") except: pass self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Point Mutations"): try: self.cmd.remove("rotamer_view") self.cmd.delete("rotamer_view") except: pass self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Point Mutant Scan"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Loop Modeling (KIC)"): # Check to see if the user has accepted the loop model # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your loop model and the results will be lost if you proceed. Proceed anyway?", "KIC Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted KIC job") dlg.Destroy() return logInfo("KIC job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("kic_view") self.cmd.delete("kic_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Docking"): # Check to see if the user has accepted the docking model # If not, ask if they really want to proceed if (self.protPanel.buttonState != "Dock!"): dlg = wx.MessageDialog(self, "You have not accepted your docking model and the results will be lost if you proceed. Proceed anyway?", "Docking Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted docking job") dlg.Destroy() return logInfo("Docking job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("dock_view") self.cmd.delete("dock_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Structure Prediction (Comparative Modeling)"): # Check to see if the user has accepted the docking model # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your comparative modeling structure and the results will be lost if you proceed. Proceed anyway?", "Docking Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted comparative modeling job") dlg.Destroy() return logInfo("Comparative modeling job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("thread_view") self.cmd.delete("thread_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Protein Design (MSD)"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Antibody Modeling"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Molecular Surfaces"): try: self.cmd.delete("curr_surf_recp") except: pass try: self.cmd.delete("curr_surf_lig") except: pass self.cmd.hide("surface", "all") if (self.parent.Selection.showSurf): self.currentProtocol = "n/a" self.parent.Selection.displaySurfaces() self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Flexible Peptide Docking"): self.protPanel.Destroy() del self.protPanel else: # Must be a custom module self.protPanel.Destroy() del self.protPanel self.currentProtocol = selectedProtocol self.seqWin.cannotDelete = False # Restart the Rosetta daemon to clear its memory up self.parent.restartDaemon() logInfo("Changed protocol to " + selectedProtocol) try: if (selectedProtocol == "Superimposition"): self.protPanel = SuperimpositionPanel(self, self.W, self.H) elif (selectedProtocol == "Energy Minimization"): self.protPanel = MinimizationPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Ensemble Browser"): self.protPanel = EnsembleBrowserPanel(self, self.W, self.H) elif (selectedProtocol == "Biological Tools"): self.protPanel = BioToolsPanel(self, self.W, self.H) elif (selectedProtocol == "Module Manager"): self.protPanel = ModuleManagerPanel(self, self.W, self.H) elif (selectedProtocol == "Ensemble Generation"): self.protPanel = EnsembleGenPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Protein Design (Fixbb)"): self.protPanel = FixbbPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Residue/Ligand Creator"): self.protPanel = ResidueCreatorPanel(self, self.W, self.H) elif (selectedProtocol == "Point Mutations"): self.protPanel = PointMutationsPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Point Mutant Scan"): self.protPanel = PointMutantScanPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Loop Modeling (KIC)"): self.protPanel = KICPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Docking"): self.protPanel = DockingPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Structure Prediction (Comparative Modeling)"): self.protPanel = CompModelPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Protein Design (MSD)"): self.protPanel = MSDPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Antibody Modeling"): self.protPanel = AntibodyPanel(self, self.W, self.H) elif (selectedProtocol == "Molecular Surfaces"): self.protPanel = SurfacesPanel(self, self.W, self.H) self.cmd.hide("surface", "all") elif (selectedProtocol == "Flexible Peptide Docking"): self.protPanel = FlexPepDockPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) else: # Custom module # Custom modules are aware of PyMOL, the Sequence Window, and the SelectionPanel # They also know about the Protocols Window through the parent variable # They also will receive activation events self.protPanel = self.modules[selectedProtocol].ModulePanel(self, self.modules[selectedProtocol].__file__, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) self.protPanel.setSeqWin(self.seqWin) self.protPanel.setPyMOL(self.pymol) self.protPanel.activate() self.seqWin.setProtocolPanel(self.protPanel) except: self.protPanel = None def setSeqWin(self, seqWin): self.seqWin = seqWin self.protPanel.setSeqWin(seqWin) self.seqWin.setProtocolPanel(self.protPanel) def setPyMOL(self, pymol): self.pymol = pymol self.cmd = pymol.cmd self.stored = pymol.stored self.protPanel.setPyMOL(pymol) def setSelectWin(self, selectWin): self.selectWin = selectWin def activate(self): self.cmd.enable("seqsele") try: self.protPanel.activate() except: # Probably a custom module that does not have the activate function implemented print "WARNING: Could not activate the ProtocolPanel for " + self.currentProtocol
class ProtocolsPanel(wx.Panel): def __init__(self, parent, W, H): wx.Panel.__init__(self, parent, id=-1, pos=(0, 0), size=(350, H-265), name="ProtocolsPanel") self.W = W self.H = H self.parent = parent self.SetBackgroundColour("#333333") self.Show() if (platform.system() == "Windows"): self.label = wx.StaticText(self, -1, "Protocols", (5, 5), (340, 25), wx.ALIGN_CENTRE) self.label.SetFont(wx.Font(12, wx.DEFAULT, wx.ITALIC, wx.BOLD)) elif (platform.system() == "Darwin"): self.label = wx.StaticBitmap(self, -1, wx.Image(self.parent.scriptdir + "/images/osx/lblProtocols.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap(), pos=(5, 5), size=(340, 25)) else: self.label = wx.StaticText(self, -1, "Protocols", style=wx.ALIGN_CENTRE) self.label.SetFont(wx.Font(12, wx.DEFAULT, wx.ITALIC, wx.BOLD)) resizeTextControlForUNIX(self.label, 0, self.GetSize()[0]) self.label.SetForegroundColour("#FFFFFF") self.protocols = ["Antibody Modeling", "Docking", "Energy Minimization", "Ensemble Browser", "Ensemble Generation", "Flexible Peptide Docking", "Loop Modeling (KIC)", "Molecular Surfaces", "Point Mutant Scan", "Point Mutations", "Protein Design (Fixbb)", "Protein Design (MSD)", "Residue/Ligand Creator", "Structure Prediction (Comparative Modeling)", "Superimposition"] if (platform.system() == "Darwin"): self.protMenu = wx.ComboBox(self, pos=(5, 30), size=(230, 25), choices=self.protocols, style=wx.CB_READONLY) else: self.protMenu = wx.ComboBox(self, pos=(5, 30), size=(230, 25), choices=self.protocols, style=wx.CB_READONLY | wx.CB_SORT) self.protMenu.SetSelection(self.protocols.index("Superimposition")) self.protMenu.SetToolTipString("List of currently available protocols") if (platform.system() == "Darwin"): self.GoBtn = wx.BitmapButton(self, id=-1, bitmap=wx.Image(self.parent.scriptdir + "/images/osx/GoBtn.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap(), pos=(240, 30), size=(100, 25)) else: self.GoBtn = wx.Button(self, id=-1, label="Go!", pos=(240, 30), size=(100, 25)) self.GoBtn.SetForegroundColour("#000000") self.GoBtn.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)) self.GoBtn.Bind(wx.EVT_BUTTON, self.changeProtocol) self.GoBtn.SetToolTipString("Change to the selected protocol") self.currentProtocol = "Superimposition" self.protPanel = SuperimpositionPanel(self, W, H) def changeProtocol(self, event): logInfo("Go button clicked") selectedProtocol = self.protMenu.GetStringSelection() if (selectedProtocol != self.currentProtocol and selectedProtocol != ""): # Destroy the old panel so we can free memory up and create the new protocol panel if (self.currentProtocol == "Superimposition"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Energy Minimization"): # Check to see if the user has accepted the minimization # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your minimization and the results will be lost if you proceed. Proceed anyway?", "Minimization Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted minimization") dlg.Destroy() return dlg.Destroy() logInfo("Minimization job rejected") # Try to delete the minimized model if the user doesn't want to accept it try: self.cmd.remove("minimized_view") self.cmd.delete("minimized_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Ensemble Browser"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Ensemble Generation"): # Check to see if the user has accepted the design # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Cancel!"): dlg = wx.MessageDialog(self, "Your ensemble is not finished and the results will be lost if you proceed. Proceed anyway?", "Design Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unfinished ensemblegen job") dlg.Destroy() return logInfo("Ensemblegen job rejected") dlg.Destroy() self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Protein Design (Fixbb)"): # Check to see if the user has accepted the design # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your design and the results will be lost if you proceed. Proceed anyway?", "Design Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted fixbb job") dlg.Destroy() return logInfo("Fixbb job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("designed_view") self.cmd.delete("designed_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Residue/Ligand Creator"): try: self.cmd.remove("params") self.cmd.delete("params") except: pass self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Point Mutations"): try: self.cmd.remove("rotamer_view") self.cmd.delete("rotamer_view") except: pass self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Point Mutant Scan"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Loop Modeling (KIC)"): # Check to see if the user has accepted the loop model # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your loop model and the results will be lost if you proceed. Proceed anyway?", "KIC Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted KIC job") dlg.Destroy() return logInfo("KIC job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("kic_view") self.cmd.delete("kic_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Docking"): # Check to see if the user has accepted the docking model # If not, ask if they really want to proceed if (self.protPanel.buttonState != "Dock!"): dlg = wx.MessageDialog(self, "You have not accepted your docking model and the results will be lost if you proceed. Proceed anyway?", "Docking Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted docking job") dlg.Destroy() return logInfo("Docking job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("dock_view") self.cmd.delete("dock_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Structure Prediction (Comparative Modeling)"): # Check to see if the user has accepted the docking model # If not, ask if they really want to proceed if (self.protPanel.buttonState == "Finalize!"): dlg = wx.MessageDialog(self, "You have not accepted your comparative modeling structure and the results will be lost if you proceed. Proceed anyway?", "Docking Not Accepted", wx.YES_NO | wx.ICON_EXCLAMATION | wx.CENTRE) if (dlg.ShowModal() == wx.ID_NO): logInfo("Go cancelled due to unaccepted comparative modeling job") dlg.Destroy() return logInfo("Comparative modeling job rejected") dlg.Destroy() # Try to delete the design model if the user doesn't want to accept it try: self.cmd.remove("thread_view") self.cmd.delete("thread_view") except: pass self.cmd.label("all", "") self.protPanel.Destroy() elif (self.currentProtocol == "Protein Design (MSD)"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Antibody Modeling"): self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Molecular Surfaces"): try: self.cmd.delete("curr_surf_recp") except: pass try: self.cmd.delete("curr_surf_lig") except: pass self.cmd.hide("surface", "all") if (self.parent.Selection.showSurf): self.currentProtocol = "n/a" self.parent.Selection.displaySurfaces() self.protPanel.Destroy() del self.protPanel elif (self.currentProtocol == "Flexible Peptide Docking"): self.protPanel.Destroy() del self.protPanel self.currentProtocol = selectedProtocol self.seqWin.cannotDelete = False # Restart the Rosetta daemon to clear its memory up self.parent.restartDaemon() logInfo("Changed protocol to " + selectedProtocol) if (selectedProtocol == "Superimposition"): self.protPanel = SuperimpositionPanel(self, self.W, self.H) elif (selectedProtocol == "Energy Minimization"): self.protPanel = MinimizationPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Ensemble Browser"): self.protPanel = EnsembleBrowserPanel(self, self.W, self.H) elif (selectedProtocol == "Ensemble Generation"): self.protPanel = EnsembleGenPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Protein Design (Fixbb)"): self.protPanel = FixbbPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Residue/Ligand Creator"): self.protPanel = ResidueCreatorPanel(self, self.W, self.H) elif (selectedProtocol == "Point Mutations"): self.protPanel = PointMutationsPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Point Mutant Scan"): self.protPanel = PointMutantScanPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Loop Modeling (KIC)"): self.protPanel = KICPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Docking"): self.protPanel = DockingPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Structure Prediction (Comparative Modeling)"): self.protPanel = CompModelPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Protein Design (MSD)"): self.protPanel = MSDPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) elif (selectedProtocol == "Antibody Modeling"): self.protPanel = AntibodyPanel(self, self.W, self.H) elif (selectedProtocol == "Molecular Surfaces"): self.protPanel = SurfacesPanel(self, self.W, self.H) self.cmd.hide("surface", "all") elif (selectedProtocol == "Flexible Peptide Docking"): self.protPanel = FlexPepDockPanel(self, self.W, self.H) self.protPanel.setSelectWin(self.selectWin) self.protPanel.setSeqWin(self.seqWin) self.protPanel.setPyMOL(self.pymol) self.protPanel.activate() self.seqWin.setProtocolPanel(self.protPanel) def setSeqWin(self, seqWin): self.seqWin = seqWin self.protPanel.setSeqWin(seqWin) self.seqWin.setProtocolPanel(self.protPanel) def setPyMOL(self, pymol): self.pymol = pymol self.cmd = pymol.cmd self.stored = pymol.stored self.protPanel.setPyMOL(pymol) def setSelectWin(self, selectWin): self.selectWin = selectWin def activate(self): self.cmd.enable("seqsele") self.protPanel.activate()