def new_project(self): if self.AMDock.state: msg = QtGui.QMessageBox.warning( self.AMDock, 'Warning', 'There are processes in the background. Do you want to close them?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if msg == QtGui.QMessageBox.No: return elif msg == QtGui.QMessageBox.Yes: try: self.pymol.force_finished() except: pass if self.AMDock.program_body.reset_function(): Variables.__init__(self.AMDock) self.prot_label.setText('Target: ') self.prot_labelB.setText('Off-Target: ') # try: # self.AMDock.output2file.conclude() # except: # pass try: os.chdir(self.AMDock.loc_project) except: pass self.clear_result_tab() self.AMDock.log_widget.textedit.append(80 * '#') self.AMDock.log_widget.textedit.append( Ft('NEW PROJECT...\n\n').resetting())
def amdock_load(self): elements = { 0: 'Working Directory', 1: 'Input Directory', 2: 'Results Directory', 3: 'PDBQT of Target Protein', 4: 'All Poses File of Target Result', 5: 'Best Pose File of Target Result', 6: 'PDBQT of Off-Target Protein', 7: 'All Poses File of Off-Target Result', 8: 'Best Pose File of Off-Target Result' } elements_score = { 0: 'Working Directory', 1: 'Input Directory', 2: 'Results Directory', 3: 'PDBQT of Target Protein', 4: 'PDBQT of Ligand' } self.AMDock.statusbar.showMessage(" Loading .amdock file...", 2000) # if self. self.data = self.AMDock.loader.load_amdock_file() if self.data: if self.AMDock.project.mode == 1: self.table1 = self.data[0] self.complete = self.data[1] self.table2 = self.data[2] else: self.table1 = self.data[0] self.complete = self.data[1] errlist = '' errlist2 = [] if self.AMDock.project.mode != 2: for index in range(0, len(self.complete)): if self.complete[index] == '1': errlist += '\n-%s' % elements[index] if len(errlist) != 0: QtGui.QMessageBox.critical( self, 'Error', 'Some files defined in .amdock file were not found or ' 'they are inaccessible.\nMissing elements:%s' % errlist) self.import_text.clear() Variables.__init__(self.AMDock) else: os.chdir(self.AMDock.project.results) self.prot_label.setText('Target: %s' % self.AMDock.target.name) self.prot_label_sel.setText('%s' % self.AMDock.target.name) self.result_table.setRowCount(len(self.table1)) self.sele1.setRange(1, len(self.table1)) f = 0 for x in self.table1: c = 0 for item in x: item = str(item) self.result_table.setItem( f, c, QtGui.QTableWidgetItem(item)) self.result_table.item( f, c).setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) if c == 4: item_v = float(item) if item_v <= -0.3: self.result_table.item( f, c).setBackgroundColor( QtGui.QColor(0, 255, 128, 200)) c += 1 f += 1 self.value1 = float(self.result_table.item(0, 1).text()) self.result_table.item(0, 1).setBackgroundColor( QtGui.QColor('darkGray')) selection_model = self.result_table.selectionModel() selection_model.select( self.result_table.model().index(0, 0), QtGui.QItemSelectionModel.ClearAndSelect) if self.AMDock.project.bsd_mode_target == 0: self.result_table.setHorizontalHeaderLabels( QtCore.QString( "Binding Site;Affinity(kcal/mol);Estimated Ki;Ki Units;Ligand Efficiency" ).split(";")) else: self.result_table.setHorizontalHeaderLabels( QtCore.QString( "Pose;Affinity(kcal/mol);Estimated Ki;Ki Units;Ligand Efficiency" ).split(";")) if self.AMDock.project.mode == 1: self.prot_labelB.setText('Off-Target: %s' % self.AMDock.offtarget.name) self.prot_label_selB.setText( '%s' % self.AMDock.offtarget.name) self.result_tableB.show() self.selectivity_value_text.show() self.selectivity.show() self.sele1.show() self.sele2.show() self.prot_label_sel.show() self.prot_label_selB.show() self.div.show() self.equal.show() self.prot_labelB.show() self.result_tableB.setRowCount(len(self.table2)) self.sele2.setRange(1, len(self.table2)) f = 0 for x in self.table2: c = 0 for item in x: item = str(item) self.result_tableB.setItem( f, c, QtGui.QTableWidgetItem(item)) self.result_tableB.item(f, c).setTextAlignment( QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) if c == 4: item_v = float(item) if item_v <= -0.3: self.result_tableB.item( f, c).setBackgroundColor( QtGui.QColor(0, 255, 128, 200)) c += 1 f += 1 self.value2 = float( self.result_tableB.item(0, 1).text()) self.result_tableB.item(0, 1).setBackgroundColor( QtGui.QColor('darkGray')) selection_model = self.result_tableB.selectionModel() selection_model.select( self.result_tableB.model().index(0, 0), QtGui.QItemSelectionModel.ClearAndSelect) if self.AMDock.project.bsd_mode_offtarget == 0: self.result_tableB.setHorizontalHeaderLabels( QtCore.QString( "Binding Site;Affinity(kcal/mol);Estimated Ki;Ki Units;Ligand Efficiency" ).split(";")) else: self.result_tableB.setHorizontalHeaderLabels( QtCore.QString( "Pose;Affinity(kcal/mol);Estimated Ki;Ki Units;Ligand Efficiency" ).split(";")) self.selectivity_value = math.exp( (self.value2 - self.value1) / (0.001987207 * 298)) self.selectivity_value_text.setText( '%.01f' % self.selectivity_value) else: for index in range(0, len(self.complete)): if self.complete[index] == '1': errlist += '\n-%s' % elements_score[index] errlist2.append(index) if len(errlist) != 0: QtGui.QMessageBox.critical( self, 'Error', 'Some files defined in .amdock file were not found or ' 'they are inaccessible.\nMissing elements:%s' % errlist) self.import_text.clear() Variables.__init__(self.AMDock) else: os.chdir(self.AMDock.project.results) self.prot_label.setText('Target: %s' % self.AMDock.target.name) self.result_table.setRowCount(len(self.table1)) self.sele1.setRange(1, len(self.table1)) f = 0 for x in self.table1: c = 0 for item in x: item = str(item) self.result_table.setItem( f, c, QtGui.QTableWidgetItem(item)) self.result_table.item( f, c).setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) if c == 4: item_v = float(item) if item_v <= -0.3: self.result_table.item( f, c).setBackgroundColor( QtGui.QColor(0, 255, 128, 200)) c += 1 f += 1 self.result_table.item(0, 1).setBackgroundColor( QtGui.QColor('darkGray')) selection_model = self.result_table.selectionModel() selection_model.select( self.result_table.model().index(0, 0), QtGui.QItemSelectionModel.ClearAndSelect) # open log if exit if os.path.exists( os.path.join(self.AMDock.project.WDIR, self.AMDock.project.name + '.log')): self.AMDock.project.log = os.path.join( self.AMDock.project.WDIR, self.AMDock.project.name + '.log') if not self.AMDock.project.log: return if os.path.exists(self.AMDock.project.log): msg = QtGui.QMessageBox.information( self.AMDock, 'Information', 'This project has a log file.' ' Do you want to open it?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if msg == QtGui.QMessageBox.Yes: self.AMDock.log_widget.textedit.append( Ft('Opening AMDock Log File...').process()) ofile = open(self.AMDock.project.log) for line in ofile: line = line.strip('\n') self.AMDock.log_widget.textedit.append(line) ofile.close() self.AMDock.log_widget.textedit.append( Ft('Opening AMDock Log File... Done.').process())
def __init__(self): super(AMDock, self).__init__() QtGui.QMainWindow.__init__(self) Variables.__init__(self) # redirect stderr to log window sys.stderr = EmittingStream(textWritten=self.normalOutputWritten) self.checker = Checker(self) self.output2file = OutputFile(self) self.loader = Loader(self) self.project = PROJECT() self.target = BASE() self.offtarget = BASE() self.ligand = BASE() self.log_thread = QtCore.QThreadPool() self.numeric_version = [1, 5, 2] self.version = "{}.{}.{} For Windows and Linux".format(*self.numeric_version) self.spacing_autoligand = 1.0 self.spacing_autodock = 0.375 self.pH = 7.40 self.para_file = None self.state = 0 # 0 not running, 2 running self.section = -1 # -1 only PD selected, 0 project, 1 input files, 2 bsd, 3 docking with open(self.style_file) as f: self.setStyleSheet(f.read()) self.icon = QtGui.QIcon() self.icon.addPixmap(QtGui.QPixmap(self.home_icon), QtGui.QIcon.Active, QtGui.QIcon.Off) self.icon.addPixmap(QtGui.QPixmap(self.home_icon), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.icon.addPixmap(QtGui.QPixmap(self.home_icon), QtGui.QIcon.Selected, QtGui.QIcon.Off) self.icon.addPixmap(QtGui.QPixmap(self.home_icon), QtGui.QIcon.Disabled, QtGui.QIcon.Off) self.icon.addPixmap(QtGui.QPixmap(self.home_icon_white), QtGui.QIcon.Selected, QtGui.QIcon.On) self.icon.addPixmap(QtGui.QPixmap(self.home_icon_white), QtGui.QIcon.Active, QtGui.QIcon.On) ##--TABS self.main_window = QtGui.QTabWidget(self) self.setCentralWidget(self.main_window) ##--Tabs for Docking Options self.lobby = Lobby(self) self.main_window.addTab(self.lobby, self.icon, "") self.program_body = Program_body(self) self.main_window.addTab(self.program_body, "Docking Options") self.main_window.setTabEnabled(1, False) ##Tabs for result analysis self.result_tab = Results(self) self.main_window.addTab(self.result_tab, "Results Analysis") self.main_window.setTabEnabled(2, False) # **Configurations_Tab self.configuration_tab = Configuration_tab(self) self.main_window.addTab(self.configuration_tab, "Configuration") # ** Help_Tab self.help_tab = Help(self) self.main_window.addTab(self.help_tab, "Info") # ** log dockwidget self.log_widget = LogWindow(self) self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.log_widget) if self.configuration_tab.log_view.isChecked(): self.log_widget.show() else: self.log_widget.hide() self.statusbar = QtGui.QStatusBar(self) self.statusbar.setObjectName("statusbar") self.setStatusBar(self.statusbar) QtCore.QMetaObject.connectSlotsByName(self) self.version_label = QtGui.QLabel("Version: %s" % self.version) self.statusbar.addPermanentWidget(self.version_label)