Skip to main content

ET-Flow: Equivariant Flow Matching for Molecular Conformer Generation

Implementation of Equivariant Flow Matching for Molecule Conformer Generation by M Hassan, N Shenoy, J Lee, H Stark, S Thaler and D Beaini.

ET-Flow is a state-of-the-art generative model for generating small molecule conformations using equivariant transformers and flow matching.

Install ET-flow

We are now available on PyPI. Easily install the package using the following command:

pip install etflow

Generating Conformations for Custom Smiles

We have a sample notebook (generate_confs.ipynb) to generate conformations for custom smiles input. One needs to pass the config and corresponding checkpoint path in order as additional inputs.

We have added support to load the model config and checkpoint with automatic download and caching. See (tutorial.ipynb) or use the following snippet to load the model and generate conformations for custom smiles input.

from etflow import BaseFlow
model=BaseFlow.from_default(model="drugs-o3")
model.predict(['CN1C=NC2=C1C(=O)N(C(=O)N2C)C'], num_samples=3, as_mol=True)

We currently support the following configurations and checkpoint:

  • drugs-o3
  • qm9-o3
  • drugs-so3

Setup Dev Environment

Run the following commands to setup the environment:

conda env create -n etflow -f env.yml
conda activate etflow
# to install the etflow package
python3 -m pip install -e .

Preprocessing Data

To pre-process the data, perform the following steps,

  1. Download the raw GEOM data and unzip the raw data using the following commands,
wget https://dataverse.harvard.edu/api/access/datafile/4327252 -O <output_folder_path/rdkit_folder.tar>
tar -zxvf <output_folder_path/rdkit_folder.tar>
  1. Process the data for ET-Flow training. First, set the DATA_DIR environment variable. All preprocessed data will be created inside this.
export DATA_DIR=</path_to_data>
python scripts/prepare_data.py -p /path/to/geom/rdkit-raw-folder
  1. Download the splits from the zenodo link (https://zenodo.org/records/13870058). Once these files are downloaded, extract the zip files to the respective folders inside $DATA_DIR,
unzip QM9.zip -d $DATA_DIR
unzip DRUGS.zip -d $DATA_DIR

Training

We provide our configs for training on the GEOM-DRUGS and the GEOM-QM9 datasets in various configurations. Run the following commands once datasets are preprocessed and the environment is set up:

python etflow/train.py -c configs/drugs-base.yaml

The following two configs from the configs/ directory can be used for replicating paper results:

  • drugs-base.yaml: ET-Flow trained on GEOM-DRUGS dataset
  • qm9-base.yaml: ET-Flow trained on GEOM-QM9 dataset

Evaluation

Before running eval with any checkpoint, create an evaluation csv (will be saved at $DATA_DIR/processed/geom.csv), using the following script,

python scripts/prepare_eval_csv.py -p /path/to/geom/rdkit-raw-folder

Evaluation happens in 2 steps as follows,

  1. Generating Conformations To run the evaluation on either GEOM or QM9 given a config and a checkpoint, run the following command,
# here n: number of inference steps for flow matching
python etflow/eval.py --config=<config-path> --checkpoint=<checkpoint-path> --dataset_type=qm9 --nsteps=50

To run the evaluation on GEOM-XL (a test-set containing much larger molecules), run the following command,

python etflow/eval_xl.py --config=<config-path> --checkpoint=<checkpoint-path> --batch_size=16 --nsteps=50
  1. Evaluating Conformations with RMSD Metrics The above sample generation script should created a generated_files.pkl at the following path, logs/samples/<config-path>/<data-time>/flow_nsteps_{value-passed-above}/generated_files.pkl. With the given path, we can get the various RMSD metrics using,
python etflow/eval_cov_mat.py --path=<path-to-generated-files.pkl> --num_workers=10

Loading a Pre-Trained Checkpoint

Coming Soon!

Acknowledgements

Our codebase is built using the following open-source contributions,

Contact

For further questions, feel free to raise an issue.

Citation

@misc{hassan2024etflow,
      title={ET-Flow: Equivariant Flow-Matching for Molecular Conformer Generation},
      author={Majdi Hassan and Nikhil Shenoy and Jungyoon Lee and Hannes Stark and Stephan Thaler and Dominique Beaini},
      year={2024},
      eprint={2410.22388},
      archivePrefix={arXiv},
      primaryClass={q-bio.QM},
      url={https://arxiv.org/abs/2410.22388},
}

Metadata

Release files for etflow 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for etflow 0.1.2
File Size Uploaded Provenance Actions
etflow-0.1.2.tar.gz 128.5 kB Without provenance Details for etflow-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for etflow 0.1.2
File Interpreter ABI Platform Actions
etflow-0.1.2-py3-none-any.whl Python 3 none any Details for etflow-0.1.2-py3-none-any.whl

Total release size: 185.8 kB

Release files / etflow-0.1.2.tar.gz

Download URL etflow-0.1.2.tar.gz
Size 128.5 kB
Tags Source
SHA-256 checksum
How to use checksums
79ba80cf1e2001bb35bf0d7fc07f58d243eb6ab668eafafe537af388407057ae
BLAKE2b-256 checksum
How to use checksums
231fe281e179ccc6b4f692b375ead4801f4c2c7c0ecb60fc0cf22b0e65d3c484
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / etflow-0.1.2-py3-none-any.whl

Download URL etflow-0.1.2-py3-none-any.whl
Size 57.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f75928fcd340863ef6af8275514fe7b32fbb06dc81ff7f94d3324d8c256f6eea
BLAKE2b-256 checksum
How to use checksums
7ad2109f1069ca7613bcda40e7ea0ab795d899fe11c45e48cd1e0cc55dcd502f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Security for etflow 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page