SMILES and MOL file parsing for molecular graph construction
Summary
Parse molecular structure data from SMILES strings or MOL files using RDKit to extract atom and bond features, enabling conversion into node-edge graph representations suitable for GNN input. This skill is essential for preparing chemical structure data from spectroscopy databases into machine-learning-ready formats.
When to use
When you have molecular structures encoded as SMILES strings or MOL files from an in-house database or spectroscopy repository, and need to convert them into node-edge graph representations with explicit atom features (atomic number, degree, formal charge, hybridization) and bond features (bond type, aromaticity) for training graph neural networks like GNN-RT.
When NOT to use
- Input is already in node-edge graph format or precomputed feature tensors — skip directly to GNN training.
- Molecular structures are incomplete, contain unspecified stereochemistry critical to your analysis, or lack proper atom valence validation.
- Input files are malformed SMILES (e.g., unbalanced parentheses) or corrupted MOL files that RDKit cannot parse without manual curation.
Inputs
- SMILES strings from in-house molecular database
- MOL format files from spectroscopy data repositories
- Spectra files containing encoded molecular structures
Outputs
- Molecular graphs with node-edge representation
- Atom feature arrays (atomic number, degree, formal charge, hybridization)
- Bond feature arrays (bond type, aromaticity)
- Serialized graph objects (pickle or HDF5 format) compatible with PyTorch DataLoader
How to apply
Load molecular structure files (SMILES or MOL format) from the database using RDKit's molecular parsing functions. For each structure, construct a molecular graph by converting it into a node-edge representation with atom features (atomic number, degree, formal charge, hybridization) and bond features (bond type, aromaticity) using RDKit's graph construction methods. Validate that all features are correctly extracted and non-null. Serialize the resulting graph objects into a format compatible with PyTorch's DataLoader (e.g., pickle or HDF5) for downstream consumption by the GNN training pipeline. The rationale is that RDKit's native graph representation captures the full chemical topology needed for end-to-end GNN learning to predict molecular properties like LC retention time.
Related tools
- RDKit (Parse SMILES and MOL files; construct molecular graphs with atom/bond feature extraction and graph serialization) — https://www.rdkit.org/
- PyTorch (Serialize and load molecular graphs via DataLoader for GNN training pipeline compatibility)
- Python (Scripting environment (Anaconda 3.6+) for orchestrating RDKit and PyTorch operations)
Examples
python Preprocess.py
Evaluation signals
- All SMILES/MOL inputs parse without errors; RDKit returns valid molecule objects for ≥95% of input records.
- Atom feature arrays contain no NaN or None values; atomic numbers, degrees, formal charges, and hybridization states are in chemically valid ranges.
- Bond feature arrays correctly reflect bond types (single, double, triple, aromatic) and aromaticity labels matching chemical structure.
- Serialized graph objects can be successfully deserialized by PyTorch DataLoader without shape/type mismatches during GNN training.
- Graph feature counts match downstream GNN input layer expectations (e.g., node feature dimension matches concatenated atom features; edge features match bond feature dimension).
Limitations
- RDKit parsing may fail on non-standard or malformed SMILES strings; validation and error handling are required.
- MOL file format variation (MOL vs. MOL2 vs. SDF) may require format-specific parsers; the skill assumes standard V2000/V3000 MOL format.
- Stereochemistry, isotopes, and formal charges must be explicitly encoded in SMILES or MOL files; implicit hydrogens and 2D coordinates in MOL files may cause feature extraction discrepancies.
- No explicit changelog or version pinning guidance provided in the repository, so RDKit API stability across versions is not guaranteed.
Evidence
- [other] Load molecular structure data (SMILES or MOL format) from the in-house database using RDKit. Construct molecular graphs by converting each structure into a node-edge representation with atom features (atomic number, degree, formal charge, hybridization) and bond features (bond type, aromaticity) using RDKit's graph construction methods.: "Load molecular structure data (SMILES or MOL format) from the in-house database using RDKit. Construct molecular graphs by converting each structure into a node-edge representation with atom features"
- [other] Serialize the molecular graphs into a format compatible with PyTorch's DataLoader (e.g., pickle or HDF5) for consumption by the GNN training pipeline.: "Serialize the molecular graphs into a format compatible with PyTorch's DataLoader (e.g., pickle or HDF5) for consumption by the GNN training pipeline."
- [readme] put your spectra files in to data directory and run [Preprocess.py]: "put your spectra files in to data directory and run [Preprocess.py]"
- [readme] It takes molecular graph as the input, and the predicted retention time as the output.: "It takes molecular graph as the input, and the predicted retention time as the output."
1---2name: smiles-mol-file-parsing3description: Use when when you have molecular structures encoded as SMILES strings or MOL files from an in-house database or spectroscopy repository, and need to convert them into node-edge graph representations with explicit atom features (atomic number, degree, formal charge, hybridization) and bond features.4license: CC-BY-4.05---67# SMILES and MOL file parsing for molecular graph construction89## Summary1011Parse molecular structure data from SMILES strings or MOL files using RDKit to extract atom and bond features, enabling conversion into node-edge graph representations suitable for GNN input. This skill is essential for preparing chemical structure data from spectroscopy databases into machine-learning-ready formats.1213## When to use1415When you have molecular structures encoded as SMILES strings or MOL files from an in-house database or spectroscopy repository, and need to convert them into node-edge graph representations with explicit atom features (atomic number, degree, formal charge, hybridization) and bond features (bond type, aromaticity) for training graph neural networks like GNN-RT.1617## When NOT to use1819- Input is already in node-edge graph format or precomputed feature tensors — skip directly to GNN training.20- Molecular structures are incomplete, contain unspecified stereochemistry critical to your analysis, or lack proper atom valence validation.21- Input files are malformed SMILES (e.g., unbalanced parentheses) or corrupted MOL files that RDKit cannot parse without manual curation.2223## Inputs2425- SMILES strings from in-house molecular database26- MOL format files from spectroscopy data repositories27- Spectra files containing encoded molecular structures2829## Outputs3031- Molecular graphs with node-edge representation32- Atom feature arrays (atomic number, degree, formal charge, hybridization)33- Bond feature arrays (bond type, aromaticity)34- Serialized graph objects (pickle or HDF5 format) compatible with PyTorch DataLoader3536## How to apply3738Load molecular structure files (SMILES or MOL format) from the database using RDKit's molecular parsing functions. For each structure, construct a molecular graph by converting it into a node-edge representation with atom features (atomic number, degree, formal charge, hybridization) and bond features (bond type, aromaticity) using RDKit's graph construction methods. Validate that all features are correctly extracted and non-null. Serialize the resulting graph objects into a format compatible with PyTorch's DataLoader (e.g., pickle or HDF5) for downstream consumption by the GNN training pipeline. The rationale is that RDKit's native graph representation captures the full chemical topology needed for end-to-end GNN learning to predict molecular properties like LC retention time.3940## Related tools4142- **RDKit** (Parse SMILES and MOL files; construct molecular graphs with atom/bond feature extraction and graph serialization) — https://www.rdkit.org/43- **PyTorch** (Serialize and load molecular graphs via DataLoader for GNN training pipeline compatibility)44- **Python** (Scripting environment (Anaconda 3.6+) for orchestrating RDKit and PyTorch operations)4546## Examples4748```49python Preprocess.py50```5152## Evaluation signals5354- All SMILES/MOL inputs parse without errors; RDKit returns valid molecule objects for ≥95% of input records.55- Atom feature arrays contain no NaN or None values; atomic numbers, degrees, formal charges, and hybridization states are in chemically valid ranges.56- Bond feature arrays correctly reflect bond types (single, double, triple, aromatic) and aromaticity labels matching chemical structure.57- Serialized graph objects can be successfully deserialized by PyTorch DataLoader without shape/type mismatches during GNN training.58- Graph feature counts match downstream GNN input layer expectations (e.g., node feature dimension matches concatenated atom features; edge features match bond feature dimension).5960## Limitations6162- RDKit parsing may fail on non-standard or malformed SMILES strings; validation and error handling are required.63- MOL file format variation (MOL vs. MOL2 vs. SDF) may require format-specific parsers; the skill assumes standard V2000/V3000 MOL format.64- Stereochemistry, isotopes, and formal charges must be explicitly encoded in SMILES or MOL files; implicit hydrogens and 2D coordinates in MOL files may cause feature extraction discrepancies.65- No explicit changelog or version pinning guidance provided in the repository, so RDKit API stability across versions is not guaranteed.6667## Evidence6869- [other] Load molecular structure data (SMILES or MOL format) from the in-house database using RDKit. Construct molecular graphs by converting each structure into a node-edge representation with atom features (atomic number, degree, formal charge, hybridization) and bond features (bond type, aromaticity) using RDKit's graph construction methods.: "Load molecular structure data (SMILES or MOL format) from the in-house database using RDKit. Construct molecular graphs by converting each structure into a node-edge representation with atom features"70- [other] Serialize the molecular graphs into a format compatible with PyTorch's DataLoader (e.g., pickle or HDF5) for consumption by the GNN training pipeline.: "Serialize the molecular graphs into a format compatible with PyTorch's DataLoader (e.g., pickle or HDF5) for consumption by the GNN training pipeline."71- [readme] put your spectra files in to data directory and run [Preprocess.py]: "put your spectra files in to data directory and run [Preprocess.py]"72- [readme] It takes molecular graph as the input, and the predicted retention time as the output.: "It takes molecular graph as the input, and the predicted retention time as the output."