Skip to main content

glycorender Logo

glycorender

A bespoke SVG to PDF/PNG renderer for the GlycoDraw platform, specialized in accurately rendering glycan structures with support for chemical notations and path-based text positioning.

PyPI version Python Version License

Features

  • Accurate SVG to PDF and PNG conversion for glycan structures
  • Support for text on paths with proper positioning and orientation
  • Special handling for monosaccharide properties like "Df" with proper styling
  • Gradient fills for circles and shapes
  • Precise connection path rendering between glycan elements
  • Support for various SVG path commands

Installation

pip install glycorender

Quick Start

from glycorender import convert_svg_to_pdf, convert_svg_to_png

# Convert SVG file to PDF
with open('glycan_structure.svg', 'r') as f:
    svg_data = f.read()
    
convert_svg_to_pdf(svg_data, 'output.pdf')

# Convert SVG file to PNG
convert_svg_to_png(svg_data, 'output.png')

# Or directly from SVG data
svg_data = """..."""
convert_svg_to_pdf(svg_data, 'output.pdf')
convert_svg_to_png(svg_data, 'output.png')

Use Cases

GlycoRender is specifically designed for:

  • Converting glycan structure diagrams from GlycoDraw to publication-quality PDFs or PNGs
  • Preserving the exact layout and styling of complex carbohydrate representations
  • Ensuring chemical notations are properly formatted in the output
  • Maintaining the correct connections between monosaccharide units

API Reference

convert_svg_to_pdf(svg_data, pdf_file_path)

Converts SVG data to a PDF file.

Parameters:

  • svg_data (str or bytes): SVG content either as a string or bytes
  • pdf_file_path (str): Path where the output PDF should be saved

convert_svg_to_png(svg_data, png_file_path)

Converts SVG data to a PNG file.

Parameters:

  • svg_data (str or bytes): SVG content either as a string or bytes
  • png_file_path (str): Path where the output PNG should be saved

Supported SVG Elements

  • <path>: Full support for path commands (M, L, H, V, Z, etc.)
  • <circle>: Support for basic circles and gradient-filled circles
  • <rect>: Support for rectangles with stroke and fill
  • <text> and <textPath>: Support for text placement along paths with proper orientation
  • <defs>: Support for path and gradient definitions
  • <radialGradient>: Support for radial gradients with stops

Dependencies

  • PyMuPDF (optional): For PNG conversion

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glycorender-0.3.1.tar.gz (129.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

glycorender-0.3.1-py3-none-any.whl (128.6 kB view details)

Uploaded Python 3

File details

Details for the file glycorender-0.3.1.tar.gz.

File metadata

  • Download URL: glycorender-0.3.1.tar.gz
  • Upload date:
  • Size: 129.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for glycorender-0.3.1.tar.gz
Algorithm Hash digest
SHA256 9849cf14d1f154c923c77eb44f8094045c3ba7ec3a9e8f8eea6590cfe8223524
MD5 24da54cfb95fe0998f2fa416f5648d80
BLAKE2b-256 2627ea8f26b8dfee76a5b149ebe52a2aecff012c45d264ad5d4678e6fa59a39c

See more details on using hashes here.

Provenance

The following attestation bundles were made for glycorender-0.3.1.tar.gz:

Publisher: python-publish.yml on BojarLab/glycorender

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file glycorender-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: glycorender-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 128.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for glycorender-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ece651bd072af34dcef73aecfaedb696a31f8e7dc42691e3054321cecee1c25c
MD5 64ac4325506b28898a2d00eacd95602c
BLAKE2b-256 e9eb2b79d4404340d0b0a038d013d45aecef2637487fd042fdf32b02859e8bc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for glycorender-0.3.1-py3-none-any.whl:

Publisher: python-publish.yml on BojarLab/glycorender

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.4.0

2 files

This release

0.3.1 This release

2 files

0.3.0

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page