Merge branch 'master' into nathan/delint

This commit is contained in:
Nathan Baker
2020-05-23 09:20:01 -07:00
6 changed files with 16 additions and 19 deletions

View File

@@ -45,7 +45,7 @@ from within a virtual environment (e.g., via [virtualenv](https://pypi.org/proje
## Requirements ## Requirements
* Python 3.1 or higher * Python 3.5 or higher
## Getting started ## Getting started

View File

@@ -215,7 +215,7 @@ def build_parser(parser=None):
group.add_argument("-k", "--keep-protons", dest="keep_protons", action="store_true", group.add_argument("-k", "--keep-protons", dest="keep_protons", action="store_true",
help="Keep protons in input file", default=False) help="Keep protons in input file", default=False)
group.add_argument("-q", "--quiet", action="store_const", const="WARNING", group.add_argument("-q", "--quiet", action="store_const", const="WARNING",
dest="log_level", help="supress non-warning messages") dest="log_level", help="suppress non-warning messages")
group.add_argument("--protonate-all", dest="protonate_all", action="store_true", group.add_argument("--protonate-all", dest="protonate_all", action="store_true",
help="Protonate all atoms (will not influence pKa calculation)", help="Protonate all atoms (will not influence pKa calculation)",
default=False) default=False)
@@ -328,4 +328,3 @@ def debug(*args):
def warning(*args): def warning(*args):
"""Log a WARN message""" """Log a WARN message"""
logger.warning(_args_to_str(args)) logger.warning(_args_to_str(args))

View File

@@ -1 +1,2 @@
pytest pytest
numpy

View File

@@ -56,6 +56,7 @@ See http://propka.org/ for the PROPKA web server.
], ],
}, },
zip_safe=True, zip_safe=True,
python_requires='>=3', python_requires='>=3.5',
tests_require=["pandas", "numpy"],
test_suite="tests", test_suite="tests",
) )

View File

@@ -1,6 +1,7 @@
# Testing PROPKA # Testing PROPKA
These tests assume that PROPKA is installed as a module on your system. These tests assume that PROPKA is installed as a module on your system the
dependencies in `../requirements.txt` are satisfied.
If you are running in a virtual environment and want to make changes to your If you are running in a virtual environment and want to make changes to your
code, module installation accomplished by code, module installation accomplished by
``` ```

View File

@@ -4,7 +4,7 @@ import os
import re import re
from pathlib import Path from pathlib import Path
import pytest import pytest
import pandas as pd from numpy.testing import assert_almost_equal
import propka.lib import propka.lib
import propka.molecular_container import propka.molecular_container
@@ -12,9 +12,10 @@ import propka.molecular_container
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
# Maximum error set by number of decimal places in pKa output as well as need # Number of decimal places for maximum tolerable error. Set by number of
# to make unmodified code work on WSL Ubuntu 18.04 # decimal places in pKa output as well as need to make unmodified code work
MAX_ERR = 0.01 # on WSL Ubuntu 18.04
MAX_ERR_DECIMALS = 2
# This directory # This directory
@@ -69,8 +70,6 @@ def run_propka(options, pdb_path, tmp_path):
molecule = propka.molecular_container.Molecular_container(str(pdb_path), args) molecule = propka.molecular_container.Molecular_container(str(pdb_path), args)
molecule.calculate_pka() molecule.calculate_pka()
molecule.write_pka() molecule.write_pka()
except Exception as err:
raise err
finally: finally:
os.chdir(cwd) os.chdir(cwd)
@@ -104,13 +103,9 @@ def compare_output(pdb, tmp_path, ref_path):
m = re.search(r'([0-9]+\.[0-9]+)', line) m = re.search(r'([0-9]+\.[0-9]+)', line)
value = float(m.group(0)) value = float(m.group(0))
test_data.append(value) test_data.append(value)
errstr = "Error exceeds maximum allowed value (%d decimal places)" % MAX_ERR_DECIMALS
df = pd.DataFrame({"reference": ref_data, "test": test_data}) assert_almost_equal(test_data, ref_data, decimal=MAX_ERR_DECIMALS,
df["difference"] = df["reference"] - df["test"] err_msg=errstr, verbose=True)
max_err = df["difference"].abs().max()
if max_err > MAX_ERR:
errstr = "Error in test (%g) exceeds maximum (%g)" % (max_err, MAX_ERR)
raise ValueError(errstr)
@pytest.mark.parametrize("pdb, options", [ @pytest.mark.parametrize("pdb, options", [