test.rs 2.58 KB
Newer Older
NOEL Philippe's avatar
NOEL Philippe committed
1 2 3 4
extern crate pdbparser;

#[test]
fn parse_f2() {
Emmanuel Bresso's avatar
Emmanuel Bresso committed
5 6 7 8 9
    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());
NOEL Philippe's avatar
NOEL Philippe committed
10 11 12 13
}

#[test]
fn parse_f2_adn() {
Emmanuel Bresso's avatar
Emmanuel Bresso committed
14 15 16 17
    let my_struct = pdbparser::read_pdb("tests/tests_file/f2_adn.pdb", "f2");
    assert_eq!(5, my_struct.get_chain_number());
    assert_eq!(8382, my_struct.get_residue_number());
    assert_eq!(47740, my_struct.get_atom_number());
NOEL Philippe's avatar
NOEL Philippe committed
18 19 20 21
}

#[test]
fn parse_trp() {
Emmanuel Bresso's avatar
Emmanuel Bresso committed
22 23 24 25
    let my_struct = pdbparser::read_pdb("tests/tests_file/trp_MD.pdb", "trp");
    assert_eq!(3, my_struct.get_chain_number());
    assert_eq!(9970, my_struct.get_residue_number());
    assert_eq!(396_109, my_struct.get_atom_number());
NOEL Philippe's avatar
NOEL Philippe committed
26 27 28 29
}

#[test]
fn parse_5jpq() {
Emmanuel Bresso's avatar
Emmanuel Bresso committed
30 31 32 33
    let my_struct = pdbparser::read_pdb("tests/tests_file/5jpq.pdb", "5jpq");
    assert_eq!(56, my_struct.get_chain_number());
    assert_eq!(15066, my_struct.get_residue_number());
    assert_eq!(95839, my_struct.get_atom_number());
NOEL Philippe's avatar
NOEL Philippe committed
34 35 36 37
}

#[test]
fn f2_res() {
Emmanuel Bresso's avatar
Emmanuel Bresso committed
38 39
    let mut my_struct = pdbparser::read_pdb("tests/tests_file/f2.pdb", "f2");
    let chain_a = my_struct.get_chain_ref('A').unwrap();
NOEL Philippe's avatar
NOEL Philippe committed
40 41 42 43 44 45 46

    let res = chain_a.get_residue_ref(1).unwrap();
    assert_eq!("THR", res.name());

    let res = chain_a.get_residue_ref(2).unwrap();
    assert_eq!("SER", res.name());

47 48 49
    let res = chain_a
        .get_residue_ref(chain_a.get_number_residue())
        .unwrap();
NOEL Philippe's avatar
NOEL Philippe committed
50
    assert_eq!("HSD", res.name());
51
}
Emmanuel Bresso's avatar
Emmanuel Bresso committed
52

Emmanuel Bresso's avatar
Emmanuel Bresso committed
53

Emmanuel Bresso's avatar
Emmanuel Bresso committed
54 55
#[test]
fn mass_center_f2() {
Emmanuel Bresso's avatar
Emmanuel Bresso committed
56
    let my_struct = pdbparser::read_pdb("tests/tests_file/f2.pdb", "f2");
Emmanuel Bresso's avatar
Emmanuel Bresso committed
57 58

    let mut atoms: Vec<pdbparser::Atom> = Vec::new();
Emmanuel Bresso's avatar
Emmanuel Bresso committed
59
    for chain in my_struct.chains {
Emmanuel Bresso's avatar
Emmanuel Bresso committed
60 61 62 63 64 65 66 67 68 69 70 71
        for residue in chain.lst_res {
            for atom in residue.lst_atom {
                atoms.push(atom);
            }
        }
    }
    assert_eq!([0.011766517, 20.1037, -0.007502083], pdbparser::center_of_mass(atoms))
}


#[test]
fn mass_center_5jpq() {
Emmanuel Bresso's avatar
Emmanuel Bresso committed
72
    let my_struct = pdbparser::read_pdb("tests/tests_file/5jpq.pdb", "5jpq");
Emmanuel Bresso's avatar
Emmanuel Bresso committed
73 74

    let mut atoms: Vec<pdbparser::Atom> = Vec::new();
Emmanuel Bresso's avatar
Emmanuel Bresso committed
75
    for chain in my_struct.chains {
Emmanuel Bresso's avatar
Emmanuel Bresso committed
76 77 78 79 80 81
        for residue in chain.lst_res {
            for atom in residue.lst_atom {
                atoms.push(atom);
            }
        }
    }
Emmanuel Bresso's avatar
Emmanuel Bresso committed
82 83
    assert_eq!([237.98595, 241.93814, 231.15921], pdbparser::center_of_mass(atoms))
}
Emmanuel Bresso's avatar
Emmanuel Bresso committed
84 85 86 87 88 89 90

#[test]
fn remove_hydrogens_f2(){
    let my_struct = pdbparser::read_pdb("tests/tests_file/f2.pdb", "f2");
    let ss_h = my_struct.remove_h().unwrap();
    assert_eq!(541, ss_h.get_atom_number());
}