Skip to main content

Convert lipid shorthand notation to SMILES, InChI, InChIKey, and RDKit molecules

Project description

PyLipidParse

Convert standard lipid shorthand notation (LIPID MAPS, SwissLipids, HMDB) to molecular structures.

CI PyPI Python 3.8+ License: MIT

What it does

No existing open-source tool converts lipid shorthand notation to SMILES, InChI, or RDKit molecules. PyLipidParse fills this gap.

from pylipidparse import LipidConverter

conv = LipidConverter()

conv.to_smiles("PC 16:0/18:1(9Z)")
# → 'CCCCCCCCCCCCCCCC(=O)OC[C@@H](OC(=O)CCCCCCCC/C=C\\CCCCCCCC)COP(=O)([O-])OCC[N+](C)(C)C'

conv.to_inchikey("FA 18:2(9Z,12Z)")
# → 'OYHQOLUKZRVURQ-HZJYTTRNSA-N'

conv.to_mol("Cer 18:1;O2/16:0")
# → <rdkit.Chem.rdchem.Mol object>

conv.to_sdf(["PC 16:0/18:1(9Z)", "PE 18:0/20:4(5Z,8Z,11Z,14Z)"], path="output.sdf")

Supported lipid classes

Class Examples Status
Fatty Acids (FA) FA 16:0, FA 18:1(9Z), FA 20:4(5Z,8Z,11Z,14Z)
Glycerolipids (GL) MG, DG, TG
Glycerophospholipids (GP) PC, PE, PA, PI, PS, PG, LPC, LPE, ...
Sphingolipids (SP) Cer, SM, HexCer, Hex2Cer
Sterols (ST) Cholesterol, CE, bile acids
Ether/plasmalogen linkages O-, P- prefix

Installation

pip (Python 3.10+)

pip install pylipidparse

uv

uv add pylipidparse

conda (all Python 3.8+ versions, recommended for older RDKit)

conda install -c conda-forge pylipidparse

From source

git clone https://github.com/MontgomeryBohde/PyLipidParse.git
cd PyLipidParse
pip install -e ".[dev]"

RDKit note: For Python 3.8/3.9, pip wheels for RDKit may not be available. Use conda: conda install -c conda-forge rdkit pygoslin

Quick start

from pylipidparse import LipidConverter

conv = LipidConverter()

# SMILES
smiles = conv.to_smiles("FA 18:1(9Z)")        # Oleic acid
smiles = conv.to_smiles("PC 16:0/18:1(9Z)")   # POPC

# InChI / InChIKey
inchi = conv.to_inchi("FA 16:0")
ik = conv.to_inchikey("FA 16:0")   # "IPCSVZSSVZVIGE-UHFFFAOYSA-N"

# RDKit Mol (for downstream cheminformatics)
mol = conv.to_mol("Cer 18:1;O2/16:0")

# Write to file
conv.to_mol_file("PC 16:0/18:1(9Z)", "popc.mol")
conv.to_sdf(["FA 16:0", "FA 18:1(9Z)", "PC 16:0/18:1(9Z)"], "lipids.sdf")

Notation requirements

PyLipidParse requires full structural notation with explicit chain positions. Sum-composition notation (e.g., PC 34:1) is rejected because a unique structure cannot be generated from it.

Works Fails
PC 16:0/18:1(9Z) PC 34:1 (no chain breakdown)
TG 16:0/18:1(9Z)/18:2(9Z,12Z) TG 16:0_18:1_18:2 (unknown positions)
FA 18:1(9Z) FA 18:1 (no double bond position)

API reference

LipidConverter(dialect="LipidMaps", cache_size=512)

Method Returns Description
to_mol(name) Chem.Mol RDKit molecule (no 2D coords)
to_smiles(name) str Canonical SMILES
to_inchi(name) str InChI string
to_inchikey(name) str InChIKey (27-char hash)
to_mol_file(name, path) Write .mol file with 2D coords
to_sdf(names, path) Write .sdf file (supports batch)

Exceptions

from pylipidparse.exceptions import (
    LipidParseError,                  # pygoslin couldn't parse the input
    UnsupportedLipidClassError,       # lipid class not yet implemented
    InsufficientStructuralDetailError, # species-level / unknown positions
    StructureGenerationError,         # molecule assembly failed
)

Contributing

Issues and pull requests are welcome at github.com/MontgomeryBohde/PyLipidParse.

Citation

If you use PyLipidParse in published work, please cite this repository and the underlying tools:

  • pygoslin: Kopczynski et al., Analytical Chemistry (2022). DOI: 10.1021/acs.analchem.1c05430
  • RDKit: Landrum, G. RDKit: Open-source cheminformatics. rdkit.org

License

MIT License — see LICENSE.

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

pylipidparse-1.0.0.tar.gz (48.2 kB view details)

Uploaded Source

Built Distribution

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

pylipidparse-1.0.0-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file pylipidparse-1.0.0.tar.gz.

File metadata

  • Download URL: pylipidparse-1.0.0.tar.gz
  • Upload date:
  • Size: 48.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pylipidparse-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e7b721f9b401deb8e9fa873f47ab2574d1a8a6c592ec1c87ea7a5d7d3b2a0ce7
MD5 cb9389c546d12c8c75d6d15bc81ae7dc
BLAKE2b-256 56b4e0956833697b5794e4048b3747340b03e6d8d4dd394ec4d1f94a61ae4af1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylipidparse-1.0.0.tar.gz:

Publisher: publish.yml on MontgomeryBohde/PyLipidParse

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

File details

Details for the file pylipidparse-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pylipidparse-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 28.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pylipidparse-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d44d442d260651a0b826ca42d5db430d39478d024723c1c153255889ba3fe014
MD5 c3caa44cba933bc46933a79855d5f3c3
BLAKE2b-256 0d67c6339b9ad570d94a208eaec819bebd0fb4e4a0a6bec1ab04bdedeb02ca1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylipidparse-1.0.0-py3-none-any.whl:

Publisher: publish.yml on MontgomeryBohde/PyLipidParse

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

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