MCP HubMCP Hub
스킬 목록으로 돌아가기

molfeat

K-Dense-AI
업데이트됨 Today
26,534
2,743
26,534
GitHub에서 보기
기타ai

정보

Molfeat는 분자 구조(예: SMILES 문자열)를 머신러닝용 수치형 특징으로 변환하는 Python 라이브러리로, 지문(fingerprints), 기술자(descriptors), 사전 훈련된 모델을 포함한 100개 이상의 특징화 도구를 지원합니다. QSAR, 가상 스크리닝, 분자 머신러닝 작업을 위해 설계되었으며, scikit-learn 호환성과 병렬 처리를 제공합니다. Claude Code 프로젝트 내에서 예측 모델링이나 유사성 검색을 위해 분자를 특징화해야 할 때 이 기술을 사용하세요.

빠른 설치

Claude Code

추천
기본
npx skills add K-Dense-AI/claude-scientific-skills -a claude-code
플러그인 명령대체
/plugin add https://github.com/K-Dense-AI/claude-scientific-skills
Git 클론대체
git clone https://github.com/K-Dense-AI/claude-scientific-skills.git ~/.claude/skills/molfeat

Claude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요

문서

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=-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 = score_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

import numpy as np

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

Prefer molfeat's built-in pretrained-model cache when possible. For custom embedding caches, use NumPy arrays instead of pickle (pickle can execute arbitrary code when loading untrusted files):

import numpy as np
from pathlib import Path

cache_file = Path("embeddings_cache.npz")  # fixed path under your project
transformer = PretrainedMolTransformer("ChemBERTa-77M-MLM", n_jobs=-1)

if cache_file.exists():
    embeddings = np.load(cache_file)["embeddings"]
else:
    embeddings = transformer(smiles_list)
    np.savez(cache_file, embeddings=embeddings)

Performance Tips

  1. Use parallelization: Set n_jobs=-1 to utilize all CPU cores
  2. Batch processing: Process multiple molecules at once instead of loops
  3. Choose appropriate featurizers: Fingerprints are faster than deep learning models
  4. Cache pretrained models: Leverage built-in caching for repeated use
  5. Use float32: Set dtype=np.float32 when precision allows
  6. Handle errors efficiently: Use ignore_errors=True for large datasets

Common Featurizers Reference

Quick reference for frequently used featurizers:

FeaturizerTypeDimensionsSpeedUse Case
ecfpFingerprint2048FastGeneral purpose
maccsFingerprint167Very fastScaffold similarity
desc2DDescriptors200+FastInterpretable models
mordredDescriptors1800+MediumComprehensive features
map4Fingerprint1024FastLarge-scale screening
ChemBERTa-77M-MLMDeep learning768Slow*Transfer learning
gin-supervised-maskingGNNVariableSlow*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 parameters
  • molfeat.trans - Transformer classes and methods
  • molfeat.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 (pin version for reproducibility):

uv pip install "molfeat[transformer]==0.11.0"  # For ChemBERTa/ChemGPT
uv pip install "molfeat[dgl]==0.11.0"          # For GIN models
uv pip install "molfeat[graphormer]==0.11.0"   # For Graphormer

Reproducibility

Save exact configurations and document versions:

transformer.to_state_yaml_file("config.yml")
import molfeat
print(f"molfeat version: {molfeat.__version__}")

Additional Resources

GitHub 저장소

K-Dense-AI/claude-scientific-skills
경로: skills/molfeat
0
agent-skillsai-scientistbioinformaticschemoinformaticsclaudeclaude-skills

연관 스킬

llamaguard

기타

LlamaGuard는 폭력 및 혐오 발언 등 6가지 안전 범주에서 LLM 입력과 출력을 조정하기 위한 Meta의 70-80억 파라미터 모델입니다. 94-95% 정확도를 제공하며 vLLM, Hugging Face 또는 Amazon SageMaker를 사용해 배포할 수 있습니다. 이 기술을 사용하여 AI 애플리케이션에 콘텐츠 필터링 및 안전 가드레일을 손쉽게 통합하세요.

스킬 보기

cost-optimization

기타

이 Claude Skill은 리소스 적정화, 태깅 전략, 지출 분석을 통해 개발자들이 클라우드 비용을 최적화할 수 있도록 지원합니다. AWS, Azure, GCP에서 클라우드 비용을 절감하고 비용 거버넌스를 구현하기 위한 프레임워크를 제공합니다. 인프라 비용을 분석하거나, 리소스를 적정화하거나, 예산 제약을 충족해야 할 때 사용하세요.

스킬 보기

quantizing-models-bitsandbytes

기타

이 스킬은 bitsandbytes를 사용하여 LLM을 8비트 또는 4비트 정밀도로 양자화하며, 최소한의 정확도 손실로 50-75%의 메모리 감소를 달성합니다. 제한된 GPU 메모리에서 더 큰 모델을 실행하거나 추론을 가속화하는 데 이상적이며, INT8, NF4, FP4와 같은 형식을 지원합니다. 이 스킬은 HuggingFace Transformers와 통합되어 QLoRA 학습 및 8비트 옵티마이저를 가능하게 합니다.

스킬 보기

dispatching-parallel-agents

기타

이 Claude Skill은 3개 이상의 독립적인 문제를 동시에 조사하고 해결하기 위해 다중 에이전트를 배치합니다. 공유 상태나 의존성 없이 해결 가능한 무관련 장애 시나리오에 맞게 설계되었습니다. 핵심 기능은 병렬 문제 해결로, 각 독립 문제 영역마다 하나의 에이전트를 할당하여 효율성을 극대화합니다.

스킬 보기