[][src]Struct chemfiles::Residue

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")));
assert_eq!(residue.id(), Ok(None));

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

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(Some(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]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl !Send for Residue

impl !Sync for Residue

Blanket Implementations

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more