$npx -y skills add K-Dense-AI/scientific-agent-skills --skill deepchemMolecular ML with diverse featurizers and pre-built datasets. Use for property prediction (ADMET, toxicity) with traditional ML or GNNs when you want extensive featurization options and MoleculeNet benchmarks. Best for quick experiments with pre-trained models, diverse molecular
| 1 | # DeepChem |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | DeepChem is a comprehensive Python library for applying machine learning to chemistry, materials science, and biology. Enable molecular property prediction, drug discovery, materials design, and biomolecule analysis through specialized neural networks, molecular featurization methods, and pretrained models. |
| 6 | |
| 7 | **Version note:** Examples target **deepchem 2.8.0** (PyPI stable, Apr 2024). Requires **Python 3.7–3.11** (`<3.12` on PyPI). Core utilities (loaders, featurizers, MoleculeNet) work without a DL backend; GNN and transformer models need the matching extra (`torch`, `tensorflow`, or `jax`). Install the backend framework first when using GPU builds. |
| 8 | |
| 9 | ## When to Use This Skill |
| 10 | |
| 11 | This skill should be used when: |
| 12 | - Loading and processing molecular data (SMILES strings, SDF files, protein sequences) |
| 13 | - Predicting molecular properties (solubility, toxicity, binding affinity, ADMET properties) |
| 14 | - Training models on chemical/biological datasets |
| 15 | - Using MoleculeNet benchmark datasets (Tox21, BBBP, Delaney, etc.) |
| 16 | - Converting molecules to ML-ready features (fingerprints, graph representations, descriptors) |
| 17 | - Implementing graph neural networks for molecules (GCN, GAT, MPNN, AttentiveFP) |
| 18 | - Applying transfer learning with pretrained models (ChemBERTa, GROVER, MolFormer) |
| 19 | - Predicting crystal/materials properties (bandgap, formation energy) |
| 20 | - Analyzing protein or DNA sequences |
| 21 | |
| 22 | ## Core Capabilities |
| 23 | |
| 24 | ### 1. Molecular Data Loading and Processing |
| 25 | |
| 26 | DeepChem provides specialized loaders for various chemical data formats: |
| 27 | |
| 28 | ```python |
| 29 | import deepchem as dc |
| 30 | |
| 31 | # Load CSV with SMILES |
| 32 | featurizer = dc.feat.CircularFingerprint(radius=2, size=2048) |
| 33 | loader = dc.data.CSVLoader( |
| 34 | tasks=['solubility', 'toxicity'], |
| 35 | feature_field='smiles', |
| 36 | featurizer=featurizer |
| 37 | ) |
| 38 | dataset = loader.create_dataset('molecules.csv') |
| 39 | |
| 40 | # Load SDF files |
| 41 | loader = dc.data.SDFLoader(tasks=['activity'], featurizer=featurizer) |
| 42 | dataset = loader.create_dataset('compounds.sdf') |
| 43 | |
| 44 | # Load protein sequences |
| 45 | loader = dc.data.FASTALoader() |
| 46 | dataset = loader.create_dataset('proteins.fasta') |
| 47 | ``` |
| 48 | |
| 49 | **Key Loaders**: |
| 50 | - `CSVLoader`: Tabular data with molecular identifiers |
| 51 | - `SDFLoader`: Molecular structure files |
| 52 | - `FASTALoader`: Protein/DNA sequences |
| 53 | - `ImageLoader`: Molecular images |
| 54 | - `JsonLoader`: JSON-formatted datasets |
| 55 | |
| 56 | ### 2. Molecular Featurization |
| 57 | |
| 58 | Convert molecules into numerical representations for ML models. |
| 59 | |
| 60 | #### Decision Tree for Featurizer Selection |
| 61 | |
| 62 | ``` |
| 63 | Is the model a graph neural network? |
| 64 | ├─ YES → Use graph featurizers |
| 65 | │ ├─ Standard GNN → MolGraphConvFeaturizer |
| 66 | │ ├─ Message passing → DMPNNFeaturizer |
| 67 | │ └─ Pretrained → GroverFeaturizer |
| 68 | │ |
| 69 | └─ NO → What type of model? |
| 70 | ├─ Traditional ML (RF, XGBoost, SVM) |
| 71 | │ ├─ Fast baseline → CircularFingerprint (ECFP) |
| 72 | │ ├─ Interpretable → RDKitDescriptors |
| 73 | │ └─ Maximum coverage → MordredDescriptors |
| 74 | │ |
| 75 | ├─ Deep learning (non-graph) |
| 76 | │ ├─ Dense networks → CircularFingerprint |
| 77 | │ └─ CNN → SmilesToImage |
| 78 | │ |
| 79 | ├─ Sequence models (LSTM, Transformer) |
| 80 | │ └─ SmilesToSeq |
| 81 | │ |
| 82 | └─ 3D structure analysis |
| 83 | └─ CoulombMatrix |
| 84 | ``` |
| 85 | |
| 86 | #### Example Featurization |
| 87 | |
| 88 | ```python |
| 89 | # Fingerprints (for traditional ML) |
| 90 | fp = dc.feat.CircularFingerprint(radius=2, size=2048) |
| 91 | |
| 92 | # Descriptors (for interpretable models) |
| 93 | desc = dc.feat.RDKitDescriptors() |
| 94 | |
| 95 | # Graph features (for GNNs) |
| 96 | graph_feat = dc.feat.MolGraphConvFeaturizer() |
| 97 | |
| 98 | # Apply featurization |
| 99 | features = fp.featurize(['CCO', 'c1ccccc1']) |
| 100 | ``` |
| 101 | |
| 102 | **Selection Guide**: |
| 103 | - **Small datasets (<1K)**: CircularFingerprint or RDKitDescriptors |
| 104 | - **Medium datasets (1K-100K)**: CircularFingerprint or graph featurizers |
| 105 | - **Large datasets (>100K)**: Graph featurizers (MolGraphConvFeaturizer, DMPNNFeaturizer) |
| 106 | - **Transfer learning**: Pretrained model featurizers (GroverFeaturizer) |
| 107 | |
| 108 | See `references/api_reference.md` for complete featurizer documentation. |
| 109 | |
| 110 | ### 3. Data Splitting |
| 111 | |
| 112 | **Critical**: For drug discovery tasks, use `ScaffoldSplitter` to prevent data leakage from similar molecular structures appearing in both training and test sets. |
| 113 | |
| 114 | ```python |
| 115 | # Scaffold splitting (recommended for molecules) |
| 116 | splitter = dc.splits.ScaffoldSplitter() |
| 117 | train, valid, test = splitter.train_valid_test_split( |
| 118 | dataset, |
| 119 | frac_train=0.8, |
| 120 | frac_valid=0.1, |
| 121 | frac_test=0.1 |
| 122 | ) |
| 123 | |
| 124 | # Ra |