PyPLogo
PyPLogo 是面向蛋白质二级结构与多序列比对的 Python 可视化工具,提供紧凑、现代、适合论文排版的结构符号,并保留对布局、颜色、图例和生物学标注的细粒度控制。
PyPLogo is a Python toolkit for publication-ready visualization of protein secondary structures and multiple-sequence alignments. It combines compact modern structure glyphs with fine control over layout, colors, legends, and biological annotations.
核心能力 / Highlights
-
绘制单条蛋白序列及其 DSSP 二级结构。
-
在多序列比对中选择任意一条序列作为二级结构参考。
-
螺旋使用拼接菱形块,beta 折叠使用扁平箭头,转角使用
T、TT或TTT。 -
默认显示主要结构
H/G/I/E/T;可选完整模式显示 bend 和 coil。 -
支持二硫键、抗体结合表位、保守性底色、残基编号和多行换行。
-
可调字体、行距、结构间距、颜色、图例、标记、注释轨道和画布尺寸。
-
通过 Matplotlib 导出高分辨率 PNG、矢量 SVG 或 PDF。
-
Visualize a single protein sequence with DSSP secondary-structure assignments.
-
Select any aligned sequence as the secondary-structure reference.
-
Show faceted helix glyphs, flat beta-strand arrows, and compact turn labels.
-
Annotate disulfide bonds, antibody epitopes, conservation, and residue numbers.
-
Export publication-ready raster or vector figures through Matplotlib.
安装 / Installation
pip install -U pyplogo
PyPI 包要求 Python 3.10 或更高版本。使用 PDB/mmCIF 的 DSSP 自动提取功能时,系统还需要可用的 mkdssp/DSSP 可执行程序。
The PyPI package requires Python 3.10 or later. Structure extraction from PDB/mmCIF files additionally requires an available mkdssp/DSSP executable.
单序列快速开始 / Single Sequence
from pyplogo import SecondaryStructureVisualizer
sequence = "ACDEFGHIKLMNPQRSTVWY"
secondary_structure = "CCHHHHHCTTTEEEECCCCC"
visualizer = SecondaryStructureVisualizer(row_length=50)
figure = visualizer.create_figure(
sequence=sequence,
secondary_structure=secondary_structure,
title="Protein secondary structure",
show_residue_numbers=True,
)
figure.savefig("secondary_structure.svg", bbox_inches="tight")
sequence 与 secondary_structure 必须等长。PyPLogo 使用 DSSP 字母:H、G、I、E、T、S,coil 使用 C。
sequence and secondary_structure must have the same length. PyPLogo accepts the DSSP codes H, G, I, E, T, and S, with C for coil.
多序列比对 / Multiple-Sequence Alignment
PyPLogo 接收已经对齐且长度相同的序列;它负责绘图,不负责执行序列比对。gap 可以写作 - 或 .。
PyPLogo draws an existing equal-length alignment; it does not run the alignment algorithm. Gaps may be written as - or ..
from pyplogo import SecondaryStructureVisualizer
alignment = {
"Reference": "MKTAC-DEFGHCIKLMNPQ",
"Homolog_A": "MKTACRDEYGHCIKLMNPQ",
"Homolog_B": "MRTAC-DEFGHCVKLMNPQ",
}
visualizer = SecondaryStructureVisualizer(
colors={
"H": "#39A96B",
"G": "#D982AA",
"I": "#6878C9",
"E": "#D7A354",
"T": "#8F7CC3",
"structure_label": "#9A642D",
"background": "#FFFFFF",
}
)
figure = visualizer.create_alignment_figure(
alignment=alignment,
structure_sequence="Reference",
# Ungapped Reference length: 18 residues
secondary_structure="CCCHHHHTTTEEEECCCC",
structure_label="Reference structure",
amino_acids_per_line=60,
structure_mode="major",
sequence_colors={
"Reference": "#A96D2D",
"Homolog_A": "#59636F",
"Homolog_B": "#7568B3",
},
disulfide_bonds=[(5, 11)],
epitope_annotations={
"Antibody A epitope": [5, 6, 7],
"Antibody B epitope": [9, 10, 11],
"Antibody C epitope": [12, 13, 14],
},
epitope_colors={
"Antibody A epitope": "#8CB9DC",
"Antibody B epitope": "#D59A9A",
"Antibody C epitope": "#A8C565",
},
show_legend=True,
legend_position="bottom",
)
figure.savefig("alignment.svg", bbox_inches="tight")
figure.savefig("alignment.png", dpi=600, bbox_inches="tight")
secondary_structure 可以使用所选参考序列的无 gap 长度,也可以使用完整比对长度。二硫键和表位位置均使用所选参考序列的 1-based 无 gap 残基编号。
secondary_structure may follow either the selected sequence's ungapped length or the full alignment length. Disulfide and epitope positions use 1-based ungapped residue coordinates from the selected reference sequence.
结构符号 / Structure Glyphs
| Code | DSSP structure | PyPLogo representation |
|---|---|---|
H |
alpha-helix | 绿色拼接菱形块 / green interlocking facets |
G |
3_10-helix | 粉色拼接菱形块 / pink interlocking facets |
I |
pi-helix | 蓝紫色拼接菱形块 / blue-violet interlocking facets |
E |
beta-strand | 扁平箭头 / flat arrow |
T |
hydrogen-bonded turn | T、TT、TTT |
S |
bend | 折线,仅完整模式显示 / bend line, full mode only |
C |
coil | 细横线,仅完整模式显示 / thin line, full mode only |
T、TT 和 TTT 对应连续 1、2、3 个或更多 turn 残基。默认 structure_mode="major" 显示 H/G/I/E/T;设置 structure_mode="all" 后额外显示 S/C 和 gap 连接符。
T, TT, and TTT represent runs of one, two, or at least three turn residues. The default structure_mode="major" shows H/G/I/E/T; structure_mode="all" additionally shows bends, coils, and gap connectors.
自定义参数 / Customization
| Category | Frequently used parameters |
|---|---|
| Reference and wrapping | structure_sequence, structure_label, amino_acids_per_line, figsize |
| Typography and spacing | sequence_font_size, label_font_size, sequence_pitch, structure_offset |
| Structure display | structure_mode, constructor colors (H/G/I/E/T/S/C, labels, background) |
| Conservation | show_conservation, conservation_threshold, conservation_full_color, conservation_partial_color |
| Residue scaffolding | show_residue_numbers, sequence_colors |
| Structure legend | show_legend, legend_position, legend_columns, legend_font_size |
| Disulfides | disulfide_bonds, show_disulfide_bonds, colors, line length/width, label and line offsets |
| Epitope tracks | epitope_annotations, epitope_colors, marker type/size, legend position/columns |
| Annotation layout | annotation_offset, annotation_track_spacing |
The defaults provide the base publication style; every group above can be overridden per figure without changing the renderer.
PDB/mmCIF 提取 / Structure Extraction
from pyplogo.extractors.structure_based import StructureExtractor
from pyplogo import SecondaryStructureVisualizer
data = StructureExtractor().from_pdb("protein.pdb", chain_id="A")
visualizer = SecondaryStructureVisualizer()
figure = visualizer.create_figure(
sequence=data.sequence,
secondary_structure=data.secondary_structure,
disulfide_bonds=data.disulfide_bonds,
title="Chain A",
)
figure.savefig("chain_A.pdf", bbox_inches="tight")
from_cif("protein.cif", chain_id="A") 提供相同的 mmCIF 工作流。
Links
- GitHub: https://github.com/SLF1303/pyplogo-toolkit
- PyPI: https://pypi.org/project/pyplogo/
- Issues: https://github.com/SLF1303/pyplogo-toolkit/issues
PyPLogo is released under the MIT License.
Metadata
Release files for pyplogo 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyplogo-0.1.7.tar.gz | 48.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyplogo-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 94.0 kB
Release files / pyplogo-0.1.7.tar.gz
| Download URL | pyplogo-0.1.7.tar.gz |
|---|---|
| Size | 48.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d38798d3d253745b374518839d1d67cf33147c14746e463c05731f68c80d4399
|
|
BLAKE2b-256 checksum How to use checksums |
f307d77f34a2512c128e60d32bec5dd01dff24816c9e29e0f9ffb4662e200d8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Release files / pyplogo-0.1.7-py3-none-any.whl
| Download URL | pyplogo-0.1.7-py3-none-any.whl |
|---|---|
| Size | 46.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ded2d4fabd8e9b91e1624032e9f26ac2023d32b195c8a9d91b5739c697700f1
|
|
BLAKE2b-256 checksum How to use checksums |
ba163690dbc570b5b0b5f712f12f0dd7eb85a735960859fa7a846e4d758a7868
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|