Struct chemfiles::Residue
[−]
[src]
pub struct Residue { /* fields omitted */ }
A Residue
is a group of atoms belonging to the same logical unit. They
can be small molecules, amino-acids in a protein, monomers in polymers,
etc.
Methods
impl Residue
[src]
fn new<'a, S>(name: S) -> Result<Residue> where
S: Into<&'a str>,
S: Into<&'a str>,
Create a new residue with the given name
Example
let residue = Residue::new("ALA").unwrap(); assert_eq!(residue.name(), Ok(String::from("ALA")));
fn with_id<'a, S>(name: S, id: u64) -> Result<Residue> where
S: Into<&'a str>,
S: Into<&'a str>,
Create a new residue with the given name
and id
as identifier.
Example
let residue = Residue::with_id("ALA", 67).unwrap(); assert_eq!(residue.name(), Ok(String::from("ALA"))); assert_eq!(residue.id(), Ok(67));
fn natoms(&self) -> Result<u64>
Get the number of atoms in this residue.
Example
let mut residue = Residue::new("water").unwrap(); assert_eq!(residue.natoms(), Ok(0)); residue.add_atom(0); residue.add_atom(1); residue.add_atom(2); assert_eq!(residue.natoms(), Ok(3));
fn id(&self) -> Result<u64>
Get the identifier of this residue in the initial topology file.
Example
let residue = Residue::with_id("", 42).unwrap(); assert_eq!(residue.id(), Ok(42));
fn name(&self) -> Result<String>
Get the name of this residue.
Example
let residue = Residue::new("water").unwrap(); assert_eq!(residue.name(), Ok(String::from("water")));
fn add_atom(&mut self, atom: u64) -> Result<()>
Add the atom at index i
in this residue.
Example
let mut residue = Residue::new("water").unwrap(); assert_eq!(residue.contains(56), Ok(false)); residue.add_atom(56).unwrap(); assert_eq!(residue.contains(56), Ok(true));
fn contains(&self, atom: u64) -> Result<bool>
Check if the atom at index i
is in this residue
Example
let mut residue = Residue::new("water").unwrap(); assert_eq!(residue.contains(56), Ok(false)); residue.add_atom(56).unwrap(); assert_eq!(residue.contains(56), Ok(true));
Trait Implementations
impl Clone for Residue
[src]
fn clone(&self) -> Residue
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more