#136 Remove codeclimate and use lint

Merged Jeffry Setiadi jeff231li

@@ -1,12 +1,13 @@
Loading
1 -
import logging as log
2 -
import os
3 1
import base64
4 2
import json
3 +
import logging as log
4 +
import os
5 +
5 6
import numpy as np
6 -
from paprika.restraints import DAT_restraint
7 -
from parmed.amber import AmberParm
8 7
from parmed import Structure
8 +
from parmed.amber import AmberParm
9 9
10 +
from paprika.restraints import DAT_restraint
10 11
11 12
# https://stackoverflow.com/questions/27909658/json-encoder-and-decoder-for-complex-numpy-arrays
12 13
# https://stackoverflow.com/a/24375113/901925
@@ -63,7 +64,6 @@
Loading
63 64
        elif isinstance(obj, (np.ndarray,)):
64 65
            return obj.tolist()
65 66
66 -
67 67
        # Let the base class default method raise the TypeError
68 68
        # return json.JSONEncoder(self, obj)
69 69
        return super(NumpyEncoder, self).default(obj)
@@ -104,8 +104,21 @@
Loading
104 104
        tmp = DAT_restraint()
105 105
        tmp.__dict__ = loaded
106 106
107 -
        properties = ["mask1", "mask2", "mask3", "mask4", "topology", "instances", "custom_restraint_values",
108 -
                      "auto_apr", "continuous_apr", "attach", "pull", "release", "amber_index"]
107 +
        properties = [
108 +
            "mask1",
109 +
            "mask2",
110 +
            "mask3",
111 +
            "mask4",
112 +
            "topology",
113 +
            "instances",
114 +
            "custom_restraint_values",
115 +
            "auto_apr",
116 +
            "continuous_apr",
117 +
            "attach",
118 +
            "pull",
119 +
            "release",
120 +
            "amber_index",
121 +
        ]
109 122
        for class_property in properties:
110 123
            if f"_{class_property}" in tmp.__dict__.keys():
111 124
                tmp.__dict__[class_property] = tmp.__dict__[f"_{class_property}"]

@@ -5,6 +5,7 @@
Loading
5 5
6 6
logger = logging.getLogger(__name__)
7 7
8 +
8 9
def read_yaml(file):
9 10
    """
10 11
    Read `Taproom <https://github.com/slochower/host-guest-benchmarks>`_ -style YAML-formatted instructions for
@@ -40,7 +41,7 @@
Loading
40 41
    regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys())))
41 42
42 43
    # For each match, look-up corresponding value in dictionary
43 -
    return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)
44 +
    return regex.sub(lambda mo: dict[mo.string[mo.start() : mo.end()]], text)
44 45
45 46
46 47
def de_alias(yaml_data):

@@ -6,32 +6,35 @@
Loading
6 6
# Safe to remove with Python 3-only code
7 7
from __future__ import absolute_import
8 8
9 +
import logging
10 +
11 +
from paprika.analyze import Analyze
12 +
9 13
# Handle versioneer
10 14
from ._version import get_versions
11 15
12 16
# Add imports here
13 17
versions = get_versions()
14 -
__version__ = versions['version']
15 -
__git_revision__ = versions['full-revisionid']
18 +
__version__ = versions["version"]
19 +
__git_revision__ = versions["full-revisionid"]
16 20
del get_versions, versions
17 21
18 -
import logging
22 +
19 23
logger = logging.getLogger(__name__)
20 24
21 25
try:
22 -
    from simtk import openmm
23 26
    from paprika.setup import Setup
24 27
25 28
    setup = Setup
26 -
except ImportError as e:
29 +
except ImportError:
27 30
    logging.info("OpenMM not found.")
28 31
    logging.info("`paprika.setup()` requires OpenMM.")
29 32
    setup = None
30 33
31 -
from paprika.analyze import Analyze
34 +
32 35
analyze = Analyze
33 36
34 37
if setup is None:
35 38
    __all__ = ["setup", "analyze"]
36 39
else:
37 -
    __all__ = ["analyze"]

@@ -1,15 +1,21 @@
Loading
1 1
"""
2 2
Tests tleap tools.
3 3
"""
4 -
4 +
import logging
5 +
import os
5 6
import random as random
6 7
import shutil
8 +
import subprocess as sp
7 9
10 +
import numpy as np
11 +
import parmed as pmd
8 12
import pytest
9 13
10 -
from paprika.align import *
11 -
from paprika.dummy import *
12 -
from paprika.tleap import *
14 +
from paprika.align import zalign
15 +
from paprika.dummy import add_dummy, write_dummy_frcmod, write_dummy_mol2
16 +
from paprika.tleap import ANGSTROM_CUBED_TO_LITERS, System
17 +
18 +
logger = logging.getLogger(__name__)
13 19
14 20
15 21
@pytest.fixture
@@ -27,7 +33,7 @@
Loading
27 33
def test_solvation_simple(clean_files):
28 34
    """ Test that we can solvate CB6-BUT using default settings. """
29 35
    waters = np.random.randint(100, 10000)
30 -
    log.debug("Trying {} waters with default settings...".format(waters))
36 +
    logger.debug("Trying {} waters with default settings...".format(waters))
31 37
    sys = System()
32 38
    sys.template_file = os.path.join(
33 39
        os.path.dirname(__file__), "../data/cb6-but/tleap_solvate.in"
@@ -46,7 +52,7 @@
Loading
46 52
def test_solvation_shapes(shape, clean_files):
47 53
    """ Test that we can solvate CB6-BUT with a truncated octahedron. """
48 54
    waters = np.random.randint(1000, 10000)
49 -
    log.debug("Trying {} waters in a truncated octahedron...".format(waters))
55 +
    logger.debug("Trying {} waters in a truncated octahedron...".format(waters))
50 56
    sys = System()
51 57
    sys.template_file = os.path.join(
52 58
        os.path.dirname(__file__), "../data/cb6-but/tleap_solvate.in"
@@ -70,7 +76,7 @@
Loading
70 76
    """ Test that we can solvate CB6-BUT with an buffer size in Angstroms. """
71 77
    random_int = np.random.randint(10, 20)
72 78
    random_size = random_int * np.random.random_sample(1) + random_int
73 -
    log.debug("Trying buffer size of {} A...".format(random_size[0]))
79 +
    logger.debug("Trying buffer size of {} A...".format(random_size[0]))
74 80
    sys = System()
75 81
    sys.template_file = os.path.join(
76 82
        os.path.dirname(__file__), "../data/cb6-but/tleap_solvate.in"
@@ -93,7 +99,7 @@
Loading
93 99
def test_solvation_potassium_control(clean_files):
94 100
    """ Test there is no potassium by default. A negative control. """
95 101
    waters = np.random.randint(1000, 10000)
96 -
    log.debug("Trying {} waters with potassium...".format(waters))
102 +
    logger.debug("Trying {} waters with potassium...".format(waters))
97 103
    sys = System()
98 104
    sys.template_file = os.path.join(
99 105
        os.path.dirname(__file__), "../data/cb6-but/tleap_solvate.in"
@@ -122,7 +128,7 @@
Loading
122 128
    n_anions = np.random.randint(1, 10)
123 129
    random_cation = random.choice(cations)
124 130
    random_anion = random.choice(anions)
125 -
    log.debug("Trying {} waters with additional ions...".format(waters))
131 +
    logger.debug("Trying {} waters with additional ions...".format(waters))
126 132
    sys = System()
127 133
    sys.template_file = os.path.join(
128 134
        os.path.dirname(__file__), "../data/cb6-but/tleap_solvate.in"
@@ -151,19 +157,19 @@
Loading
151 157
        ],
152 158
        shell=True,
153 159
    )
154 -
    log.debug("Expecting...")
155 -
    log.debug("cation = {}\tn_cations={}".format(random_cation, n_cations))
156 -
    log.debug("anion  = {}\t n_anions={}".format(random_anion, n_anions))
157 -
    log.debug("Found...")
158 -
    log.debug("             n_cations={}".format(cation_number))
159 -
    log.debug("              n_anions={}".format(anion_number))
160 +
    logger.debug("Expecting...")
161 +
    logger.debug("cation = {}\tn_cations={}".format(random_cation, n_cations))
162 +
    logger.debug("anion  = {}\t n_anions={}".format(random_anion, n_anions))
163 +
    logger.debug("Found...")
164 +
    logger.debug("             n_cations={}".format(cation_number))
165 +
    logger.debug("              n_anions={}".format(anion_number))
160 166
161 167
    assert int(cation_number) == n_cations and int(anion_number) == n_anions
162 168
163 169
164 170
def test_solvation_by_M_and_m(clean_files):
165 171
    """ Test that we can solvate CB6-BUT through molarity and molality. """
166 -
    log.debug("Trying 10 A buffer with 150 mM NaCl...")
172 +
    logger.debug("Trying 10 A buffer with 150 mM NaCl...")
167 173
    sys = System()
168 174
    sys.template_file = os.path.join(
169 175
        os.path.dirname(__file__), "../data/cb6-but/tleap_solvate.in"
@@ -231,7 +237,7 @@
Loading
231 237
    sys.target_waters = waters
232 238
    sys.output_prefix = "solvate"
233 239
    sys.build()
234 -
    log.debug("Trying {} waters after alignment...".format(waters))
240 +
    logger.debug("Trying {} waters after alignment...".format(waters))
235 241
    grepped_waters = sp.check_output(
236 242
        ["grep -oh 'WAT' ./tmp/solvate.prmtop | wc -w"], shell=True
237 243
    )
@@ -296,8 +302,8 @@
Loading
296 302
    sys.neutralize = False
297 303
    sys.build()
298 304
    with open(
299 -
            os.path.join(os.path.dirname(__file__), "../data/cb6-but/REF_cb6-but-dum.rst7"),
300 -
            "r",
305 +
        os.path.join(os.path.dirname(__file__), "../data/cb6-but/REF_cb6-but-dum.rst7"),
306 +
        "r",
301 307
    ) as f:
302 308
        contents = f.read()
303 309
        reference = [float(i) for i in contents.split()[2:]]
@@ -331,9 +337,13 @@
Loading
331 337
    sys.neutralize = False
332 338
    sys.build()
333 339
334 -
    but = pmd.load_file(os.path.join(temporary_directory, sys.output_prefix + ".prmtop"))
340 +
    but = pmd.load_file(
341 +
        os.path.join(temporary_directory, sys.output_prefix + ".prmtop")
342 +
    )
335 343
    assert np.allclose(but["@H="].atoms[0].mass, 1.008)
336 344
337 345
    sys.repartition_hydrogen_mass()
338 -
    but = pmd.load_file(os.path.join(temporary_directory, sys.output_prefix + ".prmtop"))
346 +
    but = pmd.load_file(
347 +
        os.path.join(temporary_directory, sys.output_prefix + ".prmtop")
348 +
    )
339 349
    assert np.allclose(but["@H="].atoms[0].mass, 3.024)

@@ -5,7 +5,6 @@
Loading
5 5
import os
6 6
7 7
import parmed as pmd
8 -
import pytest
9 8
10 9
import paprika.dummy as dummy
11 10
from paprika.align import zalign

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Learn more Showing 4 files with coverage changes found.

Changes in paprika/simulate.py
+1
Loading file...
Changes in paprika/tests/test_restraints.py
+1
Loading file...
Changes in setup.py
-1
Loading file...
Changes in paprika/__init__.py
+1
Loading file...
Files Coverage
paprika 0.05% 77.27%
setup.py 0.08% 16.16%
Project Totals (30 files) 74.11%
Loading