Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

SMILES Parser and Validator

Parse, validate, lightly clean, and summarise SMILES strings using RDKit.

The script can read SMILES directly from the command line or from a text file, then writes a CSV report containing parsing status, canonical SMILES, formula, molecular weight, InChIKey, and atom counts.

Features

  • Accepts SMILES from command-line arguments or a plain text file.
  • Validates structures with RDKit.
  • Optionally applies a simple cleanup pass for noisy explicit-hydrogen strings.
  • Calculates useful molecular properties.
  • Writes a structured CSV report with one row per input SMILES.

Requirements

  • Python 3.8+
  • RDKit

Recommended installation with conda:

conda install -c conda-forge rdkit

Input Options

Command-line SMILES

Pass one or more SMILES strings with --smiles:

python parse_smiles.py --smiles "CCO" "O=C(O)C" -o results.csv

Text File Input

Use --infile for a text file containing one SMILES string per line.

An example file, my_smiles.txt, is included in this folder and can be used for a quick test:

python parse_smiles.py --infile my_smiles.txt --out smiles_parsed.csv

Cleaning Behavior

By default, the script tries a simple cleanup pass if RDKit cannot parse the original SMILES.

The cleanup is intentionally basic and targets noisy explicit hydrogen patterns such as:

  • O[H]
  • [H]
  • Empty parentheses left after removing [H]

This can help with exported or messy SMILES, but it may alter the intended chemistry. To disable this behavior:

python parse_smiles.py --infile my_smiles.txt --out smiles_parsed.csv --no-clean

Output Columns

The output CSV contains:

  • input_smiles: original input string
  • used_smiles: original or cleaned string used for successful parsing
  • status: parsing result
  • error: error details when parsing fails
  • canonical_smiles
  • isomeric_smiles
  • formula
  • mol_wt
  • exact_mw
  • inchi_key
  • num_atoms
  • num_heavy_atoms

Example Workflow

python parse_smiles.py --infile my_smiles.txt --out smiles_parsed.csv

Expected terminal output:

Wrote 7 rows to smiles_parsed.csv

Open smiles_parsed.csv to inspect which structures parsed successfully and which, if any, failed.

About

Parse and validate SMILES strings using RDKit.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages