Commit bb1742c6 authored by NOEL Philippe's avatar NOEL Philippe

Add documentation for Chain struct

parent db029e4e
......@@ -2,11 +2,21 @@ use super::residue::Residue;
#[derive(Debug)]
pub struct Chain {
name: char,
lst_res: Vec<Residue>,
pub name: char,
pub lst_res: Vec<Residue>,
}
impl Chain {
/// Create a new chain structure with an empty list of residue
///
/// # Examples
///
/// ````
/// use pdbparser;
///
/// let my_chain = pdbparser::Chain::new('a');
///
/// ````
pub fn new(name: char) -> Chain {
Chain {
name,
......@@ -14,19 +24,42 @@ impl Chain {
}
}
/// Add a new structure residue to the Chain
///
/// # Examples
///
/// ````
/// use pdbparser;
///
/// let mut my_chain = pdbparser::Chain::new('a');
/// let lys = pdbparser::Residue::new(String::from("lysine"), 1);
///
/// my_chain.add_res(lys);
///
/// assert_eq!(1, my_chain.get_number_residue());
///
/// ````
pub fn add_res(&mut self, r: Residue) {
self.lst_res.push(r);
}
pub fn is_residue(&self, r: u64) -> bool {
for ii in &self.lst_res {
if ii.get_res_num() == r {
return true
}
}
return false
/// Get the number of residue in the Chain
///
/// # Examples
///
/// ````
/// use pdbparser;
///
/// let my_chain = pdbparser::Chain::new('a');
///
/// assert_eq!(0, my_chain.get_number_residue());
///
/// ````
pub fn get_number_residue(&self) -> u64 {
self.lst_res.len() as u64
}
/// Get the name of the Chain
pub fn get_name(&self) -> char {
self.name
}
......
......@@ -2,8 +2,8 @@ use super::chain::Chain;
#[derive(Debug)]
pub struct Protein {
name: String,
lst_chain: Vec<Chain>,
pub name: String,
pub lst_chain: Vec<Chain>,
last_chain_added: char,
}
......@@ -85,4 +85,5 @@ impl<'a> Protein {
self.last_chain_added = c.get_name();
self.lst_chain.push(c);
}
}
......@@ -2,9 +2,9 @@ use super::atom::Atom;
#[derive(Debug)]
pub struct Residue {
name: String,
res_num: u64,
lst_atom: Vec<Atom>,
pub name: String,
pub res_num: u64,
pub lst_atom: Vec<Atom>,
}
impl Residue {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment