Skip to main content

C++ module for featurizing molecules

Project description

cuik-molmaker

cuik-molmaker is a specialized package designed for molecular featurization, converting chemical structures into formats that can be effectively used as inputs for deep learning models, particularly graph neural networks (GNNs).

Setup conda environment

# Create conda env
conda create -n cuik_molmaker_build python=3.11 conda-forge::rdkit==2024.03.4 conda-forge::pybind11==2.13.6 conda-forge::pytorch-cpu==2.6.0 conda-forge::libboost-devel==1.84.0 conda-forge::libboost-python-devel==1.84.0 conda-forge::numpy==1.26.4

# Activate conda env
conda activate cuik_molmaker_build

Compile and run

cd repo/
mkdir -p build && cd build
# ensure that build/ directory is empty

# HACK: This is to accommodate NumPy<=2.0. In NumPy 2.0, `numpy/core/include` was moved to `numpy/_core/include`
ln -s $CONDA_PREFIX/lib/python3.11/site-packages/numpy/_core/include $CONDA_PREFIX/lib/python3.11/site-packages/numpy/core/include

cmake -DCMAKE_PREFIX_PATH="$CONDA_PREFIX/lib/python3.11/site-packages/torch/share/cmake;$CONDA_PREFIX" ..

make -j4

# .so should be created

## Optional: Install as PyPI package
cd path/to/repo
pip install .

# this should create a cuik_molmaker directory with .so file and a __init__.py file.

# Test that install works
pytest -s tests/python/test_featurize_dims.py

Usage

python
>>> import torch
>>> import cuik_molmaker
>>> atom_props_onehot = ["atomic-number", "total-degree", "formal-charge", "chirality", "num-hydrogens", "hybridization"]
>>> atom_property_list_onehot = cuik_molmaker.atom_onehot_feature_names_to_tensor(atom_props_onehot)
>>> print(f"{atom_property_list_onehot}")
tensor([ 0,  2,  9,  6, 10,  5])

Minimal conda env for import and running

# Create minimal conda env
conda create -n cuik_molmaker_import python=3.11 conda-forge::rdkit==2024.03.4 conda-forge::pytorch==2.6.0

conda activate cuik_molmaker_import

cd path/to/repo
pip install .
python -c "import cuik_molmaker; print(dir(cuik_molmaker))"

Testing

Running C++ tests using Catch2

# Step 1: Build with test flag set to on
cmake -DCUIKMOLMAKER_BUILD_TESTS=ON -DCMAKE_PREFIX_PATH="$CONDA_PREFIX/lib/python3.11/site-packages/torch/share/cmake;$CONDA_PREFIX" ..

# Optional: List tests/tags
./catch2_tests --list-tests
./catch2_tests --list-tags

# Step 2: Run all C++ tests
cd /path/to/build
./catch2_tests

Running python tests using pytest

# Step 1: Install cuik-molmaker using pip
cd path/to/repo
pip install .

# Step 2: Run pytest
pytest -s tests/python

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

cuik_molmaker-0.1a1.tar.gz (65.3 kB view details)

Uploaded Source

Built Distribution

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

cuik_molmaker-0.1a1-py3-none-manylinux2014_x86_64.whl (63.2 kB view details)

Uploaded Python 3

File details

Details for the file cuik_molmaker-0.1a1.tar.gz.

File metadata

  • Download URL: cuik_molmaker-0.1a1.tar.gz
  • Upload date:
  • Size: 65.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for cuik_molmaker-0.1a1.tar.gz
Algorithm Hash digest
SHA256 3e8a77662f53ead24ad1a106256d4cf875f7e893a10eb911838e6a658533642a
MD5 4bc8e4c194847fc8e8f02de7da829e18
BLAKE2b-256 317f7a1ceced8f140ce112d558b476dd60ef1e18138f5866cf10ae362d657630

See more details on using hashes here.

File details

Details for the file cuik_molmaker-0.1a1-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cuik_molmaker-0.1a1-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c7c217b33790835ed5c31ad0f295ae45abf5b50114b4d67054ed4ca7aab8821a
MD5 b0dd32ab5c9027eea21b7afaf4fea923
BLAKE2b-256 d7cf2b1f4a305eeb98a96175dbbbe80ea52a624803193306394113350cb35c52

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