def paintColorDots(self, painter, rect): pen = QtGui.QPen(Qt.gray) pen.setStyle(Qt.SolidLine) painter.setPen(pen) scaled_pts = [] h = rect.height() for point in self.points: x, y, r, g, b = point x = rect.left() + rect.width() * self.dataToX(x) y = rect.top() + rect.height() * (1.0 - self.alphaToY(y)) if scaled_pts: painter.drawLine(scaled_pts[-1][0], scaled_pts[-1][1], x, y) scaled_pts.append((x, y, r, g, b)) for x, y, r, g, b in scaled_pts: painter.setBrush(QtGui.QColor(255 * r, 255 * g, 255 * b)) painter.drawEllipse(x - DOT_RADIUS, y - DOT_RADIUS, 2 * DOT_RADIUS, 2 * DOT_RADIUS) if 0 <= self.hover_point < len(scaled_pts): # use larger radius for hover dot radius = DOT_RADIUS + 2 x, y, r, g, b = scaled_pts[self.hover_point] painter.setBrush(QtGui.QColor(255 * r, 255 * g, 255 * b)) painter.drawEllipse(x - radius, y - radius, 2 * radius, 2 * radius)
def set_update_status_slot(self, component, text="new status", color="light_green"): status_item_object = self.items_status_dict[component.name] status_item_object.setText(text) if color == "light_green": status_item_object.setForeground(QtGui.QBrush(QtGui.QColor(204, 255, 204))) elif color == "green": status_item_object.setForeground(QtGui.QBrush(QtGui.QColor(10, 255, 10))) elif color == "gray": status_item_object.setForeground(QtGui.QBrush(QtGui.QColor(200, 200, 200))) elif color == "red": status_item_object.setForeground(QtGui.QBrush(QtGui.QColor(255, 0, 0))) else: raise KeyError(color)
def textformat(color, style=''): fmt = QtGui.QTextCharFormat() fmt.setForeground(QtGui.QColor(color)) for word in style.split(): if word == 'bold': fmt.setFontWeight(QtGui.QFont.Bold) elif word == 'italic': fmt.setFontItalic(True) elif word.startswith('bg:'): fmt.setBackground(QtGui.QColor(word[3:])) else: print('unhandled style:', word) return fmt
def set_starting_status_slot(self, component, size_download): """It responds to the established_connection signal emitted by the thread. The signal carries the file size, that will be displayed in the window.""" # gets the graphic object that displays the status, from a dictionary previously created status_item_object = self.items_status_dict[component.name]# [self.status_col_idx] status_item_object.setText('Available: '+str(int(size_download/1048576))+' MB') status_item_object.setForeground(QtGui.QBrush(QtGui.QColor(204, 255, 204)))
def create_little_canvas(self, hit, domain_hit, default_width=300, default_height=11): # Builds the graphics view and scene. canvas_plot_scene = QtWidgets.QGraphicsScene() canvas_plot_view = QtWidgets.QGraphicsView(canvas_plot_scene) canvas_plot_view.setFixedHeight(default_height) canvas_plot_view.setFixedWidth(default_width) canvas_plot_view.setSizePolicy(self.preferred_size_policy) canvas_plot_view.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) canvas_plot_view.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) canvas_plot_view.setFrameShape(QtWidgets.QFrame.NoFrame) canvas_plot_view.setStyleSheet("border: 0px; background: %s" % self.view_bg_color) # Get the coordinates of the various graphics elements. one_res_span = default_width / float( self.query_len ) # proporzione tra la lunghezza della seq e lo spazio grafico queryspan_start = int(domain_hit['start']) queryspan_end = int(domain_hit['end']) queryspan_start_graphic = int(queryspan_start * one_res_span) queryspan_end_graphic = int(queryspan_end * one_res_span) # canvas_true_width = int(queryspan_end_graphic-queryspan_start_graphic) # space_at_end = int(int(default_width)-(canvas_true_width+queryspan_start_graphic)) # Draws a gray rectangle representing the full protein sequence. canvas_plot_scene.addRect(0, 3, default_width, 5, self.full_seq_pen, self.full_seq_brush) # Draws a colored rectangle representing the domain. line_pen = QtGui.QPen(QtGui.QColor(0, 0, 0, 255), 1) qcolor = QtGui.QColor(0, 0, 0) qcolor.setNamedColor(hit['dom_color_hex']) brush = QtGui.QBrush(qcolor) canvas_plot_scene.addRect( queryspan_start_graphic, 0, queryspan_end_graphic - queryspan_start_graphic, default_height, line_pen, brush) return canvas_plot_view
def paintValueBox(self, painter, font_metrics, x, y, right_just, value, format="%.3f"): s = format % value sw = font_metrics.width(s) sh = font_metrics.height() if right_just: rect = QtCore.QRect(x - sw - 4, y - sh, sw + 4, sh + 2) else: rect = QtCore.QRect(x, y - sh, sw + 4, sh + 2) painter.fillRect(rect, QtGui.QColor(96, 96, 128) if self.line_color == Qt.lightGray else QtGui.QColor(0xFF, 0xFF, 0xFF)) painter.drawRect(rect) painter.drawText(rect.x() + 2, y - 2, s) return rect
def add_domain_representation(self, hit, domain_hit): queryspan_start = int(domain_hit['start']) queryspan_end = int(domain_hit['end']) domain_x = self.x_init + int( queryspan_start / float(self.query_len) * self.full_seq_rect_w) domain_y = self.domain_y_init domain_w = int((queryspan_end - queryspan_start) / float(self.query_len) * self.full_seq_rect_w) domain_h = 25 domain_pen = QtGui.QPen(QtGui.QColor(0, 0, 0, 255), 1) qcolor = QtGui.QColor(0, 0, 0) qcolor.setNamedColor(hit['dom_color_hex']) domain_brush = QtGui.QBrush(qcolor) domain_rect = self.canvas_plot_scene.addRect(domain_x, domain_y, domain_w, domain_h, domain_pen, domain_brush) domain_rect.setVisible(False) return domain_rect
def _fill_list(self): """ Create the list's data. """ self.items_dict = {} # Checks the database log in order to obtain the date when each database was last downloaded. download_log_dict = {} if os.path.isfile(self.installer_protocol.download_log_filepath): with open(self.installer_protocol.download_log_filepath, "r") as l_fh: download_log_dict = json.loads(l_fh.read()) # Configure the list of items is the 'all_components_list' from the PyMod Installer class. self.view.setRowCount(len(self.installer_protocol.components_list)) for row_counter, component in enumerate(self.installer_protocol.components_list): # Create an item and set the component name as text. item = QtWidgets.QTableWidgetItem(component.full_name) # add a checkbox to the name item.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) item.setCheckState(QtCore.Qt.Unchecked) # place the items in columns self.view.setItem(row_counter, self.component_col_idx, item) self.items_dict.update({component: item}) # Set the names of the databases. self.view.setItem(row_counter, self.databases_col_idx, QtWidgets.QTableWidgetItem(component.databases_string)) # Create another item displaying the status. graphic_status = 'Wait...' status = QtWidgets.QTableWidgetItem(graphic_status) status.setForeground(QtGui.QBrush(QtGui.QColor(191, 191, 191))) self.view.setItem(row_counter, self.status_col_idx, status) # Set the source URL. self.view.setItem(row_counter, self.source_col_idx, QtWidgets.QTableWidgetItem(component.remote_source)) # Fill in the last downloaded column. if component.name in download_log_dict: last_downloaded_str = download_log_dict[component.name] else: last_downloaded_str = "Never" last_downloaded_item = QtWidgets.QTableWidgetItem(last_downloaded_str) self.view.setItem(row_counter, self.last_download_col_idx, last_downloaded_item) self.items_status_dict[component.name] = status self.items_last_download_dict[component.name] = last_downloaded_item
def setPointColor(self, point, triple): """ Opens color picker and sets color of one or three points. """ self.color_point = point self.color_triple = triple _, _, r, g, b = self.points[self.color_point] if not self.color_dialog: self.color_dialog = QtWidgets.QColorDialog(self) self.color_dialog.currentColorChanged.connect( self.updatePointColor) self.color_dialog.finished.connect(self.colorDialogClosed) self.original_color = QtGui.QColor(255 * r, 255 * g, 255 * b) self.color_dialog.setCurrentColor(self.original_color) # open modal color dialog self.color_dialog.open()
def paintZoomArea(self, painter, rect): if self.init_pos and self.zoom_pos: rect.setLeft(self.init_pos.x()) rect.setRight(self.zoom_pos.x()) painter.fillRect(rect, QtGui.QBrush(QtGui.QColor(0, 64, 128, 128)))
def draw_map(self): """ Methods that actually draw the contact/distance map on a canvas widget. """ w = self.pixel_size # Prepare the brushes. self.viridis_brushes = [] with warnings.catch_warnings(): warnings.simplefilter("ignore") for c in viridis_colors_rev: brush = QtGui.QBrush( QtGui.QColor(c[0] * 255, c[1] * 255, c[2] * 255)) self.viridis_brushes.append(brush) self.default_brush = QtGui.QBrush(QtGui.QColor(242, 242, 242)) self.highlight_brush = QtGui.QBrush(QtGui.QColor(255, 0, 0)) # Function to get the color of pixels. if self.feature_type == "contact": self.get_color = self._get_color_contact elif self.feature_type in ("distance", "distances_mean"): self._dist_bins = np.linspace(2.5, self.threshold, 63) self.get_color = self._get_color_distance elif self.feature_type in ("distances_difference", "distances_std"): self._dist_bins = np.linspace(0.0, self.threshold, 63) self.get_color = self._get_color_distance else: raise KeyError(self.feature_type) #------------------------------- # Draws the map on the canvas. - #------------------------------- # Use a transparent pen for the border pf the pixels. pen = QtGui.QPen(QtGui.QColor(0, 0, 0, 0), 0) for i in range(0, len(self.data_array)): for j in range(0, len(self.data_array)): if i <= j: # Gets the color brush. color_brush = self.get_color(self.data_array[i][j]) # Builds rectangles for both the upper and lower part of the # matrix and adds them to the graphics scene. pid = Contact_map_pixel(j * w, i * w, w, w, i=i, j=j, contact_map_window=self, pen=pen, brush=color_brush) self.canvas_plot_scene.addItem(pid) pid = Contact_map_pixel(i * w, j * w, w, w, i=j, j=i, contact_map_window=self, pen=pen, brush=color_brush) self.canvas_plot_scene.addItem(pid) # Add events to the canvas. if self.feature_type in ("contact", "distance"): # Draws the map of a single structure on the canvas. self.canvas_plot_move_event = self.move_on_plot self.canvas_plot_left_click_event = self.click_on_plot else: # Draws the map of multiple structures on the canvas. self.canvas_plot_move_event = self.move_on_plot_ali self.canvas_plot_left_click_event = self.click_on_plot_ali
def draw_plot(self): self.pymol_selection = self.target_element.get_pymol_selector() imin = 60 jmin = 40 imax = imin + 360 jmax = jmin + 360 mark_size = 2 xticks_num = [-180, -135, -90, -45, 0, 45, 90, 135, 180] yticks_num = [-180, -135, -90, -45, 0, 45, 90, 135, 180] height = 10 width = 10 #-------------------------------------------------------------- # Draws the background and the axes of the Ramachandran plot. - #-------------------------------------------------------------- # Draws the background of the Ramachandran plot. line_pen = QtGui.QPen(QtGui.QColor(0, 0, 0, 255), 1) for ii in range(0, 36): for jj in range(0, 36): region = procheck[ii][jj] color = "#ffffff" #[ 1.0, 1.0, 1.0] if region == 'F': color = "#f20000" #[.949, 0.0, 0.0] elif region == 'A': color = "#f2f200" #[.949,.949, 0.0] elif region == 'G': color = "#f2f2a9" #[.949,.949,.663] qcolor = QtGui.QColor(0, 0, 0) qcolor.setNamedColor(color) brush = QtGui.QBrush(qcolor) # edgecolor = color left = imin + jj * width top = jmin + ii * height # Actually draws the backgound. self.canvas_plot_scene.addRect(left, top, width, height, qcolor, brush) # Draw the countours of the various background regions. if ii: # top border region_prev = procheck[ii - 1][jj] if ((region_prev == 'F' and region != 'F') or (region_prev == 'A' and region in "GD") or (region_prev == 'G' and region == 'D')): self.canvas_plot_scene.addLine(left - .5, top, left + width + .5, top, line_pen) if jj: # left border region_prev = procheck[ii][jj - 1] if ((region_prev == 'F' and region != 'F') or (region_prev == 'A' and region in "GD") or (region_prev == 'G' and region == 'D')): self.canvas_plot_scene.addLine(left, top - .5, left, top + height + .5, line_pen) # Create axis lines. def add_text_to_canvas(x, y, text, anchor=None, font_color="black", font_size=6, html_font_size=10): _text = str(text) text_item = self.canvas_plot_scene.addText(_text) w = text_item.boundingRect().width() h = text_item.boundingRect().height() text_item.setPos(int(x - w / 2.5), int(y - h / 2.5)) text_item.setFont(QtGui.QFont(text_item.font().family(), font_size)) imid = (imin + imax) / 2 # midpoint of X-axis jmid = (jmin + jmax) / 2 # midpoint of Y-axis self.canvas_plot_scene.addLine(imin, jmax, imax, jmax) self.canvas_plot_scene.addLine(imin, jmin, imin, jmax) self.canvas_plot_scene.addLine(imin, jmin, imax, jmin) self.canvas_plot_scene.addLine(imax, jmin, imax, jmax) self.canvas_plot_scene.addLine(imid, jmin, imid, jmax) self.canvas_plot_scene.addLine(imin, jmid, imax, jmid) # Create tick marks and labels x_x_offset = 0 # 20 x_y_offset = 14 # 5 tic = imin for label in xticks_num: self.canvas_plot_scene.addLine(tic, jmax + 5, tic, jmax) add_text_to_canvas(tic + x_x_offset, jmax + x_y_offset, label) if len(xticks_num) != 1: tic += (imax - imin) / (len(xticks_num) - 1) tic = jmax y_x_offset = 20 # 40 y_y_offset = 0 # 10 for label in yticks_num: self.canvas_plot_scene.addLine(imin, tic, imin - 5, tic) add_text_to_canvas(imin - y_x_offset, tic - y_y_offset, text=label) if len(yticks_num) != 1: tic -= (jmax - jmin) / (len(yticks_num) - 1) # Phi label. add_text_to_canvas((imin + imax) / 2 + 5, jmax + 35, text="\u03D5 (degrees)") # Psi label. add_text_to_canvas(imin / 2 - 10, (jmin + jmax) / 2, text="\u03A8") #--------------------------------------------------------- # Actually plots the data for each residue on the scene. - #--------------------------------------------------------- # Parses the PDB structure and gets the phi and psi angles. self.residues_count = { "F": 0, # Favored "A": 0, # Additional allowed "G": 0, # Generously allowed "D": 0, # Disallowed "gly": 0, # Glycines "pro": 0, # Prolines "end_res": 0, # end-residues "total": 0, # total number of residues } self.regions_items_dict = {k: [] for k in self.residues_count} self.residues_items_dict = {k: [] for k in prot_standard_three_letters} for res_idx, res_tags in enumerate(self.residues_tags): self.residues_count["total"] += 1 if res_tags["region"] == "end_res": self.residues_count["end_res"] += 1 continue i = imin + (180 + res_tags["phi"] / math.pi * 180) j = jmin + (180 - res_tags["psi"] / math.pi * 180) # Glycines. if res_tags["resname"] == "GLY": item = Ramachandran_plot_triangle(i=i, j=j, tags=res_tags, mark_size=mark_size, parent_window=self) self.canvas_plot_scene.addItem(item) self.regions_items_dict["gly"].append(item) self.residues_count["gly"] += 1 # Prolines. elif res_tags["resname"] == "PRO": item = Ramachandran_plot_rectangle(i=i, j=j, tags=res_tags, mark_size=mark_size, parent_window=self) self.canvas_plot_scene.addItem(item) self.regions_items_dict["pro"].append(item) self.residues_count["pro"] += 1 # Other residues. else: item = Ramachandran_plot_circle(i=i, j=j, tags=res_tags, mark_size=mark_size, parent_window=self) self.canvas_plot_scene.addItem(item) if res_tags["region"] in self.residues_count: self.regions_items_dict[res_tags["region"]].append(item) self.residues_count[res_tags["region"]] += 1 if res_tags["resname"] in self.residues_items_dict: self.residues_items_dict[res_tags["resname"]].append(item) self.residues_count["T"] = sum( [self.residues_count[k] for k in ("F", "A", "G", "D")]) self.regions_items_dict["T"] = [ i for k in ("F", "A", "G", "D") for i in self.regions_items_dict[k] ]
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(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)