Rename "Tests" directory for consistency.
This commit is contained in:
7
tests/.gitignore
vendored
Normal file
7
tests/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
# Compiled python files
|
||||
*.pka
|
||||
*.out
|
||||
*.propka_input
|
||||
|
||||
|
||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
57
tests/hybrid36.py
Normal file
57
tests/hybrid36.py
Normal file
@@ -0,0 +1,57 @@
|
||||
import unittest
|
||||
|
||||
import propka.hybrid36 as hybrid36
|
||||
|
||||
class Hybrid36Test(unittest.TestCase):
|
||||
def testDecode(self):
|
||||
test_values = {
|
||||
"99999": 99999,
|
||||
"A0000": 100000,
|
||||
"0": 0,
|
||||
"9": 9,
|
||||
"A": 10,
|
||||
" ZZZZY": 43770014,
|
||||
"ZZZZZ": 43770015, # ZZZZZ - A0000 + 100000
|
||||
"a0000": 43770016,
|
||||
"zzzzz": 87440031,
|
||||
"zzzzy": 87440030,
|
||||
"99": 99,
|
||||
"A0": 100,
|
||||
"ZZ": 1035,
|
||||
"zz": 1971,
|
||||
"-99999": -99999,
|
||||
"-A0000": -100000,
|
||||
"-0": 0,
|
||||
"-9": -9,
|
||||
"-A": -10,
|
||||
"-ZZZZY": -43770014,
|
||||
"-ZZZZZ": -43770015, # ZZZZZ - A0000 + 100000
|
||||
"-a0000": -43770016,
|
||||
"-zzzzz": -87440031,
|
||||
"-zzzzy": -87440030,
|
||||
"-99": -99,
|
||||
"-A0": -100,
|
||||
"-ZZ": -1035,
|
||||
"-zz": -1971,
|
||||
"PROPKA": 954495146,
|
||||
"A001Z": 100071,
|
||||
"B0000": 1779616,
|
||||
}
|
||||
|
||||
for k, v in test_values.iteritems():
|
||||
self.assertEqual(hybrid36.decode(k), v)
|
||||
|
||||
def testErrors(self):
|
||||
test_values = [
|
||||
"99X99",
|
||||
"X9-99",
|
||||
"XYZa",
|
||||
"",
|
||||
"-",
|
||||
"!NotOk",
|
||||
]
|
||||
|
||||
for v in test_values:
|
||||
with self.assertRaises(ValueError) as e:
|
||||
hybrid36.decode(v)
|
||||
self.assertTrue(v in str(e.exception))
|
||||
2073
tests/pdb/1FTJ-Chain-A.pdb
Normal file
2073
tests/pdb/1FTJ-Chain-A.pdb
Normal file
File diff suppressed because it is too large
Load Diff
18
tests/pdb/1HPX-warn.pdb
Normal file
18
tests/pdb/1HPX-warn.pdb
Normal file
@@ -0,0 +1,18 @@
|
||||
ATOM 1 N PRO A 1 12.435 14.677 30.369 1.00 35.93 N
|
||||
ATOM 2 CA PRO A 1 11.739 15.379 29.269 1.00 34.94 C
|
||||
ATOM 2 CA PRO A 1 11.739 15.379 29.269 1.00 34.94 C
|
||||
ATOM 3 C PRO A 1 10.309 14.853 29.143 1.00 32.24 C
|
||||
ATOM 4 O PRO A 1 10.035 13.743 29.578 1.00 32.11 O
|
||||
ATOM 5 CB PRO A 1 12.566 15.121 27.988 1.00 34.34 C
|
||||
ATOM 6 CG PRO A 1 13.973 14.970 28.518 1.00 35.36 C
|
||||
ATOM 7 CD PRO A 1 13.768 14.261 29.859 1.00 35.14 C
|
||||
ATOM 8 N GLN A 2 9.436 15.666 28.552 1.00 29.85 N
|
||||
ATOM 9 CA GLN A 2 8.117 15.184 28.193 1.00 29.27 C
|
||||
ATOM 10 C GLN A 2 7.939 15.392 26.711 1.00 28.61 C
|
||||
ATOM 11 O GLN A 2 8.147 16.506 26.246 1.00 31.02 O
|
||||
ATOM 12 CB GLN A 2 7.108 15.981 28.932 1.00 28.24 C
|
||||
ATOM 13 CG GLN A 2 5.789 15.599 28.365 1.00 32.41 C
|
||||
ATOM 14 CD GLN A 2 4.735 16.247 29.153 1.00 37.59 C
|
||||
ATOM 15 OE1 GLN A 2 4.403 15.796 30.243 1.00 39.05 O
|
||||
ATOM 16 NE2 GLN A 2 4.210 17.303 28.540 1.00 39.28 N
|
||||
END
|
||||
2039
tests/pdb/1HPX.pdb
Normal file
2039
tests/pdb/1HPX.pdb
Normal file
File diff suppressed because it is too large
Load Diff
2327
tests/pdb/3SGB-subset.pdb
Normal file
2327
tests/pdb/3SGB-subset.pdb
Normal file
File diff suppressed because it is too large
Load Diff
2327
tests/pdb/3SGB.pdb
Normal file
2327
tests/pdb/3SGB.pdb
Normal file
File diff suppressed because it is too large
Load Diff
3935
tests/pdb/4DFR.pdb
Normal file
3935
tests/pdb/4DFR.pdb
Normal file
File diff suppressed because it is too large
Load Diff
98
tests/pkacalc_test.py
Normal file
98
tests/pkacalc_test.py
Normal file
@@ -0,0 +1,98 @@
|
||||
"""Reproduce tests from original PROPKA."""
|
||||
import os
|
||||
import re
|
||||
from subprocess import call
|
||||
import sys
|
||||
import unittest
|
||||
import logging
|
||||
import propka.lib
|
||||
import propka.molecular_container
|
||||
|
||||
|
||||
# This error tolerance was chosen to make Ubuntu 18.04 pass under Windows
|
||||
# Subsystem Linux.
|
||||
ACCEPTABLE_ERROR = 0.001
|
||||
|
||||
|
||||
def run_propka(args):
|
||||
"""Run PROPKA.
|
||||
|
||||
Args:
|
||||
args: command-line arguments for PROPKA
|
||||
"""
|
||||
options = propka.lib.loadOptions()
|
||||
raise NotImplementedError("Need to incorporated command-line arguments")
|
||||
pdbfiles = options.filenames
|
||||
|
||||
for pdbfile in pdbfiles:
|
||||
my_molecule = propka.molecular_container.Molecular_container(pdbfile, options)
|
||||
my_molecule.calculate_pka()
|
||||
my_molecule.write_pka()
|
||||
|
||||
|
||||
# Setting this up as a direct translation of the original runtest.py script
|
||||
# that will be run as part of 'python setup.py test'. This takes on the
|
||||
# order of 10s to run.
|
||||
|
||||
class SystemTest(unittest.TestCase):
|
||||
"""
|
||||
Run the program and compare against reference results.
|
||||
"""
|
||||
def test_pka_calc(self):
|
||||
pdbs = ['1FTJ-Chain-A',
|
||||
'1HPX',
|
||||
'4DFR']
|
||||
|
||||
test_dir = os.path.dirname(__file__)
|
||||
base_dir = os.path.dirname(test_dir)
|
||||
|
||||
executable = os.path.join(base_dir, "scripts", "propka31.py")
|
||||
|
||||
env = { "PYTHONPATH" : base_dir }
|
||||
|
||||
for pdb in pdbs:
|
||||
input_filename = os.path.join(test_dir, "pdb", pdb + ".pdb")
|
||||
output_filename = os.path.join(test_dir, pdb + ".out")
|
||||
|
||||
output_file = open(output_filename, "w")
|
||||
call([sys.executable, executable, input_filename],
|
||||
stdout=output_file, env=env)
|
||||
output_file.close()
|
||||
|
||||
# Check pka predictions.
|
||||
ref = open(os.path.join(test_dir, "results", pdb + ".dat"))
|
||||
output = open(output_filename)
|
||||
|
||||
atpka = False
|
||||
errors = []
|
||||
for line in output:
|
||||
if not atpka:
|
||||
# Start testing pka values.
|
||||
if "model-pKa" in line:
|
||||
atpka = True
|
||||
continue
|
||||
|
||||
m = re.search('([0-9]+\.[0-9]+)', line)
|
||||
if not m:
|
||||
break
|
||||
|
||||
expected_value = float(ref.readline())
|
||||
value = float(m.group(0))
|
||||
value_error = (value-expected_value)/expected_value
|
||||
|
||||
if abs(value_error) > ACCEPTABLE_ERROR:
|
||||
logging.error(value_error)
|
||||
identity = line[:m.start()].strip()
|
||||
errors.append("%12s %8.2f %8.2f" %
|
||||
(identity, expected_value, value))
|
||||
|
||||
os.remove("%s.pka" % pdb)
|
||||
os.remove("%s.propka_input" % pdb)
|
||||
|
||||
ref.close()
|
||||
output.close()
|
||||
|
||||
if errors:
|
||||
error_header = " Group Expected Calculated\n"
|
||||
self.fail("Unexpected pKa values:\n" + error_header +
|
||||
"\n".join(errors))
|
||||
85
tests/results/1FTJ-Chain-A.dat
Normal file
85
tests/results/1FTJ-Chain-A.dat
Normal file
@@ -0,0 +1,85 @@
|
||||
3.56
|
||||
3.25
|
||||
2.87
|
||||
3.52
|
||||
3.77
|
||||
3.26
|
||||
3.82
|
||||
3.92
|
||||
3.08
|
||||
3.65
|
||||
4.01
|
||||
4.01
|
||||
6.38
|
||||
4.58
|
||||
4.49
|
||||
4.90
|
||||
3.62
|
||||
4.52
|
||||
5.36
|
||||
4.67
|
||||
3.61
|
||||
3.88
|
||||
4.58
|
||||
4.66
|
||||
4.27
|
||||
3.84
|
||||
4.95
|
||||
4.68
|
||||
3.44
|
||||
6.11
|
||||
5.61
|
||||
12.90
|
||||
10.65
|
||||
99.99
|
||||
99.99
|
||||
15.10
|
||||
10.44
|
||||
14.06
|
||||
11.43
|
||||
19.83
|
||||
9.71
|
||||
12.57
|
||||
10.97
|
||||
12.75
|
||||
15.63
|
||||
11.13
|
||||
21.84
|
||||
12.00
|
||||
10.43
|
||||
10.31
|
||||
10.34
|
||||
10.49
|
||||
10.08
|
||||
10.45
|
||||
10.37
|
||||
10.25
|
||||
10.37
|
||||
11.44
|
||||
9.30
|
||||
10.41
|
||||
10.31
|
||||
10.00
|
||||
10.44
|
||||
10.31
|
||||
10.60
|
||||
10.37
|
||||
11.35
|
||||
10.41
|
||||
10.21
|
||||
10.33
|
||||
9.25
|
||||
11.16
|
||||
10.02
|
||||
12.52
|
||||
12.28
|
||||
13.22
|
||||
13.43
|
||||
12.31
|
||||
12.20
|
||||
12.24
|
||||
12.73
|
||||
7.93
|
||||
11.90
|
||||
1.20
|
||||
7.39
|
||||
1
tests/results/1HPX-warn.dat
Normal file
1
tests/results/1HPX-warn.dat
Normal file
@@ -0,0 +1 @@
|
||||
7.95
|
||||
49
tests/results/1HPX.dat
Normal file
49
tests/results/1HPX.dat
Normal file
@@ -0,0 +1,49 @@
|
||||
5.07
|
||||
3.11
|
||||
4.62
|
||||
2.55
|
||||
9.28
|
||||
1.78
|
||||
4.91
|
||||
2.13
|
||||
4.78
|
||||
3.93
|
||||
3.65
|
||||
3.89
|
||||
4.73
|
||||
3.36
|
||||
4.07
|
||||
3.70
|
||||
2.08
|
||||
2.11
|
||||
6.98
|
||||
7.11
|
||||
9.41
|
||||
11.68
|
||||
9.82
|
||||
11.61
|
||||
9.67
|
||||
9.54
|
||||
10.43
|
||||
10.32
|
||||
11.41
|
||||
10.54
|
||||
10.42
|
||||
10.92
|
||||
10.55
|
||||
11.01
|
||||
11.43
|
||||
10.47
|
||||
10.41
|
||||
11.07
|
||||
13.96
|
||||
12.41
|
||||
14.39
|
||||
12.35
|
||||
12.76
|
||||
12.42
|
||||
13.73
|
||||
12.28
|
||||
8.96
|
||||
8.96
|
||||
4.60
|
||||
2
tests/results/3SGB-subset.dat
Normal file
2
tests/results/3SGB-subset.dat
Normal file
@@ -0,0 +1,2 @@
|
||||
3.51
|
||||
12.80
|
||||
57
tests/results/3SGB.dat
Normal file
57
tests/results/3SGB.dat
Normal file
@@ -0,0 +1,57 @@
|
||||
3.21
|
||||
4.29
|
||||
3.47
|
||||
3.85
|
||||
4.22
|
||||
4.59
|
||||
3.55
|
||||
2.61
|
||||
4.48
|
||||
5.27
|
||||
4.26
|
||||
5.11
|
||||
4.60
|
||||
3.63
|
||||
3.24
|
||||
8.04
|
||||
6.15
|
||||
7.14
|
||||
99.99
|
||||
99.99
|
||||
99.99
|
||||
99.99
|
||||
99.99
|
||||
99.99
|
||||
99.99
|
||||
99.99
|
||||
99.99
|
||||
99.99
|
||||
10.27
|
||||
10.00
|
||||
10.33
|
||||
10.82
|
||||
13.96
|
||||
13.90
|
||||
10.28
|
||||
10.96
|
||||
12.23
|
||||
12.62
|
||||
10.25
|
||||
10.52
|
||||
12.31
|
||||
9.50
|
||||
10.92
|
||||
10.35
|
||||
10.44
|
||||
10.67
|
||||
11.74
|
||||
12.84
|
||||
11.95
|
||||
12.36
|
||||
11.05
|
||||
12.89
|
||||
12.19
|
||||
12.17
|
||||
12.16
|
||||
7.38
|
||||
7.56
|
||||
107
tests/results/4DFR.dat
Normal file
107
tests/results/4DFR.dat
Normal file
@@ -0,0 +1,107 @@
|
||||
3.86
|
||||
5.05
|
||||
3.99
|
||||
2.02
|
||||
3.71
|
||||
4.00
|
||||
3.85
|
||||
4.30
|
||||
3.89
|
||||
3.74
|
||||
4.05
|
||||
4.02
|
||||
2.82
|
||||
3.88
|
||||
4.03
|
||||
3.98
|
||||
2.05
|
||||
4.01
|
||||
3.79
|
||||
3.90
|
||||
3.93
|
||||
4.07
|
||||
3.70
|
||||
4.15
|
||||
4.01
|
||||
2.65
|
||||
4.50
|
||||
4.77
|
||||
3.71
|
||||
2.85
|
||||
3.90
|
||||
4.71
|
||||
4.59
|
||||
4.86
|
||||
4.47
|
||||
4.63
|
||||
4.86
|
||||
4.52
|
||||
3.73
|
||||
2.91
|
||||
4.57
|
||||
4.83
|
||||
4.62
|
||||
4.16
|
||||
3.73
|
||||
4.70
|
||||
3.38
|
||||
3.26
|
||||
6.77
|
||||
4.89
|
||||
6.85
|
||||
5.95
|
||||
4.91
|
||||
6.50
|
||||
4.87
|
||||
6.69
|
||||
7.15
|
||||
4.99
|
||||
10.86
|
||||
9.04
|
||||
10.91
|
||||
9.07
|
||||
14.10
|
||||
13.22
|
||||
11.24
|
||||
11.58
|
||||
14.07
|
||||
13.23
|
||||
11.19
|
||||
11.76
|
||||
10.47
|
||||
10.50
|
||||
10.23
|
||||
10.04
|
||||
10.32
|
||||
10.46
|
||||
10.50
|
||||
10.30
|
||||
10.26
|
||||
10.54
|
||||
10.21
|
||||
10.23
|
||||
12.34
|
||||
12.17
|
||||
12.29
|
||||
12.66
|
||||
11.95
|
||||
13.80
|
||||
13.21
|
||||
11.90
|
||||
12.49
|
||||
12.41
|
||||
12.09
|
||||
12.51
|
||||
12.06
|
||||
13.97
|
||||
12.55
|
||||
12.10
|
||||
12.39
|
||||
7.70
|
||||
7.63
|
||||
4.86
|
||||
4.83
|
||||
4.05
|
||||
4.26
|
||||
4.03
|
||||
4.47
|
||||
68
tests/runtest.py
Normal file
68
tests/runtest.py
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
""" Run test for test pdbs """
|
||||
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from subprocess import call
|
||||
import os, re
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
# A list of input structures and command-line arguments to be passed in
|
||||
# to PROPKA for each:
|
||||
pdbs = [('1FTJ-Chain-A', []),
|
||||
('1HPX', []),
|
||||
('4DFR', []),
|
||||
('3SGB', []),
|
||||
('3SGB-subset', ['--titrate_only', 'E:17,E:18,E:19,E:29,E:44,E:45,E:46,E:118,E:119,E:120,E:139']),
|
||||
('1HPX-warn', ['--quiet']),
|
||||
]
|
||||
|
||||
for pdb, args in pdbs:
|
||||
print('')
|
||||
print('RUNNING '+pdb)
|
||||
|
||||
# Run pka calculation
|
||||
fh = open(pdb + '.out', 'w')
|
||||
cmd = [sys.executable, '../scripts/propka31.py','pdb/%s.pdb' % pdb] + args
|
||||
ret = call(cmd, stdout=fh, stderr=fh)
|
||||
if ret != 0:
|
||||
print(" ERR:")
|
||||
print(" Failed to execute PROPKA on %s" % pdb)
|
||||
print(" See: %s.out" % pdb)
|
||||
sys.exit(1)
|
||||
|
||||
# Test pka predictions
|
||||
result_file = 'results/%s.dat' % pdb
|
||||
if not os.path.isfile(result_file):
|
||||
print(" ERR:")
|
||||
print(" file not found: %s" % result_file)
|
||||
sys.exit(1)
|
||||
|
||||
result = open(result_file,'r')
|
||||
atpka = False
|
||||
for line in open(pdb+'.pka', 'r').readlines():
|
||||
if not atpka:
|
||||
if "model-pKa" in line:
|
||||
# test pka
|
||||
atpka = True
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
if "-" in line:
|
||||
# done testing
|
||||
atpka = False
|
||||
continue
|
||||
|
||||
expected_value = float(result.readline())
|
||||
m = re.search('([0-9]+\.[0-9]+)', line)
|
||||
value = float(m.group(0))
|
||||
|
||||
if value != expected_value:
|
||||
print(" ERR:")
|
||||
print(line)
|
||||
print(" %s should be: %s" % (value, expected_value))
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user