Overview
The validation system detects:Syntax Errors
Invalid characters, unclosed rings, mismatched parentheses
Semantic Errors
Valence issues, stereochemistry problems, aromaticity errors
Basic Usage
Using the Tool
Direct Parser Usage
Validity Vectors
The parser returns binary validity vectors where:- 1 = valid character
- 0 = invalid/problematic character
Error Categories
The validation system categorizes errors into four types (plan_execute_agent/chemistry_parser.py:229):
1. Unclosed Rings
Detect rings that aren’t properly closed:2. Invalid Characters
Identify characters not part of SMILES syntax:plan_execute_agent/chemistry_parser.py:110):
3. Invalid Parentheses
Detect mismatched or extra parentheses:4. Semantic Issues
Detect chemistry problems even in syntactically valid SMILES:DetectChemistryProblems (plan_execute_agent/chemistry_parser.py:180):
- AtomValenceException
- KekulizeException
- AtomKekulizeException
- Other chemistry violations
Complete Parsing Workflow
Theparse_smiles() function provides comprehensive validation (plan_execute_agent/chemistry_parser.py:258):
Integration with Agent
The agent automatically validates SMILES outputs (plan_execute_agent/chem_tools.py:180):
Batch Validation
Validate multiple SMILES efficiently:Validation in Workflows
Before Property Prediction
After Molecule Generation
Error Visualization
Create visual feedback for errors:Advanced Usage
Custom Validation Rules
Best Practices
When to Validate
When to Validate
- Always validate user input before processing
- Always validate generated SMILES from models
- Before expensive computations or database queries
- After any string manipulation of SMILES
Error Handling
Error Handling
- Check
validfield before using SMILES - Log validity vectors for debugging
- Provide clear feedback to users
- Consider auto-correction for simple errors
Performance
Performance
- Cache validation results for repeated SMILES
- Use batch validation for multiple SMILES
- Validate early to fail fast
- Consider parallel validation for large datasets
Common Issues
- Unclosed Rings
- Invalid Atoms
- Parentheses
- Valence
See Also
- Name Conversion - Convert validated SMILES
- Property Prediction - Predict properties of valid SMILES
- Molecule Operations - Generate and validate molecules
- Chemical Reactions - Validate reaction SMILES