Skip to content

Commit 124effb

Browse files
committed
Merge branch 'dev' into 'main'
Finalization of v2.1.0 See merge request cdd/QSPRpred!127
2 parents 56ea83b + f889d4b commit 124effb

93 files changed

Lines changed: 9334 additions & 5168 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
!.pre-commit-config.yaml
66
/build/
77
/docs/_build
8+
/qsprpred/_version.py
89
*.pkg
910
*.tgz
1011
*.gzip
1112
*.tar.gz
1213
*.out
13-
/**/test_files/qspr/
14+
/**/test_files/generated/
15+
/**/tutorial/test_files/
16+
/**/tutorial/cli_tutorial/
1417

1518
### Python template
1619
# Byte-compiled / optimized / DLL files

.gitlab-ci.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# This workflow will install Python dependencies, run tests, and write documentation
22

3+
variables:
4+
GIT_STRATEGY: clone # clone entire repo instead of reusing workspace
5+
GIT_DEPTH: "0" # avoid shallow clone to give sonar all the info it needs
6+
37
stages:
48
- test
59
- deploy
@@ -25,16 +29,16 @@ stages:
2529
- cd clitest && ./run.sh
2630
- cd ../tutorial && ./run_all.sh
2731

32+
# # Run tests on Python version 11 (linux image)
33+
# test:python3.11:
34+
# extends: .test
35+
# image: python:3.11
36+
2837
# Run tests on Python version 10 (linux image)
2938
test:python3.10:
3039
extends: .test
3140
image: python:3.10
3241

33-
# Run tests on Python version 9 (linux image)
34-
#test:python3.9:
35-
# extends: .test
36-
# image: python:3.9
37-
3842
# Write documentation on main branch
3943
pages:
4044
stage: deploy
@@ -49,4 +53,4 @@ pages:
4953
paths:
5054
- public
5155
only:
52-
- main
56+
- main

CHANGELOG.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,49 @@
11
# Change Log
22

3-
From v2.0.0 to v2.0.1
3+
From v2.0.1 to v2.1.0.a2
44

55
## Fixes
66

7-
- Requirement python version in pyproject.toml updated to 3.10, as older version of python don't support the type hinting used in the code.
8-
- Corrected type hinting for `QSPRModel.handleInvalidsInPredictions`, which resulted in an error when importing the package in google colab.
9-
- The `predictMols` method returned random predictions in v2.0.0 due to unpatched shuffling code. This has now been fixed.
7+
- fixed error with serialization of the `DataFrameDescriptorSet` (#63)
8+
- Papyrus descriptors are not fetched by default anymore from the `Papyrus` adapter, which caused fetching of unnecessary data.
9+
- A [potential bug in new version of pandas](https://github.com/pandas-dev/pandas/issues/55009) broke scaffold generation so a workaround was implemented.
1010

1111
## Changes
12+
- `QSPRModel.evaluate` moved to a separate class `EvaluationMethod` in `qsprpred.models.interfaces`, with subclasses for cross-validation and making predictions on a test set in `qsprpred.models.evaluation_methods` (`CrossValidation` and `EvaluateTestSetPerformance` respectively).
13+
- `QSPRModel` attribute `scoreFunc` is removed.
14+
- 'qspr/models' is no longer added to the output path of `QSPRModel.save`, allowing for complete control over the output path.
15+
- `SKlearnMetrics.supportsTask` now uses a dictionary like dict[ModelTasks, list[str]] to map tasks to supported metric names. (#53)
16+
- `GBMTRandomSplit` and `ScaffoldSplit` now use the `GBMTDataSplit` to create balanced splits. `RandomSplit` still functions the same way as a completely random test split.
17+
- `PCMSplit` replaces `StratifiedPerTarget` and is compatible with `RandomSplit`, `ScaffoldSplit` and `ClusterSplit`.
18+
- `DuplicatesFilter` refactored to`RepeatsFilter`, as it also captures scenarios where triplicates/quadruplicates are found in the dataset. These scenarios are now also covered by the respective UnitTest.
19+
- The versioning scheme of development snapshots has changed from `devX` to `alphaX`/`betaX`, where `X` is an integer that increments with each release.
20+
- The following model class have been renamed and moved:
21+
- `models.models.QSPRsklearn` > `models.sklearn.SklearnModel`
22+
- `deep.models.QSPRDNN` > `extra.gpu.models.dnn.DNNModel`
23+
- `extra.models.pcm.ModelPCM` > `extra.models.pcm.PCMModel`
24+
- `extra.models.pcm.QSPRsklearnPCM` > `extra.models.pcm.SklearnPCMModel`
25+
- The command line interface modules now use input and output file paths instead
26+
of automatically placing all files in a subfolder `qspr`, allowing for more
27+
control over the output and input paths.
1228

1329
## New Features
14-
- raise error if search space for optuna optimization is missing search space type annotation or if type not in list
30+
- `GBMTDataSplit` - parent class to create globally balanced splits with the [gbmt-split](https://github.com/sohviluukkonen/gbmt-splits) package.
31+
- `ClusterSplit` - splits data based clustering of molecular fingerprints (uses `GBMTDataSplit`).
32+
- Raise error if search space for optuna optimization is missing search space type annotation or if type not in list.
33+
- When installing package with pip, the commit hash and date of the installation is saved into `qsprpred._version`
34+
- `HyperParameterOptimization` classes now accept a `evaluation_method` argument, which is an instance of `EvaluationMethod` (see above). This allows for hyperparameter optimization to be performed on a test set, or on a cross-validation set. (#11)
35+
- `HyperParameterOptimization` now accepts `score_aggregation` argument, which is a function that takes a list of scores and returns a single score. This allows for the use of different aggregation functions, such as `np.mean` or `np.median` to combine scores from different folds. (#45)
36+
- A new tutorial `adding_new_components.ipynb` has been added to the `tutorials` folder, which demonstrates how to add new model to QSPRpred.
37+
- A new function `Metrics.checkMetricCompatibility` has been added, which checks if a metric is compatible with a given task and a given prediction methods (i.e. `predict` or `predictProba`)
38+
- In `EvaluationMethod` (see above), an attribute `use_proba` has been added, which determines whether the `predict` or `predictProba` method is used to make predictions (#56).
39+
- Add new descriptorset `SmilesDesc` to use the smiles strings as a descriptor.
40+
- New module `early_stopping` with classes `EarlyStopping` and `EarlyStoppingMode` has been added. This module allows for more control over early stopping in models that support it.
41+
- Add new descriptorset `SmilesDesc` to use the smiles strings as a descriptor.
42+
- Refactoring of the test suite under `qsprpred.data` and improvement of temporary file handling (!114).
43+
- `PyBoostModel` - QSPRpred wrapper for py-boost models. Requires optional `pyboost` dependencies.
44+
- `ChempropModel` - QSPRpred wrapper for Chemprop models. Requires optional `deep` dependencies.
45+
- The `data_CLI` argument `--log_transform` (`-lt`) has been changed to `--transform_data` (`-t`), which now accepts a number of transformations to apply to the target data. Available transformations are `log`, `log10`, `log2`, `sqrt`, `cbrt`, `exp`, `exp2`, `exp10`, `square`, `cube`, `reciprocal`.
46+
- New `data_CLI`, `model_CLI` and `predict_CLI` argument `--skip_backup` (`-sb`) to skip the backup of the output files. WARNING: This will overwrite existing files.
47+
48+
## Removed Features
49+
- `StratifiedPerTarget` is replaced by `PCMSplit`.

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,18 @@ QSPRpred can be installed with pip like so (with python >= 3.10):
2424
pip install git+https://github.com/CDDLeiden/QSPRPred.git@main
2525
```
2626

27-
Note that this will install the basic dependencies, but not the optional dependencies. If you want to use the optional dependencies, you can install the package with the following installation options:
27+
Note that this will install the basic dependencies, but not the optional dependencies. If you want to use the optional dependencies, you can install the package with an option:
2828

2929
```bash
30-
# include deep neural network models and their dependencies
31-
pip install git+https://github.com/CDDLeiden/QSPRPred.git@main#egg=qsprpred[deep]
32-
33-
# include extra dependencies for PCM models and extra descriptor sets from packages other than RDKit
34-
pip install git+https://github.com/CDDLeiden/QSPRPred.git@main#egg=qsprpred[extra]
35-
36-
# include all optional dependencies
37-
pip install git+https://github.com/CDDLeiden/QSPRPred.git@main#egg=qsprpred[full]
30+
pip install git+https://github.com/CDDLeiden/QSPRPred.git@main#egg=qsprpred[<option>]
3831
```
3932

33+
The following options are available:
34+
- extra : include extra dependencies for PCM models and extra descriptor sets from packages other than RDKit
35+
- deep : include deep learning models (torch and chemprop)
36+
- pyboost : include pyboost model (requires cupy, `pip install cupy-cudaX`, replace X with your [cuda version](https://docs.cupy.dev/en/stable/install.html))
37+
- full : include all optional dependecies (requires cupy, `pip install cupy-cudaX`, replace X with your [cuda version](https://docs.cupy.dev/en/stable/install.html))
38+
4039
### Multiple Sequence Alignment Provider for Protein Descriptors
4140

4241
If you plan to optionally use QSPRPred to calculate protein descriptors for PCM, make sure to also install Clustal Omega. You can get it via `conda`:
@@ -45,20 +44,21 @@ If you plan to optionally use QSPRPred to calculate protein descriptors for PCM,
4544

4645
conda install -c bioconda clustalo
4746
```
48-
49-
This is needed to provide multiple sequence alignments for the PCM descriptors. Clustal Omega does not, however, work on Windows. In that case, you can use MAFFT instead:
47+
or install MAFFT instead:
5048

5149
```bash
5250
conda install -c biocore mafft
5351
```
52+
This is needed to provide multiple sequence alignments for the PCM descriptors.
53+
At the moment, we do not support protein descriptor calculation for PCM on Windows.
5454

5555
## Use
5656
After installation, you will have access to various command line features, but you can also use the Python API directly (see [Documentation](https://cddleiden.github.io/QSPRPred/docs/)). For a quick start, you can also check out the [Jupyter notebook tutorials](./tutorial), which documents the use of the Python API to build different types of models. [This tutorial](./tutorial/tutorial_training.ipynb) shows how a QSAR model can be trained. [This tutorial](./tutorial/tutorial_usage.ipynb) shows how to use a QSAR model to predict the bioactivity of a set of molecules. The tutorials as well as the [documentation](https://cddleiden.github.io/QSPRPred/docs/use.html) are still work in progress, and we will be happy for any contributions where it is still lacking.
5757

5858
To use the commandline to train the same QSAR model as in the tutorial use (run from tutorial folder):
5959
```bash
60-
python -m qsprpred.data_CLI -i parkinsons_pivot.tsv -pr GABAAalpha -r true -sf 0.15 -fe Morgan
61-
python -m qsprpred.model_CLI -pr GABAAalpha -r true -m PLS -s -o bayes -nt 10 -me
60+
python -m qsprpred.data_CLI -i ./data/parkinsons_pivot.tsv -o qspr/data -pr GABAAalpha -pr NMDA -r true -sp random -sf 0.15 -fe Morgan
61+
python -m qsprpred.model_CLI -dp ./qspr/data/GABAAalpha_REGRESSION_df.pkl -o ./qspr/models -m PLS -o bayes -nt 5 -me -s
6262
```
6363

6464
Workflow

clitest/run.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export PYTHONPATH=".."
66

77
# input data and base directory
88
export TEST_BASE="."
9-
export TEST_DATA='test_data_large.tsv'
9+
export TEST_DATA='data/test_data_large.tsv'
1010

1111
function cleanup() {
1212
rm -rf ${TEST_BASE}/data/backup_*;
@@ -25,21 +25,21 @@ export TRAIN_BATCH=32
2525
export TRAIN_GPUS=0
2626
export N_CPUS=2
2727
export OPTIMIZATION='bayes'
28-
export SEARCH_SPACE='data/search_space/search_space_test'
28+
export SEARCH_SPACE='./data/search_space/search_space_test.json'
2929
export N_TRIALS=2
3030

3131
###############
3232
# DATA #
3333
###############
3434
python -m qsprpred.data_CLI \
35-
-b ${TEST_BASE} \
3635
-de \
37-
-i ${TEST_DATA} \
36+
-i ${TEST_BASE}/${TEST_DATA} \
37+
-o ${TEST_BASE}/qspr/data/ \
3838
-ncpu ${N_CPUS} \
3939
-sm ${SMILES} \
4040
-pr CL fu \
4141
-th '{"CL":[6.5],"fu":[0.3]}' \
42-
-lt '{"CL":true,"fu":false}' \
42+
-tr '{"CL":"log"}' \
4343
-sp 'time' \
4444
-stc 'Year of first disclosure' \
4545
-st 2000 \
@@ -54,13 +54,13 @@ python -m qsprpred.data_CLI \
5454
# MODELLING #
5555
###############
5656
python -m qsprpred.model_CLI \
57-
-b ${TEST_BASE} \
57+
-o ${TEST_BASE}/qspr/models \
5858
-de \
59-
-dp CL_fu_SINGLECLASS \
59+
-dp ${TEST_BASE}/qspr/data/CL_fu_SINGLECLASS_df.pkl \
6060
-ncpu ${N_CPUS} \
6161
--model_types RF \
6262
-s \
63-
-o ${OPTIMIZATION} \
63+
-op ${OPTIMIZATION} \
6464
-ss ${SEARCH_SPACE} \
6565
-nt ${N_TRIALS} \
6666
-me
@@ -69,11 +69,11 @@ python -m qsprpred.model_CLI \
6969
# PREDICTING #
7070
###############
7171
python -m qsprpred.predict_CLI \
72-
-b ${TEST_BASE} \
7372
-de \
7473
-i ${TEST_DATA} \
74+
-o ${TEST_BASE}/qspr/predictions.tsv \
7575
-ncpu ${N_CPUS} \
76-
-mp ./qspr/models/RF_CL_fu_SINGLECLASS/RF_CL_fu_SINGLECLASS_meta.json \
76+
-mp ${TEST_BASE}/qspr/models/RF_CL_fu_SINGLECLASS/RF_CL_fu_SINGLECLASS_meta.json \
7777
-pr \
7878
-fv 0.0
7979

docs/api/qsprpred.data.utils.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ Subpackages
1212
Submodules
1313
----------
1414

15+
qsprpred.data.utils.data\_clustering module
16+
-------------------------------------------
17+
18+
.. automodule:: qsprpred.data.utils.data_clustering
19+
:members:
20+
:undoc-members:
21+
:show-inheritance:
22+
1523
qsprpred.data.utils.datafilters module
1624
--------------------------------------
1725

docs/api/qsprpred.deep.models.rst

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
qsprpred.extra.gpu.models package
2+
=================================
3+
4+
Submodules
5+
----------
6+
7+
qsprpred.extra.gpu.models.chemprop module
8+
-----------------------------------------
9+
10+
.. automodule:: qsprpred.extra.gpu.models.chemprop
11+
:members:
12+
:undoc-members:
13+
:show-inheritance:
14+
15+
qsprpred.extra.gpu.models.dnn module
16+
------------------------------------
17+
18+
.. automodule:: qsprpred.extra.gpu.models.dnn
19+
:members:
20+
:undoc-members:
21+
:show-inheritance:
22+
23+
qsprpred.extra.gpu.models.neural\_network module
24+
------------------------------------------------
25+
26+
.. automodule:: qsprpred.extra.gpu.models.neural_network
27+
:members:
28+
:undoc-members:
29+
:show-inheritance:
30+
31+
qsprpred.extra.gpu.models.pyboost module
32+
----------------------------------------
33+
34+
.. automodule:: qsprpred.extra.gpu.models.pyboost
35+
:members:
36+
:undoc-members:
37+
:show-inheritance:
38+
39+
qsprpred.extra.gpu.models.tests module
40+
--------------------------------------
41+
42+
.. automodule:: qsprpred.extra.gpu.models.tests
43+
:members:
44+
:undoc-members:
45+
:show-inheritance:
46+
47+
Module contents
48+
---------------
49+
50+
.. automodule:: qsprpred.extra.gpu.models
51+
:members:
52+
:undoc-members:
53+
:show-inheritance:
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
qsprpred.deep package
2-
=====================
1+
qsprpred.extra.gpu package
2+
==========================
33

44
Subpackages
55
-----------
66

77
.. toctree::
88
:maxdepth: 4
99

10-
qsprpred.deep.models
10+
qsprpred.extra.gpu.models
1111

1212
Module contents
1313
---------------
1414

15-
.. automodule:: qsprpred.deep
15+
.. automodule:: qsprpred.extra.gpu
1616
:members:
1717
:undoc-members:
1818
:show-inheritance:

docs/api/qsprpred.extra.models.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ qsprpred.extra.models package
44
Submodules
55
----------
66

7+
qsprpred.extra.models.models module
8+
-----------------------------------
9+
10+
.. automodule:: qsprpred.extra.models.models
11+
:members:
12+
:undoc-members:
13+
:show-inheritance:
14+
715
qsprpred.extra.models.pcm module
816
--------------------------------
917

0 commit comments

Comments
 (0)