Commit fda434c6 authored by NOEL Philippe's avatar NOEL Philippe

Update all tests for the Structure

parent 37445a78
......@@ -65,7 +65,7 @@ pub fn read_pdb(pdb: &str, name: &str) -> Structure {
};
let reader = BufReader::new(pdb);
let mut structure = Structure::new(String::from("toto"));
let mut structure = Structure::new(name.to_string());
for line in reader.lines() {
let l = line.unwrap();
......
......@@ -135,6 +135,28 @@ impl Structure {
n
}
/// Return the number of atom in the protein
///
/// # Examples
///
/// ````
/// use pdbparser;
///
/// let my_struct = pdbparser::read_pdb("tests/tests_file/f2.pdb", "f2");
/// assert_eq!(1085, my_struct.get_atom_number());
/// ````
pub fn get_atom_number(&self) -> u64 {
let mut n: u64 = 0;
for chain in self.chains.iter() {
for res in chain.lst_res.iter() {
for _ in res.lst_atom.iter() {
n += 1;
}
}
}
n
}
/// Generate a vector of atoms index
/// Can be used in other program like rrmsd_map to select specific atoms
///
......
......@@ -2,41 +2,41 @@ extern crate pdbparser;
#[test]
fn parse_f2() {
let my_prot = pdbparser::parse_pdb("tests/tests_file/f2.pdb", "f2");
assert_eq!("f2", my_prot.name());
assert_eq!(1, my_prot.get_number_chain());
assert_eq!(66, my_prot.get_number_residue());
assert_eq!(1085, my_prot.get_number_atom());
let my_struct = pdbparser::read_pdb("tests/tests_file/f2.pdb", "f2");
assert_eq!("f2", my_struct.name());
assert_eq!(1, my_struct.get_chain_number());
assert_eq!(66, my_struct.get_residue_number());
assert_eq!(1085, my_struct.get_atom_number());
}
#[test]
fn parse_f2_adn() {
let my_prot = pdbparser::parse_pdb("tests/tests_file/f2_adn.pdb", "f2");
assert_eq!(1, my_prot.get_number_chain());
assert_eq!(66, my_prot.get_number_residue());
assert_eq!(1085, my_prot.get_number_atom());
let my_struct = pdbparser::read_pdb("tests/tests_file/f2_adn.pdb", "f2");
assert_eq!(1, my_struct.get_chain_number());
assert_eq!(66, my_struct.get_residue_number());
assert_eq!(1085, my_struct.get_atom_number());
}
#[test]
fn parse_trp() {
let my_prot = pdbparser::parse_pdb("tests/tests_file/trp_MD.pdb", "trp");
assert_eq!(1, my_prot.get_number_chain());
assert_eq!(704, my_prot.get_number_residue());
assert_eq!(10688, my_prot.get_number_atom());
let my_struct = pdbparser::read_pdb("tests/tests_file/trp_MD.pdb", "trp");
assert_eq!(1, my_struct.get_chain_number());
assert_eq!(704, my_struct.get_residue_number());
assert_eq!(10688, my_struct.get_atom_number());
}
#[test]
fn parse_5jpq() {
let my_prot = pdbparser::parse_pdb("tests/tests_file/5jpq.pdb", "5jpq");
assert_eq!(35, my_prot.get_number_chain());
assert_eq!(8173, my_prot.get_number_residue());
assert_eq!(44801, my_prot.get_number_atom());
let my_struct = pdbparser::read_pdb("tests/tests_file/5jpq.pdb", "5jpq");
assert_eq!(35, my_struct.get_chain_number());
assert_eq!(8173, my_struct.get_residue_number());
assert_eq!(44801, my_struct.get_atom_number());
}
#[test]
fn f2_res() {
let mut my_prot = pdbparser::parse_pdb("tests/tests_file/f2.pdb", "f2");
let chain_a = my_prot.get_chain_ref('A').unwrap();
let mut my_struct = pdbparser::read_pdb("tests/tests_file/f2.pdb", "f2");
let chain_a = my_struct.get_chain_ref('A').unwrap();
let res = chain_a.get_residue_ref(1).unwrap();
assert_eq!("THR", res.name());
......
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