|
AvogadroLibs 2.1.0-20261111
|
Serialize a molecule to a SMILES string. More...
#include <avogadro/io/smileswriter.h>
Public Types | |
| enum class | HydrogenMode { Implicit , Bracket , Explicit } |
Public Member Functions | |
| void | setHydrogenMode (HydrogenMode mode) |
| HydrogenMode | hydrogenMode () const |
| void | setAtomMaps (bool enable) |
| bool | atomMaps () const |
| void | setAromatic (bool enable) |
| bool | aromatic () const |
| HydrogenMode | effectiveHydrogenMode () const |
| bool | write (const Core::Molecule &molecule, std::string &smiles) |
| const std::string & | error () const |
Tetrahedral chirality and double bond direction markers are read out of the molecule's coordinates, so they are written only for a molecule that has them; a structure without 3D positions is written without stereochemistry rather than with a guess. Which centres count as stereogenic is decided constitutionally, within the limits documented in atomequivalence_p.h.
Where a source marked a configuration undefined – see Core::stereo.h – that is honoured and no descriptor is written, since the coordinates in that case are a placement rather than a claim.
|
strong |
| void setHydrogenMode | ( | HydrogenMode | mode | ) |
Set how hydrogens are represented. Note that atomMaps() overrides this, see setAtomMaps().
| void setAtomMaps | ( | bool | enable | ) |
Emit each atom's index as a Daylight atom map class, so that the string can be correlated back to the molecule it came from.
Classes are written one-based, because Daylight assigns class zero the meaning "unmapped"; a consumer reading the classes back must subtract one to recover the Avogadro atom index.
This implies HydrogenMode::Explicit. A hydrogen folded into a bracket count has nowhere to carry a class, and in Avogadro that hydrogen is a real atom with a real index, so folding it would silently produce a partial mapping.
| void setAromatic | ( | bool | enable | ) |
Write perceived aromatic rings in the lowercase form, so benzene is "c1ccccc1" rather than "C1=CC=CC=C1". Both describe the same molecule; the lowercase form is what most toolkits produce and expect, so it is enabled by default and callers wanting Kekule output must ask for it.
Perception is Core::AromaticityPerceiver; anything it does not recognise is written with its bond orders as stored.
| HydrogenMode effectiveHydrogenMode | ( | ) | const |
| bool write | ( | const Core::Molecule & | molecule, |
| std::string & | smiles ) |
Write molecule to smiles.
| const std::string & error | ( | ) | const |