Back to tools
COSMolKit 0.2.11 / Rust / WASMFormat converter
Convert molecular records locally while preserving the chemical graph and available coordinates.
Line notation
.sdf
Source
21 charactersConverted output
13 atoms / 13 bondsConverted locally. No structure data is uploaded.
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
COSMolKit Python 0.2.11Run the same conversion with COSMolKit
The example tracks the formats and source currently selected above.
INSTALL
pip install cosmolkit==0.2.11Python 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")