pub struct Residue {
pub id: i32,
pub insertion_code: Option<char>,
pub name: String,
pub standard_name: Option<StandardResidue>,
pub category: ResidueCategory,
pub position: ResiduePosition,
/* private fields */
}Expand description
A residue within a biomolecular structure.
Residues capture crystallographic identifiers (sequence number and insertion code), the original and normalized names, classification metadata, and the atoms that belong to the residue. They are the primary unit passed between IO routines, topology builders, and structure editing operations.
Fields§
§id: i32Author-provided sequence identifier (can be negative for certain files).
insertion_code: Option<char>Optional insertion code differentiating records that share the same id.
name: StringOriginal residue name as encountered during parsing.
standard_name: Option<StandardResidue>Canonical residue assignment if the name maps to a standard alphabet entry.
category: ResidueCategoryCategory describing whether the residue is standard, heterogen, or ion.
position: ResiduePositionChain position annotation (terminus, internal, or nucleic end).
Implementations§
Source§impl Residue
impl Residue
Sourcepub fn new(
id: i32,
insertion_code: Option<char>,
name: &str,
standard_name: Option<StandardResidue>,
category: ResidueCategory,
) -> Self
pub fn new( id: i32, insertion_code: Option<char>, name: &str, standard_name: Option<StandardResidue>, category: ResidueCategory, ) -> Self
Creates a residue with the provided identifiers and classification.
The residue starts without atoms and defaults to ResiduePosition::None until the
caller updates it based on chain topology.
§Arguments
id- Sequence number pulled from the original structure file.insertion_code- Optional insertion code for distinguishing alternate residues.name- Author-provided residue label (e.g.,"ALA","DN1").standard_name- Canonical assignment when the residue matches a standard entry.category- Classification describing standard, hetero, or ion behavior.
§Returns
A Residue ready for atoms to be added.
Sourcepub fn is_standard(&self) -> bool
pub fn is_standard(&self) -> bool
Reports whether the residue maps to a standard residue definition.
§Returns
true when standard_name is set.
Sourcepub fn add_atom(&mut self, atom: Atom)
pub fn add_atom(&mut self, atom: Atom)
Appends an atom to the residue.
Duplicate atom names are guarded with a debug assertion to prevent inconsistent topologies while still allowing release builds to proceed.
§Arguments
atom- The atom to insert; ownership moves into the residue.
§Panics
Panics in debug builds if an atom with the same name already exists.
Sourcepub fn remove_atom(&mut self, name: &str) -> Option<Atom>
pub fn remove_atom(&mut self, name: &str) -> Option<Atom>
Sourcepub fn atoms(&self) -> &[Atom]
pub fn atoms(&self) -> &[Atom]
Returns an immutable slice of all atoms contained in the residue.
Enables zero-copy iteration when only read-only access is required.
§Returns
A slice view over the internal atom vector.
Sourcepub fn atom_count(&self) -> usize
pub fn atom_count(&self) -> usize
Sourcepub fn iter_atoms(&self) -> Iter<'_, Atom>
pub fn iter_atoms(&self) -> Iter<'_, Atom>
Provides an iterator over immutable atom references.
This mirrors atoms() but allows idiomatic for loops without exposing the backing
vector.
§Returns
An iterator yielding &Atom values.
Sourcepub fn iter_atoms_mut(&mut self) -> IterMut<'_, Atom>
pub fn iter_atoms_mut(&mut self) -> IterMut<'_, Atom>
Provides an iterator over mutable atom references.
§Returns
An iterator yielding &mut Atom values so callers can edit coordinates or metadata.
Sourcepub fn strip_hydrogens(&mut self)
pub fn strip_hydrogens(&mut self)
Removes all hydrogen atoms from the residue.
Used by cleaning operations when preparing structures for solvation or heavy-atom analysis.
Trait Implementations§
impl StructuralPartialEq for Residue
Auto Trait Implementations§
impl Freeze for Residue
impl RefUnwindSafe for Residue
impl Send for Residue
impl Sync for Residue
impl Unpin for Residue
impl UnwindSafe for Residue
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.