pub struct MoleculeBuilder { /* private fields */ }Expand description
Builder for constructing a Molecule incrementally.
Usage: add atoms, add bonds, then call build().
Implementations§
Source§impl MoleculeBuilder
impl MoleculeBuilder
pub fn new() -> Self
Sourcepub fn from_molecule(mol: &Molecule) -> Self
pub fn from_molecule(mol: &Molecule) -> Self
Create a builder pre-populated with all atoms and bonds from mol.
Use this to make incremental edits to an existing molecule instead of reconstructing it from scratch.
Sourcepub fn set_stereo_neighbor_order(&mut self, idx: AtomIdx, order: Vec<u32>)
pub fn set_stereo_neighbor_order(&mut self, idx: AtomIdx, order: Vec<u32>)
Set the SMILES stereo neighbor order for atom idx.
Sourcepub fn clear_stereo_neighbor_order(&mut self, idx: AtomIdx)
pub fn clear_stereo_neighbor_order(&mut self, idx: AtomIdx)
Remove the stereo neighbor order entry for atom idx.
Sourcepub fn add_stereo_group(&mut self, group: StereoGroup)
pub fn add_stereo_group(&mut self, group: StereoGroup)
Append a stereo group to this builder.
Sourcepub fn copy_stereo_from(&mut self, mol: &Molecule)
pub fn copy_stereo_from(&mut self, mol: &Molecule)
Copy all stereo neighbor order entries from mol into this builder.
Sourcepub fn atom_at(&self, idx: AtomIdx) -> &Atom
pub fn atom_at(&self, idx: AtomIdx) -> &Atom
Read-only reference to an atom already added to the builder.
Used by the SMILES parser to infer implicit bond types without consuming the builder (e.g. aromatic-aromatic → Aromatic bond).
§Panics
Panics if idx is out of range.
Sourcepub fn atom_count(&self) -> usize
pub fn atom_count(&self) -> usize
Number of atoms added so far.
Sourcepub fn atom_neighbors(
&self,
idx: AtomIdx,
) -> impl Iterator<Item = (BondIdx, AtomIdx)> + '_
pub fn atom_neighbors( &self, idx: AtomIdx, ) -> impl Iterator<Item = (BondIdx, AtomIdx)> + '_
Iterate over already-added neighbors of idx as (bond_idx, neighbor_atom_idx).
Used by kekulization tests to check whether a bond already exists in the builder.