dockonsurf / tests / test_formats.py @ master
Historique | Voir | Annoter | Télécharger (1,65 ko)
1 |
import sys |
---|---|
2 |
import unittest |
3 |
|
4 |
from rdkit.Chem import Mol, AllChem as Chem |
5 |
from ase.atoms import Atoms |
6 |
from modules.formats import adapt_format, confs_to_mol_list, \ |
7 |
rdkit_mol_to_ase_atoms
|
8 |
|
9 |
mol = Chem.MolFromMolFile('acetic.mol', removeHs=False) |
10 |
num_confs = 5
|
11 |
Chem.EmbedMultipleConfs(mol, num_confs) |
12 |
|
13 |
|
14 |
class TestConfsToMolList(unittest.TestCase): |
15 |
def test_confs_to_mol_list(self): |
16 |
self.assertIsInstance(confs_to_mol_list(mol), list) |
17 |
self.assertEqual(len(confs_to_mol_list(mol)), num_confs) |
18 |
self.assertEqual(len(confs_to_mol_list(mol, [0, 2, 4])), 3) |
19 |
|
20 |
|
21 |
class TestMolToAtoms(unittest.TestCase): |
22 |
def test_rdkit_mol_to_ase_atoms(self): |
23 |
self.assertIsInstance(rdkit_mol_to_ase_atoms(mol), Atoms)
|
24 |
atoms = rdkit_mol_to_ase_atoms(mol) |
25 |
self.assertEqual(mol.GetNumAtoms(), atoms.get_global_number_of_atoms())
|
26 |
|
27 |
|
28 |
class TestAdaptFormat(unittest.TestCase): |
29 |
def test_rdkit_mol(self): |
30 |
self.assertIsInstance(
|
31 |
adapt_format('rdkit', 'acetic.mol'), |
32 |
Mol) |
33 |
|
34 |
def test_rdkit_xyz(self): |
35 |
self.assertIsInstance(
|
36 |
adapt_format('rdkit', 'acetic.xyz'), Mol) |
37 |
|
38 |
def test_ase_mol(self): |
39 |
self.assertIsInstance(
|
40 |
adapt_format('ase', 'acetic.mol'), |
41 |
Atoms) |
42 |
|
43 |
def test_ase_xyz(self): |
44 |
self.assertIsInstance(
|
45 |
adapt_format('ase', 'acetic.xyz'), Atoms) |
46 |
|
47 |
def test_not_adeq_req(self): |
48 |
self.assertRaises(NotImplementedError, adapt_format, 'hola', |
49 |
'acetic.xyz')
|
50 |
|
51 |
def test_wrong_file_type(self): |
52 |
self.assertRaises(NotImplementedError, adapt_format, 'ase', 'good.inp') |
53 |
|
54 |
|
55 |
if __name__ == '__main__': |
56 |
unittest.main() |