SMILES–InChI Round-Trip Validation
Summary
Validate the chemical correctness and consistency of local SMILES↔InChI conversions by performing bidirectional conversions on test molecules and comparing structural equivalence. This ensures that a ComputeConverter subclass using RDKit produces chemically valid and reversible transformations without relying on external web services.
When to use
You have implemented a new RDKit-based ComputeConverter for SMILES↔InChI conversions and need to verify that the conversion methods preserve molecular structure integrity across round-trip transformations (SMILES → InChI → SMILES or vice versa) before registering it in the MSMetaEnhancer pipeline.
When NOT to use
- You are validating web service converters (e.g., CTS, CIR, PubChem) — use their API response schemas and rate-limit handling instead.
- Input molecules contain features unsupported by RDKit (e.g., exotic metals, unusual bonding) — RDKit may fail to parse or generate InChI for these.
- Your goal is to benchmark speed or throughput rather than correctness — round-trip validation is a correctness check, not a performance benchmark.
Inputs
- Reference SMILES strings (e.g., 'CC(=O)O', 'c1ccccc1')
- InChI strings generated by RDKit from test SMILES
- MSMetaEnhancer ComputeConverter subclass source code
Outputs
- pytest test report showing pass/fail for each round-trip conversion
- Validated converter implementation with confirmed chemical equivalence
- Assertion results for output dictionary structure and content correctness
How to apply
Create a pytest test file that instantiates the converter and tests conversion accuracy by: (1) selecting a set of reference SMILES inputs with known chemical structures (e.g., simple organic molecules, isomers); (2) converting SMILES to InChI using RDKit's Chem.inchi.MolToInchi; (3) converting the InChI back to canonical SMILES using RDKit's Chem.MolFromInchi and Chem.MolToSmiles with isomeric=False; (4) comparing the canonical SMILES output against the input canonical form to detect structural loss or artifact generation; (5) verifying output dictionary structure contains correct target attribute keys; (6) running pytest to confirm the converter passes all chemical correctness assertions and does not break existing tests.
Related tools
- RDKit (Performs local SMILES parsing (Chem.MolFromSmiles), InChI generation (Chem.inchi.MolToInchi), and canonical SMILES export for round-trip validation)
- pytest (Executes test suite to validate converter instantiation, conversion accuracy, output structure, and chemical correctness of round-trip transformations)
- MSMetaEnhancer (Framework providing ComputeConverter base class and registration mechanism for the validated SMILES–InChI converter) — https://github.com/RECETOX/MSMetaEnhancer
Examples
pytest tests/test_rdkit_converter.py -v
Evaluation signals
- Converter instantiation succeeds without import or initialization errors.
- Round-trip SMILES → InChI → canonical SMILES produces identical or chemically equivalent canonical SMILES output (e.g., Tautomers and stereoisomers handled consistently).
- Output dictionary keys match the target attribute names specified in the conversions list (e.g., 'inchi', 'canonical_smiles').
- All pytest assertions pass for reference SMILES test set covering simple, aromatic, and chiral molecules.
- pytest run confirms no regression in existing MSMetaEnhancer tests after converter registration.
Limitations
- RDKit may fail or produce invalid InChI for molecules with exotic metal centers, radical states, or non-standard bonding not representable in standard chemical structure formats.
- Round-trip conversion is sensitive to SMILES canonicalization settings; non-canonical input SMILES may not round-trip to identical strings, requiring comparison via canonical form or InChIKey.
- InChI generation from SMILES may lose stereo or charge information depending on RDKit configuration; test cases should document expected information loss.
- The validation approach does not cover dynamic properties (e.g., tautomeric stability, reactivity) that web services might infer from cheminformatics models.
Evidence
- [other] Implement conversion methods using RDKit to perform local molecular structure transformations (e.g., parse SMILES strings with RDKit Chem.MolFromSmiles and generate InChI with Chem.inchi.MolToInchi).: "Implement conversion methods using RDKit to perform local molecular structure transformations (e.g., parse SMILES strings with RDKit Chem.MolFromSmiles and generate InChI with Chem.inchi.MolToInchi)."
- [other] Create a pytest test file that validates converter instantiation and tests conversion accuracy against reference SMILES inputs, verifying output structure and chemical correctness.: "Create a pytest test file that validates converter instantiation and tests conversion accuracy against reference SMILES inputs, verifying output structure and chemical correctness."
- [other] MSMetaEnhancer uses RDKit as a reference implementation for implementing ComputeConverter subclasses that perform local chemical structure conversions.: "MSMetaEnhancer uses RDKit as a reference implementation for implementing ComputeConverter subclasses that perform local chemical structure conversions."
- [other] Run pytest to confirm existing tests still pass and new converter tests execute successfully.: "Run pytest to confirm existing tests still pass and new converter tests execute successfully."
- [readme] All functionality is tested with the pytest framework.: "All functionality is tested with the pytest framework."
1---2name: smiles-inchi-round-trip-validation3description: Use when you have implemented a new RDKit-based ComputeConverter for SMILES↔InChI conversions and need to verify that the conversion methods preserve molecular structure integrity across round-trip transformations (SMILES → InChI → SMILES or vice versa) before registering it in the MSMetaEnhancer.4license: CC-BY-4.05---67# SMILES–InChI Round-Trip Validation89## Summary1011Validate the chemical correctness and consistency of local SMILES↔InChI conversions by performing bidirectional conversions on test molecules and comparing structural equivalence. This ensures that a ComputeConverter subclass using RDKit produces chemically valid and reversible transformations without relying on external web services.1213## When to use1415You have implemented a new RDKit-based ComputeConverter for SMILES↔InChI conversions and need to verify that the conversion methods preserve molecular structure integrity across round-trip transformations (SMILES → InChI → SMILES or vice versa) before registering it in the MSMetaEnhancer pipeline.1617## When NOT to use1819- You are validating web service converters (e.g., CTS, CIR, PubChem) — use their API response schemas and rate-limit handling instead.20- Input molecules contain features unsupported by RDKit (e.g., exotic metals, unusual bonding) — RDKit may fail to parse or generate InChI for these.21- Your goal is to benchmark speed or throughput rather than correctness — round-trip validation is a correctness check, not a performance benchmark.2223## Inputs2425- Reference SMILES strings (e.g., 'CC(=O)O', 'c1ccccc1')26- InChI strings generated by RDKit from test SMILES27- MSMetaEnhancer ComputeConverter subclass source code2829## Outputs3031- pytest test report showing pass/fail for each round-trip conversion32- Validated converter implementation with confirmed chemical equivalence33- Assertion results for output dictionary structure and content correctness3435## How to apply3637Create a pytest test file that instantiates the converter and tests conversion accuracy by: (1) selecting a set of reference SMILES inputs with known chemical structures (e.g., simple organic molecules, isomers); (2) converting SMILES to InChI using RDKit's Chem.inchi.MolToInchi; (3) converting the InChI back to canonical SMILES using RDKit's Chem.MolFromInchi and Chem.MolToSmiles with isomeric=False; (4) comparing the canonical SMILES output against the input canonical form to detect structural loss or artifact generation; (5) verifying output dictionary structure contains correct target attribute keys; (6) running pytest to confirm the converter passes all chemical correctness assertions and does not break existing tests.3839## Related tools4041- **RDKit** (Performs local SMILES parsing (Chem.MolFromSmiles), InChI generation (Chem.inchi.MolToInchi), and canonical SMILES export for round-trip validation)42- **pytest** (Executes test suite to validate converter instantiation, conversion accuracy, output structure, and chemical correctness of round-trip transformations)43- **MSMetaEnhancer** (Framework providing ComputeConverter base class and registration mechanism for the validated SMILES–InChI converter) — https://github.com/RECETOX/MSMetaEnhancer4445## Examples4647```48pytest tests/test_rdkit_converter.py -v49```5051## Evaluation signals5253- Converter instantiation succeeds without import or initialization errors.54- Round-trip SMILES → InChI → canonical SMILES produces identical or chemically equivalent canonical SMILES output (e.g., Tautomers and stereoisomers handled consistently).55- Output dictionary keys match the target attribute names specified in the conversions list (e.g., 'inchi', 'canonical_smiles').56- All pytest assertions pass for reference SMILES test set covering simple, aromatic, and chiral molecules.57- pytest run confirms no regression in existing MSMetaEnhancer tests after converter registration.5859## Limitations6061- RDKit may fail or produce invalid InChI for molecules with exotic metal centers, radical states, or non-standard bonding not representable in standard chemical structure formats.62- Round-trip conversion is sensitive to SMILES canonicalization settings; non-canonical input SMILES may not round-trip to identical strings, requiring comparison via canonical form or InChIKey.63- InChI generation from SMILES may lose stereo or charge information depending on RDKit configuration; test cases should document expected information loss.64- The validation approach does not cover dynamic properties (e.g., tautomeric stability, reactivity) that web services might infer from cheminformatics models.6566## Evidence6768- [other] Implement conversion methods using RDKit to perform local molecular structure transformations (e.g., parse SMILES strings with RDKit Chem.MolFromSmiles and generate InChI with Chem.inchi.MolToInchi).: "Implement conversion methods using RDKit to perform local molecular structure transformations (e.g., parse SMILES strings with RDKit Chem.MolFromSmiles and generate InChI with Chem.inchi.MolToInchi)."69- [other] Create a pytest test file that validates converter instantiation and tests conversion accuracy against reference SMILES inputs, verifying output structure and chemical correctness.: "Create a pytest test file that validates converter instantiation and tests conversion accuracy against reference SMILES inputs, verifying output structure and chemical correctness."70- [other] MSMetaEnhancer uses RDKit as a reference implementation for implementing ComputeConverter subclasses that perform local chemical structure conversions.: "MSMetaEnhancer uses RDKit as a reference implementation for implementing ComputeConverter subclasses that perform local chemical structure conversions."71- [other] Run pytest to confirm existing tests still pass and new converter tests execute successfully.: "Run pytest to confirm existing tests still pass and new converter tests execute successfully."72- [readme] All functionality is tested with the pytest framework.: "All functionality is tested with the pytest framework."