def render(self, cr, area): if self.cscore is None or self.cscore.sequence_cscores is None: return height = len(self.cscore.sequence_cscores) first_seq, y_offset = divmod(float(height * area.y) / area.total_height, 1) first_seq = int(first_seq) last_seq = min(int(height * float(area.y + area.height) / area.total_height), height - 1) n_seq = min(last_seq - first_seq + 1, height) cr.rectangle(0, 0, area.width, area.height) cr.clip() cr.translate(-area.x, 0) # Guide lines cr.set_source_rgba(*Color(215, 215, 215, self.alpha).rgba) v_quartile_guidelines(cr, area.height, area.y, area.total_width, area.total_height) # Bar plot v_bar(cr, self.gradient, self.alpha, self.cscore.sequence_cscores, first_seq, n_seq, area.y, area.total_width, area.total_height) # Bottom line cr.set_source_rgba(.7, .7, .7, self.alpha) cr.set_dash([]) cr.set_line_width(0.5) x = 0.25 if not vector_based(cr): cr.set_line_width(1) x = 0.5 cr.move_to(x, -1) cr.line_to(x, area.height) cr.stroke()
def render(self, cr, area): if self.array is None: return if vector_based(cr): scaled_image_rectangles(cr, area, self.array, self.alpha) else: scaled_image(cr, area, self.image, self.alpha)
def render(self, cr, area): if self.cscore is None or self.cscore.cscores is None: return width = len(self.cscore.cscores) first_pos, x_offset = divmod(float(width * area.x) / area.total_width, 1) first_pos = int(first_pos) last_pos = min(int(width * float(area.x + area.width) / area.total_width), width - 1) n_pos = min(last_pos - first_pos + 1, width) cr.rectangle(0, 0, area.width, area.height) cr.clip() cr.translate(0, -area.y) # Guide lines cr.set_source_rgba(*Color(215, 215, 215, self.alpha).rgba) quartile_guidelines(cr, area.width, area.x, area.total_width, area.total_height) # Bar plot bar(cr, self.gradient, self.alpha, self.cscore.cscores, first_pos, n_pos, area.x, area.total_width, area.total_height) # Bottom line cr.set_source_rgba(.7, .7, .7, self.alpha) cr.set_dash([]) cr.set_line_width(0.5) offset = -0.25 if not vector_based(cr): cr.set_line_width(1) offset = -0.5 y = area.total_height + offset cr.move_to(-1, y) cr.line_to(area.width, y) cr.stroke()
def render(self, cr, area): if self._label_size is None: return detail = self.get_detail_size() if area.total_height >= detail[1]: return Labeler.render(self, cr, area) # If we don't have enough space to draw legible labels we can at least do a label sized shading. values = [float(i)/area.total_width for i in self._label_widths] first_label, n_labels, yscale = get_view_extents(area.y, area.height, area.total_height, len(self.get_data())) cr.rectangle(0, 0, area.width, area.height) cr.clip() cr.translate(-area.x + 1, 0) v_bar(cr, None, None, values, first_label, n_labels, area.y, area.total_width, area.total_height) if vector_based(cr): cr.set_source_rgba(.85, .85, .85, self.alpha) else: cr.set_source(chequers((.5, .5, .5, self.alpha), (0, 0, 0, 0), 1)) cr.fill()
def render(self, cr, area): if not self.backbones: return if (area.total_width < len(self.msa) or area.total_height < len(self.msa.sequences)): # Probably should return here, may look ugly. pass raster_backend = not vector_based(cr) msa_area = area.msa_area(self.msa) def draw_lines(contiguous_regions, linewidth): for seq in range(msa_area.sequences.start, msa_area.sequences.start + msa_area.sequences.length): y = (seq + 0.5) / len(self.msa.sequences) * area.total_height - area.y if raster_backend: y = int(y - linewidth / 2) + linewidth / 2 for region in contiguous_regions[seq].parts: if region.start + region.length < msa_area.positions.start: continue if region.start > msa_area.positions.start + msa_area.positions.length: break x_start = float(region.start) / len(self.msa) * area.total_width - area.x x_stop = float(region.start + region.length) / len(self.msa) * area.total_width - area.x if raster_backend: x_start = int(x_start) x_stop = int(x_stop) cr.move_to(x_start, y) cr.line_to(x_stop, y) linewidth = min(2, max(10, float(area.total_height) / len(self.msa.sequences) / 2)) if raster_backend: linewidth = int(linewidth) cr.save() cr.rectangle(0, 0, area.width, area.height) cr.clip() cr.set_source_rgba(0, 0, 0, self.alpha) cr.save() cr.set_line_width(linewidth/2) cr.set_dash([1, 1]) draw_lines(self.gaps, int(linewidth/2)) cr.stroke() cr.restore() cr.set_line_width(linewidth) draw_lines(self.backbones, linewidth) cr.stroke() cr.restore()