https://github.com/bojarlab/glycorender

Bespoke renderer for GlycoDraw .svg into .pdf/.png

https://github.com/bojarlab/glycorender

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.4%) to scientific vocabulary

Keywords

glycans glycoinformatics pdf renderer svg
Last synced: 5 months ago · JSON representation

Repository

Bespoke renderer for GlycoDraw .svg into .pdf/.png

Basic Info
  • Host: GitHub
  • Owner: BojarLab
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 215 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
glycans glycoinformatics pdf renderer svg
Created 11 months ago · Last pushed 9 months ago
Metadata Files
Readme License

README.md

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

bash pip install glycorender

Quick Start

```python from glycorender import convertsvgtopdf, convertsvgtopng

Convert SVG file to PDF

with open('glycanstructure.svg', 'r') as f: svgdata = f.read()

convertsvgtopdf(svgdata, 'output.pdf')

Convert SVG file to PNG

convertsvgtopng(svgdata, 'output.png')

Or directly from SVG data

svgdata = """...""" convertsvgtopdf(svgdata, 'output.pdf') convertsvgtopng(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

  • ReportLab: For PDF generation
  • PyMuPDF: For PNG conversion
  • Pillow: For PNG metadata injection

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.

Owner

  • Name: BojarLab
  • Login: BojarLab
  • Kind: organization
  • Email: daniel.bojar@gu.se
  • Location: Gothenburg, Sweden

Machine Learning in Glycobiology and Systems Biology

GitHub Events

Total
  • Release event: 6
  • Push event: 13
  • Create event: 9
Last Year
  • Release event: 6
  • Push event: 13
  • Create event: 9

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 581 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 8
  • Total maintainers: 1
pypi.org: glycorender

A bespoke SVG to PDF/PNG renderer for the GlycoDraw platform

  • Versions: 8
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 581 Last month
Rankings
Dependent packages count: 9.4%
Average: 31.2%
Dependent repos count: 53.0%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/python-publish.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
pyproject.toml pypi
  • reportlab >=3.6.0