csdb2snfg
Convert CSDB linear notation to SNFG (Symbol Nomenclature for Glycans) diagrams.
Features
- Parse CSDB linear strings into structured AST (JSON output)
- Render SNFG diagrams as PNG/SVG images
- Export PowerPoint (PPTX) with vector shapes
- Supports branching, repeating units (
/n=N/), modifiers (Me, Ac)
Current Limitations
- Only standard CSDB syntax and
repeat=nare supported. Fuzzy/XOR alternatives (<...|...>,<<...|...>>) are not yet supported. - Only orthogonal (horizontal/vertical) chain layout is supported. Diagonal or angled linkages are not available.
Installation
From PyPI (stable):
pip install glyco-csdb2snfg
From source (development):
pip install git+https://github.com/sosyphe/glyco-csdb2snfg.git
Quick Start
# Render to PNG
csdb2snfg image -c="-4)βDGlcp(1-4)βDGlcp(1-4)αDGlcp(1-" --format png -o output/
# Export to PowerPoint
csdb2snfg pptx -c="-4)βDGalp(1-4)βDGalp(1-3)αDGalp(1-" -o output/
# Parse to JSON AST
csdb2snfg parse -c="-4)βDGlcp(1-4)αDGlcp(1-"
# Batch processing (one CSDB string per line, # for comments)
csdb2snfg image -f glycans.txt --format png -o output/
Note: Use
-c="..."(with=) to prevent argparse from treating the leading-as a flag.
Python API
from csdb2snfg import parse_csdb_linear, draw_snfg, generate_snfg_pptx
tree = parse_csdb_linear("-4)βDGlcp(1-4)αDGlcp(1-")
# Render to matplotlib figure
fig, ax = draw_snfg(tree)
fig.savefig("glycan.png", dpi=300, bbox_inches="tight")
# Save SVG directly
draw_snfg(tree, save_svg="glycan.svg")
# Export to PowerPoint
buf = generate_snfg_pptx(["-4)βDGlcp(1-4)αDGlcp(1-"])
with open("glycans.pptx", "wb") as f:
f.write(buf.read())
Examples
Simple linear chain
-4)βDGlcp(1-4)βDGlcp(1-4)βDGlcp(1-4)αDGlcp(1-
Branched N-Glycan core
-4)[βDGalp(1-6)]αDManp(1-4)[βDGalp(1-3)]αDManp(1-4)βDGlcNAcp(1-4)βDGlcNAcp(1-
Repeating unit (/n=3/)
-4)βDGalp(1-4)/βDGalp(1-4)/n=3/βDGalp(1-4)αDGlcp(1-
With modifiers (Me, Ac)
-4)[Me(1-3)]αDGalp(1-6)[Ac(1-3)]αDGalp(1-6)αDGalp(1-
Complex multi-branched
-3)[[αDGalp(1-6)]αLArap(1-3)αLAraf(1-6)]βDGalp(1-3)[Me(1-4)βDGalp(1-4)βDGalp(1-6)]βDGalp(1-3)[αLAraf(1-4)βDXylp(1-6)]βDGalp(1-3)[αLAraf(1-4)βDManp(1-6)]βDGalp(1-3)βDGalp(1-3)βDGlcp(1-
License
MIT License - see LICENSE for details.
Metadata
Release files for glyco-csdb2snfg 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| glyco_csdb2snfg-0.1.0.tar.gz | 22.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| glyco_csdb2snfg-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 46.0 kB
Release files / glyco_csdb2snfg-0.1.0.tar.gz
| Download URL | glyco_csdb2snfg-0.1.0.tar.gz |
|---|---|
| Size | 22.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
966f476760db502110b23b172220fa794c42f7aabe9b4b6a61c1e332e546ad47
|
|
BLAKE2b-256 checksum How to use checksums |
173cc3ff86bf8678248eddd9237202925d86988e875247eabfc82ec5bae0bd37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.
Transparency logRelease files / glyco_csdb2snfg-0.1.0-py3-none-any.whl
| Download URL | glyco_csdb2snfg-0.1.0-py3-none-any.whl |
|---|---|
| Size | 23.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b61632fe5f81537dc1ddb00e4c379f80a456aa2be8afbb7eaf68b2d55f48dd8
|
|
BLAKE2b-256 checksum How to use checksums |
9904291ef137ce5d40602f824b67a0250384341617a07a405ed17ecd3dfa04dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.
Transparency log