pub struct MolGraph { /* private fields */ }Expand description
A dynamic molecular graph supporting ergonomic CRUD for atoms, bonds, angles, and dihedrals.
Implementations§
Source§impl MolGraph
impl MolGraph
Sourcepub fn remove_atom(&mut self, id: AtomId) -> Result<Atom, MolRsError>
pub fn remove_atom(&mut self, id: AtomId) -> Result<Atom, MolRsError>
Remove an atom and all incident bonds / angles / dihedrals.
Sourcepub fn get_atom_mut(&mut self, id: AtomId) -> Result<&mut Atom, MolRsError>
pub fn get_atom_mut(&mut self, id: AtomId) -> Result<&mut Atom, MolRsError>
Get a mutable reference to an atom.
Sourcepub fn add_bond(&mut self, a: AtomId, b: AtomId) -> Result<BondId, MolRsError>
pub fn add_bond(&mut self, a: AtomId, b: AtomId) -> Result<BondId, MolRsError>
Add a bond between two existing atoms.
Sourcepub fn remove_bond(&mut self, id: BondId) -> Result<Bond, MolRsError>
pub fn remove_bond(&mut self, id: BondId) -> Result<Bond, MolRsError>
Remove a bond and update the adjacency index.
Sourcepub fn get_bond_mut(&mut self, id: BondId) -> Result<&mut Bond, MolRsError>
pub fn get_bond_mut(&mut self, id: BondId) -> Result<&mut Bond, MolRsError>
Get a mutable reference to a bond.
Sourcepub fn add_angle(
&mut self,
i: AtomId,
j: AtomId,
k: AtomId,
) -> Result<AngleId, MolRsError>
pub fn add_angle( &mut self, i: AtomId, j: AtomId, k: AtomId, ) -> Result<AngleId, MolRsError>
Add an angle (i-j-k, j central).
Sourcepub fn remove_angle(&mut self, id: AngleId) -> Result<Angle, MolRsError>
pub fn remove_angle(&mut self, id: AngleId) -> Result<Angle, MolRsError>
Remove an angle.
Sourcepub fn get_angle(&self, id: AngleId) -> Result<&Angle, MolRsError>
pub fn get_angle(&self, id: AngleId) -> Result<&Angle, MolRsError>
Get a reference to an angle.
Sourcepub fn add_dihedral(
&mut self,
i: AtomId,
j: AtomId,
k: AtomId,
l: AtomId,
) -> Result<DihedralId, MolRsError>
pub fn add_dihedral( &mut self, i: AtomId, j: AtomId, k: AtomId, l: AtomId, ) -> Result<DihedralId, MolRsError>
Add a dihedral (i-j-k-l).
Sourcepub fn remove_dihedral(
&mut self,
id: DihedralId,
) -> Result<Dihedral, MolRsError>
pub fn remove_dihedral( &mut self, id: DihedralId, ) -> Result<Dihedral, MolRsError>
Remove a dihedral.
Sourcepub fn get_dihedral(&self, id: DihedralId) -> Result<&Dihedral, MolRsError>
pub fn get_dihedral(&self, id: DihedralId) -> Result<&Dihedral, MolRsError>
Get a reference to a dihedral.
Sourcepub fn atoms(&self) -> impl Iterator<Item = (AtomId, &Atom)>
pub fn atoms(&self) -> impl Iterator<Item = (AtomId, &Atom)>
Iterate over all (AtomId, &Atom) pairs.
Sourcepub fn bonds(&self) -> impl Iterator<Item = (BondId, &Bond)>
pub fn bonds(&self) -> impl Iterator<Item = (BondId, &Bond)>
Iterate over all (BondId, &Bond) pairs.
Sourcepub fn angles(&self) -> impl Iterator<Item = (AngleId, &Angle)>
pub fn angles(&self) -> impl Iterator<Item = (AngleId, &Angle)>
Iterate over all (AngleId, &Angle) pairs.
Sourcepub fn dihedrals(&self) -> impl Iterator<Item = (DihedralId, &Dihedral)>
pub fn dihedrals(&self) -> impl Iterator<Item = (DihedralId, &Dihedral)>
Iterate over all (DihedralId, &Dihedral) pairs.
Sourcepub fn n_dihedrals(&self) -> usize
pub fn n_dihedrals(&self) -> usize
Number of dihedrals.
Sourcepub fn neighbors(&self, id: AtomId) -> impl Iterator<Item = AtomId>
pub fn neighbors(&self, id: AtomId) -> impl Iterator<Item = AtomId>
Iterate over neighbor atom IDs of a given atom (via bond connectivity).
Sourcepub fn neighbor_bonds(&self, id: AtomId) -> impl Iterator<Item = (AtomId, f64)>
pub fn neighbor_bonds(&self, id: AtomId) -> impl Iterator<Item = (AtomId, f64)>
Iterate over (neighbor_id, bond_order) for a given atom.
Bond order is read from the "order" property (default 1.0).
Sourcepub fn rotate(&mut self, axis: [f64; 3], angle: f64, about: Option<[f64; 3]>)
pub fn rotate(&mut self, axis: [f64; 3], angle: f64, about: Option<[f64; 3]>)
Rotate all atoms that have x/y/z props around axis by angle
(radians), optionally about a center point.
Sourcepub fn merge(&mut self, other: MolGraph)
pub fn merge(&mut self, other: MolGraph)
Merge another MolGraph into self, consuming other.
All IDs in other are remapped to new IDs in self.
Sourcepub fn to_frame(&self) -> Frame
pub fn to_frame(&self) -> Frame
Export to a Frame. Each unique prop key becomes a column in the
"atoms" block. Bonds, angles, dihedrals become separate blocks with
0-based indices referencing atom row order.
Sourcepub fn from_frame(frame: &Frame) -> Result<MolGraph, MolRsError>
pub fn from_frame(frame: &Frame) -> Result<MolGraph, MolRsError>
Import from a Frame. The "atoms" block columns become props;
"bonds" block atomi/atomj columns become bonds.