Repository: ohuelab/QEPPI (language: python)

Issue:
Update



Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index 0f377e1..4652335 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,40 @@
 *.pytest_cache
 __pycache__/
 .vscode
-.DS_Store
\ No newline at end of file
+.DS_Store
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+pip-wheel-metadata/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST.in
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+junit/
\ No newline at end of file
diff --git a/qeppi.py b/QEPPI/QEPPI.py
similarity index 91%
rename from qeppi.py
rename to QEPPI/QEPPI.py
index 1484c5b..c0e95a0 100644
--- a/qeppi.py
+++ b/QEPPI/QEPPI.py
@@ -1,5 +1,5 @@
-from util import ads
-from constant import CHEM_LABELS, DESC_FUNC_DICT
+from .util import ads
+from .constant import CHEM_LABELS, DESC_FUNC_DICT, WEIGHT
 
 import numpy as np
 import pickle
@@ -16,6 +16,9 @@ def load(self, model_path):
         with open(model_path, "rb") as rf:
             model = pickle.load(rf)
         self.model = model
+    
+    def read(self, weight=WEIGHT):
+        self.model = weight
 
     def qeppi(self, mol, method="mo", detail=False):
         if method == "u":
diff --git a/QEPPI/__init__.py b/QEPPI/__init__.py
new file mode 100644
index 0000000..ed22fec
--- /dev/null
+++ b/QEPPI/__init__.py
@@ -0,0 +1,4 @@
+from .version import __version__
+from .constant import *
+from .util import *
+from .QEPPI import *
\ No newline at end of file
diff --git a/QEPPI/constant.py b/QEPPI/constant.py
new file mode 100644
index 0000000..73fb432
--- /dev/null
+++ b/QEPPI/constant.py
@@ -0,0 +1,62 @@
+from rdkit.Chem import rdMolDescriptors, Crippen
+from rdkit import Chem
+
+CHEM_LABELS = ["MW", "ALOGP", "HBD", "HBA", "TPSA", "ROTB", "AROM"]
+
+DESC_FUNC_DICT = {
+    "MW": rdMolDescriptors.CalcExactMolWt,
+    "ALOGP": Crippen.MolLogP,
+    "HBD": rdMolDescriptors.CalcNumHBD,
+    "HBA": rdMolDescriptors.CalcNumHBA,
+    "TPSA": rdMolDescriptors.CalcTPSA,
+    "ROTB": rdMolDescriptors.CalcNumRotatableBonds,
+    "AROM": rdMolDescriptors.CalcNumAromaticRings,
+}
+
+WEIGHT = {
+    "params":
+    {
+        "MW":
+            {
+                "coefficients": 
+                [0.04560031139224022, 1.7064244366404526, 494.04717332780626, 154.79350325269954, 77.10110879171509, 65.8193273039995]
+            },
+        "ALOGP":
+            {
+                "coefficients":
+                [0.016181719609428855, 1.0652885460460373, 4.667743179259679, 5.065361777530944, 0.8433343264178254, 0.7385272147814145]
+            },
+        "HBD":
+            {
+                "coefficients":
+                [0.01658054730902974, 1.1048232815489003, 1.6820912395701388, 2.7489254244785815, 0.4491737335600519, 0.5287174552710909]
+            },
+        "HBA":
+            {
+                "coefficients":
+                [0.027008607260699185, 3.626899936363813, 4.311787382094175, 2.0241291464133954e-05, 0.7128127070334573, 1.2488426349682793]
+            },
+        "TPSA":
+            {
+                "coefficients":
+                [-0.02291565292846544, 3.363039638274869, 61.95246699929325, 1.8933659551307073e-05, 11.596413833566858, 32.792265238065255]
+            },
+        "ROTB":
+            {
+                "coefficients":
+                [0.10174790710720112, 0.9321790090551001, 5.795246533579942, 5.2517652130122645, 0.8612779744315607, 0.4733348902767623]
+            },
+        "AROM":
+            {
+                "coefficients":
+                [-0.006806482079154438, 3.583035986979902, 2.392000709393099, 0.00020979756196675626, 0.47348016464327786, 1.0012588955406478]
+        },
+    },
+    "weights": 
+    {
+        "max": [0.5, 0.0, 1.0, 1.0, 0.25, 0.5, 1.0],
+        "max_ents": 380.89604800900497,
+        "mo": [0.47025, 0.10025, 0.819, 0.80725, 0.36725, 0.5295, 0.89025],
+        "mo_ents": 378.69627297573555
+    }
+}
diff --git a/util.py b/QEPPI/util.py
similarity index 100%
rename from util.py
rename to QEPPI/util.py
diff --git a/QEPPI/version.py b/QEPPI/version.py
new file mode 100644
index 0000000..f1380ee
--- /dev/null
+++ b/QEPPI/version.py
@@ -0,0 +1,1 @@
+__version__ = "0.1.7"
diff --git a/calc_QEPPI.py b/calc_QEPPI.py
index 2e2f55f..edc8a61 100644
--- a/calc_QEPPI.py
+++ b/calc_QEPPI.py
@@ -1,6 +1,6 @@
 import argparse
 
-import qeppi as ppi
+import QEPPI as ppi
 from rdkit import Chem
 from rdkit.Chem import SDMolSupplier
 import pandas as pd
diff --git a/constant.py b/constant.py
deleted file mode 100644
index ebe11a8..0000000
--- a/constant.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from rdkit.Chem import rdMolDescriptors, Crippen
-from rdkit import Chem
-
-CHEM_LABELS = ["MW", "ALOGP", "HBD", "HBA", "TPSA", "ROTB", "AROM"]
-
-DESC_FUNC_DICT = {
-    "MW": rdMolDescriptors.CalcExactMolWt,
-    "ALOGP": Crippen.MolLogP,
-    "HBD": rdMolDescriptors.CalcNumHBD,
-    "HBA": rdMolDescriptors.CalcNumHBA,
-    "TPSA": rdMolDescriptors.CalcTPSA,
-    "ROTB": rdMolDescriptors.CalcNumRotatableBonds,
-    "AROM": rdMolDescriptors.CalcNumAromaticRings,
-}
\ No newline at end of file
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..c28735b
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,35 @@
+import os
+from glob import glob
+from setuptools import setup
+
+exec(open("QEPPI/version.py").read())
+
+with open("README.md", "r", encoding="utf-8") as fh:
+    long_description = fh.read()
+
+setup(
+    name="QEPPI",
+    version=__version__,
+    author="blacktanktop",
+    author_email="blacktanktopme@gmail.com",
+    description="Calculation module of QEPPI",
+    long_description=long_description,
+    long_description_content_type="text/markdown",
+    url="https://github.com/ohuelab/QEPPI/",
+    license="MIT",
+    packages=["QEPPI"],
+    install_requires=[
+        "rdkit-pypi>=2020.9.5.2",
+        "numpy>=1.19.5",
+        "pandas>=1.1.5",
+    ],
+    test_suite="tests",
+    classifiers=[
+        "Programming Language :: Python :: 3",
+        "License :: OSI Approved :: MIT License",
+        "Operating System :: OS Independent",
+        "Topic :: Scientific/Engineering :: Chemistry",
+        "Topic :: Scientific/Engineering :: Bio-Informatics",
+    ],
+    python_requires='>=3.7',
+)


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 0000000..9c95f44
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,33 @@
+name: test
+
+on:
+  push:
+    branches: [ main ]
+  pull_request:
+    branches: [ main ]
+
+jobs:
+  test:
+
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: [3.7, 3.8]
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip
+        pip install flake8 pytest pytest-cov build
+        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
+    - name: Install
+      run: |
+        pip install .
+    - name: Run Test
+      run: |
+         pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov-report=xml --cov-report=html
\ No newline at end of file
diff --git a/tests/test_qeppi.py b/tests/test_qeppi.py
index 21f1937..05d502d 100644
--- a/tests/test_qeppi.py
+++ b/tests/test_qeppi.py
@@ -1,9 +1,12 @@
 import pytest
-import qeppi as ppi
+import QEPPI as ppi
+from QEPPI.constant import WEIGHT
 from rdkit.Chem import SDMolSupplier
 
+def test_version():
+    assert ppi.__version__
 
-def test_qeppi_value_approx():
+def test_load_qeppi_value_approx():
     correct_values = [
         0.14138488397092042,
         0.20844419255972127,
@@ -24,6 +27,32 @@ def test_qeppi_value_approx():
     q = ppi.QEPPI_Calculator()
     q.load("./model/QEPPI.model")
 
+    ppi_s = SDMolSupplier("./compunds/test.sdf")
+    ppi_mols = [mol for mol in ppi_s if mol is not None]
+    for i, j in zip(ppi_mols, correct_values):
+        assert q.qeppi(i) == pytest.approx(j)
+
+def test_read_qeppi_value_approx():
+    correct_values = [
+        0.14138488397092042,
+        0.20844419255972127,
+        0.20349457838077856,
+        0.8374457753324647,
+        0.40286064451685927,
+        0.1037465060768894,
+        0.08835509613475574,
+        0.5713916001329409,
+        0.7897952756770426,
+        0.5757902101651236,
+        0.759799221073293,
+        0.5237059407202563,
+        0.5713814680494992,
+        0.6021230144891282,
+    ]
+
+    q = ppi.QEPPI_Calculator()
+    q.read(WEIGHT)
+
     ppi_s = SDMolSupplier("./compunds/test.sdf")
     ppi_mols = [mol for mol in ppi_s if mol is not None]
     for i, j in zip(ppi_mols, correct_values):