def create_dialog(): dialog = QtWidgets.QDialog() dialog.setWindowTitle('Lighting Settings') sliders = [ "Diffuse Reflection", ('ambient', 0, 1, None), ('reflect', -1, 1, None), "Direct Light from Front", ('direct (+reflect)', -1, 1, None), # diffuse, coupled with "reflect" ('spec_direct', 0, 1, None), ('spec_direct_power', 0, 100, 1), "Free placeable directed Lights", ('light_count', 1, 8, 1), ('edit_light', 1, 7, 1), "Specular Reflection", ('spec_count', -1, 8, 1), # ('spec_power', -1, 200, 1), # deprecated since v1.5 ('shininess', 0, 100, None), # same as spec_power ('spec_reflect', -0.01, 1, None), ('specular', 0, 1, None), ('specular_intensity (=specular)', 0, 1, None), # same as specular "Ambient Occlusion (Surface only)", ('ambient_occlusion_mode', 0, 2, 1), ('ambient_occlusion_scale', 1.0, 50., None), ('ambient_occlusion_smooth', 1, 20, 1), "Ray trace only", ('power', 1, 10, None), ('reflect_power', 1, 10, None), ] layout = QtWidgets.QVBoxLayout(dialog) button_layout = QtWidgets.QHBoxLayout() layout.addLayout(button_layout) layout.setContentsMargins(5, 0, 5, 0) button_layout.addWidget( QtWidgets.QLabel("<font color=red>Presets:</font>")) presets = [ ("Default", preset_default), ("Metal", preset_metal), ("Plastic", preset_plastic), ("Rubber", preset_rubber), ("X-Ray", preset_xray), ] for name, fun in presets: btn = QtWidgets.QPushButton(name, dialog) btn.pressed.connect(fun) btn.setAutoDefault(False) button_layout.addWidget(btn) form_layout = QtWidgets.QFormLayout() form_layout.setContentsMargins(0, 0, 0, 0) form_layout.setVerticalSpacing(0) form_layout.setLabelAlignment(Qt.AlignLeft) layout.addLayout(form_layout) for i, item in enumerate(sliders, 1): if isinstance(item, str): label = QtWidgets.QLabel("<font color=blue>" + item + "</font>") form_layout.addRow(label) continue name, min, max, res = item if res is None: res = 0.01 if (max - min < 100) else 0.1 line_edit = QtWidgets.QLineEdit(dialog) slider = SettingSlider(dialog, name.split()[0], min, max, res, line_edit) h_layout = QtWidgets.QHBoxLayout() h_layout.addWidget(slider, 3) h_layout.addWidget(line_edit, 1) form_layout.addRow(name, h_layout) return dialog
def initialize_plot(self, pymod, target_element, residues_tags, plot_title, aa_list): self.pymod = pymod self.target_element = target_element self.residues_tags = residues_tags self.plot_title = plot_title self.setWindowTitle("%s Ramachandran Plot" % self.target_element.my_header) self.aa_list = aa_list # Frame of the window containing a row for some control buttons, a row for # the plot and a row for a messagebar. self.plot_frame = QtWidgets.QWidget() self.plot_frame_layout = QtWidgets.QGridLayout() self.plot_frame.setLayout(self.plot_frame_layout) self.setCentralWidget(self.plot_frame) # Control frame. self.controls_frame = QtWidgets.QWidget() self.controls_frame_layout = QtWidgets.QGridLayout() self.controls_frame.setLayout(self.controls_frame_layout) self.plot_frame_layout.addWidget(self.controls_frame, 0, 0) self.scale_factor = 0 self.scale_down_button = QtWidgets.QPushButton("Zoom out") try: self.scale_down_button.setIcon(QtGui.QIcon.fromTheme("go-down")) except: pass self.scale_down_button.clicked.connect( lambda a=None: self.scale_plot_down()) self.controls_frame_layout.addWidget(self.scale_down_button, 0, 0) self.scale_up_button = QtWidgets.QPushButton("Zoom in") try: self.scale_up_button.setIcon(QtGui.QIcon.fromTheme("go-up")) except: pass self.scale_up_button.clicked.connect( lambda a=None: self.scale_plot_up()) self.controls_frame_layout.addWidget(self.scale_up_button, 0, 1) self.controls_frame_layout.setAlignment(QtCore.Qt.AlignLeft) # Frame containing the plot (with a scrollbar). self.canvas_plot_frame = QtWidgets.QWidget() self.canvas_plot_frame.setStyleSheet("background-color: white") self.canvas_plot_frame_layout = QtWidgets.QGridLayout() self.canvas_plot_frame.setLayout(self.canvas_plot_frame_layout) self.canvas_plot_scrollarea = QtWidgets.QScrollArea() self.canvas_plot_scrollarea.setWidgetResizable(True) self.canvas_plot_scrollarea.setWidget(self.canvas_plot_frame) self.plot_frame_layout.addWidget(self.canvas_plot_scrollarea, 1, 0) self.default_pen = QtGui.QPen(QtGui.QColor(0, 0, 0, 255), 1) self.default_brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 230)) self.highlight_brush = QtGui.QBrush(QtGui.QColor(255, 0, 255)) self.highlight_region_brush = QtGui.QBrush(QtGui.QColor(0, 255, 255)) # Builds the scene where to draw the Ramachandran plot. self.canvas_plot_scene = QtWidgets.QGraphicsScene() # Builds the graphics view containing the scene above. self.canvas_plot_view = QtWidgets.QGraphicsView(self.canvas_plot_scene) self.canvas_plot_frame_layout.addWidget(self.canvas_plot_view) # A bottom frame fo the window, containing some buttons to interact with the graph. self.message_frame = QtWidgets.QFrame() self.message_frame_layout = QtWidgets.QFormLayout() self.message_frame.setLayout(self.message_frame_layout) self.plot_frame_layout.addWidget(self.message_frame, 1, 1) # Label to show which residue/position pair is currently being hovered by the mouse pointer. self.view_label_prefix = "Showing: " self.default_message = "Hover dots to color residues of the same type" # Hover over title. self.message_label = QtWidgets.QLabel(self.default_message) self.message_label.setStyleSheet(small_font_style) self.message_frame_layout.addRow(self.message_label) # Actually draws the plot. self.draw_plot() # Shows some data about the type of residues and their dihedral angles. self.regions_labels_dict = {} tot_regular_res = float(self.residues_count["T"]) label_params = [ ("F", "Residues in the most favoured regions", "residues in most favoured regions", True, True), ("A", "Residues in additional allowed regions", "residues in additional allowed regions", True, True), ("G", "Residues in generously allowed regions", "residues in generously allowed regions", True, True), ("D", "Residues in disallowed regions", "residues in disallowed regions", True, True), ("T", "Non-gly and non-pro residues (circles)", "non-glycine and non-proline residues", True, True), ("end_res", "End-residues", "end residues", False, False), ("gly", "Gly residues (triangles)", "glycine residues", True, False), ("pro", "Pro residues (squares)", "proline residues", True, False), ("total", "Total number of residues", "all residues", True, False) ] for region, label, message, active, use_ratio in label_params: region_label = Ramachandran_plot_info_labels( label, message, region, active, self) region_label.setStyleSheet(small_font_style) if use_ratio: text = "%s (%s%%)" % (self.residues_count[region], round( self.residues_count[region] / tot_regular_res * 100, 1)) else: text = str(self.residues_count[region]) region_label_count = QtWidgets.QLabel(text) region_label_count.setStyleSheet(small_font_style) self.message_frame_layout.addRow(region_label, region_label_count) self.regions_labels_dict[region] = { "info": region_label, "data": region_label_count }
def __init__(self, parent, protocol): super(Similarity_searches_results_window_qt, self).__init__(parent) self.protocol = protocol ######################### # Configure the window. # ######################### self.setWindowTitle(self._get_window_title()) # Sets the central widget. self.central_widget = QtWidgets.QWidget() self.setCentralWidget(self.central_widget) # The window has a main vbox layout. self.main_vbox = QtWidgets.QVBoxLayout() ################ # Upper frame. # ################ title_text = self._get_upper_frame_title() self.upper_frame_title = QtWidgets.QLabel(title_text) self.main_vbox.addWidget(self.upper_frame_title) ################# # Middle frame. # ################# # Scroll area which contains the widgets, set as the centralWidget. self.middle_scroll = QtWidgets.QScrollArea() self.main_vbox.addWidget(self.middle_scroll) # Widget that contains the collection of Vertical Box. self.middle_widget = QtWidgets.QWidget() # Scroll area properties. self.middle_scroll.setWidgetResizable(True) self.middle_scroll.setWidget(self.middle_widget) # QFormLayout in the middle frame. self.middle_formlayout = QtWidgets.QFormLayout() self.middle_widget.setLayout(self.middle_formlayout) #----------------- # Buttons frame. - #----------------- # Set the frame and its layout. self.buttons_frame = QtWidgets.QFrame() self.middle_formlayout.addRow(self.buttons_frame) self.buttons_hbox = QtWidgets.QHBoxLayout() self.buttons_frame.setLayout(self.buttons_hbox) # Build the control buttons. self.blast_select_all_button = QtWidgets.QPushButton(text="Select All") self.blast_select_all_button.clicked.connect(self.blast_select_all) self.blast_select_none_button = QtWidgets.QPushButton(text="Select None") self.blast_select_none_button.clicked.connect(self.blast_select_none) self.blast_select_n_button = QtWidgets.QPushButton(text="Select Top:") self.blast_select_n_button.clicked.connect(self.blast_select_n) for button in [self.blast_select_all_button, self.blast_select_none_button, self.blast_select_n_button]: self.buttons_hbox.addWidget(button) # Build the line-edit for selecting only top entries. self.blast_select_n_enf = PyMod_entryfield_qt(label_text="", value="10", validate={'validator': 'integer', 'min': 1, 'max': 5000}) self.blast_select_n_enf.entry.setFixedWidth(70) self.buttons_hbox.addWidget(self.blast_select_n_enf.entry) # Align to the left all these widgets. self.buttons_hbox.setAlignment(QtCore.Qt.AlignLeft) for button in [self.blast_select_all_button, self.blast_select_none_button, self.blast_select_n_button]: button.setFixedWidth(button.sizeHint().width()+30) #----------------- # Results frame. - #----------------- # Set the frame and its layout. self.results_frame = QtWidgets.QFrame() self.middle_formlayout.addRow(self.results_frame) self.results_grid = QtWidgets.QGridLayout() self.results_frame.setLayout(self.results_grid) # Calls a method which actually displays the similarity searches results. self.display_blast_hits() # Align the gridded widgets to the left. self.results_grid.setAlignment(QtCore.Qt.AlignLeft) self.results_grid.setHorizontalSpacing(30) ################# # Bottom frame. # ################# self.main_button = QtWidgets.QPushButton("Submit") self.main_button.clicked.connect(lambda a=None: self.protocol.blast_results_state()) self.main_vbox.addWidget(self.main_button) self.main_button.setFixedWidth(self.main_button.sizeHint().width()) # Sets the main vertical layout. self.central_widget.setLayout(self.main_vbox) self.main_vbox.setAlignment(self.main_button, QtCore.Qt.AlignCenter)
def build_strategy_specific_modes_frames(self): """ Build components of the GUI to show the alignment options. """ #------------------------------------------ # Perform a profile to profile alignment. - #------------------------------------------ if self.protocol.can_perform_ptp_alignment: # profile_profile_rb_text = "Profile to profile: perform a profile to profile alignment." profile_profile_rb_text = "Profile to profile" self.profile_to_profile_radiobutton = QtWidgets.QRadioButton(profile_profile_rb_text) self.profile_to_profile_radiobutton.clicked.connect(self.click_on_profile_to_profile_radio) self.profile_to_profile_radiobutton._value = "profile-to-profile" self.profile_to_profile_radiobutton.setChecked(True) self.alignment_mode_vbox.addWidget(self.profile_to_profile_radiobutton) self.alignment_mode_button_group.addButton(self.profile_to_profile_radiobutton) #----------------------------------------- # Perform sequence to profile alignment. - #----------------------------------------- sequence_profile_rb_text = None build_target_profile_frame = False # Shows a different label for the checkbutton if there is one or more clusters involved. if len(self.protocol.selected_clusters_list) > 1: # sequence_profile_rb_text = "Sequence to profile: align to a target profile the rest of the selected sequences." sequence_profile_rb_text = "Sequence to profile" build_target_profile_frame = True elif len(self.protocol.selected_clusters_list) == 1: profile_cluster_name = self.protocol.involved_clusters_list[0].my_header # sequence_profile_rb_text = "Sequence to profile: align the selected sequence to the target profile '%s'." % (profile_cluster_name) sequence_profile_rb_text = "Sequence to profile" # Radiobutton. self.sequence_to_profile_radiobutton = QtWidgets.QRadioButton(sequence_profile_rb_text) self.sequence_to_profile_radiobutton.clicked.connect(self.click_on_sequence_to_profile_radio) self.sequence_to_profile_radiobutton._value = "sequence-to-profile" if not self.protocol.can_perform_ptp_alignment: self.sequence_to_profile_radiobutton.setChecked(True) self.alignment_mode_vbox.addWidget(self.sequence_to_profile_radiobutton) self.alignment_mode_button_group.addButton(self.sequence_to_profile_radiobutton) # If there is more than one selected cluster, then build a frame to let the user choose # which is going to be the target profile. if build_target_profile_frame: # Frame with the options to choose which is going to be the target profile. self.target_profile_frame = QtWidgets.QFormLayout() self.alignment_mode_vbox.addLayout(self.target_profile_frame) # Label. self.target_alignment_label = QtWidgets.QLabel("Target profile:") self.target_alignment_label.setStyleSheet("margin-left: 35px") # Combobox. self.target_alignment_combobox = QtWidgets.QComboBox() for cluster in self.protocol.involved_clusters_list: self.target_alignment_combobox.addItem(cluster.my_header) self.target_alignment_combobox.setEditable(False) self.target_profile_frame.addRow(self.target_alignment_label, self.target_alignment_combobox) self.target_alignment_combobox.setFixedWidth(self.target_alignment_combobox.sizeHint().width())
def __init__(self, parent, protocol): super(Hmmscan_results_window_qt, self).__init__(parent) self.protocol = protocol self.query_len = len( self.protocol.query_element.my_sequence.replace('-', '')) ######################### # Configure the window. # ######################### self.setWindowTitle("HMMSCAN Results") # Sets the central widget. self.central_widget = QtWidgets.QWidget() self.setCentralWidget(self.central_widget) # The window has a main vbox layout. self.main_vbox = QtWidgets.QVBoxLayout() # Parameters used to draw the 'QGraphicsView' widgets for showing domains. self.preferred_size_policy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) self.view_bg_color = "transparent" self.full_seq_pen = QtGui.QPen(QtGui.QColor(0, 0, 0, 0), 2) self.full_seq_color = "#7f7f7f" qcolor = QtGui.QColor(0, 0, 0) qcolor.setNamedColor(self.full_seq_color) self.full_seq_brush = QtGui.QBrush(qcolor) self.font_qcolor = QtGui.QColor(220, 220, 220, 255) self.font_size = 7 ################ # Upper frame. # ################ self.upper_frame = QtWidgets.QFrame() self.upper_frame_layout = QtWidgets.QGridLayout() self.upper_frame.setLayout(self.upper_frame_layout) self.main_vbox.addWidget(self.upper_frame) if 'query_descr' in self.protocol.parsed_res[ 0] and self.protocol.parsed_res[0]['query_descr']: labelseq = self.protocol.query_element.my_header # + '\n' + querydescr else: try: if len(self.protocol.query_element.description) > 79: labelseq = self.protocol.query_element.description[:78] + '...' else: labelseq = self.protocol.query_element.description except TypeError: labelseq = self.protocol.query_element.my_header self.upper_frame_title = QtWidgets.QLabel( "HMMSCAN search results for " + labelseq) self.upper_frame_layout.addWidget(self.upper_frame_title) #------------------------- # Domain graphics frame. - #------------------------- # Builds the scene where to draw the domain representations. self.canvas_plot_scene = QtWidgets.QGraphicsScene() self.canvas_plot_view = QtWidgets.QGraphicsView(self.canvas_plot_scene) self.canvas_plot_view.setFixedHeight(120) self.canvas_plot_view.setSizePolicy(self.preferred_size_policy) self.canvas_plot_view.setStyleSheet("background: %s" % self.view_bg_color) self.upper_frame_layout.addWidget(self.canvas_plot_view) # Draw a rectangle with the full sequence. self.x_init = 10 y_init = 95 # 95 self.domain_y_init = y_init - 7 self.full_seq_rect_w = 800 full_seq_rect_h = 10 self.canvas_plot_scene.addRect(self.x_init, y_init, self.full_seq_rect_w, full_seq_rect_h, self.full_seq_pen, self.full_seq_brush) # Draw the labels for the N- and C-terminal residues. text_offset_y = 15 text_offset_x = 10 text_n = self.canvas_plot_scene.addText("1") text_n.setPos(self.x_init - text_offset_x, y_init + text_offset_y) text_n.setDefaultTextColor(self.font_qcolor) text_n.setFont(QtGui.QFont(text_n.font().family(), self.font_size)) c_label = str(self.query_len) text_c = self.canvas_plot_scene.addText(c_label) text_offset_x_add = 5 if len(c_label) > 2: text_offset_x_add = 10 text_c.setPos( self.x_init + self.full_seq_rect_w - text_offset_x - text_offset_x_add, y_init + text_offset_y) text_c.setDefaultTextColor(self.font_qcolor) text_c.setFont(QtGui.QFont(text_c.font().family(), self.font_size)) ################# # Middle frame. # ################# # Scroll area which contains the widgets, set as the centralWidget. self.middle_scroll = QtWidgets.QScrollArea() self.main_vbox.addWidget(self.middle_scroll) # Widget that contains the collection of Vertical Box. self.middle_widget = QtWidgets.QWidget() # Scroll area properties. self.middle_scroll.setWidgetResizable(True) self.middle_scroll.setWidget(self.middle_widget) # QFormLayout in the middle frame. self.middle_formlayout = QtWidgets.QFormLayout() self.middle_widget.setLayout(self.middle_formlayout) #----------------- # Results frame. - #----------------- # Set the frame and its layout. self.results_frame = QtWidgets.QFrame() self.middle_formlayout.addRow(self.results_frame) self.results_grid = QtWidgets.QGridLayout() self.results_frame.setLayout(self.results_grid) # Calls a method which actually displays the similarity searches results. self.display_hmmscan_hits() # Align the gridded widgets to the left. self.results_grid.setAlignment(QtCore.Qt.AlignLeft) self.results_grid.setHorizontalSpacing(30) ################# # Bottom frame. # ################# self.main_button = QtWidgets.QPushButton("Submit") self.main_button.clicked.connect( lambda a=None: self.protocol.hmmer_results_state()) self.main_vbox.addWidget(self.main_button) self.main_button.setFixedWidth(self.main_button.sizeHint().width()) # Sets the main vertical layout. self.central_widget.setLayout(self.main_vbox) self.main_vbox.setAlignment(self.main_button, QtCore.Qt.AlignCenter)
def initUI(self): #---------------------------- # Left frame (for headers). - #---------------------------- self.sequence_ID_groupbox = QtWidgets.QGroupBox('SEQUENCE ID') # self.sequence_ID_groupbox.setStyleSheet("QLabel {font: 14pt COURIER NEW font-weight: bold} ") id_frame_stylesheet = "QLabel {font: %spt %s; font-weight: %s; color: white}" % ( self.main_window.font_size, self.main_window.font, self.main_window.font_weight) self.sequence_ID_groupbox.setStyleSheet(id_frame_stylesheet) self.id_form_layout = QtWidgets.QFormLayout() #self.left_scroll self.left_scroll = QtWidgets.QScrollArea() self.left_scroll.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOn) self.left_scroll.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAsNeeded) self.left_scroll.resize(200, 400) self.left_scroll.setWidget( self.sequence_ID_groupbox ) # sequence_ID_groupbox dentro left_scroll area self.left_scroll.setWidgetResizable(True) #self.left_frame self.left_frame = QtWidgets.QFrame(self) self.left_frame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.left_frame.resize(200, 400) self.left_frame.setStyleSheet(self.style) self.left_frame.setFrameShadow(QtWidgets.QFrame.Sunken) #self.left_frame_layout self.left_frame_layout = QtWidgets.QVBoxLayout(self) self.left_frame_layout.addWidget(self.left_scroll) self.left_frame.setLayout( self.left_frame_layout) # left_frame_layout dentro left_frame #------------------------------- # Right frame (for sequences). - #------------------------------- # This groupbox self.sequence_SEQ_groupbox = QtWidgets.QGroupBox('SEQUENCES') seq_frame_stylesheet = "QLabel {font: %spt %s; font-weight: %s; color: white}" % ( self.main_window.font_size, self.main_window.font, self.main_window.font_weight) self.sequence_SEQ_groupbox.setStyleSheet(seq_frame_stylesheet) self.seq_form_layout = QtWidgets.QFormLayout() #self.right_scroll self.right_scroll = QtWidgets.QScrollArea() self.right_scroll.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOn) self.right_scroll.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAsNeeded) self.right_scroll.resize(900, 400) self.right_scroll.setWidget( self.sequence_SEQ_groupbox ) # sequence_ID_groupbox dentro left_scroll area self.right_scroll.setWidgetResizable(True) #self.right_frame self.right_frame = QtWidgets.QFrame(self) self.right_frame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.right_frame.resize(900, 400) self.right_frame.setStyleSheet(self.style) self.right_frame.setFrameShadow(QtWidgets.QFrame.Sunken) #self.right_frame_layout self.right_frame_layout = QtWidgets.QVBoxLayout(self) self.right_frame_layout.addWidget(self.right_scroll) self.right_frame.setLayout( self.right_frame_layout) # left_frame_layout dentro left_frame #connect the two Vertical Bars to move them togheter self.left_scroll.verticalScrollBar().valueChanged.connect( self.right_scroll.verticalScrollBar().setValue) self.right_scroll.verticalScrollBar().valueChanged.connect( self.left_scroll.verticalScrollBar().setValue) #---------------------------------- # Bottom part of the main window. - #---------------------------------- self.splitter1 = QtWidgets.QSplitter(QtCore.Qt.Horizontal) self.splitter1.addWidget(self.left_frame) self.splitter1.addWidget(self.right_frame) # creating sequence and position labels self.label_sequence = QtWidgets.QLabel(self) self.label_sequence.setText('Sequence:') self.label_sequence.setStyleSheet(small_font_style) self.textbox_sequence = QtWidgets.QLineEdit(self) self.textbox_sequence.setStyleSheet(self.style + "; " + small_font_style) self.textbox_sequence.setReadOnly(True) self.label_position = QtWidgets.QLabel(self) self.label_position.setText('Position:') self.label_position.setStyleSheet(small_font_style) self.textbox_position = QtWidgets.QLineEdit(self) self.textbox_position.setReadOnly(True) self.textbox_position.setStyleSheet(self.style + "; " + small_font_style) self.textbox_position.setMinimumWidth( 675) # Width of the residues message bar width. # creating an horizontal layout with sequence and position labels self.text_layout = QtWidgets.QHBoxLayout() self.text_layout.addWidget(self.label_sequence) self.text_layout.addWidget(self.textbox_sequence) self.text_layout.addWidget(self.label_position) self.text_layout.addWidget(self.textbox_position) # creating a layout with sequence window and labels self.grid = QtWidgets.QVBoxLayout() self.grid.addWidget(self.splitter1) self.grid.addLayout(self.text_layout) self.setLayout(self.grid)