pub struct Chain {
pub id: String,
/* private fields */
}Expand description
Polymer chain containing an ordered list of residues.
The chain preserves the order residues were added, mirrors the chain identifier seen in
structure files (e.g., "A"), and provides iteration helpers for both residues and
atoms while keeping the internal storage private.
Fields§
§id: StringChain identifier matching the source structure (usually a single character).
Implementations§
Source§impl Chain
impl Chain
Sourcepub fn add_residue(&mut self, residue: Residue)
pub fn add_residue(&mut self, residue: Residue)
Adds a residue to the chain while preventing duplicate identifiers.
Residues are appended in insertion order. Duplicate (id, insertion_code) pairs are
rejected during debug builds to guard against malformed inputs.
§Arguments
residue- The residue to append.
Sourcepub fn residue_mut(
&mut self,
id: i32,
insertion_code: Option<char>,
) -> Option<&mut Residue>
pub fn residue_mut( &mut self, id: i32, insertion_code: Option<char>, ) -> Option<&mut Residue>
Sourcepub fn residues(&self) -> &[Residue]
pub fn residues(&self) -> &[Residue]
Returns an immutable slice containing all residues in order.
Useful for bulk analysis or when interfacing with APIs that operate on slices.
§Returns
Slice view of the underlying residue list.
Sourcepub fn residue_count(&self) -> usize
pub fn residue_count(&self) -> usize
Sourcepub fn iter_residues(&self) -> Iter<'_, Residue>
pub fn iter_residues(&self) -> Iter<'_, Residue>
Provides an iterator over immutable residue references.
This mirrors residues() but avoids exposing slice internals and composes nicely with
iterator adaptors.
§Returns
A standard slice iterator over Residue references.
Sourcepub fn iter_residues_mut(&mut self) -> IterMut<'_, Residue>
pub fn iter_residues_mut(&mut self) -> IterMut<'_, Residue>
Provides an iterator over mutable residue references.
§Returns
A mutable slice iterator that allows in-place modifications.
Sourcepub fn iter_atoms(&self) -> impl Iterator<Item = &Atom>
pub fn iter_atoms(&self) -> impl Iterator<Item = &Atom>
Iterates over all atoms contained in the chain.
Residues are traversed in order and their atom iterators flattened, yielding atoms in the same relative ordering seen in the original structure.
§Returns
Iterator that yields immutable Atom references.
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 all atoms with mutable access.
§Returns
Iterator producing mutable Atom references for bulk editing operations.
Sourcepub fn retain_residues<F>(&mut self, f: F)
pub fn retain_residues<F>(&mut self, f: F)
Retains only residues that satisfy the provided predicate.
§Arguments
f- Predicate invoked for each residue; keep the residue when it returnstrue.
Trait Implementations§
Source§impl FromIterator<Chain> for Structure
impl FromIterator<Chain> for Structure
impl StructuralPartialEq for Chain
Auto Trait Implementations§
impl Freeze for Chain
impl RefUnwindSafe for Chain
impl Send for Chain
impl Sync for Chain
impl Unpin for Chain
impl UnwindSafe for Chain
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.