pub struct Structure {
pub box_vectors: Option<[[f64; 3]; 3]>,
/* private fields */
}Expand description
High-level biomolecular assembly composed of zero or more chains.
A Structure wraps individual chains, tracks optional periodic box vectors, and offers
convenience iterators for traversing chains, residues, and atoms alongside contextual
metadata. Builders and operations mutate the structure to clean, solvate, or analyze
biological systems.
Fields§
§box_vectors: Option<[[f64; 3]; 3]>Optional periodic box represented as crystallographic basis vectors.
Implementations§
Source§impl Structure
impl Structure
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty structure with no chains or box vectors.
§Returns
A new Structure identical to Structure::default().
Sourcepub fn add_chain(&mut self, chain: Chain)
pub fn add_chain(&mut self, chain: Chain)
Appends a chain to the structure, asserting unique chain IDs in debug builds.
The chain is inserted at the end of the current collection and becomes visible to iterator methods immediately.
§Arguments
chain- Chain instance whoseidmust be unique within the structure.
Sourcepub fn remove_chain(&mut self, id: &str) -> Option<Chain>
pub fn remove_chain(&mut self, id: &str) -> Option<Chain>
Sourcepub fn find_residue(
&self,
chain_id: &str,
residue_id: i32,
insertion_code: Option<char>,
) -> Option<&Residue>
pub fn find_residue( &self, chain_id: &str, residue_id: i32, insertion_code: Option<char>, ) -> Option<&Residue>
Finds a residue using chain ID, residue number, and optional insertion code.
§Arguments
chain_id- Identifier of the chain to search.residue_id- Numeric residue index (typically PDBresSeq).insertion_code- Optional insertion code differentiating duplicate IDs.
§Returns
Some(&Residue) when the residue is located, otherwise None.
Sourcepub fn find_residue_mut(
&mut self,
chain_id: &str,
residue_id: i32,
insertion_code: Option<char>,
) -> Option<&mut Residue>
pub fn find_residue_mut( &mut self, chain_id: &str, residue_id: i32, insertion_code: Option<char>, ) -> Option<&mut Residue>
Sourcepub fn sort_chains_by_id(&mut self)
pub fn sort_chains_by_id(&mut self)
Sorts chains lexicographically by their identifier.
Sourcepub fn chain_count(&self) -> usize
pub fn chain_count(&self) -> usize
Sourcepub fn residue_count(&self) -> usize
pub fn residue_count(&self) -> usize
Sourcepub fn atom_count(&self) -> usize
pub fn atom_count(&self) -> usize
Sourcepub fn iter_chains(&self) -> Iter<'_, Chain>
pub fn iter_chains(&self) -> Iter<'_, Chain>
Provides an iterator over immutable chains.
§Returns
std::slice::Iter<'_, Chain> spanning all chains in insertion order.
Sourcepub fn iter_chains_mut(&mut self) -> IterMut<'_, Chain>
pub fn iter_chains_mut(&mut self) -> IterMut<'_, Chain>
Provides an iterator over mutable chains.
§Returns
std::slice::IterMut<'_, Chain> for in-place modification of chains.
Sourcepub fn iter_atoms(&self) -> impl Iterator<Item = &Atom>
pub fn iter_atoms(&self) -> impl Iterator<Item = &Atom>
Iterates over immutable atoms across all chains.
§Returns
An iterator yielding &Atom in chain/residue order.
Sourcepub fn iter_atoms_mut(&mut self) -> impl Iterator<Item = &mut Atom>
pub fn iter_atoms_mut(&mut self) -> impl Iterator<Item = &mut Atom>
Iterates over mutable atoms across all chains.
§Returns
An iterator yielding &mut Atom for direct coordinate editing.
Sourcepub fn retain_residues<F>(&mut self, f: F)
pub fn retain_residues<F>(&mut self, f: F)
Retains residues that satisfy a predicate, removing all others.
The predicate receives the chain ID and a residue reference, enabling context-sensitive filtering.
§Arguments
f- Closure returningtrueto keep the residue.
Sourcepub fn prune_empty_chains(&mut self)
pub fn prune_empty_chains(&mut self)
Removes any chain that became empty after residue pruning.
Sourcepub fn iter_atoms_with_context(
&self,
) -> impl Iterator<Item = (&Chain, &Residue, &Atom)>
pub fn iter_atoms_with_context( &self, ) -> impl Iterator<Item = (&Chain, &Residue, &Atom)>
Iterates over atoms while including chain and residue context.
§Returns
An iterator yielding triples (&Chain, &Residue, &Atom) for every atom.
Sourcepub fn geometric_center(&self) -> Point
pub fn geometric_center(&self) -> Point
Computes the geometric center of all atom coordinates.
Falls back to the origin when the structure contains no atoms.
§Returns
A Point located at the unweighted centroid.
Sourcepub fn center_of_mass(&self) -> Point
pub fn center_of_mass(&self) -> Point
Computes the mass-weighted center of all atoms.
Uses element atomic masses and returns the origin when the total mass is below numerical tolerance.
§Returns
A Point representing the center of mass.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Structure
impl RefUnwindSafe for Structure
impl Send for Structure
impl Sync for Structure
impl Unpin for Structure
impl UnwindSafe for Structure
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.