Task tutorial
Standardize salts before a duplicate review
Create an explicit review representation for salt-containing records without overwriting the submitted SMILES.
You will make
A small, local report that retains each source SMILES and adds a standardization result suitable for a deliberately chosen duplicate-review policy.
Steps
- Keep the submitted SMILES unchanged as the source record.
- Parse it locally and standardize with largest_fragment_only=True only when that matches the review policy.
- Compare the review representation, then retain both values and the policy in the resulting report.
import chematic
inputs = ["CC(=O)[O-].[Na+]", "O=C(O)C"]
report = []
for smiles in inputs:
mol = chematic.from_smiles(smiles)
standardized = mol.standardize(largest_fragment_only=True)
report.append({"input_smiles": smiles, "review_smiles": standardized.smiles})
for row in report:
print(row)Expected result
The sodium-acetate input CC(=O)[O-].[Na+] and acetic acid O=C(O)C both report CC(O)=O as review_smiles. The original input strings remain available in the report.
If it does not work
Standardization intentionally changes a representation: largest-fragment selection removes counterions, and other policies may neutralize charges or canonicalize tautomers. Do not use the review form as a replacement for salt form, stereochemistry, provenance, or an asserted material identity.