ALGen-1

August 8, 2025 · View on GitHub

DOI arXiv License Python Last Commit

ALGen-1

ALGen✨ is the main component of a molecular generative modeling (GM) workflow designed to generate novel chemical compounds with desired properties. ALGen encompasses the initial stages of the workflow illustrated in Figure 1, from data preprocessing through molecule generation and the implementation of the inner active learning (AL) cycles.

The pipeline includes the following core stages:

  1. 🧠 Training
    A variational autoencoder (VAE) is first trained on a general molecule dataset to learn how to generate chemically valid structures. The model is then fine-tuned on a specific training dataset to focus generation toward molecules with desired affinity to a target.

  2. 🧪 Molecule Generation
    After training, the VAE is used to sample new candidate molecules from its latent space.

    The VAE architecture comprised an encoder, a latent space, and a decoder. The input is represented as a 3D tensor resulting from the one-hot encoding of the SMILES sequence. The encoder fed the input into a Long Short-Term Memory (LSTM) layer followed by a fully connected layer with 256 units. This layer further processes the encoded sequence information and reduces its dimensionality into a 128-dimensional latent vector. The decoder reconstructs the sequences, expanding the latent vector through an LSTM layer followed by a fully connected layer with 256 units. The activation function used was ReLu. Finally, a softmax activation layer was applied to produce the output sequence.

  3. 🔁 Inner Active Learning (AL) Cycles
    Generated molecules are evaluated for chemical validity and ranked based on drug-likeness (QED), synthetic accessibility (SA), and similarity to the initial-specific training set. Molecules meeting defined thresholds are added to a temporal-specific dataset for subsequent fine-tuning. These AL cycles are repeated iteratively, enabling progressive refinement of the model toward molecules with increasingly desirable properties.

Alt Text

For further technical details and results please refer to the paper.

(back to top)

Table of Contents

(back to top)

Installation

To install ALGen, follow these steps:

  1. Clone the repository:

    git clone https://github.com/IFilella/ALGen-1
    cd ALGen-1
    
  2. Create virtual environment:

    conda create -n ALGen python=3.10
    conda activate ALGen
    
  3. Install ALGen:

    make install
    

    Hardware Requirements: ALGen is designed to run efficiently on a single GPU. A CUDA-compatible GPU with sufficient RAM is recommended for optimal performance

    Install compatible TensorFlow and CUDA Toolkit.

    First check your CUDA version:

    nvcc --version
    

    Then, check your CUDA compatibility here and install correspondingly:

    conda install -c conda-forge tensorflow=x.x            # replace x for your version
    

    You can check your installation running this commands on python:

    import tensorflow as tf
    print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
    

Others:

  1. Test ALGen:

    make test
    
  2. Uninstall ALGen and clean:

    make uninstall
    make clean
    

(back to top)

Usage

Once the environment is set up and the package is installed, you can run the generative pipeline using the following command:

python generator.py \
  -g data/general_set.smi \
  -e 100 \
  -v 0.1 \
  -t 0.1 \
  -b 100 \
  -s 1.2 \
  -q 1000 \
  -n algen_run \
  -o results \
  -pa data/specific_set.smi \
  -ial 10 \
  -qed 0.6 \
  -sa 5 \
  -ta 0.6

Warning: The training sets (-g data/general_set.smi, -pa data/specific_set.smi) are used for the initial training of the VAE, not for generating.

For a full list of parameters, see the Configuration section.

More examples are provided in the Examples section.

(back to top)

Configuration

The behavior of ALGen is controlled via command-line arguments. Below is a list of configurable parameters and their purpose:

ArgumentDescriptionDefault
-g, --general_set_smilesPath to the general SMILES file used for training.Required
-e, --epochsNumber of training epochs.100
-v, --validation_sizeProportion of the dataset to be used as the validation set (e.g., 0.1 for 10%).0.1
-t, --test_sizeProportion of the dataset to be used as the test set.0.1
-b, --batch_sizeNumber of samples per training batch.100
-s, --sampling_temperatureSampling temperature during generation; controls randomness. Lower values make outputs more deterministic.1.2
-q, --quantityNumber of molecules to generate.1000
-n, --nameName of the current generative run. Used to label output files.'algen_run'
-o, --outdirPath to the output directory where results will be saved.'results'
-pa, --specific_set_smilesPath to specific SMILES file for transfer learning.Required
-pt, --pretrainedPath to a pretrained weights file to fine-tune training.None
-ial, --inner_alNumber of inner active learning (AL) iterations to run.10
-qed, --druglikenessQED threshold (quantitative estimate of drug-likeness) score for generated molecules.0.6
-sa, --sascoreSynthetic accessibility score threshold for generated molecules.6
-ta, --tanimotoTanimoto similarity threshold for generated molecules.0.6
-r, --restartFlag to restart a previously interrupted run from the last checkpoint. Use as a standalone switch (no value needed).False

(back to top)

Examples

In these examples, ALGen generates 1000 molecules at each inner AL cycle from a total of 10. These are filtered according to the threshold values of 0.6, 5, and 0.6 (QED, SA, and Tanimoto, respectively).

🔹Molecular Generation from pretrained weights

Including the -pt.

python generator.py \
  -g data/general_set.smi \
  -e 100 \
  -v 0.1 \
  -t 0.1 \
  -b 100 \
  -s 1.2 \
  -q 1000 \
  -n algen_run \
  -o results \
  -pa data/specific_set.smi \
  -pt data/pretrained_weights.hdf5 \
  -ial 5 \
  -qed 0.6 \
  -sa 5 \
  -ta 0.6

Although having the pretrained weights from the training of the general training set, the -g flag should also be provided for model sizes and analysis purposes.

🔹Molecular Generation with training from general training set

Without the -pt.

python generator.py \
  -g data/general_set.smi \
  -e 100 \
  -v 0.1 \
  -t 0.1 \
  -b 16 \
  -s 1.2 \
  -q 1000 \
  -n algen_run \
  -o results \
  -pa data/specific_set.smi \
  -ial 5 \
  -qed 0.6 \
  -sa 5 \
  -ta 0.6

🔹Restart the Molecular Generation

Add the -r (-pt and -pa are no longer necessary).

python generator.py \
  -g data/general_set.smi \
  -e 100 \
  -v 0.1 \
  -t 0.1 \
  -b 100 \
  -s 1.2 \
  -q 1000 \
  -n algen_run \
  -o results \
  -ial 10 \
  -qed 0.6 \
  -sa 5 \
  -ta 0.6
  -r

(back to top)

License

This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0). For full licensing terms, please refer to the LICENSE file in this repository.

(back to top)

Citation

If you use this work in your research, please cite the following paper:

Filella-Merce, I., Molina, A., Díaz, L. et al. Optimizing drug design by merging generative AI with a physics-based active learning framework. Commun Chem 8, 238 (2025). https://doi.org/10.1038/s42004-025-01635-7

A preprint of this work is also available on arXiv:

Filella-Merce, I., et al. (2023). Optimizing Drug Design by Merging Generative AI With Active Learning Frameworks. arXiv:2305.06334. https://arxiv.org/abs/2305.06334

(back to top)

Contact

Isaac Filella-Mercè Email: isaac.filella1@bsc.es Affiliation: Barcelona Supercomputing Center

Alexis Molina Email: alexis.molina@nostrumbiodiscovery.com Affiliation: Nostrum Biodiscovery S.L.

Júlia Vilalta-Mor Email: julia.vilalta@bsc.es Affiliation: Barcelona Supercomputing Center

(back to top)