Utility Functions and Classes
Dataset utilities
pycirclizely.utils.fetch_genbank_by_accid
fetch_genbank_by_accid(
accid: str,
gbk_outfile: Union[str, Path, None] = None,
email: Union[str, None] = None,
) -> TextIO
Fetch genbank text by Accession ID
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
accid
|
str
|
Accession ID. |
required |
gbk_outfile
|
Union[str, Path, None]
|
If file path is set, write fetch data to file. |
None
|
email
|
Union[str, None]
|
Email address to notify download limitation (Required for bulk download). |
None
|
pycirclizely.utils.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):
- Chromosome BED file (e.g.
chr1 0 248956422
) - Cytoband file (e.g.
chr1 0 2300000 p36.33 gneg
) - Chromosome links (e.g.
chr1 1000 4321 chr3 8000 5600
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Dataset name ( |
'hg38'
|
cache_dir
|
str | Path | None
|
Output cache directory (Default: |
None
|
overwrite_cache
|
bool
|
If True, overwrite cache dataset. Assumed to be used when cache dataset is corrupt. |
False
|
pycirclizely.utils.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
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
Genbank or GFF filename (e.g. |
required |
cache_dir
|
str | Path | None
|
Output cache directory (Default: |
None
|
overwrite_cache
|
bool
|
If True, overwrite cache file. Assumed to be used when cache file is corrupt. |
False
|
pycirclizely.utils.load_example_tree_file
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)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
Target filename. |
required |
Color utilities
pycirclizely.utils.ColorCycler
Color cycler that manages color selection from palettes.
The cycler can work in two modes: 1. Automatic cycling: When no index is provided, it remembers the last position in the palette and returns the next color each time (reset with reset_cycle()) 2. Indexed access: When an index is provided, it returns the color at that position (modulo the palette length) without affecting the cycle position.
For sequential palettes, colors are distributed evenly across the available range.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
palette
|
Union[str, list[str]]
|
Name of the palette to use or list of color strings. |
'Plotly'
|
palette_type
|
Optional[Type]
|
Either QUALITATIVE or SEQUENTIAL. Required for custom color lists, optional for built-in palettes. |
None
|
Methods:
Name | Description |
---|---|
get_color |
Get a color from the palette. |
get_colors |
Get multiple colors from the palette. |
reset_cycle |
Reset the automatic color cycle to the beginning of the palette. |
set_palette |
Change the current color palette. |
Attributes
Functions
get_color
Get a color from the palette.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index
|
Optional[int]
|
Optional position in the palette. If None, returns the next color in the automatic cycle sequence. |
None
|
get_colors
Get multiple colors from the palette.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
Number of colors to return. Must be positive. |
required |
set_palette
Change the current color palette.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
palette
|
Union[str, list[str]]
|
Either a palette name or list of color strings. |
required |
palette_type
|
Optional[Type]
|
Either QUALITATIVE or SEQUENTIAL. Required for custom color lists, optional for built-in palettes. |
None
|
pycirclizely.utils.parse_color
Convert css, hex (including 8-digit with alpha), or named colors into an rgb/rgba string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color
|
str
|
A string representing the color in CSS, hex, or named format. |
required |
Helper functions
pycirclizely.utils.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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
groups
|
list[int]
|
List of each group number (e.g., |
required |
space_bw_group
|
float
|
Space size between groups. |
15
|
space_in_group
|
float
|
Space size within groups. |
2
|
endspace
|
bool
|
If True, insert space after the end group. |
True
|