def drawLine(self, x1, y1, x2, y2, css_class): # print("draw line", x1, y1, x2, y2) llim = 0.001 rlim = 0.999 if (x1 < llim): x1 = llim elif (x1 > rlim): x1 = rlim if (x2 < llim): x2 = llim elif (x2 > rlim): x2 = rlim if x1 == x2: bot_y = y1 if y1 > y2 else y2 top_y = y1 + y2 - bot_y self.vertical_lines.append( VerticalLine(x1, top_y, bot_y, 2, 'vertical_line ' + css_class)) else: left_x = x1 if x1 < x2 else x2 right_x = x1 + x2 - left_x self.horizontal_lines.append( HorizontalLine(left_x, right_x, y1, 2, 'horizontal_line ' + css_class))
def drawAxes(self, span, compact, maxIntvl, chr_offs, cycles_section_bottom): for ch in compact.keys(): for s in compact[ch]: # print "ch:", ch, s[0], s[1] len = s[1] - s[0] offset = self.findMergedIntervalOffset(compact[ch], s[0], maxIntvl[ch]) x1 = chr_offs[ch][0] + chr_offs[ch][1] * ( offset + maxIntvl[ch] / 2.0) / (span[ch] + 0.0) x2 = chr_offs[ch][0] + chr_offs[ch][1] * ( offset + len + maxIntvl[ch] / 2.0) / (span[ch] + 0.0) self.horizontal_lines.append( HorizontalLine(x1, x2, cycles_section_bottom, height=2, css_style='axes_line'))
def drawSections(self, intervals, ilist, cycles_section_top, cycles_section_bottom, auto_scale): dotted_lines = [(x, type) for x, type, chrom in ilist.offset_breaks() if type == ':'] for x, line_type in dotted_lines: css_style = 'vertical_dotted_line' self.vertical_lines.append( VerticalLine(x, cycles_section_top - 5, cycles_section_bottom, width=1, css_style=css_style)) i = 0 chromosome_lines = [(0, '--', intervals[0][0])] + [ (x, type, chrom) for x, type, chrom in ilist.offset_breaks() if type == '--' or type == '-' ] for x, line_type, name in chromosome_lines: if line_type == '-': css_style = 'vertical_species_line' else: css_style = 'vertical_dashed_line' end = 1.0 if i == len(chromosome_lines) - 1 else chromosome_lines[ i + 1][0] self.texts.append( Text(name, (x + end) / 2 - 0.012, cycles_section_bottom + 7)) bottom = cycles_section_bottom + 20 if line_type == '-' else cycles_section_bottom width = 2 if line_type == '-' else 1 if x != 0: self.vertical_lines.append( VerticalLine(x, cycles_section_top - 5, bottom, width=width, css_style=css_style)) i += 1 self.horizontal_lines.append( HorizontalLine(0, 1, cycles_section_bottom, height=2, css_style='axes_line'))