Skip to main content

Parse HELM strings into RDKit molecules

Project description

helmkit

A Python library for converting HELM (Hierarchical Editing Language for Macromolecules) notation to RDKit molecules.

Table of Contents

Basic Usage

from helmkit import Molecule

# Create a molecule from a HELM string
helm_string = "PEPTIDE1{A.R.G}$$$$"
molecule = Molecule(helm_string)

# Access the RDKit molecule object
rdkit_mol = molecule.mol

Installation

To install helmkit, you can use either uv or pip.

With uv

uv pip install helmkit

or if you have added it as a dependency to your pyproject.toml:

uv add helmkit

Without uv

pip install helmkit

Quick Example

from helmkit import Molecule
from rdkit.Chem import AllChem, Draw

# Create a simple tripeptide (Ala-Arg-Gly)
molecule = Molecule("PEPTIDE1{A.R.G}$$$$")

# Generate 2D coordinates for visualization
AllChem.Compute2DCoords(molecule.mol)

# Save the image
img = Draw.MolToImage(molecule.mol)
img.save("tripeptide.png")

Understanding HELM Notation

HELM (Hierarchical Editing Language for Macromolecules) is a notation for representing complex biomolecules. A basic HELM string has the following format:

PEPTIDE1{A.R.G}|PEPTIDE2{S.G.C}$PEPTIDE1,PEPTIDE2,1:R1-3:R3$$$V2.0

Where:

  • PEPTIDE1{A.R.G} defines the first chain (a peptide with amino acids A, R, G)
  • PEPTIDE2{S.G.C} defines the second chain
  • PEPTIDE1,PEPTIDE2,1:R1-3:R3 defines a connection between the chains (R1 of residue 1 in PEPTIDE1 connects to R3 of residue 3 in PEPTIDE2)
  • $ characters separate different sections of the HELM string

Using Custom Monomer Data

By default, helmkit uses the monomer data in helmkit/data/monomers.sdf. To use a custom SDF file:

from helmkit import Molecule, load_monomer_library

# Load your custom monomer data
custom_sdf_path = "/path/to/your/custom_monomers.sdf"
custom_monomers = load_monomer_library(custom_sdf_path)

# Create molecule with custom monomer data
molecule = Molecule("PEPTIDE1{A.R.G}$$$$", monomer_df=custom_monomers)

SDF File Structure Requirements

The SDF file containing monomer data must have the following properties for each molecule:

Required Properties:

  • symbol: A unique identifier for the monomer (e.g., "A" for alanine)
  • m_RgroupIdx: Comma-separated list of R-group atom indices (e.g., "1,2,None,None")

Optional Properties:

  • m_Rgroups: Comma-separated list of R-group types (e.g., "H,OH,None,None")
  • m_type: Monomer type (e.g., "aa" for amino acid)
  • m_subtype: Monomer subtype
  • m_abbr: Monomer abbreviation

Example SDF Entry:

Your molecule atom data here...
...

> <symbol>
A

> <m_Rgroups>
H,OH,None,None

> <m_RgroupIdx>
1,2,None,None

> <m_type>
aa

> <m_subtype>
natural

> <m_abbr>
Ala

$$$$

Parallel Processing of Peptides

For workflows involving a large number of peptides, helmkit provides a function to process them in parallel, significantly improving performance.

from helmkit import load_monomer_library
from helmkit import load_peptides_in_parallel

# Load your custom monomer data (optional)
custom_sdf_path = "/path/to/your/custom_monomers.sdf"
monomer_db = load_monomer_library(custom_sdf_path)

# A list of HELM strings
helm_strings = ["PEPTIDE1{A.R.G}$$$$", "PEPTIDE1{S.G.T}$$$$"]

# Process peptides in parallel
molecules = load_peptides_in_parallel(helm_strings, monomer_db)

Development Setup

To set up a development environment, first clone the repository. Then, from the root of the repository, use uv to sync the environment:

uv sync -U

Running Tests

To run the test suite, execute pytest from the root of the repository:

pytest

Project details


Download files

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

Source Distribution

helmkit-0.5.0.tar.gz (139.9 kB view details)

Uploaded Source

Built Distribution

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

helmkit-0.5.0-py3-none-any.whl (99.1 kB view details)

Uploaded Python 3

File details

Details for the file helmkit-0.5.0.tar.gz.

File metadata

  • Download URL: helmkit-0.5.0.tar.gz
  • Upload date:
  • Size: 139.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for helmkit-0.5.0.tar.gz
Algorithm Hash digest
SHA256 26e29a4f79892d0e9265e6ce40b6f6125f4be121ce650a1fcbd9e31c53f9b0a1
MD5 016b58f6e4f00e30ebd65a8b2714d182
BLAKE2b-256 77f6b1ce195d2dae963a4c0f2dc701dad2878e33e626a87efa27cc23f7863259

See more details on using hashes here.

File details

Details for the file helmkit-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: helmkit-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 99.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for helmkit-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbf35591804e93ec8fc3c0297171613ead991e190e971b00ab1748c50795f8a4
MD5 03afb329891f92f3e37afa8625ace3e8
BLAKE2b-256 96d3eb7c03ee5c0d269e7e80a8a8bdce58692c160fb19470b7c49197e80ecd98

See more details on using hashes here.

Supported by

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