Skip to content

FeatureSegment Class

FeatureSegment

FeatureSegment(name: str, start: int, end: int, feature_track: FeatureTrack)

Feature Segment Class

PARAMETER DESCRIPTION
name

Segment name

TYPE: str

start

Segment start position

TYPE: int

end

Segment end position

TYPE: int

feature_track

Parent feature track

TYPE: FeatureTrack

name property

name: str

Segment name

start property

start: int

Segment start position

end property

end: int

Segment end position

range property

range: tuple[int, int]

Segment (start, end) range

size property

size: int

Segment size

feature_track property

feature_track: FeatureTrack

Parent feature track

track_start property

track_start: int

Segment start position in track

track_end property

track_end: int

Segment end position in track

gid2feature_dict property

gid2feature_dict: dict[str, dict[str, Any]]

gid & feature dict (Sort by start coordinate)

transform_features property

transform_features: list[SeqFeature]

Coordinate transformed features

Segment-level coordinate is transformed to track-level coordinate.

transform_exon_features property

transform_exon_features: list[SeqFeature]

Coordinate transformed exon features

Segment-level coordinate is transformed to track-level coordinate.

transform_text_kws_list property

transform_text_kws_list: list[dict[str, Any]]

Coordinate transformed text keywords list

is_within_range

is_within_range(pos: int | tuple[int, int]) -> bool

Check target pos is within segment range

transform_coord

transform_coord(x: int | float | NDArray) -> int | float | NDArray[np.float64]

Transform segment-level coordinate to track-level coordinate

PARAMETER DESCRIPTION
x

Segment level coordinate(s)

TYPE: int | float | NDArray

RETURNS DESCRIPTION
track_coord

Track level coordinate(s)

TYPE: int | float | NDArray[float64]

add_text

add_text(
    x: float,
    text: str,
    *,
    size: float = 12,
    vpos: VPos = "top",
    hpos: HPos = "left",
    ymargin: float = 0.2,
    rotation: float = 45,
    **kwargs
) -> None

Add text

PARAMETER DESCRIPTION
x

Text x coordinate

TYPE: float

text

Text content

TYPE: str

size

Text size

TYPE: float DEFAULT: 12

vpos

Vertical position (top|center|bottom)

TYPE: str DEFAULT: 'top'

hpos

Horizontal position (left|center|right)

TYPE: str DEFAULT: 'left'

ymargin

Y margin

TYPE: float DEFAULT: 0.2

rotation

Text rotation

TYPE: float DEFAULT: 45

**kwargs

TYPE: dict DEFAULT: {}

add_sublabel

add_sublabel(
    text: str | None = None,
    *,
    size: float = 12,
    pos: str = "bottom-left",
    ymargin: float = 0.2,
    rotation: float = 0,
    **kwargs
) -> None

Add sublabel

PARAMETER DESCRIPTION
text

Text content. If None, {start:,} - {end:,} bp label is set.

TYPE: str | None DEFAULT: None

size

Text size

TYPE: float DEFAULT: 12

pos

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

TYPE: str DEFAULT: 'bottom-left'

ymargin

Y margin

TYPE: float DEFAULT: 0.2

rotation

Text rotation

TYPE: float DEFAULT: 0

**kwargs

segment.add_text() method keyword arguments (e.g. color="red", ...)

TYPE: dict DEFAULT: {}

add_feature

add_feature(
    start: int,
    end: int,
    strand: int = 1,
    *,
    plotstyle: PlotStyle = "arrow",
    arrow_shaft_ratio: float = 0.5,
    extra_tooltip: dict[str, str] | None = None,
    label: str = "",
    text_kws: dict[str, Any] | None = None,
    **kwargs
) -> None

Add feature

PARAMETER DESCRIPTION
start

Start position

TYPE: int

end

End position

TYPE: int

strand

Feature strand

TYPE: int DEFAULT: 1

plotstyle

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

TYPE: PlotStyle DEFAULT: 'arrow'

arrow_shaft_ratio

Arrow shaft size ratio

TYPE: float DEFAULT: 0.5

extra_tooltip

Extra tooltip dict for html figure

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

label

Feature label text

TYPE: str DEFAULT: ''

text_kws

segment.add_text() method keyword arguments (e.g. dict(size=12, color="red", ...))

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

**kwargs

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

TYPE: dict DEFAULT: {}

add_features

add_features(
    features: SeqFeature | list[SeqFeature],
    *,
    plotstyle: PlotStyle = "arrow",
    arrow_shaft_ratio: float = 0.5,
    label_type: str | None = None,
    label_handler: Callable[[str], str] | None = None,
    extra_tooltip: dict[str, str] | None = None,
    ignore_outside_range: bool = False,
    text_kws: dict[str, Any] | None = None,
    **kwargs
) -> None

Add features (BioPython SeqFeature)

PARAMETER DESCRIPTION
features

BioPython SeqFeature or SeqFeature list

TYPE: SeqFeature | list[SeqFeature]

plotstyle

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

TYPE: PlotStyle DEFAULT: 'arrow'

arrow_shaft_ratio

Arrow shaft size ratio

TYPE: float DEFAULT: 0.5

label_type

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

TYPE: str | None DEFAULT: None

label_handler

Label handler function to customize label display. If None, set label handler to exclude labels containing hypothetical.

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

extra_tooltip

Extra tooltip dict for html figure

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

ignore_outside_range

If True and the feature position is outside the range of the track segment, ignore it without raising an error.

TYPE: bool DEFAULT: False

text_kws

segment.add_text() method keyword arguments (e.g. dict(color="red", ...))

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

**kwargs

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

TYPE: dict DEFAULT: {}

add_exon_feature

add_exon_feature(
    locs: list[tuple[int, int]],
    strand: int = 1,
    *,
    plotstyle: PlotStyle = "arrow",
    arrow_shaft_ratio: float = 0.5,
    label: str = "",
    patch_kws: dict[str, Any] | None = None,
    intron_patch_kws: dict[str, Any] | None = None,
    text_kws: dict[str, Any] | None = None
) -> None

Add exon feature

PARAMETER DESCRIPTION
locs

Exon locations (e.g. [(0, 100), (200, 300), (350, 400)])

TYPE: list[tuple[int, int]]

strand

Feature strand

TYPE: int DEFAULT: 1

plotstyle

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

TYPE: PlotStyle DEFAULT: 'arrow'

arrow_shaft_ratio

Arrow shaft size ratio

TYPE: float DEFAULT: 0.5

label

Feature label

TYPE: str DEFAULT: ''

patch_kws

Exon patch properties (e.g. dict(fc="red", lw=0.5, hatch="//", ...)) 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(color="red", lw=2.0, ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html

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

text_kws

segment.add_text() method keyword arguments (e.g. dict(size=12, color="red", ...))

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

add_exon_features

add_exon_features(
    features: SeqFeature | list[SeqFeature],
    *,
    plotstyle: PlotStyle = "arrow",
    arrow_shaft_ratio: float = 0.5,
    label_type: str | None = None,
    label_handler: Callable[[str], str] | None = None,
    extra_tooltip: dict[str, str] | None = None,
    ignore_outside_range: bool = False,
    patch_kws: dict[str, Any] | None = None,
    intron_patch_kws: dict[str, Any] | None = None,
    text_kws: dict[str, Any] | None = None
) -> None

Add exon features (BioPython SeqFeature)

PARAMETER DESCRIPTION
features

BioPython SeqFeature or SeqFeature list

TYPE: SeqFeature | list[SeqFeature]

plotstyle

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

TYPE: PlotStyle DEFAULT: 'arrow'

arrow_shaft_ratio

Arrow shaft size ratio

TYPE: float DEFAULT: 0.5

label_type

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

TYPE: str | None DEFAULT: None

label_handler

Label handler function to customize label display. If None, set label handler to exclude labels containing hypothetical.

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

extra_tooltip

Extra tooltip dict for html figure

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

ignore_outside_range

If True and the feature position is outside the range of the track segment, ignore it without raising an error.

TYPE: bool DEFAULT: False

patch_kws

Exon patch properties (e.g. dict(fc="red", lw=0.5, hatch="//", ...)) 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(color="red", lw=2.0, ...)) https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html

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

text_kws

segment.add_text() method keyword arguments (e.g. dict(size=12, color="red", ...))

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