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]

Create a new residue with the given name

Example

let residue = Residue::new("ALA").unwrap();
assert_eq!(residue.name(), Ok(String::from("ALA")));

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));

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));

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));

Get the name of this residue.

Example

let residue = Residue::new("water").unwrap();
assert_eq!(residue.name(), Ok(String::from("water")));

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));

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]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Drop for Residue
[src]

A method called when the value goes out of scope. Read more