🛠️ Molfeat
分子の構造情報(SMILESなど)
📺 まず動画で見る(YouTube)
▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
Molecular featurization for ML (100+ featurizers). ECFP, MACCS, descriptors, pretrained models (ChemBERTa), convert SMILES to features, for QSAR and molecular ML.
🇯🇵 日本人クリエイター向け解説
分子の構造情報(SMILESなど)
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o molfeat.zip https://jpskill.com/download/4189.zip && unzip -o molfeat.zip && rm molfeat.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/4189.zip -OutFile "$d\molfeat.zip"; Expand-Archive "$d\molfeat.zip" -DestinationPath $d -Force; ri "$d\molfeat.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
molfeat.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
molfeatフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-18
- 同梱ファイル
- 4
💬 こう話しかけるだけ — サンプルプロンプト
- › Molfeat を使って、最小構成のサンプルコードを示して
- › Molfeat の主な使い方と注意点を教えて
- › Molfeat を既存プロジェクトに組み込む方法を教えて
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] molfeat
Molfeat - 分子特徴量化ハブ
概要
Molfeatは、100以上の事前学習済み埋め込みと手作りの特徴量化器を統合した、分子特徴量化のための包括的なPythonライブラリです。化学構造(SMILES文字列またはRDKit分子)を数値表現に変換し、QSARモデリング、バーチャルスクリーニング、類似性探索、深層学習アプリケーションなどの機械学習タスクに利用できます。高速な並列処理、scikit-learn互換のトランスフォーマー、および組み込みのキャッシュ機能を備えています。
このスキルを使用する場面
このスキルは、以下のような作業を行う際に使用してください。
- 分子機械学習: QSAR/QSPRモデルの構築、物性予測
- バーチャルスクリーニング: 生物学的活性を持つ化合物ライブラリのランキング
- 類似性探索: 構造的に類似した分子の発見
- 化学空間分析: クラスタリング、可視化、次元削減
- 深層学習: 分子データに対するニューラルネットワークのトレーニング
- 特徴量化パイプライン: SMILESをML対応の表現に変換
- ケモインフォマティクス: 分子特徴抽出を必要とするあらゆるタスク
インストール
uv pip install molfeat
# すべてのオプションの依存関係を含める場合
uv pip install "molfeat[all]"
特定のフィーチャライザーのためのオプションの依存関係:
molfeat[dgl]- GNNモデル (GINバリアント)molfeat[graphormer]- Graphormerモデルmolfeat[transformer]- ChemBERTa, ChemGPT, MolT5molfeat[fcd]- FCD記述子molfeat[map4]- MAP4フィンガープリント
コアコンセプト
Molfeatは、特徴量化を3つの階層的なクラスに整理しています。
1. 計算器 (molfeat.calc)
個々の分子を特徴量ベクトルに変換する呼び出し可能なオブジェクトです。RDKit Chem.Mol オブジェクトまたはSMILES文字列を受け入れます。
計算器を使用する場面:
- 単一分子の特徴量化
- カスタム処理ループ
- 直接的な特徴量計算
例:
from molfeat.calc import FPCalculator
calc = FPCalculator("ecfp", radius=3, fpSize=2048)
features = calc("CCO") # numpy配列 (2048,) を返します
2. トランスフォーマー (molfeat.trans)
計算器をラップし、並列処理によるバッチ処理を可能にするscikit-learn互換のトランスフォーマーです。
トランスフォーマーを使用する場面:
- 分子データセットのバッチ特徴量化
- scikit-learnパイプラインとの統合
- 並列処理 (自動CPU利用)
例:
from molfeat.trans import MoleculeTransformer
from molfeat.calc import FPCalculator
transformer = MoleculeTransformer(FPCalculator("ecfp"), n_jobs=-1)
features = transformer(smiles_list) # 並列処理
3. 事前学習済みトランスフォーマー (molfeat.trans.pretrained)
バッチ推論とキャッシングを備えた深層学習モデル用の特殊なトランスフォーマーです。
事前学習済みトランスフォーマーを使用する場面:
- 最先端の分子埋め込み
- 大規模な化学データセットからの転移学習
- 深層学習の特徴量抽出
例:
from molfeat.trans.pretrained import PretrainedMolTransformer
transformer = PretrainedMolTransformer("ChemBERTa-77M-MLM", n_jobs=-1)
embeddings = transformer(smiles_list) # 深層学習の埋め込み
クイックスタートワークフロー
基本的な特徴量化
import datamol as dm
from molfeat.calc import FPCalculator
from molfeat.trans import MoleculeTransformer
# 分子データをロード
smiles = ["CCO", "CC(=O)O", "c1ccccc1", "CC(C)O"]
# 計算器とトランスフォーマーを作成
calc = FPCalculator("ecfp", radius=3)
transformer = MoleculeTransformer(calc, n_jobs=-1)
# 分子を特徴量化
features = transformer(smiles)
print(f"Shape: {features.shape}") # (4, 2048)
設定の保存とロード
# 再現性のためにフィーチャライザーの設定を保存
transformer.to_state_yaml_file("featurizer_config.yml")
# 正確な設定を再ロード
loaded = MoleculeTransformer.from_state_yaml_file("featurizer_config.yml")
エラーの適切な処理
# 無効なSMILESを含む可能性のあるデータセットを処理
transformer = MoleculeTransformer(
calc,
n_jobs=-1,
ignore_errors=True, # 失敗しても続行
verbose=True # エラーの詳細をログ出力
)
features = transformer(smiles_with_errors)
# 失敗した分子に対してはNoneを返します
適切なフィーチャライザーの選択
従来の機械学習 (RF, SVM, XGBoost) の場合
フィンガープリントから始める:
# ECFP - 最も人気があり、汎用性が高い
FPCalculator("ecfp", radius=3, fpSize=2048)
# MACCS - 高速で、足場ホッピングに適している
FPCalculator("maccs")
# MAP4 - 大規模スクリーニングに効率的
FPCalculator("map4")
解釈可能なモデルの場合:
# RDKit 2D記述子 (200以上の名前付きプロパティ)
from molfeat.calc import RDKitDescriptors2D
RDKitDescriptors2D()
# Mordred (1800以上の包括的な記述子)
from molfeat.calc import MordredDescriptors
MordredDescriptors()
複数のフィーチャライザーを組み合わせる:
from molfeat.trans import FeatConcat
concat = FeatConcat([
FPCalculator("maccs"), # 167次元
FPCalculator("ecfp") # 2048次元
]) # 結果: 2215次元の結合された特徴量
深層学習の場合
トランスフォーマーベースの埋め込み:
# ChemBERTa - 77MのPubChem化合物で事前学習済み
PretrainedMolTransformer("ChemBERTa-77M-MLM")
# ChemGPT - 自己回帰言語モデル
PretrainedMolTransformer("ChemGPT-1.2B")
グラフニューラルネットワーク:
# 異なる事前学習目的を持つGINモデル
PretrainedMolTransformer("gin-supervised-masking")
PretrainedMolTransformer("gin-supervised-infomax")
# 量子化学のためのGraphormer
PretrainedMolTransformer("Graphormer-pcqm4mv2")
類似性探索の場合
# ECFP - 汎用性が高く、最も広く使用されている
FPCalculator("ecfp")
# MACCS - 高速で、足場ベースの類似性
FPCalculator("maccs")
# MAP4 - 大規模データベースに効率的
FPCalculator("map4")
# USR/USRCAT - 3D形状類似性
from molfeat.calc import USRDescriptors
USRDescriptors()
薬理団ベースのアプローチの場合
# FCFP - 官能基ベース
FPCalculator("fcfp" 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
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.
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
uv pip install molfeat
# With all optional dependencies
uv pip install "molfeat[all]"
Optional dependencies for specific featurizers:
molfeat[dgl]- GNN models (GIN variants)molfeat[graphormer]- Graphormer modelsmolfeat[transformer]- ChemBERTa, ChemGPT, MolT5molfeat[fcd]- FCD descriptorsmolfeat[map4]- MAP4 fingerprints
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=-1)
X_train = transformer(train_smiles)
clf = RandomForestClassifier(n_estimators=500)
clf.fit(X_train, train_labels)
# Screen large library
X_screen = transformer(screening_library) # e.g., 1M compounds
predictions = clf.predict_proba(X_screen)[:, 1]
# Rank and select top hits
top_indices = predictions.argsort()[::-1][:1000]
top_hits = [screening_library[i] for i in top_indices]
Similarity Search
from sklearn.metrics.pairwise import cosine_similarity
# Query molecule
calc = FPCalculator("ecfp")
query_fp = calc(query_smiles).reshape(1, -1)
# Database fingerprints
transformer = MoleculeTransformer(calc, n_jobs=-1)
database_fps = transformer(database_smiles)
# Compute similarity
similarities = cosine_similarity(query_fp, database_fps)[0]
top_similar = similarities.argsort()[-10:][::-1]
Scikit-learn Pipeline Integration
from sklearn.pipeline import Pipeline
from sklearn.ensemble import RandomForestClassifier
# Create end-to-end pipeline
pipeline = Pipeline([
('featurizer', MoleculeTransformer(FPCalculator("ecfp"), n_jobs=-1)),
('classifier', RandomForestClassifier(n_estimators=100))
])
# Train and predict directly on SMILES
pipeline.fit(smiles_train, y_train)
predictions = pipeline.predict(smiles_test)
Comparing Multiple Featurizers
featurizers = {
'ECFP': FPCalculator("ecfp"),
'MACCS': FPCalculator("maccs"),
'Descriptors': RDKitDescriptors2D(),
'ChemBERTa': PretrainedMolTransformer("ChemBERTa-77M-MLM")
}
results = {}
for name, feat in featurizers.items():
transformer = MoleculeTransformer(feat, n_jobs=-1)
X = transformer(smiles)
# Evaluate with your ML model
score = evaluate_model(X, y)
results[name] = score
Discovering Available Featurizers
Use the ModelStore to explore all available featurizers:
from molfeat.store.modelstore import ModelStore
store = ModelStore()
# List all available models
all_models = store.available_models
print(f"Total featurizers: {len(all_models)}")
# Search for specific models
chemberta_models = store.search(name="ChemBERTa")
for model in chemberta_models:
print(f"- {model.name}: {model.description}")
# Get usage information
model_card = store.search(name="ChemBERTa-77M-MLM")[0]
model_card.usage() # Display usage examples
# Load model
transformer = store.load("ChemBERTa-77M-MLM")
Advanced Features
Custom Preprocessing
class CustomTransformer(MoleculeTransformer):
def preprocess(self, mol):
"""Custom preprocessing pipeline"""
if isinstance(mol, str):
mol = dm.to_mol(mol)
mol = dm.standardize_mol(mol)
mol = dm.remove_salts(mol)
return mol
transformer = CustomTransformer(FPCalculator("ecfp"), n_jobs=-1)
Batch Processing Large Datasets
def featurize_in_chunks(smiles_list, transformer, chunk_size=10000):
"""Process large datasets in chunks to manage memory"""
all_features = []
for i in range(0, len(smiles_list), chunk_size):
chunk = smiles_list[i:i+chunk_size]
features = transformer(chunk)
all_features.append(features)
return np.vstack(all_features)
Caching Expensive Embeddings
import pickle
cache_file = "embeddings_cache.pkl"
transformer = PretrainedMolTransformer("ChemBERTa-77M-MLM", n_jobs=-1)
try:
with open(cache_file, "rb") as f:
embeddings = pickle.load(f)
except FileNotFoundError:
embeddings = transformer(smiles_list)
with open(cache_file, "wb") as f:
pickle.dump(embeddings, f)
Performance Tips
- Use parallelization: Set
n_jobs=-1to utilize all CPU cores - Batch processing: Process multiple molecules at once instead of loops
- Choose appropriate featurizers: Fingerprints are faster than deep learning models
- Cache pretrained models: Leverage built-in caching for repeated use
- Use float32: Set
dtype=np.float32when precision allows - Handle errors efficiently: Use
ignore_errors=Truefor large datasets
Common Featurizers Reference
Quick reference for frequently used featurizers:
| Featurizer | Type | Dimensions | Speed | Use Case |
|---|---|---|---|---|
ecfp |
Fingerprint | 2048 | Fast | General purpose |
maccs |
Fingerprint | 167 | Very fast | Scaffold similarity |
desc2D |
Descriptors | 200+ | Fast | Interpretable models |
mordred |
Descriptors | 1800+ | Medium | Comprehensive features |
map4 |
Fingerprint | 1024 | Fast | Large-scale screening |
ChemBERTa-77M-MLM |
Deep learning | 768 | Slow* | Transfer learning |
gin-supervised-masking |
GNN | Variable | Slow* | Graph-based models |
*First run is slow; subsequent runs benefit from caching
Resources
This skill includes comprehensive reference documentation:
references/api_reference.md
Complete API documentation covering:
molfeat.calc- All calculator classes and parametersmolfeat.trans- Transformer classes and methodsmolfeat.store- ModelStore usage- Common patterns and integration examples
- Performance optimization tips
When to load: Reference when implementing specific calculators, understanding transformer parameters, or integrating with scikit-learn/PyTorch.
references/available_featurizers.md
Comprehensive catalog of all 100+ featurizers organized by category:
- Transformer-based language models (ChemBERTa, ChemGPT)
- Graph neural networks (GIN, Graphormer)
- Molecular descriptors (RDKit, Mordred)
- Fingerprints (ECFP, MACCS, MAP4, and 15+ others)
- Pharmacophore descriptors (CATS, Gobbi)
- Shape descriptors (USR, ElectroShape)
- Scaffold-based descriptors
When to load: Reference when selecting the optimal featurizer for a specific task, exploring available options, or understanding featurizer characteristics.
Search tip: Use grep to find specific featurizer types:
grep -i "chembert" references/available_featurizers.md
grep -i "pharmacophore" references/available_featurizers.md
references/examples.md
Practical code examples for common scenarios:
- Installation and quick start
- Calculator and transformer examples
- Pretrained model usage
- Scikit-learn and PyTorch integration
- Virtual screening workflows
- QSAR model building
- Similarity searching
- Troubleshooting and best practices
When to load: Reference when implementing specific workflows, troubleshooting issues, or learning molfeat patterns.
Troubleshooting
Invalid Molecules
Enable error handling to skip invalid SMILES:
transformer = MoleculeTransformer(
calc,
ignore_errors=True,
verbose=True
)
Memory Issues with Large Datasets
Process in chunks or use streaming approaches for datasets > 100K molecules.
Pretrained Model Dependencies
Some models require additional packages. Install specific extras:
uv pip install "molfeat[transformer]" # For ChemBERTa/ChemGPT
uv pip install "molfeat[dgl]" # For GIN models
Reproducibility
Save exact configurations and document versions:
transformer.to_state_yaml_file("config.yml")
import molfeat
print(f"molfeat version: {molfeat.__version__}")
Additional Resources
- Official Documentation: https://molfeat-docs.datamol.io/
- GitHub Repository: https://github.com/datamol-io/molfeat
- PyPI Package: https://pypi.org/project/molfeat/
- Tutorial: https://portal.valencelabs.com/datamol/post/types-of-featurizers-b1e8HHrbFMkbun6
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (14,811 bytes)
- 📎 references/api_reference.md (11,502 bytes)
- 📎 references/available_featurizers.md (10,709 bytes)
- 📎 references/examples.md (17,709 bytes)