Skip to content

utils

utils

ColorCycler

Color Cycler Class

__new__

__new__(n: int | None = None) -> str

Get hexcolor cyclically from cmap by counter or user specified number

ColorCycler() works same as ColorCycler.get_color() (syntactic sugar)

PARAMETER DESCRIPTION
n

Number for color cycle. If None, counter class variable is used.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
hexcolor

Cyclic hexcolor string

TYPE: str

reset_cycle classmethod

reset_cycle() -> None

Reset cycle counter

set_cmap classmethod

set_cmap(name: str) -> None

Set colormap (Default: tab10)

get_color classmethod

get_color(n: int | None = None) -> str

Get hexcolor cyclically from cmap by counter or user specified number

PARAMETER DESCRIPTION
n

Number for color cycle. If None, counter class variable is used.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
hexcolor

Cyclic hexcolor string

TYPE: str

get_color_list classmethod

get_color_list(n: int | None = None) -> list[str]

Get hexcolor list of colormap

PARAMETER DESCRIPTION
n

If n is None, all(=cmap.N) hexcolors are extracted from colormap. If n is specified, hexcolors are extracted from n equally divided colormap.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
hexcolor_list

Hexcolor list

TYPE: list[str]

fetch_genbank_by_accid

fetch_genbank_by_accid(
    accid: str, gbk_outfile: str | Path | None = None, email: str | None = None
) -> TextIOWrapper

Fetch genbank text by 'Accession ID'

PARAMETER DESCRIPTION
accid

Accession ID

TYPE: str

gbk_outfile

If file path is set, write fetch data to file

TYPE: str | Path | None DEFAULT: None

email

Email address to notify download limitation (Required for bulk download)

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
TextIOWrapper

Genbank data

Examples:

>>> gbk_text = fetch_genbank_by_accid("NC_013600")
>>> gbk = Genbank(gbk_text)

load_example_genbank_dataset

load_example_genbank_dataset(
    name: GenbankDatasetName,
    *,
    cache_dir: str | Path | None = None,
    overwrite_cache: bool = False,
    quiet: bool = True
) -> list[Path]

Load pygenomeviz example genbank dataset

Load genbank datasets from https://github.com/moshi4/pygenomeviz-data-v1 and cache datasets in local directory (Default: ~/.cache/pygenomeviz/).

List of dataset name

  • acinetobacter_phage (4 species)
  • yersinia_phage (4 species)
  • enterobacteria_phage (6 species)
  • mycoplasma_mycoides (4 species)
  • escherichia_coli (4 species, gzip compressed)
  • saccharomyces (3 species, gzip compressed)
PARAMETER DESCRIPTION
name

Dataset name (e.g. enterobacteria_phage)

TYPE: str

cache_dir

Output cache directory (Default: ~/.cache/pygenomeviz/)

TYPE: str | Path | None DEFAULT: None

overwrite_cache

If True, overwrite cached dataset

TYPE: bool DEFAULT: False

quiet

If True, no print log on screen.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
gbk_files

Genbank files

TYPE: list[Path]

load_example_gff_file

load_example_gff_file(
    filename: GffExampleFileName,
    *,
    cache_dir: str | Path | None = None,
    overwrite_cache: bool = False
) -> Path

Load pygenomeviz example GFF file

Load example GFF file from https://github.com/moshi4/pygenomeviz-data-v1/ and cache GFF file in local directory (Default: ~/.cache/pygenomeviz/).

List of example GFF filename

  • enterobacteria_phage.gff
  • mycoplasma_mycoides.gff
  • escherichia_coli.gff.gz
  • saccharomyces_cerevisiae.gff.gz
PARAMETER DESCRIPTION
filename

GFF filename (e.g. enterobacteria_phage.gff)

TYPE: str

cache_dir

Output cache directory (Default: ~/.cache/pygenomeviz/)

TYPE: str | Path | None DEFAULT: None

overwrite_cache

If True, overwrite cached GFF file

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
gff_file

GFF file

TYPE: Path

extract_features_within_range

extract_features_within_range(
    features: list[SeqFeature], *, target_range: tuple[int, int]
) -> list[SeqFeature]

Extract features by target range

PARAMETER DESCRIPTION
features

Features to be extracted

TYPE: list[SeqFeature]

target_range

Target range

TYPE: tuple[int, int]

RETURNS DESCRIPTION
range_features

Features within target range

TYPE: list[SeqFeature]

interpolate_color

interpolate_color(base_color: str, v: float, vmin: float = 0, vmax: float = 100) -> str

Interpolate the base color between vmin and vmax

vmin[nearly white] <= v <= vmax[base_color]

PARAMETER DESCRIPTION
base_color

Base color for interpolation

TYPE: str

v

Interpolation value

TYPE: float

vmin

Min value

TYPE: float DEFAULT: 0

vmax

Max value

TYPE: float DEFAULT: 100

RETURNS DESCRIPTION
interpolate_color

Interpolated hexcolor

TYPE: str

is_pseudo_feature

is_pseudo_feature(feature: SeqFeature) -> bool

Check target feature is pseudo or not from qualifiers tag

PARAMETER DESCRIPTION
feature

Target feature

TYPE: SeqFeature

RETURNS DESCRIPTION
check_result

pseudo check result

TYPE: bool