From 52bbe8b56c0d8d2cda2b084e1ad936d80c40e431 Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 12 Aug 2022 14:51:38 +0000 Subject: Make homology track display directional arrows based on query strand --- .../marker_regression/display_mapping_results.py | 93 ++++++++++------------ 1 file changed, 43 insertions(+), 50 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py index 9425e1f3..af63713f 100644 --- a/wqflask/wqflask/marker_regression/display_mapping_results.py +++ b/wqflask/wqflask/marker_regression/display_mapping_results.py @@ -1398,61 +1398,54 @@ class DisplayMappingResults: geneYLocation += 3 * self.BAND_HEIGHT + 3 * self.BAND_SPACING # draw the detail view - if self.endMb - self.startMb <= self.DRAW_DETAIL_MB and geneEndPix - geneStartPix > self.EACH_GENE_ARROW_SPACING * 3: - utrColor = ImageColor.getrgb("rgb(66%, 66%, 66%)") - arrowColor = ImageColor.getrgb("rgb(70%, 70%, 70%)") + utrColor = ImageColor.getrgb("rgb(66%, 66%, 66%)") + arrowColor = ImageColor.getrgb("rgb(70%, 70%, 70%)") - # draw the line that runs the entire length of the gene - im_drawer.line( - xy=( - (geneStartPix, geneYLocation + \ - self.EACH_GENE_HEIGHT / 2 * zoom), - (geneEndPix, geneYLocation + self.EACH_GENE_HEIGHT / 2 * zoom)), - fill=outlineColor, width=1) - - # draw the arrows - if geneEndPix - geneStartPix < 1: - genePixRange = 1 - else: - genePixRange = int(geneEndPix - geneStartPix) - for xCoord in range(0, genePixRange): - - if (xCoord % self.EACH_GENE_ARROW_SPACING == 0 and xCoord + self.EACH_GENE_ARROW_SPACING < geneEndPix - geneStartPix) or xCoord == 0: - if query_strand == "+": - im_drawer.line( - xy=((geneStartPix + xCoord, geneYLocation), - (geneStartPix + xCoord + self.EACH_GENE_ARROW_WIDTH, - geneYLocation + (self.EACH_GENE_HEIGHT / 2) * zoom)), - fill=arrowColor, width=1) - im_drawer.line( - xy=((geneStartPix + xCoord, - geneYLocation + self.EACH_GENE_HEIGHT * zoom), - (geneStartPix + xCoord + self.EACH_GENE_ARROW_WIDTH, - geneYLocation + (self.EACH_GENE_HEIGHT / 2) * zoom)), - fill=arrowColor, width=1) - else: - im_drawer.line( - xy=((geneStartPix + xCoord + self.EACH_GENE_ARROW_WIDTH, - geneYLocation), - (geneStartPix + xCoord, - geneYLocation + (self.EACH_GENE_HEIGHT / 2) * zoom)), - fill=arrowColor, width=1) - im_drawer.line( - xy=((geneStartPix + xCoord + self.EACH_GENE_ARROW_WIDTH, - geneYLocation + self.EACH_GENE_HEIGHT * zoom), - (geneStartPix + xCoord, - geneYLocation + (self.EACH_GENE_HEIGHT / 2) * zoom)), - fill=arrowColor, width=1) - # draw the genes as rectangles + # draw the line that runs the entire length of the gene + im_drawer.line( + xy=( + (geneStartPix, geneYLocation + \ + self.EACH_GENE_HEIGHT / 2 * zoom), + (geneEndPix, geneYLocation + self.EACH_GENE_HEIGHT / 2 * zoom)), + fill=outlineColor, width=1) + + # draw the arrows + if geneEndPix - geneStartPix < 1: + genePixRange = 1 else: - im_drawer.rectangle( - xy=((geneStartPix, geneYLocation), - (geneEndPix, (geneYLocation + self.EACH_GENE_HEIGHT * zoom))), - outline=outlineColor, fill=fillColor) + genePixRange = int(geneEndPix - geneStartPix) + for xCoord in range(0, genePixRange): + + if (xCoord % self.EACH_GENE_ARROW_SPACING == 0 and xCoord + self.EACH_GENE_ARROW_SPACING < geneEndPix - geneStartPix) or xCoord == 0: + if query_strand == "+": + im_drawer.line( + xy=((geneStartPix + xCoord, geneYLocation), + (geneStartPix + xCoord + self.EACH_GENE_ARROW_WIDTH, + geneYLocation + (self.EACH_GENE_HEIGHT / 2) * zoom)), + fill=arrowColor, width=1) + im_drawer.line( + xy=((geneStartPix + xCoord, + geneYLocation + self.EACH_GENE_HEIGHT * zoom), + (geneStartPix + xCoord + self.EACH_GENE_ARROW_WIDTH, + geneYLocation + (self.EACH_GENE_HEIGHT / 2) * zoom)), + fill=arrowColor, width=1) + else: + im_drawer.line( + xy=((geneStartPix + xCoord + self.EACH_GENE_ARROW_WIDTH, + geneYLocation), + (geneStartPix + xCoord, + geneYLocation + (self.EACH_GENE_HEIGHT / 2) * zoom)), + fill=arrowColor, width=1) + im_drawer.line( + xy=((geneStartPix + xCoord + self.EACH_GENE_ARROW_WIDTH, + geneYLocation + self.EACH_GENE_HEIGHT * zoom), + (geneStartPix + xCoord, + geneYLocation + (self.EACH_GENE_HEIGHT / 2) * zoom)), + fill=arrowColor, width=1) COORDS = "%d, %d, %d, %d" % ( geneStartPix, geneYLocation, geneEndPix, (geneYLocation + self.EACH_GENE_HEIGHT)) - # NL: 06-02-2011 Rob required to display NCBI info in a new window + gifmap.append( HtmlGenWrapper.create_area_tag( shape='rect', -- cgit v1.2.3