Commit db029e4e authored by NOEL Philippe's avatar NOEL Philippe

add documentation for protein structure

parent 3843ffa4
......@@ -4,18 +4,43 @@ use super::chain::Chain;
pub struct Protein {
name: String,
lst_chain: Vec<Chain>,
last_chain: char,
last_chain_added: char,
}
impl<'a> Protein {
/// Create a new protein structure
///
/// # Examples
///
/// ````
/// use pdbparser;
///
/// let my_prot = pdbparser::Protein::new(String::from("my_prot"));
///
/// ````
pub fn new(n : String) -> Protein {
Protein {
name: n,
lst_chain: Vec::new(),
last_chain: ' ',
last_chain_added: ' ',
}
}
/// Return True if the chain is in the protein
///
/// # Examples
///
/// ````
/// use pdbparser;
///
/// let mut my_prot = pdbparser::Protein::new(String::from("my_prot"));
/// let my_chain_a = pdbparser::Chain::new('n');
/// my_prot.add_chain(my_chain_a);
///
/// assert!(my_prot.is_chain('n'));
///
/// ````
pub fn is_chain(&self, c: char) -> bool {
for ii in &self.lst_chain {
if ii.get_name() == c {
......@@ -25,7 +50,39 @@ impl<'a> Protein {
return false
}
pub fn get_num_of_chain(&self) -> u32 {
/// Get the number of chain in the protein
///
/// # Examples
///
/// ````
/// use pdbparser;
///
/// let my_prot = pdbparser::Protein::new(String::from("my_prot"));
///
/// assert_eq!(0, my_prot.get_number_chain());
/// ````
pub fn get_number_chain(&self) -> u32 {
self.lst_chain.len() as u32
}
/// Add a new chain structure in the protein
///
/// # Examples
///
/// ````
/// use pdbparser;
///
/// let mut my_prot = pdbparser::Protein::new(String::from("my_prot"));
/// let my_chain_a = pdbparser::Chain::new('n');
///
/// my_prot.add_chain(my_chain_a);
///
/// assert_eq!(1, my_prot.get_number_chain());
///
/// ````
pub fn add_chain(&mut self, c: Chain) {
self.last_chain_added = c.get_name();
self.lst_chain.push(c);
}
}
......@@ -5,15 +5,13 @@ pub struct Residue {
name: String,
res_num: u64,
lst_atom: Vec<Atom>,
chain: char,
}
impl Residue {
pub fn new(name: String, res_num: u64, chain: char) -> Residue {
pub fn new(name: String, res_num: u64) -> Residue {
Residue {
name,
res_num,
chain,
lst_atom: Vec::new(),
}
}
......@@ -21,13 +19,13 @@ impl Residue {
pub fn get_res_num(&self) -> u64 {
self.res_num
}
pub fn get_number_atom(&self) -> u64 {
self.lst_atom.len() as u64
}
pub fn add_atom(&mut self, atom_name: String, atom_number: u64, coord: [f32; 3]) {
self.lst_atom.push(Atom::new(atom_name, atom_number, coord));
}
pub fn get_atom_number(&self) -> u64 {
self.lst_atom.len() as u64
}
}
\ No newline at end of file
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