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]
pub fn new<'a, S>(name: S) -> Result<Residue> where
S: Into<&'a str>,
[src]
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"))); assert_eq!(residue.id(), Ok(None));
pub fn with_id<'a, S>(name: S, id: u64) -> Result<Residue> where
S: Into<&'a str>,
[src]
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(Some(67)));
pub fn natoms(&self) -> Result<u64>
[src]
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));
pub fn id(&self) -> Result<Option<u64>>
[src]
Get the identifier of this residue in the initial topology file.
Example
let residue = Residue::with_id("", 42).unwrap(); assert_eq!(residue.id(), Ok(Some(42)));
pub fn name(&self) -> Result<String>
[src]
Get the name of this residue.
Example
let residue = Residue::new("water").unwrap(); assert_eq!(residue.name(), Ok(String::from("water")));
pub fn add_atom(&mut self, atom: u64) -> Result<()>
[src]
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));
pub fn contains(&self, atom: u64) -> Result<bool>
[src]
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
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more