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

pip install pylipidparse

uv

uv add pylipidparse

From source

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

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.1.0.tar.gz (54.7 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.1.0-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pylipidparse-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b7a9097e2f70feed63ae0a288d0a0a75c4ec850f0b6c2bb2f3ff8040409ad2b0
MD5 8dc5c4e30df80973699e6be0af057a71
BLAKE2b-256 fe557b1226d1852d745de05a7c0a29503cbb87e843bffbc295b85c425e567fea

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylipidparse-1.1.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: pylipidparse-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.1 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 058451fe7552fa9a5f6abbb220d95122edbfde19e9c01d03b43c0e31539189bf
MD5 6f095e1c151f6b3af5a9e9d2530fba94
BLAKE2b-256 df2e72f5f489070699287aa055372556f55b87940ab8c86ed2876182264ea367

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylipidparse-1.1.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