---
name: chemical-structure-deduplication
description: Use when after applying biotransformation rules to generate candidate product structures from input molecules, when the same transformed structure can be produced via multiple transformation pathways or rule applications, and you need a single canonical representation while tracking which rules and.
license: CC-BY-4.0
metadata:
  edam_operation: http://edamontology.org/operation_3629
  edam_topics:
  - http://edamontology.org/topic_0154
  - http://edamontology.org/topic_3407
  tools:
  - RDKit
  - HassounLab/BAM
derived_from:
- doi: 10.1021/acs.analchem.4c01565
  title: bam
evidence_spans:
- standard library for parsing and manipulating SMILES and chemical structures
- HassounLab/BAM
claims: []
provenance:
  collection: https://w3id.org/holobiomicslab/asb-skill/collection/metabolomics/v1
  assembled_by: scripts/collect_metabolomics_collection.py
  sources:
  - build: coll_bam
    doi: 10.1021/acs.analchem.4c01565
    title: bam
  dedup_kept_from: coll_bam
schema_version: 0.2.0
---

# chemical-structure-deduplication

## Summary

Deduplicate transformed molecular structures generated by biotransformation rule application, eliminating redundant candidates while preserving parent–product relationships. This skill ensures a non-redundant candidate pool for downstream molecular structure annotation in untargeted metabolomics.

## When to use

After applying biotransformation rules to generate candidate product structures from input molecules, when the same transformed structure can be produced via multiple transformation pathways or rule applications, and you need a single canonical representation while tracking which rules and parent structures generated each product.

## When NOT to use

- Input structures have not yet been transformed by biotransformation rules—deduplication is a post-transformation step, not an input validation step.
- You require stereochemistry-aware deduplication and canonical SMILES loses stereochemical information critical to your analysis.
- Parent–product traceability is not important for your use case and you only need a unique set of structures without derivation history.

## Inputs

- List of transformed molecular structures with SMILES strings
- Applied rule identifiers for each transformation
- Parent–product relationship metadata
- Original input SMILES for each product

## Outputs

- Deduplicated structure collection in JSON or CSV format
- Mapping of unique product SMILES to multiple derivation pathways
- Consolidated metadata containing original SMILES, all applicable rule identifiers, product SMILES, and transformation metadata

## How to apply

Following biotransformation rule application via RDKit, collect all generated product structures with their associated metadata (original SMILES, applied rule identifier, product SMILES). Canonicalize each product SMILES string using RDKit to ensure consistent representation regardless of input ordering or derivation pathway. Group products by their canonical SMILES and merge entries, consolidating the list of parent structures and rule identifiers that produced each unique product. The deduplication maintains the parent–product relationships as a structured mapping rather than discarding alternative derivation paths, allowing downstream ranking or evaluation steps to leverage evidence from multiple biotransformation rules.

## Related tools

- **RDKit** (Parse, validate, and canonicalize SMILES strings; implement deduplication logic via canonical structure representation)
- **HassounLab/BAM** (Framework implementing biotransformation rule application and structure deduplication as part of the full molecular structure discovery pipeline) — https://github.com/HassounLab/BAM

## Evaluation signals

- All deduplicated product SMILES are unique when canonicalized; no two entries share identical canonical SMILES.
- Cardinality check: number of deduplicated unique products ≤ total number of transformation outputs before deduplication.
- Parent–product traceability is preserved: each deduplicated product record contains the complete list of rule identifiers and original parent structures that generated it.
- Serialized output (JSON or CSV) is well-formed and contains no malformed SMILES entries; RDKit can parse 100% of output SMILES strings without errors.
- Spot-check: manually confirm that products generated by different rules from the same parent are merged into a single entry with multiple rule identifiers listed, not as separate rows.

## Limitations

- Canonical SMILES representation may lose stereochemical information; if stereoisomers are biochemically distinct, additional stereochemistry-aware deduplication logic is required.
- RDKit's canonicalization depends on SMILES input validity; malformed or non-standard SMILES strings may fail to canonicalize or may canonicalize inconsistently.
- Deduplication is exact (canonical string matching); near-duplicate structures (e.g., tautomers, protonation states) are not merged and require additional chemical reasoning to handle.
- Parent–product mapping scales linearly in memory and storage with the number of derivation pathways; very large transformation spaces with many redundant products may require iterative or streaming deduplication.

## Evidence

- [other] Collect and deduplicate the transformed structures, maintaining parent–product relationships.: "Collect and deduplicate the transformed structures, maintaining parent–product relationships."
- [other] Serialize the results as a structured output file (JSON or CSV) containing original SMILES, applied rule identifier, product SMILES, and transformation metadata.: "Serialize the results as a structured output file (JSON or CSV) containing original SMILES, applied rule identifier, product SMILES, and transformation metadata."
- [other] Parse and validate each SMILES string using RDKit to ensure chemical validity.: "Parse and validate each SMILES string using RDKit to ensure chemical validity."
- [other] Apply each biotransformation rule to every input structure, generating candidate product structures according to the rule definitions.: "Apply each biotransformation rule to every input structure, generating candidate product structures according to the rule definitions."
