{"id":"datamol","name":"datamol","summary":"RDKitをPython風にラップし、インターフェースを簡素化し、デフォルトも合理的なものです。標準的な創薬開発にはSMILES解析、標準化、記述子、指紋、クラスタリング、3D準配器、並列処理などが推奨されます。","body":"# Datamol Cheminformatics Skill\n\n## Overview\n\nDatamol is a Python library that provides a lightweight, Pythonic abstraction layer over RDKit for molecular cheminformatics. Simplify complex molecular operations with sensible defaults, efficient parallelization, and modern I/O capabilities. All molecular objects are native `rdkit.Chem.Mol` instances, ensuring full compatibility with the RDKit ecosystem.\n\n**Version note:** Examples target **datamol 0.12.x** (PyPI stable: **0.12.5**, June 2024). Since 0.10.0, modules are lazy-loaded by default (set `DATAMOL_DISABLE_LAZY_LOADING=1` to disable). Since 0.12.2, RDKit is a direct PyPI dependency of datamol. Fingerprints use RDKit's `rdFingerprintGenerator` API (0.12.5+).\n\n**Key capabilities**:\n- Molecular format conversion (SMILES, SELFIES, InChI)\n- Structure standardization and sanitization\n- Molecular descriptors and fingerprints\n- 3D conformer generation and analysis\n- Clustering and diversity selection\n- Scaffold and fragment analysis\n- Chemical reaction application\n- Visualization and alignment\n- Batch processing with parallelization\n- Cloud storage support via fsspec\n\n## Installation and Setup\n\nGuide users to install datamol:\n\n```bash\nuv pip install datamol\n```\n\nRDKit is installed automatically with datamol. For remote file paths (S3, GCS, HTTP), install the matching fsspec backend:\n\n```bash\nuv pip install s3fs   # AWS S3\nuv pip install gcsfs  # Google Cloud Storage\n```\n\n**Import convention**:\n```python\nimport datamol as dm\n```\n\n## Core Workflows\n\nTen workflow areas, each with worked code, are documented in\n[references/core_workflows.md](references/core_workflows.md):\n\n| # | Area | Covers |\n| --- | --- | --- |\n| 1 | Basic molecule handling | `to_mol`, batch conversion, error handling, canonical and isomeric SMILES, sanitization and full standardization |\n| 2 | Reading and writing files | SDF, SMILES, CSV, Excel with rendered structures, the universal reader/writer, and cloud or HTTPS paths |\n| 3 | Descriptors and properties | the standard descriptor set, parallel computation, aromaticity, stereochemistry, flexibility, and filtering |\n| 4 | Fingerprints and similarity | ECFP4 and other types, pairwise and cross-set distances, nearest-neighbour lookup (Tanimoto distance = 1 − similarity) |\n| 5 | Clustering and diversity | similarity clustering, diverse subset picking, and cluster centroids |\n| 6 | Scaffold analysis | Bemis-Murcko scaffolds, grouping and counting, and scaffold-disjoint train/test splits |\n| 7 | Fragmentation | fragmenting molecules, finding common fragments across a library, and fragment-based scoring |\n| 8 | 3D conformers | generation, access, RMSD clustering, representative selection, and SASA |\n| 9 | Visualization | grids, files, publication SVG, substructure alignment, atom and bond highlighting, conformer display |\n| 10 | Chemical reactions | reaction SMARTS, applying to a molecule or a whole library |\n\nThree end-to-end pipelines — load/filter/analyze, SAR by scaffold series, and virtual\nscreening — are in [references/workflow_patterns.md](references/workflow_patterns.md).\n\n## Parallelization\n\nDatamol includes built-in parallelization for many operations. Use `n_jobs` parameter:\n- `n_jobs=1`: Sequential (no parallelization)\n- `n_jobs=-1`: Use all available CPU cores\n- `n_jobs=4`: Use 4 cores\n\n**Functions supporting parallelization**:\n- `dm.read_sdf(..., n_jobs=-1)`\n- `dm.descriptors.batch_compute_many_descriptors(..., n_jobs=-1)`\n- `dm.cluster_mols(..., n_jobs=-1)`\n- `dm.pdist(..., n_jobs=-1)`\n- `dm.conformers.sasa(..., n_jobs=-1)`\n\n**Progress bars**: Many batch operations support `progress=True` parameter.\n\n## Reference Documentation\n\nFor detailed API documentation, consult these reference files:\n\n- **`references/core_api.md`**: Core namespace functions (conversions, standardization, fingerprints, clustering)\n- **`references/io_module.md`**: File I/O operations (read/write SDF, CSV, Excel, remote files)\n- **`references/conformers_module.md`**: 3D conformer generation, clustering, SASA calculations\n- **`references/descriptors_viz.md`**: Molecular descriptors and visualization functions\n- **`references/fragments_scaffolds.md`**: Scaffold extraction, BRICS/RECAP fragmentation\n- **`references/reactions_data.md`**: Chemical reactions and toy datasets\n\n## Best Practices\n\n1. **Always standardize molecules** from external sources:\n   ```python\n   mol = dm.standardize_mol(mol, disconnect_metals=True, normalize=True, reionize=True)\n   ```\n\n2. **Check for None values** after molecule parsing:\n   ```python\n   mol = dm.to_mol(smiles)\n   if mol is None:\n       # Handle invalid SMILES\n   ```\n\n3. **Use parallel processing** for large datasets:\n   ```python\n   result = dm.operation(..., n_jobs=-1, progress=True)\n   ```\n\n4. **Use cloud I/O only when requested** — confirm remote write paths; install `s3fs`/`gcsfs` as needed:\n   ```python\n   df = dm.read_sdf(\"s3://bucket/compounds.sdf\")\n   ```\n\n5. **Use appropriate fingerprints** for similarity:\n   - ECFP (Morgan): General purpose, structural similarity\n   - MACCS: Fast, smaller feature space\n   - Atom pairs: Considers atom pairs and distances\n\n6. **Consider scale limitations**:\n   - Butina clustering: ~1,000 molecules (full distance matrix)\n   - For larger datasets: Use diversity selection or hierarchical methods\n\n7. **Scaffold splitting for ML**: Ensure proper train/test separation by scaffold\n\n8. **Align molecules** when visualizing SAR series\n\n## Error Handling\n\n```python\n# Safe molecule creation\ndef safe_to_mol(smiles):\n    try:\n        mol = dm.to_mol(smiles)\n        if mol is not None:\n            mol = dm.standardize_mol(mol)\n        return mol\n    except Exception as e:\n        print(f\"Failed to process {smiles}: {e}\")\n        return None\n\n# Safe batch processing\nvalid_mols = []\nfor smiles in smiles_list:\n    mol = safe_to_mol(smiles)\n    if mol is not None:\n        valid_mols.append(mol)\n```\n\n## Integration with Machine Learning\n\nDatamol ships with `scipy` and `scikit-learn` as dependencies. Import them as normal PyPI packages — they are not scripts bundled in this skill.\n\n```python\nimport numpy as np\n\n# Feature generation\nX = np.array([dm.to_fp(mol) for mol in mols])\n\n# Or descriptors\ndesc_df = dm.descriptors.batch_compute_many_descriptors(mols, n_jobs=-1)\nX = desc_df.values\n\n# Train model (scikit-learn PyPI package)\nfrom sklearn.ensemble import RandomForestRegressor  # third-party library\nmodel = RandomForestRegressor()\nmodel.fit(X, y_target)\n\n# Predict\npredictions = model.predict(X_test)\n```\n\n## Troubleshooting\n\n**Issue**: Molecule parsing fails\n- **Solution**: Use `dm.standardize_smiles()` first or try `dm.fix_mol()`\n\n**Issue**: Memory errors with clustering\n- **Solution**: Use `dm.pick_diverse()` instead of full clustering for large sets\n\n**Issue**: Slow conformer generation\n- **Solution**: Reduce `n_confs` or increase `rms_cutoff` to generate fewer conformers\n\n**Issue**: Remote file access fails\n- **Solution**: Install the matching fsspec backend (`uv pip install s3fs` or `gcsfs`) and verify only the provider credentials needed for that backend are set (see Remote file support above)\n\n## Additional Resources\n\n- **Datamol Documentation**: https://docs.datamol.io/\n- **RDKit Documentation**: https://www.rdkit.org/docs/\n- **GitHub Repository**: https://github.com/datamol-io/datamol","author":"@K-Dense-AI","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/datamol","license":"MIT","category":"coding","lang":"en","tokens":1808,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/conformers_module.md","size":5022,"sha256":"3735cad8894e1c8a592571d87230f8d39dea60d5e5d99383e7f556abffd4bea1"},{"path":"references/core_api.md","size":4721,"sha256":"8ab67ec05e958f0aa90cd3990ac8e5a5e26828e769969ca9169e4df93c5c1ef8"},{"path":"references/core_workflows.md","size":12013,"sha256":"9da350395b5d868dd9905dc108d39a4e2e21d361893c2d56ffef0821b455e9ff"},{"path":"references/descriptors_viz.md","size":7366,"sha256":"e15a98657fe5b83c64b0de65d26aec840393be987045a854d8c582cdbf6424db"},{"path":"references/fragments_scaffolds.md","size":5808,"sha256":"9e9c9e2db781792f117fb72d1d819d71b7ab476ca2d5572e7732f5f59a28828b"},{"path":"references/io_module.md","size":4812,"sha256":"68455850206e7de38731a59c2d88019971499006c0249833e33fa4cbd46df461"},{"path":"references/reactions_data.md","size":6742,"sha256":"deb60ec2111eb31395f2f0a822c020d50d754a7d316f2451160e3a5456dfe5b4"},{"path":"references/workflow_patterns.md","size":2798,"sha256":"5d083f499cd45aef8c4caad179186a8c0b959fd123d3c9d9a1500e7ec4ef184e"}],"requires":{"mcp":[],"tools":["Read Write Edit Bash"]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":["docs.datamol.io","www.rdkit.org"]}}