Reconstruction guides
Run file-based examples from the repository root with MolGR installed. For your first molecule, follow the 338-S tutorial.
Select the backend and postprocessing
This example reconstructs the ABACAL fixture with the Python reference backend. It disables both coordination-bond completion and stereochemistry assignment.
from pathlib import Path
from molgr.interface import xyz_to_rdmol
xyz = Path("tests/data/tmqmg/reconstruction/ABACAL.xyz").read_text()
mol = xyz_to_rdmol(
xyz, total_charge=0, spin_multiplicity=1, backend="python",
make_dative_bonds=False, make_stereochemistry=False,
)
Both backends use the installed native extension. Disabling postprocessing does not change the charge/spin targets or disable the default SMILES graph check.
Configure a call independently
from pathlib import Path
from molgr.config import MolGRConfig
from molgr.interface import xyz_to_rdmol
config = MolGRConfig()
config.cpp_backend.max_threads = 1
config.cpp_backend.enable_target_bucket_parallelism = False
config.cpp_backend.enable_candidate_scoring_parallelism = False
mol = xyz_to_rdmol(
Path("tests/data/xyz/338-S.xyz").read_text(encoding="utf-8"),
total_charge=0,
spin_multiplicity=1,
config=config,
)
Omitting config uses the mutable global molgr.config.CONFIG; an explicit instance keeps settings local to the call. See all configuration fields and batch and multiprocessing settings.
SMILES and explicit hydrogens
Reconstruction returns an RDKit molecule with the input 3D coordinates and all explicit hydrogen atoms. SMILES strings and SDF files are derived exports. Each format and its writer settings determine which properties survive conversion.
Successful outputs undergo SMILES graph round-trip validation in the installed RDKit version by default. Use molgr.mol_from_smiles() to retain explicit hydrogen nodes and localized bond orders. For RDKit aromatic output, pass kekulize=False to both reconstruction and reading. Ordinary SMILES does not preserve 3D coordinates or all of MolGR's electronic-state information; retain the original Mol or export an appropriate structure file when geometry matters.
See the SMILES round-trip contract for details, SMILES_ROUNDTRIP_FAILED diagnostics, and optional stereochemistry validation.