Skip to main content

Python client for the LCMD molecular database — typed access to molecules, reactions, fragments, and assembly templates

Project description

LCMD-DB

Python client for the LCMD molecular database.

Installation

uv add lcmd-db
# or
pip install lcmd-db

Quick start

from lcmd_db import load_dataset

# Load a subset (molecules included by default)
data = load_dataset("qm9")
data.molecules  # polars DataFrame

# Include multiple entity types
data = load_dataset("qm9", include=["molecules", "reactions", "fragments"])

# Include XYZ structure files
data = load_dataset("qm9", include_structures=True)

# Select specific properties
data = load_dataset("qm9", molecule_properties=["smiles", "energy"])

# Choose output format
data = load_dataset("qm9", data_format="csv")

# Force re-download (bypass cache)
data = load_dataset("qm9", force_download=True)

Dataset API

load_dataset returns a SubsetData object containing polars DataFrames for each entity type. Convert it to a typed Dataset for lazy loading, filtering, and indexing:

data = load_dataset("qm9")

# Get a typed, iterable Dataset
molecules = data.as_dataset("molecules")

# Index and iterate
mol = molecules[0]          # Molecule(id=..., properties={...})
batch = molecules[10:20]    # Dataset slice

# Filter with polars expressions
import polars as pl
heavy = molecules.filter(pl.col("molecular_weight") > 100)

# Select specific columns
subset = molecules.select("smiles", "energy")

# Train/test split
train, test = molecules.train_test_split(test_size=0.2, seed=42)

# Export
df = molecules.to_polars()
pdf = molecules.to_pandas()
atoms = molecules.to_ase()   # requires ase

CLI

# Download a dataset
lcmd-db download qm9
lcmd-db download qm9 --include molecules --include structures
lcmd-db download qm9 -f csv --force

# Browse available schemas
lcmd-db schema list
lcmd-db schema show qm9

# Manage cache
lcmd-db cache clear
lcmd-db cache clear qm9

# Sync type stubs for autocomplete
lcmd-db stubs sync

Configuration

Settings are controlled via environment variables (prefix LCMD_DB_) or programmatically:

Variable Description Default
LCMD_DB_BASE_URL API base URL https://lcmd-app.epfl.ch
LCMD_DB_CACHE_DIR Cache directory OS-dependent
LCMD_DB_TIMEOUT Download timeout (seconds) 300
LCMD_DB_AUTO_SYNC_STUBS Auto-sync type stubs on import true
from lcmd_db import settings

settings.base_url = "https://custom-instance.example.com"

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

lcmd_db-0.3.4.tar.gz (242.1 kB view details)

Uploaded Source

Built Distribution

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

lcmd_db-0.3.4-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file lcmd_db-0.3.4.tar.gz.

File metadata

  • Download URL: lcmd_db-0.3.4.tar.gz
  • Upload date:
  • Size: 242.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for lcmd_db-0.3.4.tar.gz
Algorithm Hash digest
SHA256 6c1721ff687f2a94bf1efdbb9b0471452b33a16c5e76de199f07b429e614045f
MD5 5006a164d9595b3152edad5e40caeecf
BLAKE2b-256 e3473aa397595a6889e07f59c649321b4a111da0f48e0006573b48dc4d760802

See more details on using hashes here.

File details

Details for the file lcmd_db-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: lcmd_db-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 36.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for lcmd_db-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5a215d093ad2c8bec7dff8c96ae4e6225a4dee31ca7ad437285e459a5e2ffe2a
MD5 8f47f222c82f5507a5043601e073805c
BLAKE2b-256 fa37c83cc0dcf695178ba44c179b4731f982fb9d4accfead5f8b9488d9f20f41

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