plasmidcanvas.feature

Module Contents

Classes

Feature

Abstract base class representing a feature

MultiPairFeature

An abstract Feauture type that spans multiple base pairs

SinglePairFeature

An abstract Feature class representing a Feature that relates to only a single base pair

LabelBase

A base class for labels.

SinglePairLabel

A class representing a label associated with a single base pair feature on a plasmid. Inheriting from both SinglePairLabel and LabelBase.

RestrictionSite

A class representing a restriction site on a plasmid as an extention of SinglePairLabel.

CurvedMultiPairLabel

A class representing a curved label associated with multiple base pairs on a plasmid.

RectangleFeature

A class representing a curved rectangular feature associated with multiple base pairs on a plasmid.

DirectionalMultiPairFeature

An abstract class representing a directional feature associated with multiple base pairs on a plasmid.

ArrowFeature

A class representing a curved arrow feature associated with multiple base pairs on a plasmid.

class plasmidcanvas.feature.Feature(name: str)

Abstract base class representing a feature

Initializes the Feature object.

Parameters:

name (str) – The name of the feature.

name: str
color: str
get_name() str

Get the name of the feature.

Returns:

The name of the feature.

Return type:

str

set_name(name: str)

Set the name of the feature.

Parameters:

name (str) – The name to set for the feature.

get_color() str

Get the color of the feature.

Returns:

The color of the feature.

Return type:

str

set_color(color: str) None

Set the color of the feature.

Parameters:

color (str) – The color to set for the feature. Use words e.g “red” or hex values e.g. “#FFFFFF”

class plasmidcanvas.feature.MultiPairFeature(name: str, start_pair: int, end_pair: int)

Bases: Feature

Inheritance diagram of plasmidcanvas.feature.MultiPairFeature

An abstract Feauture type that spans multiple base pairs

Initializes the MultiPairFeature object.

Parameters:
  • name (str) – The name of the feature.

  • start_pair (int) – The starting base pair of the feature.

  • end_pair (int) – The ending base pair of the feature.

start_pair: int
end_pair: int
SUPPORTED_LABEL_STYLES = ['on-circle', 'off-circle']
label_style = ['off-circle']
length() int

Calculates and returns the length of the feature. i.e. end_pair - start_pair

Returns:

The length of the feature.

Return type:

int

get_start_pair() int

Get the starting base pair of the feature.

Returns:

The starting base pair.

Return type:

int

set_start_pairs(start_pair: int) None

Set the starting base pair of the feature.

Parameters:

start_pair – The starting base pair to set.

get_end_pair() int

Get the ending base pair of the feature.

Returns:

The ending base pair.

Return type:

int

set_end_pairs(end_pair) None

Set the ending base pair of the feature.

Parameters:

end_pair – The ending base pair to set.

get_orbit() int

Get the orbit of the feature.

Returns:

The orbit value of the feature.

Return type:

int

set_orbit(orbit: int) None

Set the orbit of the feature. Mostly used internally for overlapping features, but can be used to force features into an orbit. The higher the orbit, the closer to the center of the plasmid the feature is placed. i.e orbit = 0 is the default, orbit = 4 circles four times the width of a feature closer to the center.

Parameters:

orbit (int) – The orbit value to set.

get_label_font_size() int

Get the font size of the labels associated with the feature.

Returns:

The font size of the labels.

Return type:

int

set_label_font_size(font_size: int) None

Set the font size of the labels associated with the feature.

Parameters:

font_size (int) – The font size to set.

get_label_styles() list[str]

Get the list of label styles associated with the feature.

Returns:

label_style – The list of label styles.

Return type:

list[str]

set_label_styles(label_styles: list[str])

Set the list of label styles associated with the feature.

Parameters:

label_styles (list[str]) – The list of label styles to set. Currently supported styles

“on-circle” - The label is applied onto the feature using curved text. (The base pair location is not included in this labelling)

“off-circle” - A label is placed off the circle with the name and bp range, connected by a small line

Note

A plasmid can have both, one or none of the label styles applied at the same time

Raises:

ValueError – If the given label_style is not in MultiPairFeature.SUPPORTED_LABEL_STYLES as listed above.

class plasmidcanvas.feature.SinglePairFeature(name: str, base_pair: int)

Bases: Feature

Inheritance diagram of plasmidcanvas.feature.SinglePairFeature

An abstract Feature class representing a Feature that relates to only a single base pair

Initializes the SinglePairFeature object.

Parameters:
  • name (str) – The name of the feature.

  • base_pair (int) – The base pair associated with the feature.

base_pair: int
get_base_pair() int

Get the base pair associated with the feature.

Returns:

The base pair.

Return type:

int

set_base_pair(base_pair) None

Set the base pair associated with the feature.

Parameters:

base_pair – The base pair to set.

class plasmidcanvas.feature.LabelBase(name: str)

A base class for labels.

Initializes the LabelBase object.

Parameters:

name (str) – The name of the label.

DEFAULT_FONT_SIZE: int
DEFAULT_FONT_COLOR: str = 'black'
label_text: str = 'UntitledLabel'
font_color: str
font_size: int
get_font_color() str

Get the color of the label font.

Returns:

The color of the label font.

Return type:

str

set_font_color(font_color: str) None

Set the color of the label font.

Parameters:

font_color (str) – The color of the label font.

set_label_text(label_text: str) None

Set the text of the label.

Parameters:

label_text (str) – The text of the label.

get_label_text() str

Get the text of the label.

Returns:

label_text – The text of the label.

Return type:

str

get_font_size() int

Get the size of the label font.

Returns:

font_size – The size of the label font.

Return type:

int

set_font_size(font_size: int) None

Set the size of the label font.

Parameters:

font_size (int) – The size of the label font.

class plasmidcanvas.feature.SinglePairLabel(name: str, base_pair: int)

Bases: SinglePairFeature, LabelBase

Inheritance diagram of plasmidcanvas.feature.SinglePairLabel

A class representing a label associated with a single base pair feature on a plasmid. Inheriting from both SinglePairLabel and LabelBase.

Initializes the SinglePairLabel object.

Parameters:
  • name (str) – The name of the label.

  • base_pair (int) – The base pair associated with the label.

line_length_sf: float
line_color: str
get_line_color() str

Get the color of the line connecting the label to the feature.

Returns:

The color of the line.

Return type:

str

set_line_color(line_color: str) None

Set the color of the line connecting the label to the feature.

Parameters:

line_color (str) – The color of the line.

get_line_length_sf() float

Get the scale factor for the length of the line connecting the label to the feature.

Returns:

The scale factor for the line length.

Return type:

float

set_line_length_sf(line_length_sf: float) None

Set the scale factor for the length of the line connecting the label to the feature.

Parameters:

line_length_sf (float) – The scale factor for the line length.

class plasmidcanvas.feature.RestrictionSite(text: str, base_pair: int)

Bases: SinglePairLabel

Inheritance diagram of plasmidcanvas.feature.RestrictionSite

A class representing a restriction site on a plasmid as an extention of SinglePairLabel.

Initializes the RestrictionSite object. Creating a label in the format “<text> (<base_pair>)”. For more control over the label text, use SinglePairLabel.

Parameters:
  • text (str) – The text to display on the restiction site. e.g. “BspMI”, “BfuAI, BspMI”, “Multiple Cloning Site”

  • base_pair (int) – The base pair position of the restriction site.

class plasmidcanvas.feature.CurvedMultiPairLabel(name: str, start_pair: int, end_pair: int)

Bases: MultiPairFeature, LabelBase

Inheritance diagram of plasmidcanvas.feature.CurvedMultiPairLabel

A class representing a curved label associated with multiple base pairs on a plasmid.

Initializes the CurvedMultiPairLabel object.

Parameters:
  • name (str) – The name of the curved label.

  • start_pair (int) – The starting base pair position of the label.

  • end_pair (int) – The ending base pair position of the label.

SUPPORTED_CURVE_ALIGNMENTS: list[str] = ['bottom', 'top']
set_curve_alignment(curve_align: str) None

Sets the alignment of the curved label. i.e. does the text follow the bottom or top of the curve? (use bottom for curves in the bottom half of the circle and top for the top half)

Parameters:

curve_align (str) – The alignment of the curved label (‘bottom’ or ‘top’).

get_curve_alignment() str

Returns the alignment of the curved label.

Returns:

The alignment of the curved label.

Return type:

str

class plasmidcanvas.feature.RectangleFeature(name: str, start_pair: int, end_pair: int)

Bases: MultiPairFeature

Inheritance diagram of plasmidcanvas.feature.RectangleFeature

A class representing a curved rectangular feature associated with multiple base pairs on a plasmid.

Initializes the MultiPairFeature object.

Parameters:
  • name (str) – The name of the feature.

  • start_pair (int) – The starting base pair of the feature.

  • end_pair (int) – The ending base pair of the feature.

line_width_scale_factor: float = 1
get_line_width_scale_factor() float

Returns the scale factor for the width of the rectangle.

Returns:

The scale factor for the width of the rectangle.

Return type:

float

set_line_width_scale_factor(sf: float) None

Sets the scale factor for the width of the rectangle.

Parameters:

sf (float) – The scale factor for the width of the rectangle.

class plasmidcanvas.feature.DirectionalMultiPairFeature(name: str, start_pair: int, end_pair: int, direction: int = 1)

Bases: MultiPairFeature

Inheritance diagram of plasmidcanvas.feature.DirectionalMultiPairFeature

An abstract class representing a directional feature associated with multiple base pairs on a plasmid.

Initializes a directional multi-pair feature.

Parameters:
  • name (str) – The name of the feature.

  • start_pair (int) – The start base pair.

  • end_pair (int) – The end base pair.

  • direction (int, optional) – The direction of the feature, either 1 for clockwise or -1 for anti-clockwise (default is 1).

direction: int = 1
get_direction() int

Returns the direction of the feature.

Returns:

The direction of the feature. (1 for clockwise or -1 for anti-clockwise)

Return type:

int

set_direction(direction: int) None

Sets the direction of the feature.

Parameters:

direction (int) – The direction of the feature, either 1 for clockwise or -1 for anti-clockwise.

Raises:

ValueError – If direction is neither 1 or -1.

class plasmidcanvas.feature.ArrowFeature(name: str, start_pair: int, end_pair: int, direction: int = 1)

Bases: DirectionalMultiPairFeature

Inheritance diagram of plasmidcanvas.feature.ArrowFeature

A class representing a curved arrow feature associated with multiple base pairs on a plasmid.

Initializes a directional multi-pair feature.

Parameters:
  • name (str) – The name of the feature.

  • start_pair (int) – The start base pair.

  • end_pair (int) – The end base pair.

  • direction (int, optional) – The direction of the feature, either 1 for clockwise or -1 for anti-clockwise (default is 1).

line_width_scale_factor: float = 1
get_line_width_scale_factor() float

Returns the scale factor for the width of the arrow.

Returns:

The scale factor for the width of the arrow.

Return type:

float

set_line_width_scale_factor(sf: float) None

Sets the scale factor for the width of the arrow.

Parameters:

sf (float) – The scale factor to set.