Generative models for antimicrobial peptide design: auto-encoders and beyond

May 18, 2026 · View on GitHub


Overview

This repository contains the code of our paper: Generative models for antimicrobial peptide design: auto-encoders and beyond. Here you can find the following things:

.
├── src_autoencoders   # Source code for the auto-encoders + the RNN
└── src_lm             # Source code for the language model

The datasets used for training and comparison, as well as the saved models can be found in Zenodo: TBA

Running the models

The source for the auto-encoders and the language model are using different versions of the frameworks: TensorFlow, Keras and keras-hub. All auto-encoders and the RNN are only Keras <= 3.0.0 compatible! The language model can be used or trained using more up-to-date versions of the frameworks. Problems may occur due to the different keras and tensorflow versions.

Setup

We recommend using micromamba for setting up the environments for the models. You can find more information & a one-liner installation in the official micromamba GitHub.

You should be able to import the environment.yaml files in the respective model directory directly into a micromamba environment with: micromamba env create -f path/zo/environment.yaml.

Example calls

The main script have a simple command-line interface located in each utils.py file.

The respective training scripts should create a folder called model_runs (model is a placeholder). Inside this folder each call to the training scripts create another directory for the current run, the folder name is a time-stamp of the pattern: run_DD_MM_YYYY-HH:MM:SS.

Calling the auto-encoders

The configuration of the auto-encoder based models is handled by: config.py. The script included three separate dictionaries and a variable for the dataset directory:

  • data_dirs: path to the dataset
  • config: general config for all models
  • annealing: configuration for the different annealing schedules of the VAEs
  • wae: WAE specific configuration The main script for the auto-encoders is: aes.py
# Calling:
python3 aes.py
Other scripts (insidle src_autoencoders)
  • aes.py: This is the main script
  • autoencoders.py: This contains the definition of the different VAE models
  • wae_models.py: This contains the definitions for the WAE model
  • utils.py: This contains different unitlity methods like plotting
  • data.py: Data related utilities

Calling the RNN

Inside the src_autoencoders directory is the simple_rnn.py script. This is the main script to call the RNN. This script contains its own config dict: rnn_config.

# Calling:
python3 simple_rnn.py

Calling the language model

  • Available parameters for training are:
    • Batch size: b, --batch-size
    • Attention heads: -hd, --heads
    • Num Layers: -l, --layers
    • Dropout: -d, --dropout
    • Intermediate dimension: id, --intermed-dim
    • Embedding dimension: -ed, --embed-dim
    • Infile: -i
# Training:
python3 train_llm.py -i ./data/amps.csv -b 64 -e 100
Generating sequences:
  • Change the following paths in the: lm_sampler.py script
    • The tokenizer vocabulary: vocabulary="./llm_runs/your_run_direcory/assets/tokenizer/vocabulary.txt"
    • The model: model = keras.models.load_model("./llm_runs/your_run_directory/llm.keras")
    • Call the script: python3 llm_sampler.py

Citation

If you are using this work or parts of it please cite:

Zenodo

BMC BioData Mining

License

  • The main parts of this work are distributed under the: Academic Software License v1.0 (ASL).
  • Some parts about the RNN is distributed under the MIT License.