Skip to content

FeatureTrack Class

FeatureTrack

FeatureTrack(
    name: str,
    size: int,
    start_pos: int = 0,
    labelsize: int = 20,
    labelcolor: str = "black",
    labelmargin: float = 0.01,
    linewidth: int = 1,
    linecolor: str = "black",
    spines: bool = False,
    ratio: float = 1.0,
)

Bases: Track

FeatureTrack Class

PARAMETER DESCRIPTION
name

Track name

TYPE: str

size

Track size

TYPE: int

start_pos

Track start position. Track start-end range is defined as (start_pos, start_pos + size).

TYPE: int DEFAULT: 0

labelsize

Track label size

TYPE: int DEFAULT: 20

labelcolor

Track label color

TYPE: str DEFAULT: 'black'

labelmargin

Track label margin

TYPE: float DEFAULT: 0.01

linewidth

Track line width

TYPE: int DEFAULT: 1

linecolor

Track line color

TYPE: str DEFAULT: 'black'

spines

Display track spines

TYPE: bool DEFAULT: False

ratio

Track height ratio

TYPE: float DEFAULT: 1.0

add_feature

add_feature(
    start: int,
    end: int,
    strand: LiteralTypes.STRAND = 1,
    label: str = "",
    labelsize: int = 15,
    labelcolor: str = "black",
    plotstyle: LiteralTypes.PLOTSTYLE = "bigarrow",
    facecolor: str = "orange",
    edgecolor: str = "black",
    linewidth: float = 0,
    labelrotation: int = 45,
    labelvpos: LiteralTypes.LABELVPOS = "strand",
    labelhpos: LiteralTypes.LABELHPOS = "center",
    labelha: LiteralTypes.LABELHA = "left",
    arrow_shaft_ratio: float = 0.5,
    size_ratio: float = 1.0,
    patch_kws: dict[str, Any] | None = None,
) -> None

Add feature to track

PARAMETER DESCRIPTION
start

Featrue start position

TYPE: int

end

Feature end position

TYPE: int

strand

Feature strand

TYPE: int DEFAULT: 1

label

Feature label

TYPE: str DEFAULT: ''

labelsize

Feature label size

TYPE: int DEFAULT: 15

labelcolor

Feature label color

TYPE: str DEFAULT: 'black'

plotstyle

Feature plot style (bigarrow|arrow|bigbox|box|bigrbox|rbox)

TYPE: str DEFAULT: 'bigarrow'

facecolor

Feature facecolor

TYPE: str DEFAULT: 'orange'

edgecolor

Feature edgecolor

TYPE: str DEFAULT: 'black'

linewidth

Feature edge linewidth

TYPE: float DEFAULT: 0

labelrotation

Feature label rotation

TYPE: int DEFAULT: 45

labelvpos

Feature label vertical position (top|center|bottom|strand) If 'strand' is set, 'top' or 'bottom' is auto selected by strand.

TYPE: str DEFAULT: 'strand'

labelhpos

Feature label horizontal position (left|center|right)

TYPE: str DEFAULT: 'center'

labelha

Feature label horizontal alignment (left|center|right)

TYPE: str DEFAULT: 'left'

arrow_shaft_ratio

Feature arrow shaft ratio

TYPE: float DEFAULT: 0.5

size_ratio

Feature size ratio to track

TYPE: float DEFAULT: 1.0

patch_kws

Patch properties (e.g. fc="red", ec="black", lw=0.5, ...) https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html

TYPE: dict[str, Any] | None DEFAULT: None

add_exon_feature

add_exon_feature(
    exon_regions: list[tuple[int, int]],
    strand: LiteralTypes.STRAND = 1,
    label: str = "",
    labelsize: int = 15,
    labelcolor: str = "black",
    plotstyle: LiteralTypes.PLOTSTYLE = "bigarrow",
    facecolor: str = "orange",
    edgecolor: str = "black",
    linewidth: float = 0,
    labelrotation: int = 45,
    labelvpos: LiteralTypes.LABELVPOS = "strand",
    labelhpos: LiteralTypes.LABELHPOS = "center",
    labelha: LiteralTypes.LABELHA = "left",
    arrow_shaft_ratio: float = 0.5,
    size_ratio: float = 1.0,
    exon_labels: list[str] | None = None,
    exon_label_kws: dict[str, Any] | None = None,
    patch_kws: dict[str, Any] | None = None,
    intron_patch_kws: dict[str, Any] | None = None,
) -> None

Add exon feature to track

PARAMETER DESCRIPTION
exon_regions

Exon feature start-end postion list

TYPE: list[tuple[int, int]]

strand

Feature strand

TYPE: int DEFAULT: 1

label

Feature label

TYPE: str DEFAULT: ''

labelsize

Feature label size

TYPE: int DEFAULT: 15

labelcolor

Feature label color

TYPE: str DEFAULT: 'black'

plotstyle

Feature plot style (bigarrow|arrow|bigbox|box|bigrbox|rbox)

TYPE: str DEFAULT: 'bigarrow'

facecolor

Feature facecolor

TYPE: str DEFAULT: 'orange'

edgecolor

Feature edgecolor

TYPE: str DEFAULT: 'black'

linewidth

Feature edge linewidth

TYPE: float DEFAULT: 0

labelrotation

Feature label rotation

TYPE: int DEFAULT: 45

labelvpos

Feature label vertical position (top|center|bottom|strand) If 'strand' is set, 'top' or 'bottom' is auto selected by strand.

TYPE: str DEFAULT: 'strand'

labelhpos

Feature label horizontal position (left|center|right)

TYPE: str DEFAULT: 'center'

labelha

Feature label horizontal alignment (left|center|right)

TYPE: str DEFAULT: 'left'

arrow_shaft_ratio

Feature arrow shaft ratio

TYPE: float DEFAULT: 0.5

size_ratio

Feature size ratio to track

TYPE: float DEFAULT: 1.0

exon_labels

Exon labels. Array length must be same as exon_regions.

TYPE: list[str] | None DEFAULT: None

exon_label_kws

Text properties (e.g. dict(size=12, color="red", ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.text.html

TYPE: dict[str, Any] | None DEFAULT: None

patch_kws

Exon patch properties (e.g. dict(fc="red", ec="black", lw=0.5, ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html

TYPE: dict[str, Any] | None DEFAULT: None

intron_patch_kws

Intron patch properties (e.g. dict(ec="red", lw=2, ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html

TYPE: dict[str, Any] | None DEFAULT: None

add_features

add_features(
    features: list[SeqFeature],
    label_type: str | None = None,
    label_handle_func: Callable[[str], str] | None = None,
    labelsize: int = 15,
    labelcolor: str = "black",
    plotstyle: LiteralTypes.PLOTSTYLE = "bigarrow",
    facecolor: str = "orange",
    edgecolor: str = "black",
    linewidth: float = 0,
    labelrotation: int = 45,
    labelvpos: LiteralTypes.LABELVPOS = "strand",
    labelhpos: LiteralTypes.LABELHPOS = "center",
    labelha: LiteralTypes.LABELHA = "left",
    arrow_shaft_ratio: float = 0.5,
    size_ratio: float = 1.0,
    patch_kws: dict[str, Any] | None = None,
) -> None

Add features (BioPython's SeqFeature list)

PARAMETER DESCRIPTION
features

BioPython's SeqFeature list

TYPE: str

label_type

Label type (e.g. gene,protein_id,product,etc...)

TYPE: str | None DEFAULT: None

label_handle_func

User defined function to handle label. Useful for filtering out unnecesary labels such as hypothetical ~~~, omitting labels with long characters, etc.

TYPE: Callable[[str], str] | None DEFAULT: None

labelsize

Feature label size

TYPE: int DEFAULT: 15

labelcolor

Feature label color

TYPE: str DEFAULT: 'black'

plotstyle

Feature plot style (bigarrow|arrow|bigbox|box|bigrbox|rbox)

TYPE: str DEFAULT: 'bigarrow'

facecolor

Feature facecolor. If Genbank qualifiers has facecolor key (e.g. /facecolor="red"), facecolor key value is applied preferentially.

TYPE: str DEFAULT: 'orange'

edgecolor

Feature edgecolor

TYPE: str DEFAULT: 'black'

linewidth

Feature edge linewidth

TYPE: float DEFAULT: 0

labelrotation

Feature label rotation

TYPE: int DEFAULT: 45

labelvpos

Feature label vertical position (top|center|bottom|strand) If 'strand' is set, 'top' or 'bottom' is auto selected by strand.

TYPE: str DEFAULT: 'strand'

labelhpos

Feature label horizontal position (left|center|right)

TYPE: str DEFAULT: 'center'

labelha

Feature label horizontal alignment (left|center|right)

TYPE: str DEFAULT: 'left'

arrow_shaft_ratio

Feature arrow shaft ratio

TYPE: float DEFAULT: 0.5

size_ratio

Feature size ratio to track

TYPE: float DEFAULT: 1.0

patch_kws

Patch properties (e.g. dict(fc="red", ec="black", lw=0.5, ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html

TYPE: dict[str, Any] | None DEFAULT: None

add_genbank_features

add_genbank_features(
    gbk: Genbank,
    feature_type: str = "CDS",
    label_type: str | None = None,
    label_handle_func: Callable[[str], str] | None = None,
    allow_partial: bool = False,
    pseudogene: bool = False,
    labelsize: int = 15,
    labelcolor: str = "black",
    plotstyle: LiteralTypes.PLOTSTYLE = "bigarrow",
    facecolor: str = "orange",
    facecolor_handle_func: Callable[[SeqFeature], str] | None = None,
    edgecolor: str = "black",
    linewidth: float = 0,
    labelrotation: int = 45,
    labelvpos: LiteralTypes.LABELVPOS = "strand",
    labelhpos: LiteralTypes.LABELHPOS = "center",
    labelha: LiteralTypes.LABELHA = "left",
    arrow_shaft_ratio: float = 0.5,
    size_ratio: float = 1.0,
    patch_kws: dict[str, Any] | None = None,
) -> None

Add features from genbank record

PARAMETER DESCRIPTION
gbk

Genbank object

TYPE: Genbank

feature_type

Feature type (e.g. CDS,rRNA,tRNA,etc...)

TYPE: str DEFAULT: 'CDS'

label_type

Label type (e.g. gene,protein_id,product,etc...)

TYPE: str | None DEFAULT: None

label_handle_func

User defined function to handle label. Useful for filtering out unnecesary labels such as hypothetical ~~~, omitting labels with long characters, etc.

TYPE: Callable[[str], str] | None DEFAULT: None

allow_partial

If True, features that are partially included in range are also extracted

TYPE: bool DEFAULT: False

pseudogene

If True and feature_type='CDS', only add CDS features with /pseudo or /pseudogene qualifiers.

TYPE: bool DEFAULT: False

labelsize

Feature label size

TYPE: int DEFAULT: 15

labelcolor

Feature label color

TYPE: str DEFAULT: 'black'

plotstyle

Feature plot style (bigarrow|arrow|bigbox|box|bigrbox|rbox)

TYPE: str DEFAULT: 'bigarrow'

facecolor

Feature facecolor. If Genbank qualifiers has facecolor key (e.g. /facecolor="red"), facecolor key value is applied preferentially.

TYPE: str DEFAULT: 'orange'

facecolor_handle_func

User defined function to handle feature facecolor.

TYPE: Callable[[SeqFeature], str] | None DEFAULT: None

edgecolor

Feature edgecolor

TYPE: str DEFAULT: 'black'

linewidth

Feature edge linewidth

TYPE: float DEFAULT: 0

labelrotation

Feature label rotation

TYPE: int DEFAULT: 45

labelvpos

Feature label vertical position (top|center|bottom|strand) If 'strand' is set, 'top' or 'bottom' is auto selected by strand.

TYPE: str DEFAULT: 'strand'

labelhpos

Feature label horizontal position (left|center|right)

TYPE: str DEFAULT: 'center'

labelha

Feature label horizontal alignment (left|center|right)

TYPE: str DEFAULT: 'left'

arrow_shaft_ratio

Feature arrow shaft ratio

TYPE: float DEFAULT: 0.5

size_ratio

Feature size ratio to track

TYPE: float DEFAULT: 1.0

patch_kws

Patch properties (e.g. dict(fc="red", ec="black", lw=0.5, ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html

TYPE: dict[str, Any] | None DEFAULT: None

add_gff_features

add_gff_features(
    gff: Gff,
    feature_type: str = "CDS",
    parse_exon_intron: bool = False,
    label_type: str | None = None,
    label_handle_func: Callable[[str], str] | None = None,
    labelsize: int = 15,
    labelcolor: str = "black",
    plotstyle: LiteralTypes.PLOTSTYLE = "bigarrow",
    facecolor: str = "orange",
    facecolor_handle_func: Callable[[SeqFeature], str] | None = None,
    edgecolor: str = "black",
    linewidth: float = 0,
    labelrotation: int = 45,
    labelvpos: LiteralTypes.LABELVPOS = "strand",
    labelhpos: LiteralTypes.LABELHPOS = "center",
    labelha: LiteralTypes.LABELHA = "left",
    arrow_shaft_ratio: float = 0.5,
    size_ratio: float = 1.0,
    patch_kws: dict[str, Any] | None = None,
    intron_patch_kws: dict[str, Any] | None = None,
) -> None

Add features from GFF record

PARAMETER DESCRIPTION
gff

GFF object

TYPE: Gff

feature_type

Feature type (e.g. CDS,gene,mRNA,etc...)

TYPE: str DEFAULT: 'CDS'

parse_exon_intron

If True, try to parse and add exon-intron structured feature (Expected to be used for eukaryote with feature_type=mRNA|ncRNA)

TYPE: bool DEFAULT: False

label_type

Label type in attributes column (e.g. ID,Name,product,etc...)

TYPE: str | None DEFAULT: None

label_handle_func

User defined function to handle label. Useful for filtering out unnecesary labels such as hypothetical ~~~, omitting labels with long characters, etc.

TYPE: Callable[[str], str] | None DEFAULT: None

labelsize

Feature label size

TYPE: int DEFAULT: 15

labelcolor

Feature label color

TYPE: str DEFAULT: 'black'

plotstyle

Feature plot style (bigarrow|arrow|bigbox|box|bigrbox|rbox)

TYPE: str DEFAULT: 'bigarrow'

facecolor

Feature facecolor. If GFF attributes column has facecolor tag (e.g. facecolor=red;), facecolor tag value is applied preferentially.

TYPE: str DEFAULT: 'orange'

facecolor_handle_func

User defined function to handle feature facecolor.

TYPE: Callable[[SeqFeature], str] | None DEFAULT: None

edgecolor

Feature edgecolor

TYPE: str DEFAULT: 'black'

linewidth

Feature edge linewidth

TYPE: float DEFAULT: 0

labelrotation

Feature label rotation

TYPE: int DEFAULT: 45

labelvpos

Feature label vertical position (top|center|bottom|strand) If 'strand' is set, 'top' or 'bottom' is auto selected by strand.

TYPE: str DEFAULT: 'strand'

labelhpos

Feature label horizontal position (left|center|right)

TYPE: str DEFAULT: 'center'

labelha

Feature label horizontal alignment (left|center|right)

TYPE: str DEFAULT: 'left'

arrow_shaft_ratio

Feature arrow shaft ratio

TYPE: float DEFAULT: 0.5

size_ratio

Feature size ratio to track

TYPE: float DEFAULT: 1.0

patch_kws

Patch properties (e.g. dict(fc="red", ec="black", lw=0.5, ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html

TYPE: dict[str, Any] | None DEFAULT: None

intron_patch_kws

Intron patch properties (e.g. dict(ec="red", lw=0.5, ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html

TYPE: dict[str, Any] | None DEFAULT: None

add_subtrack

add_subtrack(
    name: str | None = None, ratio: float = 1.0, position: str = "below"
) -> None

Add subtrack to feature track

PARAMETER DESCRIPTION
name

Subtrack name. If None, subtrack name is automatically set.

TYPE: str | None DEFAULT: None

ratio

Subtrack size ratio to feature track

TYPE: float DEFAULT: 1.0

position

Subtrack position (above|below)

TYPE: str DEFAULT: 'below'

get_subtrack

get_subtrack(name: str) -> FeatureSubTrack

Get subtrack by name

PARAMETER DESCRIPTION
name

Target subtrack name

TYPE: str

RETURNS DESCRIPTION
subtrack

Target subtrack

TYPE: FeatureSubTrack

set_sublabel

set_sublabel(
    text: str | None = None,
    size: int = 15,
    color: str = "black",
    position: str = "bottom-left",
    ymargin: float = 0.2,
    sublabel_kws: dict[str, Any] | None = None,
) -> None

Set sublabel to feature track

PARAMETER DESCRIPTION
text

Sublabel text. If None, {start} - {end} bp label text is set.

TYPE: str | None DEFAULT: None

size

Sublabel size

TYPE: int DEFAULT: 15

color

Sublabel color

TYPE: str DEFAULT: 'black'

position

Sublabel position ([top|bottom]-[left|center|right])

TYPE: str DEFAULT: 'bottom-left'

ymargin

Sublabel y-margin

TYPE: float DEFAULT: 0.2

sublabel_kws

Text properties (e.g. dict(size=12, color="red", ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.text.html

TYPE: dict[str, Any] | None DEFAULT: None