def spacer_ticker(canvas, feature, cLen, Y0, nudge, offset, side): """Draw separator indicators.""" # take start and end points location = feature.location Zs = location.nofuzzy_start Ze = location.nofuzzy_end # calculate loop offset coordinates loop_offZs = offset_coord(Zs, cLen, offset) loop_offZe = offset_coord(Ze, cLen, offset) # calculate nudge offset coordinates offZs = nudge_coord(loop_offZs, nudge) offZe = nudge_coord(loop_offZe, nudge) xs, xe = offZs*u, offZe*u # set Y axis coordinates y0 = Y0-dop*3.5 if side == 'low': yT1 = y0-h*4 else: yT1 = y0+h*4 # draw canvas.setLineWidth(2) ttl = canvas.beginPath() ttl.moveTo(xs,y0) ttl.lineTo(xs,yT1) ttl.lineTo(xe,yT1) ttl.lineTo(xe,y0) canvas.drawPath(ttl, stroke=1, fill=0) ttl.close()
def ref_ticker(canvas, feature, cLen, Y0, nudge, offset): """Draw contig separators.""" # get contig name name = feature.qualifiers.get('id')[0] # take start and end points location = feature.location Zs = location.nofuzzy_start Ze = location.nofuzzy_end # calculate loop offset coordinates loop_offZs = offset_coord(Zs, cLen, offset) loop_offZe = offset_coord(Ze, cLen, offset) # calculate nudge offset coordinates offZs = nudge_coord(loop_offZs, nudge) offZe = nudge_coord(loop_offZe, nudge) xs, xe = offZs*u, offZe*u xmid = (xe+xs)/2 # set Y axis coordinates y0 = Y0+dop*3 # draw canvas.setLineWidth(2) ttl = canvas.beginPath() ttl.moveTo(xs,y0+w) ttl.lineTo(xs,y0+w+h*2) ttl.lineTo(xe,y0+w+h*2) ttl.lineTo(xe,y0+w) canvas.drawPath(ttl, stroke=1, fill=0) canvas.setFont(bFont, NfSize) canvas.drawCentredString(xmid, y0+h*5, name) canvas.setFont(rFont, NfSize) ttl.close()
def orf_coords(feature, Y_map, cLen, nudge, offset): """Calculate CDS coordinates in drawing space.""" # evaluate what strand the ORF is on (determines direction of arrow) cstrand = feature.strand if cstrand is None: cstrand = 1 # take start and end points location = feature.location Zs = location.nofuzzy_start Ze = location.nofuzzy_end featL = Ze - Zs # calculate loop offset coordinates loop_offZs = offset_coord(Zs, cLen, offset) loop_offZe = offset_coord(Ze, cLen, offset) # calculate nudge offset coordinates offZs = nudge_coord(loop_offZs, nudge) offZe = nudge_coord(loop_offZe, nudge) # calculate X axis coordinates (expr of cstrand has changed) if cstrand == -1 : # reverse orientation xs,xe = offZe*u,offZs*u # start and end xn = xe+minL*u # neck of arrow else : # forward orientation xs,xe = offZs*u,offZe*u # start and end xn = xe-minL*u # neck of arrow midLZ = ((offZs+offZe)/2)*u # middle of ORF for optional label # evaluate splits split_flag = False if (xs < xe and cstrand == -1) or (xs > xe and cstrand == 1): midLZ = 0 split_flag = True # set Y axis coordinates y0 = Y_map yt,yb,ynt,ynb = y0+w,y0-w,y0+h,y0-h coords = xs, xe, xn, y0, yt, yb, ynt, ynb return featL, midLZ, coords, split_flag
def contig_ticker(canvas, feature, cLen, Y0, offset, offset_mode): """Draw contig separators.""" # get contig name name = feature.qualifiers.get('id')[0] # take start and end points location = feature.location Zs = location.nofuzzy_start Ze = location.nofuzzy_end # calculate offset coordinates if offset_mode == 'loop': offZs = offset_coord(Zs, cLen, offset) offZe = offset_coord(Ze, cLen, offset) elif offset_mode == 'nudge': offZs = nudge_coord(Zs, offset) offZe = nudge_coord(Ze, offset) else: offZs = Zs offZe = Ze xs, xe = offZs*u, offZe*u # set Y axis coordinates y0 = Y0-dop*3.5 # draw canvas.setLineWidth(2) ttl = canvas.beginPath() ttl.moveTo(xs,y0) ttl.lineTo(xs,y0-h*4) ttl.lineTo(xs+dop,y0-h*4) canvas.drawPath(ttl, stroke=1, fill=0) canvas.setFont(bFont, NfSize) canvas.drawString(xs+dop*2, y0-h*4.5, name) canvas.setFont(rFont, SfSize) canvas.drawString(xs+dop*2,y0-h*8,"".join(["[",str(Zs),"-",str(Ze),"]"])) canvas.setFont(rFont, NfSize) ttl.close()
def baseliner(cLen, canvas, Y_map, nudge): # loop offset has no effect """Draw sequence baseline.""" canvas.setLineWidth(3) y0 = Y_map Zs = 0 # all sequences are initially aligned on the left Ze = cLen # calculate nudge offsets offZs = nudge_coord(Zs, nudge) offZe = nudge_coord(Ze, nudge) # set zeroes x0 = offZs*u x1 = offZe*u pBL = canvas.beginPath() pBL.moveTo(x0,y0) pBL.lineTo(x1,y0) canvas.drawPath(pBL, stroke=1, fill=0) pBL.close()
def contig_ticker(canvas, feature, cLen, Y0, nudge, offset, side): """Draw contig separators.""" # get contig name try: name = feature.qualifiers.get('locus_tag')[0] except TypeError: name = 'unnamed feature' # take start and end points location = feature.location Zs = location.nofuzzy_start Ze = location.nofuzzy_end # calculate loop offset coordinates loop_offZs = offset_coord(Zs, cLen, offset) loop_offZe = offset_coord(Ze, cLen, offset) # calculate nudge offset coordinates offZs = nudge_coord(loop_offZs, nudge) offZe = nudge_coord(loop_offZe, nudge) xs, xe = offZs*u, offZe*u # set Y axis coordinates if side == 'low': y0 = Y0-dop*3.5 yT1 = y0-h*4 yT2 = y0-h*4.5 yT3 = y0-h*8 else: y0 = Y0+dop*3.5 yT1 = y0+h*4 yT2 = y0+h*4.5 yT3 = y0+h*8 # draw canvas.setLineWidth(2) ttl = canvas.beginPath() ttl.moveTo(xs,y0) ttl.lineTo(xs,yT1) ttl.lineTo(xs+dop,yT1) canvas.drawPath(ttl, stroke=1, fill=0) canvas.setFont(bFont, NfSize) canvas.drawString(xs+dop*2, yT2, name) canvas.setFont(rFont, SfSize) canvas.drawString(xs+dop*2,yT3,"".join(["[",str(Zs),"-",str(Ze),"]"])) canvas.setFont(rFont, NfSize) ttl.close()
def baseliner(cLen, canvas, Y_map, offset, offset_mode): """Draw sequence baseline.""" canvas.setLineWidth(3) y0 = Y_map Zs = 0 # all sequences are initially aligned on the left Ze = cLen # calculate offsets if offset_mode == 'nudge': offZs = nudge_coord(Zs, offset) offZe = nudge_coord(Ze, offset) else: offZs = Ze offZe = Zs x0 = offZs * u x1 = offZe * u pBL = canvas.beginPath() pBL.moveTo(x0, y0) pBL.lineTo(x1, y0) canvas.drawPath(pBL, stroke=1, fill=0) pBL.close()
def baseliner(cLen, canvas, Y_map, offset, offset_mode): """Draw sequence baseline.""" canvas.setLineWidth(3) y0 = Y_map Zs = 0 # all sequences are initially aligned on the left Ze = cLen # calculate offsets if offset_mode == 'nudge': offZs = nudge_coord(Zs, offset) offZe = nudge_coord(Ze, offset) else: offZs = Ze offZe = Zs x0 = offZs*u x1 = offZe*u pBL = canvas.beginPath() pBL.moveTo(x0,y0) pBL.lineTo(x1,y0) canvas.drawPath(pBL, stroke=1, fill=0) pBL.close()
def contig_ticker(canvas, feature, cLen, Y0, offset, offset_mode): """Draw contig separators.""" # get contig name name = feature.qualifiers.get('id')[0] # take start and end points location = feature.location Zs = location.nofuzzy_start Ze = location.nofuzzy_end # calculate offset coordinates if offset_mode == 'loop': offZs = offset_coord(Zs, cLen, offset) offZe = offset_coord(Ze, cLen, offset) elif offset_mode == 'nudge': offZs = nudge_coord(Zs, offset) offZe = nudge_coord(Ze, offset) else: offZs = Zs offZe = Ze xs, xe = offZs * u, offZe * u # set Y axis coordinates y0 = Y0 - dop * 3.5 # draw canvas.setLineWidth(2) ttl = canvas.beginPath() ttl.moveTo(xs, y0) ttl.lineTo(xs, y0 - h * 4) ttl.lineTo(xs + dop, y0 - h * 4) canvas.drawPath(ttl, stroke=1, fill=0) canvas.setFont(bFont, NfSize) canvas.drawString(xs + dop * 2, y0 - h * 4.5, name) canvas.setFont(rFont, SfSize) canvas.drawString(xs + dop * 2, y0 - h * 8, "".join(["[", str(Zs), "-", str(Ze), "]"])) canvas.setFont(rFont, NfSize) ttl.close()