Skip to content

Utility Class

load_prokaryote_example_file

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

Load pycirclize example Genbank or GFF file

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

List of example Genbank or GFF filename

  • enterobacteria_phage.[gbk|gff]
  • mycoplasma_alvi.[gbk|gff]
  • escherichia_coli.[gbk|gff].gz
PARAMETER DESCRIPTION
filename

Genbank or GFF filename (e.g. enterobacteria_phage.gff)

TYPE: str

cache_dir

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

TYPE: str | Path | None DEFAULT: None

overwrite_cache

If True, overwrite cache file. Assumed to be used when cache file is corrupt.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
file_path

Genbank or GFF file

TYPE: Path

load_eukaryote_example_dataset

load_eukaryote_example_dataset(
    name: str = "hg38",
    cache_dir: str | Path | None = None,
    overwrite_cache: bool = False,
) -> tuple[Path, Path, list[ChrLink]]

Load pycirclize eukaryote example dataset

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

List of dataset contents (download from UCSC)

  1. Chromosome BED file (e.g. chr1 0 248956422)
  2. Cytoband file (e.g. chr1 0 2300000 p36.33 gneg)
  3. Chromosome links (e.g. chr1 1000 4321 chr3 8000 5600)
PARAMETER DESCRIPTION
name

Dataset name (hg38|hs1|mm10|mm39)

TYPE: str DEFAULT: 'hg38'

cache_dir

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

TYPE: str | Path | None DEFAULT: None

overwrite_cache

If True, overwrite cache dataset. Assumed to be used when cache dataset is corrupt.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
chr_bed_file

BED file

TYPE: Path

cytoband_file

Cytoband file

TYPE: Path

chr_links

Chromosome links

TYPE: list[ChrLink]

load_example_tree_file

load_example_tree_file(filename: str) -> Path

Load example phylogenetic tree file

List of example tree filename

  • small_example.nwk (7 species)
  • medium_example.nwk (21 species)
  • large_example.nwk (190 species)
  • alphabet.nwk (26 species)
PARAMETER DESCRIPTION
filename

Target filename

TYPE: str

RETURNS DESCRIPTION
tree_file

Tree file (Newick format)

TYPE: Path

load_example_image_file

load_example_image_file(filename: str) -> Path

Load example image file from local package data

e.g. python_logo.png

PARAMETER DESCRIPTION
filename

Image file name

TYPE: str

RETURNS DESCRIPTION
image_file_path

Image file path

TYPE: Path

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_fetch_data = fetch_genbank_by_accid("NC_002483")
>>> gbk = Genbank(gbk_fetch_data)

calc_group_spaces

calc_group_spaces(
    groups: list[int],
    *,
    space_bw_group: float = 15,
    space_in_group: float = 2,
    endspace: bool = True
) -> list[float]

Calculate spaces between/within groups

This function can be used to easily calculate the space size when data is separated into multiple groups for display. For example, to set up a space to divide [A, B, C, D, E, F, G, H, I, J] into three groups such as [(A, B, C, D), (E, F, G), (H, I, J)], set groups=[4, 3, 3].

PARAMETER DESCRIPTION
groups

List of each group number (e.g. [4, 3, 3])

TYPE: list[int]

space_bw_group

Space size between group

TYPE: float DEFAULT: 15

space_in_group

Space size within group

TYPE: float DEFAULT: 2

endspace

If True, insert space after the end group

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
spaces

Spaces between/within groups

TYPE: list[float]

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()

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]