1use rdkit_ffi::rd;
2
3pub struct Molecule {
4 pub rd_mol: cxx::SharedPtr<rd::RWMol>
5}
6
7impl Molecule {
8 pub fn new_from_smiles(smiles: &str) -> Self {
9 cxx::let_cxx_string!(smiles_cxx = smiles);
10 Self { rd_mol: rd::SmilesParse_smi_to_mol(&smiles_cxx) }
11 }
12
13 pub fn num_atoms(&self) -> u32 { rd::RWMol_get_num_atoms(&self.rd_mol) }
14 pub fn num_heavy_atoms(&self) -> u32 { rd::RWMol_get_num_heavy_atoms(&self.rd_mol) }
15 pub fn num_bonds(&self) -> u32 { rd::RWMol_get_num_bonds(&self.rd_mol) }
16
17
18}
19
20#[cfg(test)]
21mod test_mod_molecule {
22 use super::*;
23
24 #[test]
25 fn test_molecule() {
26 let mol = Molecule::new_from_smiles("CCNCC");
27 assert_eq!(mol.num_atoms(), 5);
28 assert_eq!(mol.num_bonds(), 4);
29 assert_eq!(mol.num_heavy_atoms(), 5);
30 }
31}