Rendering shapes and text

Drawing shapes and text

Each of the functions below takes as arguments information about the screen coordinates, and yields a series of SVG tags specifying lines, shapes and text to be drawn. Each function also accepts optional kwdargs which can include additional SVG attributes such as fill and stroke colors.

class genomeview.svg.Renderer(backend, x, y, width, height)[source]
text(self, x, y, text, size=10, anchor="middle", family="Helvetica", **kwdargs)[source]

Draws text. Anchor specifies the horizontal positioning of the text with respect to the point (x,y) and must be one of {start, middle, end}. Font size and family can also be specified.

text_with_background(self, x, y, text, size=10, anchor="middle", family="Helvetica", text_color="black", bg="white", bg_opacity=0.8, **kwdargs)[source]

Draws text on an opaque background. bg specifies the background color, and bg_opacity ranges from 0 (completely transparent) to 1 (completely opaque).

rect(x, y, width, height, **kwdargs)[source]

Draws a rect whose upper left point is (x,y) with the specified width and height.

line(x1, y1, x2, y2, **kwdargs)[source]

Draws a line from (x1,y1) to (x2,y2).

line_with_arrows(x1, y1, x2, y2, n=5, direction="right", color="black", **kwdargs)[source]

Draws a line from (x1,y1) to (x2,y2) with n arrows spaced between. The line and arrows will be drawn in the specified color.

Converting genomic coordinates to screen coordinates

class genomeview.Scale(chrom, start, end, strand, source)[source]

Maintains information about a projection of a specific genomic interval into screen coordinates.

That is, we’re interested in visualizing an interval (chrom:start-end) on a canvas of a specified pixel width. The scale enables converting genomic coordinates into the display coordinates.

get_seq(start=None, end=None, strand='+')[source]

Gets the nucleotide sequence of an interval. By default, returns the sequence for the current genomic interval.

relpixels(genomic_size)[source]

Takes a genomic length (ie, a number of basepairs) and converts it to a relative screen length in pixels.

topixels(genomic_position)[source]

Converts a genomic position to a pixel location in the current coordinate system.