---
name: smiles-inchi-round-trip-validation
description: 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.
license: CC-BY-4.0
metadata:
  edam_operation: http://edamontology.org/operation_3762
  edam_topics:
  - http://edamontology.org/topic_3047
  - http://edamontology.org/topic_0154
  tools:
  - MSMetaEnhancer
  - pytest
  - RDKit
derived_from:
- doi: 10.21105/joss.04494
  title: msmetaenhancer
evidence_spans:
- MSMetaEnhancer is a tool used for `.msp` files annotation
- 'Converter Builder: Automatically discovers and instantiates available converters'
- make sure the existing tests still work by running ``pytest``
claims: []
provenance:
  collection: https://w3id.org/holobiomicslab/asb-skill/collection/metabolomics/v1
  assembled_by: scripts/collect_metabolomics_collection.py
  sources:
  - build: coll_msmetaenhancer
    doi: 10.21105/joss.04494
    title: msmetaenhancer
  dedup_kept_from: coll_msmetaenhancer
schema_version: 0.2.0
---

# 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."
