Skip to main content

A Python package for building and optimizing cheminformatics workflows using Bayesian optimization and LLM agents

Project description

cmxflow 🧪

Docs CI codecov Python 3.11+ Code style: black License: MIT

Build cheminformatics and computational chemistry pipelines with composable blocks. Tune end-to-end with Bayesian Optimization. Or ask an LLM agent to do it.

Quick examples

Prepare ligands for docking

from cmxflow import Workflow
from cmxflow.sources import MoleculeSourceBlock
from cmxflow.operators import (
    MoleculeStandardizeBlock,
    IonizeMoleculeBlock,
    EnumerateStereoBlock,
    ConformerGenerationBlock,
)
from cmxflow.sinks import MoleculeSinkBlock

# Standardize → ionize (pH 6.4–8.4) → enumerate stereo → generate 3D conformers
workflow = Workflow()
workflow.add(
    MoleculeSourceBlock(),
    MoleculeStandardizeBlock(),
    IonizeMoleculeBlock(),
    EnumerateStereoBlock(),
    ConformerGenerationBlock(),
    MoleculeSinkBlock(),
)
workflow("library.smi", "prepared.sdf")

Dock a congeneric series

Pure-Python docking. Free docking is the default (index_poses=False); scaffold-indexed mode caches poses by Bemis–Murcko scaffold for ~3× faster throughput on congeneric series with consistent pose alignment.

from cmxflow import Workflow
from cmxflow.sources import MoleculeSourceBlock
from cmxflow.operators import ConformerGenerationBlock, MoleculeDockBlock
from cmxflow.sinks import MoleculeSinkBlock
from cmxflow.utils.parallel import make_parallel

workflow = Workflow()
workflow.add(
    MoleculeSourceBlock(),
    ConformerGenerationBlock(),
    make_parallel(
        MoleculeDockBlock(
            receptor="receptor.pdb",
            site_reference="crystal_ligand.sdf",
            index_poses=True,  # omit for free docking
        )
    ),
    MoleculeSinkBlock(),
)
workflow("library.smi", "docked.sdf")

Tune a ligand-based virtual screen

from cmxflow import Workflow
from cmxflow.sources import MoleculeSourceBlock
from cmxflow.operators import MoleculeSimilarityBlock
from cmxflow.scores import EnrichmentScoreBlock
from cmxflow.opt import Optimizer

# Rank a library by 2D similarity to a known active, then tune the
# fingerprint end-to-end to maximize enrichment AUC.
workflow = Workflow()
workflow.add(
    MoleculeSourceBlock(),
    MoleculeSimilarityBlock(queries="crystal_ligand.sdf"),
    EnrichmentScoreBlock(target="active"),
)

opt = Optimizer(workflow, "benchmark.csv")
opt.optimize(n_trials=30, direction="maximize")

print(f"Best enrichment AUC: {opt.best_score:.3f}")
print(opt.best_params)
# Best enrichment AUC: 0.836
# {'fingerprint_type': 'morgan', 'similarity_metric': 'sokal', 'radius': 2, 'nbits': 2545}

The four fingerprint parameters above are searched automatically — every block exposes its mutable parameters to the optimizer.

Or build it conversationally via an LLM agent

claude mcp add cmxflow -- cmxflow-mcp

"How many of the molecules in library.csv pass Lipinski's rules?"

"I need to build a ligand-based virtual screening workflow. I'm not sure if 2D or 3D is better. Can you optimize two workflows?"

"Dock the molecules in hits.csv against receptor.pdb with crystal_ligand.sdf as a reference."

The agent can build, run, and optimize workflows. See Using with Claude for full transcripts.

What's in the box

  • 15+ blocks for sourcing, transforming, filtering, clustering, scoring, and docking molecules
  • Bayesian optimization of pipeline parameters via Optuna
  • Parallel execution for compute-heavy blocks (conformer generation, docking)
  • Workflow serialization for save / load / reuse
  • An MCP server with five tools: build_workflow, run_workflow, optimize_workflow, manage_workflows, view_structures

Install

pip install cmxflow

MCP server

claude mcp add cmxflow -- cmxflow-mcp

Optional: PyMOL

Required only for the view_structures MCP tool (3D visualization):

conda install -c conda-forge pymol-open-source

Documentation

Project

MIT licensed. See CONTRIBUTING.md and RELEASING.md.

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

cmxflow-0.4.0.tar.gz (94.9 kB view details)

Uploaded Source

Built Distribution

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

cmxflow-0.4.0-py3-none-any.whl (118.1 kB view details)

Uploaded Python 3

File details

Details for the file cmxflow-0.4.0.tar.gz.

File metadata

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

File hashes

Hashes for cmxflow-0.4.0.tar.gz
Algorithm Hash digest
SHA256 377191224552fec17ef4a708da03783a6c262baecf53e0ee0a72a83cc65b4238
MD5 ad0e59b15f70ef1ee9f3bd91a889da59
BLAKE2b-256 a47ba40b9f3fbde28711273b2d29122f8c2ff841a84681f4cfea9699eb7c3c3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for cmxflow-0.4.0.tar.gz:

Publisher: release.yml on b-shields/cmxflow

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

File details

Details for the file cmxflow-0.4.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for cmxflow-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f372e96b31f18e6cb2a3dbf96591fb8895463f2294018c4192a6f86e9487996
MD5 291859e9876997c3b27d335a67307c7f
BLAKE2b-256 d5d1c9ba70b92ae0b19a92853e766506e8cdecdcc451ac283799f736651e0beb

See more details on using hashes here.

Provenance

The following attestation bundles were made for cmxflow-0.4.0-py3-none-any.whl:

Publisher: release.yml on b-shields/cmxflow

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