1
"""
2
test_smi2confs.py
3
"""
4 0
import sys
5 0
import os
6 0
import pytest
7

8
# define location of input files for testing
9 0
mydir = os.path.dirname(os.path.abspath(__file__))
10

11
# import functions to aid testing
12 0
sys.path.append(os.path.join(os.path.dirname(__file__), 'helpers'))
13 0
from helper import *
14

15 0
from quanformer.initialize_confs import *
16

17
# -----------------------
18

19 0
def test_generate_confs():
20 0
    mol = read_mol(os.path.join(mydir, 'data_tests', 'steric_clash.smi'))
21 0
    mol_with_confs = generate_confs(mol)
22 0
    assert mol_with_confs.NumConfs() == 5
23

24

25 0
def test_resolve_clashes():
26 0
    mol = read_mol(os.path.join(mydir, 'data_tests', 'steric_clash.smi'))
27 0
    mol = generate_confs(mol)
28 0
    for conf in mol.GetConfs():
29 0
        resolve_clashes(conf, os.path.join(mydir, 'clashes.out'))
30 0
    statinfo = os.stat(os.path.join(mydir, 'clashes.out'))
31 0
    assert statinfo.st_size == 405
32 0
    os.remove(os.path.join(mydir, 'clashes.out'))
33

34

35 0
def test_quick_opt():
36
    # TODO
37 0
    pass
38

39

40 0
def test_initialize_confs():
41 0
    os.chdir(mydir)
42 0
    initialize_confs(os.path.join(mydir, 'data_tests', 'methane.smi'))
43 0
    statinfo = os.stat(os.path.join(mydir, 'methane.sdf'))
44 0
    assert statinfo.st_size == 612
45 0
    os.remove(os.path.join(mydir, 'methane.sdf'))
46 0
    os.remove(os.path.join(mydir, 'numConfs.txt'))
47

48

49 0
def test_initialize_confs_rename():
50 0
    initialize_confs(os.path.join(mydir, 'data_tests', 'methane_c2p.sdf'))
51 0
    statinfo = os.stat(os.path.join(mydir, 'methane_c2p_quanformer.sdf'))
52 0
    assert statinfo.st_size == 702
53 0
    os.remove(os.path.join(mydir, 'methane_c2p_quanformer.sdf'))
54 0
    os.remove(os.path.join(mydir, 'numConfs.txt'))
55

56

57
# test manually without pytest
58 0
if 0:
59
    test_generate_confs()
60
    test_resolve_clashes()
61
    test_quick_opt()
62
    test_initialize_confs()
63
    test_initialize_confs_rename()

Read our documentation on viewing source code .

Loading