Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

molfeat

БесплатноБез исполняемых скриптовНе проверен

Molecular featurization for ML (100+ featurizers). ECFP, MACCS, descriptors, pretrained models (ChemBERTa), convert SMILES to features, for QSAR and molecular M

Об этом скилле

Molfeat - Molecular Featurization Hub

Overview

Molfeat is a comprehensive Python library for molecular featurization that unifies 100+ pre-trained embeddings and hand-crafted featurizers. Convert chemical structures (SMILES strings or RDKit molecules) into numerical representations for machine learning tasks including QSAR modeling, virtual screening, similarity searching, and deep learning applications. Features fast parallel processing, scikit-learn compatible transformers, and built-in caching.

Version note: Examples target molfeat 0.11.0 (PyPI stable, May 2025). Requires Python 3.9–3.10 (requires-python caps below 3.11). Depends on datamol ≥0.8.0 and PyTorch ≥1.13. Since 0.8.7, prefer datamol Mol objects over raw rdkit.Chem.Mol. Since 0.10.1, fingerprint calculators use RDKit's rdFingerprintGenerator API internally. Since 0.11.0, pretrained models load in memory and base models are set to PyTorch evaluation mode automatically.

When to Use This Skill

This skill should be used when working with:

  • Molecular machine learning: Building QSAR/QSPR models, property prediction
  • Virtual screening: Ranking compound libraries for biological activity
  • Similarity searching: Finding structurally similar molecules
  • Chemical space analysis: Clustering, visualization, dimensionality reduction
  • Deep learning: Training neural networks on molecular data
  • Featurization pipelines: Converting SMILES to ML-ready representations
  • Cheminformatics: Any task requiring molecular feature extraction

Installation

Use a Python 3.9 or 3.10 environment (molfeat does not install on 3.11+ as of 0.11.0):

uv pip install "molfeat==0.11.0"

# With all pip-installable optional dependencies
uv pip install "molfeat[all]==0.11.0"

Optional dependency extras (PyPI):

  • molfeat[dgl] — GNN models (GIN variants); upstream recommends dgl<=2.0 (graphbolt issues in newer DGL)
  • molfeat[graphormer] — Graphormer models
  • molfeat[transformer] — ChemBERTa, ChemGPT, MolT5
  • molfeat[fcd] — FCD descriptors
  • molfeat[pyg] — PyTorch Geometric featurizers
  • molfeat[viz] — NGLView visualization widgets

External featurizers: MAP4 is not bundled in molfeat extras — install from reymond-group/map4 separately. Some heavy deps (DGL, dgllife, graphormer-pretrained) are easier via conda-forge; see optional dependencies.

Core Concepts

Molfeat organizes featurization into three hierarchical classes:

1. Calculators (molfeat.calc)

Callable objects that convert individual molecules into feature vectors. Accept RDKit Chem.Mol objects or SMILES strings.

Use calculators for:

  • Single molecule featurization
  • Custom processing loops
  • Direct feature computation

Example:

from molfeat.calc import FPCalculator

calc = FPCalculator("ecfp", radius=3, fpSize=2048)
features = calc("CCO")  # Returns numpy array (2048,)

2. Transformers (molfeat.trans)

Scikit-learn compatible transformers that wrap calculators for batch processing with parallelization.

Use transformers for:

  • Batch featurization of molecular datasets
  • Integration with scikit-learn pipelines
  • Parallel processing (automatic CPU utilization)

Example:

from molfeat.trans import MoleculeTransformer
from molfeat.calc import FPCalculator

transformer = MoleculeTransformer(FPCalculator("ecfp"), n_jobs=-1)
features = transformer(smiles_list)  # Parallel processing

3. Pretrained Transformers (molfeat.trans.pretrained)

Specialized transformers for deep learning models with batched inference and caching.

Use pretrained transformers for:

  • State-of-the-art molecular embeddings
  • Transfer learning from large chemical datasets
  • Deep learning feature extraction

Example:

from molfeat.trans.pretrained import PretrainedMolTransformer

transformer = PretrainedMolTransformer("ChemBERTa-77M-MLM", n_jobs=-1)
embeddings = transformer(smiles_list)  # Deep learning embeddings

Quick Start Workflow

Basic Featurization

import datamol as dm
from molfeat.calc import FPCalculator
from molfeat.trans import MoleculeTransformer

# Load molecular data
smiles = ["CCO", "CC(=O)O", "c1ccccc1", "CC(C)O"]

# Create calculator and transformer
calc = FPCalculator("ecfp", radius=3)
transformer = MoleculeTransformer(calc, n_jobs=-1)

# Featurize molecules
features = transformer(smiles)
print(f"Shape: {features.shape}")  # (4, 2048)

Save and Load Configuration

# Save featurizer configuration for reproducibility
transformer.to_state_yaml_file("featurizer_config.yml")

# Reload exact configuration
loaded = MoleculeTransformer.from_state_yaml_file("featurizer_config.yml")

Handle Errors Gracefully

# Process dataset with potentially invalid SMILES
transformer = MoleculeTransformer(
    calc,
    n_jobs=-1,
    ignore_errors=True,  # Continue on failures
    verbose=True          # Log error details
)

features = transformer(smiles_with_errors)
# Returns None for failed molecules

Choosing the Right Featurizer

For Traditional Machine Learning (RF, SVM, XGBoost)

Start with fingerprints:

# ECFP - Most popular, general-purpose
FPCalculator("ecfp", radius=3, fpSize=2048)

# MACCS - Fast, good for scaffold hopping
FPCalculator("maccs")

# MAP4 - Efficient for large-scale screening
FPCalculator("map4")

For interpretable models:

# RDKit 2D descriptors (200+ named properties)
from molfeat.calc import RDKitDescriptors2D
RDKitDescriptors2D()

# Mordred (1800+ comprehensive descriptors)
from molfeat.calc import MordredDescriptors
MordredDescriptors()

Combine multiple featurizers:

from molfeat.trans import FeatConcat

concat = FeatConcat([
    FPCalculator("maccs"),      # 167 dimensions
    FPCalculator("ecfp")         # 2048 dimensions
])  # Result: 2215-dimensional combined features

For Deep Learning

Transformer-based embeddings:

# ChemBERTa - Pre-trained on 77M PubChem compounds
PretrainedMolTransformer("ChemBERTa-77M-MLM")

# ChemGPT - Autoregressive language model
PretrainedMolTransformer("ChemGPT-1.2B")

Graph neural networks:

# GIN models with different pre-training objectives
PretrainedMolTransformer("gin-supervised-masking")
PretrainedMolTransformer("gin-supervised-infomax")

# Graphormer for quantum chemistry
PretrainedMolTransformer("Graphormer-pcqm4mv2")

For Similarity Searching

# ECFP - General purpose, most widely used
FPCalculator("ecfp")

# MACCS - Fast, scaffold-based similarity
FPCalculator("maccs")

# MAP4 - Efficient for large databases
FPCalculator("map4")

# USR/USRCAT - 3D shape similarity
from molfeat.calc import USRDescriptors
USRDescriptors()

For Pharmacophore-Based Approaches

# FCFP - Functional group based
FPCalculator("fcfp")

# CATS - Pharmacophore pair distributions
from molfeat.calc import CATSCalculator
CATSCalculator(mode="2D")

# Gobbi - Explicit pharmacophore features
FPCalculator("gobbi2D")

Common Workflows

Building a QSAR Model

from molfeat.trans import MoleculeTransformer
from molfeat.calc import FPCalculator
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import cross_val_score

# Featurize molecules
transformer = MoleculeTransformer(FPCalculator("ecfp"), n_jobs=-1)
X = transformer(smiles_train)

# Train model
model = RandomForestRegressor(n_estimators=100)
scores = cross_val_score(model, X, y_train, cv=5)
print(f"R² = {scores.mean():.3f}")

# Save configuration for deployment
transformer.to_state_yaml_file("production_featurizer.yml")

Virtual Screening Pipeline

from sklearn.ensemble import RandomForestClassifier

# Train on known actives/inactives
transformer = MoleculeTransformer(FPCalculator("ecfp"), n_jobs=-

Установить molfeat в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read Write Edit Bash

Вложенные файлы

references/api_reference.mdreferences/available_featurizers.mdreferences/examples.md

FAQ

Что делает скилл molfeat?

Molecular featurization for ML (100+ featurizers). ECFP, MACCS, descriptors, pretrained models (ChemBERTa), convert SMILES to features, for QSAR and molecular ML.

Как установить скилл molfeat?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл molfeat запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить molfeat с