Skip to main content

peptidegym

Gymnasium-Compatible RL Environments for Therapeutic Peptide Design

Python 3.10+ License: MIT Tests PyPI version


PeptideGym provides the first Gymnasium-compatible reinforcement learning environments for therapeutic peptide design. It models peptide construction as a sequential decision process — an RL agent builds peptide sequences residue-by-residue, receiving rewards from pluggable biophysical property predictors. PeptideGym enables researchers to benchmark any Gymnasium-compatible RL algorithm (PPO, DQN, SAC via Stable Baselines3, CleanRL, or RLlib) on peptide design without writing custom training loops.

Three environment families cover distinct therapeutic peptide classes:

  • Antimicrobial peptides (AMPs) — cationic, amphipathic sequences that disrupt microbial membranes
  • Cyclic peptides — macrocyclic binders with enhanced stability and oral bioavailability
  • Vaccine epitopes — short peptides optimized for MHC-I binding and T-cell recognition

Installation

pip install peptidegym              # Core (numpy, gymnasium)
pip install peptidegym[train]       # + SB3, PyTorch for RL training
pip install peptidegym[all]         # Everything

Development install:

git clone https://github.com/HassDhia/peptidegym.git
cd peptidegym
pip install -e ".[all]"

Quick Start

import gymnasium as gym
import peptidegym

env = gym.make("PeptideGym/AMP-v0")
obs, info = env.reset(seed=42)
for _ in range(100):
    action = env.action_space.sample()
    obs, reward, terminated, truncated, info = env.step(action)
    if terminated or truncated:
        print(f"Designed peptide: {info['sequence']} (reward: {reward:.3f})")
        obs, info = env.reset()
env.close()

Train a PPO Agent

from stable_baselines3 import PPO
import gymnasium as gym
import peptidegym

env = gym.make("PeptideGym/AMP-v0")
model = PPO("MlpPolicy", env, verbose=1)
model.learn(total_timesteps=90_000)

# Evaluate
obs, _ = env.reset()
done = False
while not done:
    action, _ = model.predict(obs, deterministic=True)
    obs, reward, terminated, truncated, info = env.step(action)
    done = terminated or truncated
print(f"Designed AMP: {info['sequence']}, Activity: {info.get('activity_score', 'N/A')}")

Environments

Environment Task Action Space Observation Difficulty Tiers
PeptideGym/AMP-v0 Design antimicrobial peptide Discrete(21) — 20 AAs + STOP Sequence + biophysical properties Easy, Medium, Hard
PeptideGym/CyclicPeptide-v0 Design cyclic peptide binder Discrete(24) — 20 AAs + 3 cyclization + linear stop Sequence + properties + cyclization validity Easy, Medium, Hard
PeptideGym/Epitope-v0 Optimize vaccine epitope Discrete(21) — 20 AAs + STOP Sequence + HLA encoding + binding estimate Easy, Medium, Hard

Each environment is available in three difficulty tiers (e.g., PeptideGym/AMP-Easy-v0, PeptideGym/AMP-Hard-v0) for a total of 9 benchmark configurations.

Architecture

┌─────────────────────────────────────────────────────┐
│                   RL Agent (PPO)                     │
│              via Stable Baselines3                   │
└────────────────────┬────────────────────────────────┘
                     │ action (amino acid or special)
                     ▼
┌─────────────────────────────────────────────────────┐
│              PeptideGym Environment                  │
│  ┌───────────┐  ┌──────────────┐  ┌───────────┐    │
│  │  AMP-v0   │  │CyclicPep-v0  │  │ Epitope-v0│    │
│  └─────┬─────┘  └──────┬───────┘  └─────┬─────┘    │
│        └───────────────┬┘───────────────┘            │
│                        ▼                             │
│            Pluggable RewardBackend                   │
│  ┌──────────────┐  ┌──────────────┐  ┌───────────┐ │
│  │  Heuristic   │  │   AMPlify    │  │ NetMHCpan │ │
│  │  (default)   │  │  (optional)  │  │ (optional)│ │
│  └──────────────┘  └──────────────┘  └───────────┘ │
└─────────────────────────────────────────────────────┘

All environments share the Gymnasium API (reset(), step(), observation_space, action_space). Default heuristic reward backends require no external dependencies. Optional backends (AMPlify, NetMHCpan, MHCflurry) can be swapped in for research-grade reward signals.

Paper

The accompanying paper is available at:

Citation

If you use peptidegym in your research, please cite:

@software{dhia2026peptidegym,
  author = {Dhia, Hass},
  title = {PeptideGym: Gymnasium-Compatible Reinforcement Learning Environments for Therapeutic Peptide Design},
  year = {2026},
  publisher = {Smart Technology Investments Research Institute},
  url = {https://github.com/HassDhia/peptidegym}
}

License

MIT License. See LICENSE for details.

Contact

Hass Dhia -- Smart Technology Investments Research Institute

Metadata

Release files for peptidegym 0.1.0

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

Source distribution (sdist)

Source distribution for peptidegym 0.1.0
File Size Uploaded Provenance
peptidegym-0.1.0.tar.gz 27.7 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 58.1 kB

Release files / peptidegym-0.1.0.tar.gz

Download URL peptidegym-0.1.0.tar.gz
Size 27.7 kB
Tags Source
SHA-256 checksum
How to use checksums
833b965f4690c13ace3526ed77070f871fad87cd7cb933db792c5f8cc73fe05b
BLAKE2b-256 checksum
How to use checksums
baf9e2e18ad0b02d20c031be908bc8f6d1765f77ac0fbe75572fb9dbb15ba690
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Release files / peptidegym-0.1.0-py3-none-any.whl

Download URL peptidegym-0.1.0-py3-none-any.whl
Size 30.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ff3ace38634f62ecee0a180eff5dd0d3c16ce832941ad2175a397d0be301106
BLAKE2b-256 checksum
How to use checksums
351044a1f986a07743690491dd0ac718fc3f205d3927aa4e7d1eb3f111a0cf35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Security for peptidegym 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 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