K-Dense-AI/scientific-agent-skills / skills/rdkit
rdkit
VerifiedCheminformatics toolkit for fine-grained molecular control. SMILES/SDF parsing, descriptors (MW, LogP, TPSA), fingerprints, substructure search, 2D/3D generation, similarity, reactions. For standard workflows with simpler interface, use datamol (wrapper around RDKit). Use rdkit for advanced control, custom sanitization, specialized algorithms.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.7 KB |
| references/api_reference.md | markdown | 18.4 KB |
| references/core_capabilities.md | markdown | 17.6 KB |
| references/descriptors_reference.md | markdown | 12.4 KB |
| references/review.md | markdown | 5.3 KB |
| references/smarts_patterns.md | markdown | 7.8 KB |
| references/workflows_and_best_practices.md | markdown | 8.3 KB |
| scripts/_common.py | script | 2.6 KB |
| scripts/molecular_properties.py | script | 7.1 KB |
| scripts/similarity_search.py | script | 10.3 KB |
| scripts/substructure_filter.py | script | 12.7 KB |
scripts/_common.py
View on GitHub"""Shared, source-index-preserving molecular file reader (no standardization)."""
import sys
from pathlib import Path
from rdkit import Chem
SOURCE_INDEX = "_SkillRDKitSourceIndex"
def read_molecule_records(file_path):
"""Yield (one-based source record, sanitized nonempty Mol).
SMILES input has no header; first field is SMILES and optional remainder is
the name. CXSMILES extensions are parsed before names. Blank/comment lines
are ignored but physical line IDs are retained.
SDF IDs are supplier record numbers. Invalid records are logged to stderr.
"""
path = Path(file_path)
if not path.is_file():
raise FileNotFoundError(f"File not found: {path}")
suffix = path.suffix.lower()
if suffix in {".smi", ".smiles", ".txt"}:
with path.open(encoding="utf-8") as stream:
for index, line in enumerate(stream, 1):
fields = line.strip().split(maxsplit=1)
if not fields or fields[0].startswith("#"):
continue
params = Chem.SmilesParserParams()
params.parseName = True
mol = Chem.MolFromSmiles(line.strip(), params)
if mol is None or mol.GetNumAtoms() == 0:
print(f"[FAIL] Invalid molecule at record {index}", file=sys.stderr)
continue
mol.SetIntProp(SOURCE_INDEX, index)
yield index, mol
elif suffix == ".mol":
mol = Chem.MolFromMolFile(str(path))
if mol is None or mol.GetNumAtoms() == 0:
print("[FAIL] Invalid molecule at record 1", file=sys.stderr)
return
mol.SetIntProp(SOURCE_INDEX, 1)
yield 1, mol
elif suffix == ".sdf":
with Chem.SDMolSupplier(str(path)) as supplier:
for index, mol in enumerate(supplier, 1):
if mol is None or mol.GetNumAtoms() == 0:
print(f"[FAIL] Invalid molecule at record {index}", file=sys.stderr)
continue
# Overwrite any input property with the actual source record.
mol.SetIntProp(SOURCE_INDEX, index)
yield index, mol
else:
raise ValueError(f"Unsupported file format: {suffix}")
def molecule_smiles(mol):
"""Preserve enhanced stereo groups when plain isomeric SMILES is insufficient."""
if mol.GetStereoGroups():
return Chem.MolToCXSmiles(
mol, Chem.SmilesWriteParams(), flags=Chem.CXSmilesFields.CX_ENHANCEDSTEREO
)
return Chem.MolToSmiles(mol, canonical=True, isomericSmiles=True)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |