Giter VIP home page Giter VIP logo

gnina-torch's Introduction

gnina-torch

GitHub Actions Build Status codecov

Documentation Status DOI

PyTorch implementation of GNINA scoring function.

References

@software{
  gninatorch_2022,
  author = {Meli, Rocco and McNutt, Andrew},
  doi = {10.5281/zenodo.6943066},
  month = {7},
  title = {{gninatorch}},
  url = {https://github.com/RMeli/gnina-torch},
  version = {0.0.1},
  year = {2022}
}

If you are using gnina-torch, please consider citing the following references:

Protein-Ligand Scoring with Convolutional Neural Networks, M. Ragoza, J. Hochuli, E. Idrobo, J. Sunseri, and D. R. Koes, J. Chem. Inf. Model. 2017, 57 (4), 942-957. DOI: 10.1021/acs.jcim.6b00740

libmolgrid: Graphics Processing Unit Accelerated Molecular Gridding for Deep Learning Applications J. Sunseri and D. R. Koes, J. Chem. Inf. Model. 2020, 60 (3), 1079-1084. DOI: 10.1021/acs.jcim.9b01145

If you are using the pre-trained default2018 and dense models from GNINA, please consider citing the following reference as well:

Three-Dimensional Convolutional Neural Networks and a Cross-Docked Data Set for Structure-Based Drug Design, P. G. Francoeur, T. Masuda, J. Sunseri, A. Jia, R. B. Iovanisci, I. Snyder, and D. R. Koes, J. Chem. Inf. Model. 2020, 60 (9), 4200-4215. DOI: 10.1021/acs.jcim.0c00411

If you are using the pre-trained default model ensemble from GNINA, please consider citing the following reference as well:

GNINA 1.0: molecular docking with deep learning, A. T. McNutt, P. Francoeur, R. Aggarwal, T. Masuda, R. Meli, M. Ragoza, J. Sunseri, D. R. Koes, J. Cheminform. 2021, 13 (43). DOI: 10.1186/s13321-021-00522-2

Installation

The gninatorch Python package has several dependencies, including:

A full developement environment can be installed using the conda package manager and the provided conda environment file (devtools/conda-envs/gninatorch.yaml):

conda env create -f devtools/conda-envs/gninatorch.yaml
conda activate gninatorch

Once the conda environment is created and activated, the gninatorch package can be installed using pip as follows:

python -m pip install .

Tests

In order to check the installation, unit tests are provided and can be run with pytest:

pytest --cov=gninatorch

Usage

Training and inference modules try to follow the original Caffe implementation of gnina/scripts, however not all features are implemented.

The folder examples includes some complete examples for training and inference.

The folder gninatorch/weights contains pre-trained models from GNINA, converted from Caffe to PyTorch.

Pre-trained GNINA models

Pre-trained GNINA models can be loaded as follows:

from gninatorch.gnina import setup_gnina_model

model = setup_gnina_model(MODEL)

where MODEL corresponds to the --cnn argument in GNINA.

A single model will return log_CNNscore and CNNaffinity, while an ensemble of models will return log_CNNscore, CNNaffinity, and CNNvariance.

Inference with pre-trained GNINA models (--cnn argument in GNINA) is implemented in the gnina module:

python -m gninatorch.gnina --help

Training

Training is implemented in the training module:

python -m gninatorch.training --help

Inference

Inference is implemented in the inference module:

python -m gninatorch.inference --help

Acknowledgments

Project based on the Computational Molecular Science Python Cookiecutter version 1.6.

The pre-trained weights of GNINA converted to PyTorch were kindly provided by Andrew McNutt (@drewnutt).


Copyright (c) 2021-2022, Rocco Meli

gnina-torch's People

Contributors

drewnutt avatar rmeli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gnina-torch's Issues

gnina-torch

hi,

Will this script work fully in windows 10?
many thanks

Sh-Y

Pytest error after install with mamba-forge

My conda env is in mamba-forge so the environment 'gninatorch' has python in ~/mambaforge/envs/gninatorch/bin/python
then in directoy: ~/gnina-torch I run python -m pytest --cov=gninatorch

THE ERROR IS :

--------------------------------------- Captured log call --------------------------------------
ERROR    ignite.engine.engine.Engine:engine.py:1086 Current run is terminating due to exception: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
  File "/data2/rjli/gnina-torch/gninatorch/models.py", line 320, in forward
        x = x.view(-1, self.features_out_size)
    
        lig_pose_raw = self.lig_pose(x)
                       ~~~~~~~~~~~~~ <--- HERE
        lig_pose_log = F.log_softmax(lig_pose_raw, dim=1)
    
  File "/data2/rjli/mambaforge/envs/gninatorch/lib/python3.9/site-packages/torch/nn/modules/container.py", line 141, in forward
    def forward(self, input):
        for module in self:
            input = module(input)
                    ~~~~~~ <--- HERE
        return input
  File "/data2/rjli/mambaforge/envs/gninatorch/lib/python3.9/site-packages/torch/nn/modules/linear.py", line 103, in forward
    def forward(self, input: Tensor) -> Tensor:
        return F.linear(input, self.weight, self.bias)
               ~~~~~~~~ <--- HERE
RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`

ERROR    ignite.engine.engine.Engine:engine.py:992 Engine run is terminating due to exception: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
  File "/data2/rjli/gnina-torch/gninatorch/models.py", line 320, in forward
        x = x.view(-1, self.features_out_size)
    
        lig_pose_raw = self.lig_pose(x)
                       ~~~~~~~~~~~~~ <--- HERE
        lig_pose_log = F.log_softmax(lig_pose_raw, dim=1)
    
  File "/data2/rjli/mambaforge/envs/gninatorch/lib/python3.9/site-packages/torch/nn/modules/container.py", line 141, in forward
    def forward(self, input):
        for module in self:
            input = module(input)
                    ~~~~~~ <--- HERE
        return input
  File "/data2/rjli/mambaforge/envs/gninatorch/lib/python3.9/site-packages/torch/nn/modules/linear.py", line 103, in forward
    def forward(self, input: Tensor) -> Tensor:
        return F.linear(input, self.weight, self.bias)
               ~~~~~~~~ <--- HERE
RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
=============================================================================================== warnings summary ================================================================================================
../mambaforge/envs/gninatorch/lib/python3.9/site-packages/mlflow/utils/requirements_utils.py:12
  /data2/rjli/mambaforge/envs/gninatorch/lib/python3.9/site-packages/mlflow/utils/requirements_utils.py:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources

../mambaforge/envs/gninatorch/lib/python3.9/site-packages/pkg_resources/__init__.py:2871
  /data2/rjli/mambaforge/envs/gninatorch/lib/python3.9/site-packages/pkg_resources/__init__.py:2871: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('mpl_toolkits')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

../mambaforge/envs/gninatorch/lib/python3.9/site-packages/pkg_resources/__init__.py:2871
  /data2/rjli/mambaforge/envs/gninatorch/lib/python3.9/site-packages/pkg_resources/__init__.py:2871: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform linux, python 3.9.16-final-0 -----------
Name                        Stmts   Miss  Cover
-----------------------------------------------
gninatorch/__init__.py          5      0   100%
gninatorch/dataloaders.py      73      1    99%
gninatorch/gnina.py           105      7    93%
gninatorch/inference.py        87     50    43%
gninatorch/losses.py           32      0   100%
gninatorch/metrics.py          28      0   100%
gninatorch/models.py          218     39    82%
gninatorch/setup.py            12      0   100%
gninatorch/training.py        235     67    71%
gninatorch/transforms.py       20      0   100%
gninatorch/utils.py            39     16    59%
-----------------------------------------------
TOTAL                         854    180    79%

============================================================================================ short test summary info ============================================================================================
FAILED tests/test_gnina.py::test_gnina_model_prediction[redock_default2018-CNNscore0-CNNaffinity0] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina_model_prediction[general_default2018-CNNscore1-CNNaffinity1] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina_model_prediction[crossdock_default2018-CNNscore2-CNNaffinity2] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina_model_prediction[dense-CNNscore3-CNNaffinity3] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina_model_prediction_ensemble[redock_default2018-CNNscore0-CNNaffinity0-CNNvariance0] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina_model_prediction_ensemble[general_default2018-CNNscore1-CNNaffinity1-CNNvariance1] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina_model_prediction_ensemble[crossdock_default2018-CNNscore2-CNNaffinity2-CNNvariance2] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina_model_prediction_ensemble[dense-CNNscore3-CNNaffinity3-CNNvariance3] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina[redock_default2018-CNNscore0-CNNaffinity0] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina[general_default2018-CNNscore1-CNNaffinity1] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina[crossdock_default2018-CNNscore2-CNNaffinity2] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina[dense-CNNscore3-CNNaffinity3] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina_ensemble[redock_default2018_ensemble-CNNscore0-CNNaffinity0-CNNvariance0] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina_ensemble[general_default2018_ensemble-CNNscore1-CNNaffinity1-CNNvariance1] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina_ensemble[crossdock_default2018_ensemble-CNNscore2-CNNaffinity2-CNNvariance2] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina_ensemble[dense_ensemble-CNNscore3-CNNaffinity3-CNNvariance3] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_gnina.py::test_gnina_ensemble[default-CNNscore4-CNNaffinity4-CNNvariance4] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_inference.py::test_inference - RuntimeError: The following operation failed in the TorchScript interpreter.
FAILED tests/test_inference.py::test_inference_affinity - RuntimeError: The following operation failed in the TorchScript interpreter.
FAILED tests/test_inference.py::test_inference_flex - RuntimeError: The following operation failed in the TorchScript interpreter.
FAILED tests/test_models.py::test_forward_pose[default2017] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_pose[default2018] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_pose[dense] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_affinity[default2017] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_affinity[default2018] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_affinity[dense] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_affinity[hires_pose] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_flex[default2017] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_flex[default2018] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_flex[dense] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_affinity_big[default2017] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_affinity_big[default2018] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_affinity_big[dense] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_affinity_big[hires_pose] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_forward_affinity_big[hires_affinity] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_gnina_model_ensemble_average[default2017] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_gnina_model_ensemble_average[default2018] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_models.py::test_gnina_model_ensemble_average[dense] - RuntimeError: CUDA error: CUBLAS_STATUS_NOT_SUPPORTED when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
FAILED tests/test_training.py::test_training - RuntimeError: The following operation failed in the TorchScript interpreter.
FAILED tests/test_training.py::test_training_with_test - RuntimeError: The following operation failed in the TorchScript interpreter.
FAILED tests/test_training.py::test_training_pose_and_affinity_with_test - RuntimeError: The following operation failed in the TorchScript interpreter.
FAILED tests/test_training.py::test_training_lr_scheduler_with_test - RuntimeError: The following operation failed in the TorchScript interpreter.
FAILED tests/test_training.py::test_training_flexposepose_with_test - RuntimeError: The following operation failed in the TorchScript interpreter.
============================================================================= 43 failed, 88 passed, 3 warnings in 149.65s (0:02:29)

Allow file mapped GNINA typer

Allow the use ofmolgrid.FileMappedGninaTyper and provide the following input parameters for consistency with published models:

  • --ligmap
  • --recmap

Common weights initialisation

Define weights and biases initialisation function outside of models' __init__ and perform initialisation with nn.Module.apply() function.

Check how biases are initialised and perform the same initialisation.

Segmentation fault (core dumped)

Test Error

 $ pytest --cov==gninatorch
Segmentation fault (core dumped)

System Details

CentOS7 Linux server
Anaconda environment (python3.9)

I have created this environment and install all the libraries manually.

(It takes hours in the 'solving' process when running conda env create -f devtools/conda-envs/gninatorch.yaml, so I quit and created a environment 'gninatorch' and install libraries one by one as the yml shows)

After all dependencies have been installed (I additionally installed scikit-learn-intelex as the scikit-learn suggests), I run python -m pip install . the gninatorch 0.0.2+3.ge46cb51 successfully installed. BUT It could not success at $ pytest --cov==gninatorch.

-------------conda list---------------

_libgcc_mutex             0.1                        main    anaconda
_openmp_mutex             5.1                       1_gnu    anaconda
abseil-cpp                20211102.0           h27087fc_1    conda-forge
alembic                   1.8.1              pyhd8ed1ab_0    conda-forge
appdirs                   1.4.4              pyhd3eb1b0_0    anaconda
arrow-cpp                 8.0.0            py39h60b952e_0    anaconda
asttokens                 2.0.5              pyhd3eb1b0_0    anaconda
attrs                     22.1.0           py39h06a4308_0    anaconda
aws-c-common              0.4.57               he6710b0_1    anaconda
aws-c-event-stream        0.1.6                h2531618_5    anaconda
aws-checksums             0.1.9                he6710b0_0    anaconda
aws-sdk-cpp               1.8.185              hce553d0_0    anaconda
backcall                  0.2.0              pyhd3eb1b0_0    anaconda
bcrypt                    3.2.2            py39hb9d737c_0    conda-forge
black                     22.6.0           py39h06a4308_0    anaconda
blas                      1.0                         mkl    anaconda
blinker                   1.6.2              pyhd8ed1ab_0    conda-forge
boost-cpp                 1.78.0               he72f1d9_0    conda-forge
bottleneck                1.3.5            py39h7deecbd_0    anaconda
brotli                    1.0.9                h166bdaf_7    conda-forge
brotli-bin                1.0.9                h166bdaf_7    conda-forge
brotlipy                  0.7.0           py39h27cfd23_1003    anaconda
bzip2                     1.0.8                h7f98852_4    conda-forge
c-ares                    1.18.1               h7f8727e_0    anaconda
ca-certificates           2023.01.10           h06a4308_0    anaconda
certifi                   2022.12.7        py39h06a4308_0    anaconda
cffi                      1.15.1           py39h5eee18b_3    anaconda
cfgv                      3.3.1            py39h06a4308_0    anaconda
charset-normalizer        2.0.4              pyhd3eb1b0_0    anaconda
click                     8.1.6           unix_pyh707e725_0    conda-forge
cloudpickle               2.2.1              pyhd8ed1ab_0    conda-forge
codecov                   2.1.11             pyhd3eb1b0_0    anaconda
configparser              5.3.0              pyhd8ed1ab_0    conda-forge
coverage                  6.3.2            py39h7f8727e_0    anaconda
cryptography              38.0.4           py39h9ce1e76_0    anaconda
cudatoolkit               11.3.1               h2bc3f7f_2    anaconda
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
daal4py                   2023.1.1         py39h79cecc1_0    defaults
dal                       2023.1.1         hdb19cb5_48679    defaults
databricks-cli            0.17.7             pyhd8ed1ab_1    conda-forge
decorator                 5.1.1              pyhd3eb1b0_0    anaconda
distlib                   0.3.6            py39h06a4308_0    anaconda
docker-py                 6.1.3              pyhd8ed1ab_0    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
exceptiongroup            1.1.2                    pypi_0    pypi
executing                 0.8.3              pyhd3eb1b0_0    anaconda
fftw                      3.3.9                h27cfd23_1    anaconda
filelock                  3.9.0            py39h06a4308_0    anaconda
flake8                    6.0.0            py39h06a4308_0    anaconda
flask                     2.3.2              pyhd8ed1ab_0    conda-forge
flit-core                 3.6.0              pyhd3eb1b0_0    anaconda
freetype                  2.12.1               h4a9f257_0    anaconda
gflags                    2.2.2             he1b5a44_1004    conda-forge
giflib                    5.2.1                h5eee18b_1    anaconda
gitdb                     4.0.10             pyhd8ed1ab_0    conda-forge
gitpython                 3.1.32             pyhd8ed1ab_0    conda-forge
glog                      0.6.0                h6f12383_0    conda-forge
gninatorch                0.0.2+3.ge46cb51          pypi_0    pypi
greenlet                  2.0.1            py39h6a678d5_0    anaconda
grpc-cpp                  1.46.1               h33aed49_1    anaconda
gunicorn                  20.1.0           py39hf3d152e_3    conda-forge
icu                       70.1                 h27087fc_0    conda-forge
identify                  2.5.5            py39h06a4308_0    anaconda
idna                      3.4              py39h06a4308_0    anaconda
ignite                    0.4.12                     py_0    pytorch
importlib-metadata        6.8.0              pyha770c72_0    conda-forge
importlib_resources       6.0.0              pyhd8ed1ab_1    conda-forge
iniconfig                 2.0.0                    pypi_0    pypi
intel-openmp              2021.4.0          h06a4308_3561    anaconda
ipython                   8.8.0            py39h06a4308_0    anaconda
isort                     5.9.3              pyhd3eb1b0_0    anaconda
itsdangerous              2.1.2              pyhd8ed1ab_0    conda-forge
jedi                      0.18.1           py39h06a4308_1    anaconda
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
joblib                    1.3.0              pyhd8ed1ab_1    conda-forge
jpeg                      9e                   h7f8727e_0    anaconda
keyutils                  1.6.1                h166bdaf_0    conda-forge
kiwisolver                1.4.4            py39h6a678d5_0    anaconda
krb5                      1.19.3               h3790be6_0    conda-forge
lcms2                     2.12                 h3be6417_0    anaconda
ld_impl_linux-64          2.38                 h1181459_1    anaconda
lerc                      3.0                  h295c915_0    anaconda
libbrotlicommon           1.0.9                h166bdaf_7    conda-forge
libbrotlidec              1.0.9                h166bdaf_7    conda-forge
libbrotlienc              1.0.9                h166bdaf_7    conda-forge
libcurl                   7.87.0               h91b91d3_0    anaconda
libdeflate                1.8                  h7f8727e_5    anaconda
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 h516909a_1    conda-forge
libevent                  2.1.10               h9b69904_4    conda-forge
libffi                    3.4.2                h6a678d5_6    anaconda
libgcc-ng                 11.2.0               h1234567_1    anaconda
libgfortran-ng            11.2.0               h00389a5_1    anaconda
libgfortran5              11.2.0               h1234567_1    anaconda
libgomp                   11.2.0               h1234567_1    anaconda
libnghttp2                1.46.0               hce63b2e_0    anaconda
libpng                    1.6.37               hbc83047_0    anaconda
libprotobuf               3.20.3               he621ea3_0    anaconda
libsodium                 1.0.18               h36c2ea0_1    conda-forge
libssh2                   1.10.0               h8f2d780_0    anaconda
libstdcxx-ng              11.2.0               h1234567_1    anaconda
libthrift                 0.15.0               he6d91bd_0    conda-forge
libtiff                   4.5.0                h6a678d5_1    anaconda
libuv                     1.40.0               h7b6447c_0    anaconda
libwebp                   1.2.4                h11a3e52_0    anaconda
libwebp-base              1.2.4                h5eee18b_0    anaconda
lz4-c                     1.9.4                h6a678d5_0    anaconda
mako                      1.2.4              pyhd8ed1ab_0    conda-forge
markdown                  3.4.3              pyhd8ed1ab_0    conda-forge
markupsafe                2.1.1            py39h7f8727e_0    anaconda
matplotlib-base           3.4.3            py39h2fa2bec_2    conda-forge
matplotlib-inline         0.1.6            py39h06a4308_0    anaconda
mccabe                    0.7.0              pyhd3eb1b0_0    anaconda
mkl                       2021.4.0           h06a4308_640    anaconda
mkl-service               2.4.0            py39h7f8727e_0    anaconda
mkl_fft                   1.3.1            py39hd3c417c_0    anaconda
mkl_random                1.2.2            py39h51133e4_0    anaconda
mlflow                    2.5.0            py39ha39b057_0    conda-forge
molgrid                   0.5.3                    pypi_0    pypi
mpi                       1.0                       mpich    anaconda
mpich                     4.1.1                hbae89fd_0    defaults
mypy                      0.981            py39h06a4308_0    anaconda
mypy_extensions           0.4.3            py39h06a4308_1    anaconda
ncurses                   6.4                  h6a678d5_0    anaconda
nodeenv                   1.7.0            py39h06a4308_0    anaconda
numexpr                   2.8.4            py39he184ba9_0    anaconda
numpy                     1.23.5           py39h14f4228_0    anaconda
numpy-base                1.23.5           py39h31eccc5_0    anaconda
oauthlib                  3.2.2              pyhd8ed1ab_0    conda-forge
openssl                   1.1.1s               h7f8727e_0    anaconda
orc                       1.7.4                h07ed6aa_0    anaconda
packaging                 22.0             py39h06a4308_0    anaconda
pandas                    1.5.2            py39h417a72b_0    anaconda
paramiko                  3.2.0              pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd3eb1b0_0    anaconda
pathspec                  0.10.3           py39h06a4308_0    anaconda
pexpect                   4.8.0              pyhd3eb1b0_3    anaconda
pickleshare               0.7.5           pyhd3eb1b0_1003    anaconda
pillow                    9.3.0            py39h6a678d5_2    anaconda
pip                       22.3.1           py39h06a4308_0    anaconda
platformdirs              2.5.2            py39h06a4308_0    anaconda
pluggy                    1.2.0                    pypi_0    pypi
pooch                     1.4.0              pyhd3eb1b0_0    anaconda
pre-commit                2.20.0           py39h06a4308_0    anaconda
prometheus_client         0.17.1             pyhd8ed1ab_0    conda-forge
prometheus_flask_exporter 0.22.4             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.36           py39h06a4308_0    anaconda
protobuf                  3.20.3           py39h6a678d5_0    anaconda
psutil                    5.9.0            py39h5eee18b_0    anaconda
ptyprocess                0.7.0              pyhd3eb1b0_2    anaconda
pure_eval                 0.2.2              pyhd3eb1b0_0    anaconda
py                        1.11.0             pyhd3eb1b0_0    anaconda
pyarrow                   8.0.0            py39h992f0b0_0    anaconda
pycodestyle               2.10.0           py39h06a4308_0    anaconda
pycparser                 2.21               pyhd3eb1b0_0    anaconda
pyflakes                  3.0.1            py39h06a4308_0    anaconda
pygments                  2.11.2             pyhd3eb1b0_0    anaconda
pyjwt                     2.8.0              pyhd8ed1ab_0    conda-forge
pynacl                    1.5.0            py39hb9d737c_1    conda-forge
pyopenssl                 22.0.0             pyhd3eb1b0_0    anaconda
pyparsing                 3.1.0              pyhd8ed1ab_0    conda-forge
pyquaternion              0.9.9                    pypi_0    pypi
pysocks                   1.7.1            py39h06a4308_0    anaconda
pytest                    7.4.0                    pypi_0    pypi
pytest-cov                3.0.0              pyhd3eb1b0_0    anaconda
python                    3.9.16               h7a1cb2a_0    anaconda
python-dateutil           2.8.2              pyhd3eb1b0_0    anaconda
python_abi                3.9                      2_cp39    conda-forge
pytorch                   1.11.0          py3.9_cuda11.3_cudnn8.2.0_0    pytorch
pytorch-mutex             1.0                        cuda    pytorch
pytz                      2022.7           py39h06a4308_0    anaconda
pywin32-on-windows        0.1.0              pyh1179c8e_3    conda-forge
pyyaml                    6.0              py39hb9d737c_4    conda-forge
querystring_parser        1.2.4                      py_0    conda-forge
re2                       2022.04.01           h27087fc_0    conda-forge
readline                  8.2                  h5eee18b_0    anaconda
requests                  2.28.1           py39h06a4308_0    anaconda
scikit-learn              1.2.0            py39h6a678d5_0    anaconda
scikit-learn-intelex      2023.1.1         py39h06a4308_0    defaults
scipy                     1.10.0           py39h14f4228_0    anaconda
setuptools                65.6.3           py39h06a4308_0    anaconda
six                       1.16.0             pyhd3eb1b0_1    anaconda
smmap                     3.0.5              pyh44b312d_0    conda-forge
snappy                    1.1.9                h295c915_0    anaconda
sqlalchemy                1.4.39           py39h5eee18b_0    anaconda
sqlite                    3.40.1               h5082296_0    anaconda
sqlparse                  0.4.4              pyhd8ed1ab_0    conda-forge
stack_data                0.2.0              pyhd3eb1b0_0    anaconda
tabulate                  0.9.0              pyhd8ed1ab_1    conda-forge
tbb                       2021.6.0             hdb19cb5_1    anaconda
threadpoolctl             3.2.0              pyha21a80b_0    conda-forge
tk                        8.6.12               h1ccaba5_0    anaconda
toml                      0.10.2             pyhd3eb1b0_0    anaconda
tomli                     2.0.1            py39h06a4308_0    anaconda
torchvision               0.13.1          cpu_py39h164cc8f_0    anaconda
tornado                   6.1              py39hb9d737c_3    conda-forge
tqdm                      4.64.1           py39h06a4308_0    anaconda
traitlets                 5.7.1            py39h06a4308_0    anaconda
typing_extensions         4.4.0            py39h06a4308_0    anaconda
tzdata                    2022a                hda174b7_0    anaconda
ukkonen                   1.0.1            py39hdb19cb5_0    anaconda
urllib3                   1.26.14          py39h06a4308_0    anaconda
utf8proc                  2.6.1                h27cfd23_0    anaconda
virtualenv                20.17.1          py39h06a4308_0    anaconda
wcwidth                   0.2.5              pyhd3eb1b0_0    anaconda
websocket-client          1.6.1              pyhd8ed1ab_0    conda-forge
werkzeug                  2.3.6              pyhd8ed1ab_0    conda-forge
wheel                     0.37.1             pyhd3eb1b0_0    anaconda
xz                        5.2.10               h5eee18b_1    anaconda
yaml                      0.2.5                h7f98852_2    conda-forge
zipp                      3.16.2             pyhd8ed1ab_0    conda-forge
zlib                      1.2.13               h5eee18b_0    anaconda
zstd                      1.5.2                ha4553b6_0    anaconda

Learning rate scheduler is called twice on both train and test losses

PR #10 asserts that "the learning rate update is based on the loss function of the test set (instead of the training set)". This was the intent (although it should probably monitor the loss function of the training set for consistency), but by attaching the LR scheduler update to the evaluator

# TODO: Define handle elsewhere and attach using input arguments
# TODO: Save lr history
# Event.COMPLETED since we want the full evaluation to be completed
@evaluator.on(Events.COMPLETED)
def scheduler(evaluator):

effectively causes the LR scheduler to be called twice, since the same evaluator is used to evaluate the training set and the test set.

@trainer.on(Events.EPOCH_COMPLETED(every=args.test_every))
def log_training_results(trainer):
evaluator.run(train_loader)

@trainer.on(Events.EPOCH_COMPLETED(every=args.test_every))
def log_test_results(trainer):
evaluator.run(test_loader)

Possible solutions suggested by @vfdev-5:

  • Use if/else to check which data loader has been used by the evaluator
  • Use custom filtering (decorated if/else) to check which data loader has been used by the evaluator
  • Register custom events (to distinguish between train and test evaluation)
  • Split into two distinct evaluators
  • Call the scheduler update directly in the interested evaluation function

Default arguments logging is confusing

The function

def print_args(
args: argparse.Namespace, header: Optional[str] = None, stream=sys.stdout
):
"""
Print command line arguments to stream.py
Parameters
----------
args: argparse.Namespace
Command line arguments
header: str
stream:
Output stream
"""
if header is not None:
print(header, file=stream)
for name, value in vars(args).items():
if type(value) is float:
print(f"{name}: {value:.5E}", file=stream)
else:
print(f"{name} = {value!r}", file=stream)
# Flush stream
print("", end="", file=stream, flush=True)

is too simplistic. This function prints out all the CLI arguments to the log file, including the default ones.

This might be confusing at times. For example, when there is no binding affinity annotation the following is printed to the log file:

[...]
affinity_pos = None
[...]
pseudo_huber_affinity_loss = False
delta_affinity_loss: 4.00000E+00
scale_affinity_loss: 1.00000E+00
penalty_affinity_loss: 1.00000E+00
[...]

Only the variables that are relevant for the run should be printed out. In this case affinity_pos = None should be printed (to indicate that there is no binding affinity annotation), but everything else is superfluous and confusing.

The same happens for dynamic learning rate:

[...]
lr_dynamic = False
lr_patience = 5
lr_reduce: 1.00000E-01
lr_min: 1.00000E-05
[...]

lr_dynamic = False should be printed, everything else is superfluous and confusing.

Are pretrained models available?

I would love to use this module within liGAN instead of depending on the full gnina platform. Have the caffe model weights been converted to pytorch somewhere publicly available?

Inconsistent CLI arguments for model specification

The models_dict variable has changed considerably:

gnina-torch/gnina/models.py

Lines 1069 to 1078 in bc780b8

models_dict = {
("default2017", False): Default2017Pose,
("default2017", True): Default2017Affinity,
("default2018", False): Default2018Pose,
("default2018", True): Default2018Affinity,
("dense", False): DensePose,
("dense", True): DenseAffinity,
("hires_pose", True): HiResPose,
("hires_affinity", True): HiResAffinity,
}

and therefore the following code needs to be adjusted:
# Scoring function
parser.add_argument(
"-m",
"--model",
type=str,
default="default2017",
help="Model name",
choices=[k[0] for k in models_dict.keys()], # Model names
)

The inference code needs to be updated as well:
parser.add_argument("model", type=str, help="Model")

Expose additional parameters

Some parameters are not exposed to the user, use default values or are not implemented (compared to the original GNINA implementation in Caffe). This issue tracks all parameters that need to be added and exposed to the user.

molgrid.ExampleProvider parameters:

  • --ligmolcache
  • --recmolcache
  • --stratify_receptor

molgrid.GridMaker parameters:

  • --dimension
  • --resolution

Loss parameters:

  • --scale (affinity loss)
  • --penalty (affinity loss)

*** Error in `python': free(): invalid pointer: 0x00002aaaffba8c40 ***

I'm getting a strange error: *** Error in 'python': free(): invalid pointer: 0x00002aaaffba8c40 *** when trying to run GNINA from a separate file:

I have a file gnina_feat.py with the following code:

import torch
from argparse import Namespace
import tempfile
from tqdm.autonotebook import tqdm

from gninatorch import setup, gnina, dataloaders

class VoxelLoader(dataloaders.GriddedExamplesLoader):
    def __len__(self):
        return self.num_batches

grid_args = Namespace(**{'data_root':'',
                    'batch_size':20,
                    'ligmolcache':"",
                    'recmolcache':"",
                    'cache_structures':False,
                    'dimension':23.5,
                    'resolution':0.5,
                    'balanced':False,
                    'shuffle':False,
                    'stratify_receptor':False,
                    'stratify_pos':False,
                    'iteration_scheme':'small',
                    'stratify_max':0,
                    'stratify_min':0,
                    'stratify_step':0})


def get_gnina_feats_from_df(df, device='cuda'):
    temp_name = next(tempfile._get_candidate_names())
    types_file = f'/local/tmp/{temp_name}.types'

    with open(types_file, "w") as text_file:
        for i, (_, row) in enumerate(df.iterrows()):
            file_str = f"{i} {row['docked_pocket_path']} {row['docked_ligand_path']}"
            print(file_str, file=text_file)
    
    provider = setup.setup_example_provider(
        types_file, grid_args, training=False
    )
    grid_maker = setup.setup_grid_maker(grid_args)

    all_loader = VoxelLoader(
        example_provider=provider,
        grid_maker=grid_maker,
        random_translation=0,
        random_rotation=False,
        device=device,
    )

    model = gnina.setup_gnina_model('dense_ensemble')[0]
    model.to(torch.device(device))

    feats = list()
    with torch.inference_mode():
        for batch in tqdm(all_loader, desc='Predicting GNINA features'):
            feat = list()
            for mod in model.models:
                feat.append(mod.features(batch[0]).squeeze()[None])
            feats.append(torch.cat(feat).mean(0))
        feats = torch.cat(feats).cpu()
    return [f for f in feats]

Then in a separate file I call:

feats = get_gnina_feats_from_df(df)

Which yields the error:

*** Error in `python': free(): invalid pointer: 0x00002aaaffba8c40 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x81329)[0x2aaaab675329]
/home/kirillshmilovich/.local/lib/python3.10/site-packages/molgrid/molgrid.so(_ZNSt23_Sp_counted_ptr_inplaceIN10libmolgrid15ExampleProviderESaIS1_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv+0x539)[0x2aab88d32c09]
/home/kirillshmilovich/.local/lib/python3.10/site-packages/molgrid/molgrid.so(_ZN5boost6python7objects14pointer_holderISt10shared_ptrIN10libmolgrid15ExampleProviderEES5_ED1Ev+0x5a)[0x2aab88d00bba]
/home/kirillshmilovich/.local/lib/python3.10/site-packages/molgrid/molgrid.so(+0x6d8c9f)[0x2aab88f00c9f]
python[0x50ec0e]
python[0x4ec2c6]
python[0x50eadc]
python[0x4f8478]
python(_PyFunction_Vectorcall+0xa5)[0x4ff2a5]
python(_PyEval_EvalFrameDefault+0x31f)[0x4ef96f]
python(_PyFunction_Vectorcall+0x6f)[0x4ff26f]
python(_PyEval_EvalFrameDefault+0x731)[0x4efd81]
python[0x50a69e]
python(PyObject_Call+0xb8)[0x50b048]
python(_PyEval_EvalFrameDefault+0x2a50)[0x4f20a0]
python(_PyFunction_Vectorcall+0x6f)[0x4ff26f]
python(_PyEval_EvalFrameDefault+0x13b2)[0x4f0a02]
python(_PyFunction_Vectorcall+0x6f)[0x4ff26f]
python(_PyEval_EvalFrameDefault+0x4b2c)[0x4f417c]
python[0x50a69e]
python(_PyEval_EvalFrameDefault+0x13b2)[0x4f0a02]
python[0x50a7f6]
python(_PyEval_EvalFrameDefault+0x2a50)[0x4f20a0]
python(_PyFunction_Vectorcall+0x6f)[0x4ff26f]
python(_PyEval_EvalFrameDefault+0x4b2c)[0x4f417c]
python[0x50a69e]
python(_PyEval_EvalFrameDefault+0x13b2)[0x4f0a02]
python(_PyFunction_Vectorcall+0x6f)[0x4ff26f]
python(_PyEval_EvalFrameDefault+0x13b2)[0x4f0a02]
python(_PyFunction_Vectorcall+0x6f)[0x4ff26f]
python(_PyEval_EvalFrameDefault+0x31f)[0x4ef96f]
python(_PyFunction_Vectorcall+0x6f)[0x4ff26f]
python(_PyEval_EvalFrameDefault+0x31f)[0x4ef96f]
python(_PyFunction_Vectorcall+0x6f)[0x4ff26f]
python(_PyEval_EvalFrameDefault+0x13b2)[0x4f0a02]
python[0x50a69e]
python(_PyEval_EvalFrameDefault+0x13b2)[0x4f0a02]
python(_PyFunction_Vectorcall+0x6f)[0x4ff26f]
python(_PyEval_EvalFrameDefault+0x31f)[0x4ef96f]
python(_PyFunction_Vectorcall+0x6f)[0x4ff26f]
python(_PyEval_EvalFrameDefault+0x31f)[0x4ef96f]
python(_PyFunction_Vectorcall+0x6f)[0x4ff26f]
python(_PyEval_EvalFrameDefault+0x13b2)[0x4f0a02]
python(_PyFunction_Vectorcall+0x6f)[0x4ff26f]
python(_PyEval_EvalFrameDefault+0x13b2)[0x4f0a02]
python(_PyFunction_Vectorcall+0x6f)[0x4ff26f]
python(_PyEval_EvalFrameDefault+0x31f)[0x4ef96f]
python[0x594fd2]
python(PyEval_EvalCode+0x87)[0x594f17]
python[0x5c7667]
python[0x5c24c0]
python[0x45ba37]
python(_PyRun_SimpleFileObject+0x19f)[0x5bc9df]
python(_PyRun_AnyFileObject+0x43)[0x5bc7e3]
python(Py_RunMain+0x38d)[0x5b95fd]
python(Py_BytesMain+0x39)[0x588099]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x2aaaab616555]
python[0x587f4e]
======= Memory map: ========
00400000-0041f000 r--p 00000000 00:3d 563664911                          /home/kirillshmilovich/.conda/envs/binding_affinity/bin/python3.10
0041f000-0061f000 r-xp 0001f000 00:3d 563664911                          /home/kirillshmilovich/.conda/envs/binding_affinity/bin/python3.10
0061f000-00721000 r--p 0021f000 00:3d 563664911                          /home/kirillshmilovich/.conda/envs/binding_affinity/bin/python3.10
00722000-00723000 r--p 00321000 00:3d 563664911                          /home/kirillshmilovich/.conda/envs/binding_affinity/bin/python3.10
00723000-00755000 rw-p 00322000 00:3d 563664911                          /home/kirillshmilovich/.conda/envs/binding_affinity/bin/python3.10
00755000-1dff1000 rw-p 00000000 00:00 0                                  [heap]
200000000-200200000 ---p 00000000 00:00 0 
200200000-200400000 rw-s 00000000 00:05 48522                            /dev/nvidiactl
200400000-202400000 rw-s 00000000 00:05 48522                            /dev/nvidiactl
202400000-205400000 rw-s 00000000 00:05 48522                            /dev/nvidiactl
205400000-206000000 ---p 00000000 00:00 0 
206000000-206200000 rw-s 00000000 00:05 48522                            /dev/nvidiactl
206200000-206400000 rw-s 00000000 00:05 48522                            /dev/nvidiactl
206400000-206600000 rw-s 206400000 00:05 53296                           /dev/nvidia-uvm
206600000-206800000 rw-s 00000000 00:05 48522                            /dev/nvidiactl
206800000-206a00000 ---p 00000000 00:00 0 
206a00000-206c00000 rw-s 00000000 00:05 48522                            /dev/nvidiactl
206c00000-300200000 ---p 00000000 00:00 0 
10000000000-10104000000 ---p 00000000 00:00 0 
3c52e000000-3c56e000000 rw-p 00000000 00:00 0 
2aaaaaaab000-2aaaaaacd000 r-xp 00000000 09:00 203039084                  /usr/lib64/ld-2.17.so
2aaaaaacd000-2aaaaaacf000 r-xp 00000000 00:00 0                          [vdso]
2aaaaaacf000-2aaaaaad0000 rw-p 00000000 00:00 0 
2aaaaaad0000-2aaaaaad7000 r--s 00000000 09:00 140121628                  /usr/lib64/gconv/gconv-modules.cache
2aaaaaad7000-2aaaaaadc000 r--p 00000000 00:3d 481877408                  /home/kirillshmilovich/.conda/envs/binding_affinity/lib/python3.10/lib-dynload/_socket.cpython-310-x86_64-linux-gnu.so
2aaaaaadc000-2aaaaaae5000 r-xp 00005000 00:3d 481877408                  /home/kirillshmilovich/.conda/envs/binding_affinity/lib/python3.10/lib-dynload/_socket.cpython-310-x86_64-linux-gnu.so
2aaaaaae5000-2aaaaaaed000 r--p 0000e000 00:3d 481877408                  /home/kirillshmilovich/.conda/envs/binding_affinity/lib/python3.10/lib-dynload/_socket.cpython-310-x86_64-linux-gnu.so
2aaaaaaed000-2aaaaaaee000 ---p 00016000 00:3d 481877408                  /home/kirillshmilovich/.conda/envs/binding_affinity/lib/python3.10/lib-dynload/_socket.cpython-310-x86_64-linux-gnu.so
2aaaaaaee000-2aaaaaaef000 r--p 00016000 00:3d 481877408                  /home/kirillshmilovich/.conda/envs/binding_affinity/lib/python3.10/lib-dynload/_socket.cpython-310-x86_64-linux-gnu.so
2aaaaaaef000-2aaaaaaf0000 rw-p 00017000 00:3d 481877408                  /home/kirillshmilovich/.conda/envs/binding_affinity/lib/python3.10/lib-dynload/_socket.cpython-310-x86_64-linux-gnu.so
2aaaaaaf0000-2aaaaaaf1000 r--p 00000000 00:3d 481877383                  /home/kirillshmilovich/.conda/envs/binding_affinity/lib/python3.10/lib-dynload/_heapq.cpython-310-x86_64-linux-gnu.so
2aaaaaaf1000-2aaaaaaf4000 r-xp 00001000 00:3d 481877383                  /home/kirillshmilovich/.conda/envs/binding_affinity/lib/python3.10/lib-dynload/_heapq.cpython-310-x86_64-linux-gnu.soAborted

Strangely, if I place a debug statement within the get_gnina_feats_from_df function, e.g. at the end of the original file,

with torch.inference_mode():
      for batch in tqdm(all_loader, desc='Predicting GNINA features'):
          feat = list()
          for mod in model.models:
              feat.append(mod.features(batch[0]).squeeze()[None])
          feats.append(torch.cat(feat).mean(0))
      feats = torch.cat(feats).cpu()
 import ipdb; ipdb.set_trace()
 return [f for f in feats]

and then continue after entering that debug statement (i.e., pressing c after entering the debugger) everything appears to run fine without error. Although the error appears again once I Cntl-C out of the debugger.

Do you have any idea what the origin of this error might be and how I might be able to fix it and get this to work without using the debugger?

Timings

Add timings for training:

  • Epoch time
  • Elapsed time
  • Total time

Names of some output files are hard-coded

Some output files currently have a fixed name:

  • Training log file: training.log
  • Inference log file: inference.log
  • Checkpoint files: checkpoint_${iter}.pt

This can be problematic when training different models (for example on different cross-validation folds). Checkpoints can result in the following errors:

  • Previous checkpoint file already removed by another process
FileNotFoundError: [Errno 2] No such file or directory: 'training/flex1/checkpoint_1.pt'
  • New checkpoint file already present:
ValueError: Files ['checkpoint_2.pt'] with extension '.pt' are already present in the directory training/flex1/. If you want to use this directory anyway, pass `require_empty=False`.

Add functionality to use GNINA pre-trained models

Weights of the pre-trained GNINA models were provided in #34 by @drewnutt , getting a steps closer towards #33 .

The following needs to be implemented in order to have the weights readily available:

  • Automatic loading weights into the current models
  • Support ensemble of models #38
    • Support GNINA default model #44
  • Publish package on PyPI and conda-forge
    • Change name to gninatorch #37

This additional functionality could be implemented in gnina.py and follow the GNINA command line as closely as possible. In addition to .types files, it would be good to use molgrid.openbabel to provide the --receptor and --ligand options.

Guidance on preparing data for training from structures

Is there any info/tutorials/examples on how I can generate data files from my own structures/docked poses as input compatible for training gnina models. I know libmolgrid is used for handling the data to enable things random rotations for data augmentation, but I can't seem to find anything on how I can go about featurizing my own structures into the file scheme read by libmolgrid, (i.e., using the ExampleProvider). (edited)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.