Back to tools

Format converter

Convert molecular records locally while preserving the chemical graph and available coordinates.

COSMolKit 0.2.11 / Rust / WASM
Line notation
.sdf

Source

21 characters

Converted output

13 atoms / 13 bonds
Converted locally. No structure data is uploaded.
SUPPORTED FORMATS

Formats available in this converter

COSMolKit reads and writes the molecular graph locally. Coordinate-dependent exports use the coordinates available in the source or generated by the selected workflow.

Input formats

SMILES; MOL or SDF V2000/V3000; Tripos MOL2; PDB; PDBx/mmCIF; XYZ.

Output formats

SMILES; MOL V2000/V3000; SDF V2000/V3000; PDB; SVG depiction.

PYTHON BACKEND

Run the same conversion with COSMolKit

The example tracks the formats and source currently selected above.

COSMolKit Python 0.2.11
INSTALLpip install cosmolkit==0.2.11

Python 3.9+ / Rust-native wheel

convert_molecule.py
from pathlib import Path
from cosmolkit import Molecule

source = "CC(=O)Oc1ccccc1C(=O)O"
mol = Molecule.from_smiles(source)
try:
    mol_2d = mol.with_2d_coordinates()
except (ValueError, NotImplementedError):
    mol_2d = Molecule.from_smiles(mol.to_smiles()).with_2d_coordinates()
output = mol_2d.to_2d_sdf_string(format="v2000")

Path("molecule.sdf").write_text(output, encoding="utf-8")