class Hmmscan_options_window_qt(PyMod_protocol_window_qt): def build_protocol_middle_frame(self): # Add the buttons to choose the database in which to search for domain profiles. if self.protocol.father_protocol.domain_search_mode == 'remote': self.hmmer_database_rds = PyMod_radioselect_qt( label_text="Database Selection", buttons=("PFAM", "Gene3D")) for button in self.hmmer_database_rds.get_buttons(): button.clicked.connect(self.database_opt_cmd) elif self.protocol.father_protocol.domain_search_mode == 'local': # Build the list of database names. self.protocol.hmmscan_db_dict = { } # This dictionary associates a database code (displayed in the GUI) to its filename. db_list = [] for db_filename in self.protocol.hmmscan_db_list: db_name = "".join(db_filename.split(".")[0:-2]) db_list.append(db_name) self.protocol.hmmscan_db_dict[db_name] = db_filename # Packs the PHMMER database selection widget. self.hmmer_database_rds = PyMod_radioselect_qt( label_text="Database Selection", buttons=db_list) self.middle_formlayout.add_widget_to_align(self.hmmer_database_rds) # E-value selection. self.e_value_threshold_enf = PyMod_entryfield_qt( label_text="E-value Threshold", value="1.0", validate={ 'validator': 'real', 'min': 0.0, 'max': 1000.0 }) self.middle_formlayout.add_widget_to_align(self.e_value_threshold_enf) # Note about the Gene3D and Evalues. if self.protocol.father_protocol.domain_search_mode == 'remote': info_note = ('Note: The Gene3D online database will\n' 'ignore custom cut-off parameters since\n' 'they use a post processing step that\n' 'involves preset thresholds.') self.notelabel = QtWidgets.QLabel(info_note) self.middle_formlayout.addRow(self.notelabel) self.middle_formlayout.set_input_widgets_width(140) def database_opt_cmd(self): if self.hmmer_database_rds.getvalue() == 'Gene3D': self.e_value_threshold_enf.entry.setStyleSheet( inactive_entry_style) self.e_value_threshold_enf.entry.setEnabled(False) else: self.e_value_threshold_enf.entry.setStyleSheet(active_entry_style) self.e_value_threshold_enf.entry.setEnabled(True)
class Contact_map_options_window_qt(PyMod_protocol_window_qt): """ Window with options for the contact map analysis. """ feature_types_list = [ "Contacts", "Distances", "Distance Difference", "Distance Mean", "Distance Std" ] interaction_centers_list = ["Carbon alpha", "Carbon beta"] default_contact_threshold = 8.0 default_distance_threshold = 18.0 default_distance_diff_threshold = 3.5 default_distance_mean_threshold = default_distance_threshold default_distance_std_threshold = default_distance_diff_threshold def build_protocol_middle_frame(self): # Feature type selection. if len(self.protocol.target_sequences) == 1: # Contact and distance. sel_option_idx = 0 all_options_idx = (0, 1) elif len(self.protocol.target_sequences ) == 2: # Distance difference, mean and std. sel_option_idx = 2 all_options_idx = (2, 3, 4) elif len(self.protocol.target_sequences) > 2: # Distance mean and std. sel_option_idx = 3 all_options_idx = (3, 4) features_buttons = [ self.feature_types_list[i] for i in all_options_idx ] self.feature_type_rds = PyMod_radioselect_qt(label_text="Feature Type", buttons=features_buttons) for button, option_idx in zip(self.feature_type_rds.get_buttons(), all_options_idx): button.clicked.connect( lambda e=None, o=option_idx: self.feature_type_state(o)) self.feature_type_rds.setvalue(self.feature_types_list[sel_option_idx]) self.middle_formlayout.add_widget_to_align(self.feature_type_rds) # Distance threshold for contacts. if len(self.protocol.target_sequences) == 1: threshold = self.default_contact_threshold elif len(self.protocol.target_sequences) == 2: threshold = self.default_distance_diff_threshold else: threshold = self.default_distance_threshold self.dist_threshold_enf = PyMod_entryfield_qt( label_text="Contact Threshold (%s)" % ("\u212B"), value=str(threshold), validate={ 'validator': 'real', 'min': 1.0, 'max': 100.0 }) self.middle_formlayout.add_widget_to_align(self.dist_threshold_enf) # Interaction center selection. self.interaction_center_rds = PyMod_radioselect_qt( label_text="Interaction Center", buttons=self.interaction_centers_list) self.interaction_center_rds.setvalue(self.interaction_centers_list[0]) self.middle_formlayout.add_widget_to_align(self.interaction_center_rds) # Reference structure combobox. if len(self.protocol.target_sequences) > 1: structures_list = [ element.my_header for element in self.protocol.target_sequences ] self.reference_combobox = PyMod_combobox_qt( label_text="Reference Structure", items=structures_list) self.reference_combobox.combobox.setCurrentIndex(0) self.middle_formlayout.add_widget_to_align(self.reference_combobox) self.middle_formlayout.set_input_widgets_width("auto", padding=10) def feature_type_state(self, state): """ Launched when the user changes the "Feature Type" in the Options window. """ # Change the status of the Tkinter checkbutton. if state == 0: self.feature_type_rds.setvalue(self.feature_types_list[0]) self.dist_threshold_enf.setvalue( str(self.default_contact_threshold)) elif state == 1: self.feature_type_rds.setvalue(self.feature_types_list[1]) self.dist_threshold_enf.setvalue( str(self.default_distance_threshold)) elif state == 2: self.feature_type_rds.setvalue(self.feature_types_list[2]) self.dist_threshold_enf.setvalue( str(self.default_distance_diff_threshold)) elif state == 3: self.feature_type_rds.setvalue(self.feature_types_list[3]) self.dist_threshold_enf.setvalue( str(self.default_distance_mean_threshold)) elif state == 4: self.feature_type_rds.setvalue(self.feature_types_list[4]) self.dist_threshold_enf.setvalue( str(self.default_distance_std_threshold)) else: KeyError(state) def get_feature_type(self): feature_type = self.feature_type_rds.getvalue() if feature_type == self.feature_types_list[0]: return "contact", feature_type elif feature_type == self.feature_types_list[1]: return "distance", feature_type elif feature_type == self.feature_types_list[2]: return "distances_difference", feature_type elif feature_type == self.feature_types_list[3]: return "distances_mean", feature_type elif feature_type == self.feature_types_list[4]: return "distances_std", feature_type else: raise KeyError(feature_type) def get_interaction_center(self): int_center_string = self.interaction_center_rds.getvalue() if int_center_string == self.interaction_centers_list[0]: return "ca" elif int_center_string == self.interaction_centers_list[1]: return "cb" else: raise KeyError(int_center_string) def get_reference_id(self): try: return self.reference_combobox.get_index() except: print("- WARNING: could not obtain the reference structure id.") return 0