File size: 409 Bytes
233f6d4 6a594c1 233f6d4 6a594c1 233f6d4 6a594c1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | from rdkit import Chem
MAX_HEAVY_ATOMS = 50
def validate_smiles(smiles: str) -> bool:
"""Return True if the SMILES is parseable, non-empty, and within size limits."""
if not smiles or not smiles.strip():
return False
mol = Chem.MolFromSmiles(smiles.strip())
if mol is None:
return False
if mol.GetNumHeavyAtoms() > MAX_HEAVY_ATOMS:
return False
return True
|