torchdrug

24
2
Source

Graph-based drug discovery toolkit. Molecular property prediction (ADMET), protein modeling, knowledge graph reasoning, molecular generation, retrosynthesis, GNNs (GIN, GAT, SchNet), 40+ datasets, for PyTorch-based ML on molecules, proteins, and biomedical graphs.

Install

mkdir -p .claude/skills/torchdrug && curl -L -o skill.zip "https://mcp.directory/api/skills/download/1657" && unzip -o skill.zip -d .claude/skills/torchdrug && rm skill.zip

Installs to .claude/skills/torchdrug

About this skill

TorchDrug

Overview

TorchDrug is a comprehensive PyTorch-based machine learning toolbox for drug discovery and molecular science. Apply graph neural networks, pre-trained models, and task definitions to molecules, proteins, and biological knowledge graphs, including molecular property prediction, protein modeling, knowledge graph reasoning, molecular generation, retrosynthesis planning, with 40+ curated datasets and 20+ model architectures.

When to Use This Skill

This skill should be used when working with:

Data Types:

  • SMILES strings or molecular structures
  • Protein sequences or 3D structures (PDB files)
  • Chemical reactions and retrosynthesis
  • Biomedical knowledge graphs
  • Drug discovery datasets

Tasks:

  • Predicting molecular properties (solubility, toxicity, activity)
  • Protein function or structure prediction
  • Drug-target binding prediction
  • Generating new molecular structures
  • Planning chemical synthesis routes
  • Link prediction in biomedical knowledge bases
  • Training graph neural networks on scientific data

Libraries and Integration:

  • TorchDrug is the primary library
  • Often used with RDKit for cheminformatics
  • Compatible with PyTorch and PyTorch Lightning
  • Integrates with AlphaFold and ESM for proteins

Getting Started

Installation

uv pip install torchdrug
# Or with optional dependencies
uv pip install torchdrug[full]

Quick Example

from torchdrug import datasets, models, tasks
from torch.utils.data import DataLoader

# Load molecular dataset
dataset = datasets.BBBP("~/molecule-datasets/")
train_set, valid_set, test_set = dataset.split()

# Define GNN model
model = models.GIN(
    input_dim=dataset.node_feature_dim,
    hidden_dims=[256, 256, 256],
    edge_input_dim=dataset.edge_feature_dim,
    batch_norm=True,
    readout="mean"
)

# Create property prediction task
task = tasks.PropertyPrediction(
    model,
    task=dataset.tasks,
    criterion="bce",
    metric=["auroc", "auprc"]
)

# Train with PyTorch
optimizer = torch.optim.Adam(task.parameters(), lr=1e-3)
train_loader = DataLoader(train_set, batch_size=32, shuffle=True)

for epoch in range(100):
    for batch in train_loader:
        loss = task(batch)
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()

Core Capabilities

1. Molecular Property Prediction

Predict chemical, physical, and biological properties of molecules from structure.

Use Cases:

  • Drug-likeness and ADMET properties
  • Toxicity screening
  • Quantum chemistry properties
  • Binding affinity prediction

Key Components:

  • 20+ molecular datasets (BBBP, HIV, Tox21, QM9, etc.)
  • GNN models (GIN, GAT, SchNet)
  • PropertyPrediction and MultipleBinaryClassification tasks

Reference: See references/molecular_property_prediction.md for:

  • Complete dataset catalog
  • Model selection guide
  • Training workflows and best practices
  • Feature engineering details

2. Protein Modeling

Work with protein sequences, structures, and properties.

Use Cases:

  • Enzyme function prediction
  • Protein stability and solubility
  • Subcellular localization
  • Protein-protein interactions
  • Structure prediction

Key Components:

  • 15+ protein datasets (EnzymeCommission, GeneOntology, PDBBind, etc.)
  • Sequence models (ESM, ProteinBERT, ProteinLSTM)
  • Structure models (GearNet, SchNet)
  • Multiple task types for different prediction levels

Reference: See references/protein_modeling.md for:

  • Protein-specific datasets
  • Sequence vs structure models
  • Pre-training strategies
  • Integration with AlphaFold and ESM

3. Knowledge Graph Reasoning

Predict missing links and relationships in biological knowledge graphs.

Use Cases:

  • Drug repurposing
  • Disease mechanism discovery
  • Gene-disease associations
  • Multi-hop biomedical reasoning

Key Components:

  • General KGs (FB15k, WN18) and biomedical (Hetionet)
  • Embedding models (TransE, RotatE, ComplEx)
  • KnowledgeGraphCompletion task

Reference: See references/knowledge_graphs.md for:

  • Knowledge graph datasets (including Hetionet with 45k biomedical entities)
  • Embedding model comparison
  • Evaluation metrics and protocols
  • Biomedical applications

4. Molecular Generation

Generate novel molecular structures with desired properties.

Use Cases:

  • De novo drug design
  • Lead optimization
  • Chemical space exploration
  • Property-guided generation

Key Components:

  • Autoregressive generation
  • GCPN (policy-based generation)
  • GraphAutoregressiveFlow
  • Property optimization workflows

Reference: See references/molecular_generation.md for:

  • Generation strategies (unconditional, conditional, scaffold-based)
  • Multi-objective optimization
  • Validation and filtering
  • Integration with property prediction

5. Retrosynthesis

Predict synthetic routes from target molecules to starting materials.

Use Cases:

  • Synthesis planning
  • Route optimization
  • Synthetic accessibility assessment
  • Multi-step planning

Key Components:

  • USPTO-50k reaction dataset
  • CenterIdentification (reaction center prediction)
  • SynthonCompletion (reactant prediction)
  • End-to-end Retrosynthesis pipeline

Reference: See references/retrosynthesis.md for:

  • Task decomposition (center ID → synthon completion)
  • Multi-step synthesis planning
  • Commercial availability checking
  • Integration with other retrosynthesis tools

6. Graph Neural Network Models

Comprehensive catalog of GNN architectures for different data types and tasks.

Available Models:

  • General GNNs: GCN, GAT, GIN, RGCN, MPNN
  • 3D-aware: SchNet, GearNet
  • Protein-specific: ESM, ProteinBERT, GearNet
  • Knowledge graph: TransE, RotatE, ComplEx, SimplE
  • Generative: GraphAutoregressiveFlow

Reference: See references/models_architectures.md for:

  • Detailed model descriptions
  • Model selection guide by task and dataset
  • Architecture comparisons
  • Implementation tips

7. Datasets

40+ curated datasets spanning chemistry, biology, and knowledge graphs.

Categories:

  • Molecular properties (drug discovery, quantum chemistry)
  • Protein properties (function, structure, interactions)
  • Knowledge graphs (general and biomedical)
  • Retrosynthesis reactions

Reference: See references/datasets.md for:

  • Complete dataset catalog with sizes and tasks
  • Dataset selection guide
  • Loading and preprocessing
  • Splitting strategies (random, scaffold)

Common Workflows

Workflow 1: Molecular Property Prediction

Scenario: Predict blood-brain barrier penetration for drug candidates.

Steps:

  1. Load dataset: datasets.BBBP()
  2. Choose model: GIN for molecular graphs
  3. Define task: PropertyPrediction with binary classification
  4. Train with scaffold split for realistic evaluation
  5. Evaluate using AUROC and AUPRC

Navigation: references/molecular_property_prediction.md → Dataset selection → Model selection → Training

Workflow 2: Protein Function Prediction

Scenario: Predict enzyme function from sequence.

Steps:

  1. Load dataset: datasets.EnzymeCommission()
  2. Choose model: ESM (pre-trained) or GearNet (with structure)
  3. Define task: PropertyPrediction with multi-class classification
  4. Fine-tune pre-trained model or train from scratch
  5. Evaluate using accuracy and per-class metrics

Navigation: references/protein_modeling.md → Model selection (sequence vs structure) → Pre-training strategies

Workflow 3: Drug Repurposing via Knowledge Graphs

Scenario: Find new disease treatments in Hetionet.

Steps:

  1. Load dataset: datasets.Hetionet()
  2. Choose model: RotatE or ComplEx
  3. Define task: KnowledgeGraphCompletion
  4. Train with negative sampling
  5. Query for "Compound-treats-Disease" predictions
  6. Filter by plausibility and mechanism

Navigation: references/knowledge_graphs.md → Hetionet dataset → Model selection → Biomedical applications

Workflow 4: De Novo Molecule Generation

Scenario: Generate drug-like molecules optimized for target binding.

Steps:

  1. Train property predictor on activity data
  2. Choose generation approach: GCPN for RL-based optimization
  3. Define reward function combining affinity, drug-likeness, synthesizability
  4. Generate candidates with property constraints
  5. Validate chemistry and filter by drug-likeness
  6. Rank by multi-objective scoring

Navigation: references/molecular_generation.md → Conditional generation → Multi-objective optimization

Workflow 5: Retrosynthesis Planning

Scenario: Plan synthesis route for target molecule.

Steps:

  1. Load dataset: datasets.USPTO50k()
  2. Train center identification model (RGCN)
  3. Train synthon completion model (GIN)
  4. Combine into end-to-end retrosynthesis pipeline
  5. Apply recursively for multi-step planning
  6. Check commercial availability of building blocks

Navigation: references/retrosynthesis.md → Task types → Multi-step planning

Integration Patterns

With RDKit

Convert between TorchDrug molecules and RDKit:

from torchdrug import data
from rdkit import Chem

# SMILES → TorchDrug molecule
smiles = "CCO"
mol = data.Molecule.from_smiles(smiles)

# TorchDrug → RDKit
rdkit_mol = mol.to_molecule()

# RDKit → TorchDrug
rdkit_mol = Chem.MolFromSmiles(smiles)
mol = data.Molecule.from_molecule(rdkit_mol)

With AlphaFold/ESM

Use predicted structures:

from torchdrug import data

# Load AlphaFold predicted structure
protein = data.Protein.from_pdb("AF-P12345-F1-model_v4.pdb")

# Build graph with spatial edges
graph = protein.residue_graph(
    node_position="ca",
    edge_types=["sequential", "radius"],
    radius_cutoff=10.0
)

With PyTorch Lightning

Wrap tasks for Lightning training:

import pytorch_lightning as pl

class LightningTask(pl.LightningModule):
    def __init__(self, torchdrug_task):
        super().__init__()
        self.task = torchdrug_task

    def training_step(self, batch, batch_idx):
        return self.task(batc

---

*Content truncated.*

software-architecture

davila7

Guide for quality focused software architecture. This skill should be used when users want to write code, design architecture, analyze code, in any case that relates to software development.

473163

scroll-experience

davila7

Expert in building immersive scroll-driven experiences - parallax storytelling, scroll animations, interactive narratives, and cinematic web experiences. Like NY Times interactives, Apple product pages, and award-winning web experiences. Makes websites feel like experiences, not just pages. Use when: scroll animation, parallax, scroll storytelling, interactive story, cinematic website.

12580

planning-with-files

davila7

Implements Manus-style file-based planning for complex tasks. Creates task_plan.md, findings.md, and progress.md. Use when starting complex multi-step tasks, research projects, or any task requiring >5 tool calls.

7966

humanizer

davila7

Remove signs of AI-generated writing from text. Use when editing or reviewing text to make it sound more natural and human-written. Based on Wikipedia's comprehensive "Signs of AI writing" guide. Detects and fixes patterns including: inflated symbolism, promotional language, superficial -ing analyses, vague attributions, em dash overuse, rule of three, AI vocabulary words, negative parallelisms, and excessive conjunctive phrases. Credits: Original skill by @blader - https://github.com/blader/humanizer

10352

game-development

davila7

Game development orchestrator. Routes to platform-specific skills based on project needs.

14649

2d-games

davila7

2D game development principles. Sprites, tilemaps, physics, camera.

12744

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,5711,369

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

1,1161,191

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

1,4181,109

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

1,194747

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

1,154684

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

1,312614

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.