mother-ml 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mother_ml-1.0.0/LICENSE +28 -0
- mother_ml-1.0.0/PKG-INFO +71 -0
- mother_ml-1.0.0/pyproject.toml +353 -0
- mother_ml-1.0.0/src/mother/__init__.py +27 -0
- mother_ml-1.0.0/src/mother/chem.py +137 -0
- mother_ml-1.0.0/src/mother/cv/__init__.py +19 -0
- mother_ml-1.0.0/src/mother/cv/config.py +71 -0
- mother_ml-1.0.0/src/mother/cv/core.py +358 -0
- mother_ml-1.0.0/src/mother/cv/cv_methods.py +278 -0
- mother_ml-1.0.0/src/mother/cv/report/__init__.py +8 -0
- mother_ml-1.0.0/src/mother/cv/report/cluster.py +402 -0
- mother_ml-1.0.0/src/mother/data/mother_config.yaml +168 -0
- mother_ml-1.0.0/src/mother/errors.py +18 -0
- mother_ml-1.0.0/src/mother/explain/__init__.py +0 -0
- mother_ml-1.0.0/src/mother/feature_generation/__init__.py +15 -0
- mother_ml-1.0.0/src/mother/feature_generation/config.py +194 -0
- mother_ml-1.0.0/src/mother/feature_generation/core.py +261 -0
- mother_ml-1.0.0/src/mother/feature_generation/fp_gen.py +100 -0
- mother_ml-1.0.0/src/mother/ml/__init__.py +357 -0
- mother_ml-1.0.0/src/mother/ml/config.py +79 -0
- mother_ml-1.0.0/src/mother/ml/core.py +272 -0
- mother_ml-1.0.0/src/mother/ml/estimators.py +530 -0
- mother_ml-1.0.0/src/mother/ml/models/__init__.py +0 -0
- mother_ml-1.0.0/src/mother/ml/models/m_catboost.py +1389 -0
- mother_ml-1.0.0/src/mother/ml/models/m_lasso.py +172 -0
- mother_ml-1.0.0/src/mother/ml/models/m_randomForest.py +412 -0
- mother_ml-1.0.0/src/mother/ml/models/m_tabpfn.py +844 -0
- mother_ml-1.0.0/src/mother/ml/models/utils.py +12 -0
- mother_ml-1.0.0/src/mother/ml/properties.py +48 -0
- mother_ml-1.0.0/src/mother/ml/rna.py +446 -0
- mother_ml-1.0.0/src/mother/ml/utils.py +594 -0
- mother_ml-1.0.0/src/mother/optimization/__init__.py +3 -0
- mother_ml-1.0.0/src/mother/optimization/config.py +56 -0
- mother_ml-1.0.0/src/mother/optimization/core.py +308 -0
- mother_ml-1.0.0/src/mother/optimization/report/__init__.py +0 -0
- mother_ml-1.0.0/src/mother/optimization/report/optuna_qc.py +79 -0
- mother_ml-1.0.0/src/mother/optimization/utils.py +50 -0
- mother_ml-1.0.0/src/mother/pipeline_utils.py +898 -0
- mother_ml-1.0.0/src/mother/preprocessing/__init__.py +8 -0
- mother_ml-1.0.0/src/mother/preprocessing/config.py +43 -0
- mother_ml-1.0.0/src/mother/preprocessing/core.py +171 -0
- mother_ml-1.0.0/src/mother/preprocessing/data/Salts.txt +19 -0
- mother_ml-1.0.0/src/mother/preprocessing/data/kekulization_fixes.txt +11 -0
- mother_ml-1.0.0/src/mother/preprocessing/standardizer.py +523 -0
- mother_ml-1.0.0/src/mother/preprocessing/utils.py +138 -0
- mother_ml-1.0.0/src/mother/report/utils.py +0 -0
- mother_ml-1.0.0/src/mother/settings.py +182 -0
- mother_ml-1.0.0/src/mother/utils.py +146 -0
mother_ml-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Bayer
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
mother_ml-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: mother-ml
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A ML framework that takes care
|
|
5
|
+
Author: Thomas Wolf, Florian Huber, Nicolas Peschke, Niklas Toetsch, Satya Kanuri, Alex Calabrese, Samantha Martinez, Hamza Ibrahim, Agata Zieba, Yunhee Jeong, Nesma Mousa, Lukas Hebing, Kai Sommer, Nicolas Arning
|
|
6
|
+
License: BSD 3-Clause License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026, Bayer
|
|
9
|
+
|
|
10
|
+
Redistribution and use in source and binary forms, with or without
|
|
11
|
+
modification, are permitted provided that the following conditions are met:
|
|
12
|
+
|
|
13
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
14
|
+
list of conditions and the following disclaimer.
|
|
15
|
+
|
|
16
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
17
|
+
this list of conditions and the following disclaimer in the documentation
|
|
18
|
+
and/or other materials provided with the distribution.
|
|
19
|
+
|
|
20
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
21
|
+
contributors may be used to endorse or promote products derived from
|
|
22
|
+
this software without specific prior written permission.
|
|
23
|
+
|
|
24
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
25
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
26
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
27
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
28
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
29
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
30
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
31
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
32
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
33
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
|
+
Requires-Dist: catboost>=1.2.6,<=1.2.8
|
|
35
|
+
Requires-Dist: feature-engine>=1.8.0,<2
|
|
36
|
+
Requires-Dist: numpy>=2.2,<2.3
|
|
37
|
+
Requires-Dist: optuna>=4.2.0,<5
|
|
38
|
+
Requires-Dist: pandas>=2.2,<3.0
|
|
39
|
+
Requires-Dist: pydantic-settings>=2.4.0,<3
|
|
40
|
+
Requires-Dist: rdkit>=2024.9.1
|
|
41
|
+
Requires-Dist: scikit-learn<=1.5.0
|
|
42
|
+
Requires-Dist: single-source>=0.4.0,<0.5
|
|
43
|
+
Requires-Dist: colorama>=0.4.6,<0.5
|
|
44
|
+
Requires-Dist: boruta>=0.4.3,<0.5
|
|
45
|
+
Requires-Dist: quantile-forest>=1.4.0,<2
|
|
46
|
+
Requires-Dist: hdbscan>=0.8.40,<0.9 ; extra == 'clustering'
|
|
47
|
+
Requires-Dist: kmedoids>=0.5.3.1,<0.6 ; extra == 'clustering'
|
|
48
|
+
Requires-Dist: matplotlib>3.7.0 ; extra == 'report'
|
|
49
|
+
Requires-Dist: seaborn>=0.13.2,<0.14 ; extra == 'report'
|
|
50
|
+
Requires-Dist: umap-learn>=0.5.7,<0.6 ; extra == 'report'
|
|
51
|
+
Requires-Dist: plotly>=6.0.1,<7 ; extra == 'report'
|
|
52
|
+
Requires-Dist: ipywidgets>=8.1.5,<9 ; extra == 'report'
|
|
53
|
+
Requires-Dist: igraph>=0.11.8,<0.12 ; extra == 'report'
|
|
54
|
+
Requires-Dist: leidenalg>=0.10.2,<0.11 ; extra == 'report'
|
|
55
|
+
Requires-Dist: anndata ; extra == 'rna'
|
|
56
|
+
Requires-Dist: scanpy ; extra == 'rna'
|
|
57
|
+
Requires-Dist: rnanorm ; extra == 'rna'
|
|
58
|
+
Requires-Dist: tabpfn==2.1.0 ; extra == 'tabpfn'
|
|
59
|
+
Requires-Dist: torch>=2.3.0,<3 ; extra == 'tabpfn'
|
|
60
|
+
Requires-Dist: torch>=2.3.0,<3 ; extra == 'torch'
|
|
61
|
+
Requires-Python: >=3.10, <3.14
|
|
62
|
+
Project-URL: Homepage, https://github.com/Bayer-Group/MotherML
|
|
63
|
+
Project-URL: Documentation, https://bayer-group.github.io/MotherML/
|
|
64
|
+
Project-URL: Repository, https://github.com/Bayer-Group/MotherML
|
|
65
|
+
Project-URL: Issues, https://github.com/Bayer-Group/MotherML/issues
|
|
66
|
+
Project-URL: Changelog, https://bayer-group.github.io/MotherML/Changelog/
|
|
67
|
+
Provides-Extra: clustering
|
|
68
|
+
Provides-Extra: report
|
|
69
|
+
Provides-Extra: rna
|
|
70
|
+
Provides-Extra: tabpfn
|
|
71
|
+
Provides-Extra: torch
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "mother-ml"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "A ML framework that takes care"
|
|
5
|
+
requires-python = ">=3.10, <3.14"
|
|
6
|
+
license = { file = "LICENSE" }
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "Thomas Wolf" },
|
|
9
|
+
{ name = "Florian Huber" },
|
|
10
|
+
{ name = "Nicolas Peschke" },
|
|
11
|
+
{ name = "Niklas Toetsch" },
|
|
12
|
+
{ name = "Satya Kanuri" },
|
|
13
|
+
{ name = "Alex Calabrese" },
|
|
14
|
+
{ name = "Samantha Martinez" },
|
|
15
|
+
{ name = "Hamza Ibrahim" },
|
|
16
|
+
{ name = "Agata Zieba" },
|
|
17
|
+
{ name = "Yunhee Jeong" },
|
|
18
|
+
{ name = "Nesma Mousa" },
|
|
19
|
+
{ name = "Lukas Hebing" },
|
|
20
|
+
{ name = "Kai Sommer" },
|
|
21
|
+
{ name = "Nicolas Arning" },
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
dependencies = [
|
|
25
|
+
"catboost>=1.2.6,<=1.2.8",
|
|
26
|
+
"feature-engine>=1.8.0,<2",
|
|
27
|
+
"numpy>=2.2,<2.3",
|
|
28
|
+
"optuna>=4.2.0,<5",
|
|
29
|
+
"pandas>=2.2,<3.0",
|
|
30
|
+
"pydantic-settings>=2.4.0,<3",
|
|
31
|
+
"rdkit>=2024.9.1",
|
|
32
|
+
"scikit-learn<=1.5.0",
|
|
33
|
+
"single-source>=0.4.0,<0.5",
|
|
34
|
+
"colorama>=0.4.6,<0.5",
|
|
35
|
+
"boruta>=0.4.3,<0.5",
|
|
36
|
+
"quantile-forest>=1.4.0,<2"
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/Bayer-Group/MotherML"
|
|
41
|
+
Documentation = "https://bayer-group.github.io/MotherML/"
|
|
42
|
+
Repository = "https://github.com/Bayer-Group/MotherML"
|
|
43
|
+
Issues = "https://github.com/Bayer-Group/MotherML/issues"
|
|
44
|
+
Changelog = "https://bayer-group.github.io/MotherML/Changelog/"
|
|
45
|
+
|
|
46
|
+
[project.optional-dependencies]
|
|
47
|
+
### Torch
|
|
48
|
+
torch = ["torch>=2.3.0,<3"]
|
|
49
|
+
|
|
50
|
+
### Report block
|
|
51
|
+
report = [
|
|
52
|
+
"matplotlib>3.7.0",
|
|
53
|
+
"seaborn>=0.13.2,<0.14",
|
|
54
|
+
"umap-learn>=0.5.7,<0.6",
|
|
55
|
+
"plotly>=6.0.1,<7",
|
|
56
|
+
"ipywidgets>=8.1.5,<9",
|
|
57
|
+
"igraph>=0.11.8,<0.12",
|
|
58
|
+
"leidenalg>=0.10.2,<0.11",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
### RNA block
|
|
62
|
+
rna = [
|
|
63
|
+
"anndata",
|
|
64
|
+
"scanpy",
|
|
65
|
+
"rnanorm",
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
### Clustering block
|
|
69
|
+
clustering = [
|
|
70
|
+
"hdbscan>=0.8.40,<0.9",
|
|
71
|
+
"kmedoids>=0.5.3.1,<0.6",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
### TabPFN
|
|
75
|
+
tabpfn = [
|
|
76
|
+
"tabpfn==2.1.0",
|
|
77
|
+
"torch>=2.3.0,<3",
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
[dependency-groups]
|
|
81
|
+
dev = [
|
|
82
|
+
"ipykernel",
|
|
83
|
+
"isort",
|
|
84
|
+
"mypy>0.981",
|
|
85
|
+
"poethepoet",
|
|
86
|
+
"pre-commit",
|
|
87
|
+
"pylint",
|
|
88
|
+
"pytest",
|
|
89
|
+
"pytest-cov",
|
|
90
|
+
"ruff>=0.9.2,<1",
|
|
91
|
+
"types-pyyaml>=6.0.12.20241230",
|
|
92
|
+
"python-semantic-release>=10.2.0,<11",
|
|
93
|
+
]
|
|
94
|
+
examples = [
|
|
95
|
+
"polaris-lib>=0.13.0,<0.14",
|
|
96
|
+
"shap>=0.47.2,<0.48",
|
|
97
|
+
]
|
|
98
|
+
docs = [
|
|
99
|
+
"mkdocs",
|
|
100
|
+
"mkdocs-git-revision-date-localized-plugin",
|
|
101
|
+
"mkdocs-include-markdown-plugin",
|
|
102
|
+
"mkdocs-material",
|
|
103
|
+
"mkdocstrings[python]",
|
|
104
|
+
"markdown-exec[ansi]>=1.7.0,<2",
|
|
105
|
+
"mkdocs-jupyter>=0.25.1,<0.26",
|
|
106
|
+
"mkdocs-git-authors-plugin>=0.9.2,<0.10",
|
|
107
|
+
]
|
|
108
|
+
test_duration = [
|
|
109
|
+
"pytest-html>=4.0.2,<5",
|
|
110
|
+
"pytest-xdist[psutil]>=3.3.1,<4",
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
[tool.pytest.ini_options]
|
|
114
|
+
# Ensure modules are not reloaded between tests
|
|
115
|
+
python_files = ["test_*.py", "*_test.py"]
|
|
116
|
+
python_classes = ["Test*"]
|
|
117
|
+
python_functions = ["test_*"]
|
|
118
|
+
# Add this to prevent module reloading
|
|
119
|
+
addopts = "--import-mode=importlib"
|
|
120
|
+
|
|
121
|
+
# Custom markers
|
|
122
|
+
markers = [
|
|
123
|
+
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
|
|
124
|
+
"serial: marks tests that should not run in parallel (modifies global state)",
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
log_cli = true
|
|
128
|
+
log_cli_level = "INFO"
|
|
129
|
+
#log_cli_level = "DEBUG"
|
|
130
|
+
# log_cli_format = "%(asctime)s %(levelname)8s %(message)s (%(filename)s:%(lineno)s)"
|
|
131
|
+
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
|
132
|
+
log_cli_format = "%(asctime)s | %(name)30s | %(levelname)8s | %(message)s"
|
|
133
|
+
#testpaths = [
|
|
134
|
+
# "test/unit",
|
|
135
|
+
#]
|
|
136
|
+
|
|
137
|
+
[tool.pylint.main]
|
|
138
|
+
|
|
139
|
+
extension-pkg-allow-list = "rdkit"
|
|
140
|
+
# Specify a score threshold under which the program will exit with error.
|
|
141
|
+
fail-under = 8
|
|
142
|
+
|
|
143
|
+
[tool.pylint."MESSAGES CONTROL"]
|
|
144
|
+
|
|
145
|
+
disable = "too-few-public-methods"
|
|
146
|
+
|
|
147
|
+
[tool.pylint.basic]
|
|
148
|
+
variable-naming-style = "snake_case"
|
|
149
|
+
# Naming style matching correct class attribute names.
|
|
150
|
+
class-attribute-naming-style = "any"
|
|
151
|
+
function-naming-style = "any"
|
|
152
|
+
|
|
153
|
+
# Naming style matching correct class names.
|
|
154
|
+
class-naming-style = "PascalCase"
|
|
155
|
+
method-naming-style = "any"
|
|
156
|
+
# Naming style matching correct module names.
|
|
157
|
+
module-naming-style = "any"
|
|
158
|
+
|
|
159
|
+
[tool.pylint.format]
|
|
160
|
+
# Number of spaces of indent required inside a hanging or continued line.
|
|
161
|
+
indent-after-paren = 4
|
|
162
|
+
|
|
163
|
+
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
|
|
164
|
+
# tab).
|
|
165
|
+
indent-string = " "
|
|
166
|
+
|
|
167
|
+
# Maximum number of characters on a single line.
|
|
168
|
+
max-line-length = 100
|
|
169
|
+
|
|
170
|
+
[tool.pylint.logging]
|
|
171
|
+
# The type of string formatting that logging methods do. `old` means using %
|
|
172
|
+
# formatting, `new` is for `{}` formatting.
|
|
173
|
+
logging-format-style = "new"
|
|
174
|
+
|
|
175
|
+
# Logging modules to check that the string format arguments are in logging
|
|
176
|
+
# function parameter format.
|
|
177
|
+
logging-modules = ["logging"]
|
|
178
|
+
|
|
179
|
+
[tool.ruff]
|
|
180
|
+
# Exclude a variety of commonly ignored directories.
|
|
181
|
+
exclude = [
|
|
182
|
+
".git",
|
|
183
|
+
".ipynb_checkpoints",
|
|
184
|
+
".mypy_cache",
|
|
185
|
+
".pytest_cache",
|
|
186
|
+
".pytype",
|
|
187
|
+
".ruff_cache",
|
|
188
|
+
".venv",
|
|
189
|
+
".vscode",
|
|
190
|
+
".scannerwork",
|
|
191
|
+
"__pypackages__",
|
|
192
|
+
"_build",
|
|
193
|
+
"build",
|
|
194
|
+
"dist",
|
|
195
|
+
"site-packages",
|
|
196
|
+
"**qm_transformations.py",
|
|
197
|
+
]
|
|
198
|
+
indent-width = 4
|
|
199
|
+
line-length = 120
|
|
200
|
+
|
|
201
|
+
# Assume Python 3.11.
|
|
202
|
+
target-version = "py311"
|
|
203
|
+
|
|
204
|
+
[tool.ruff.lint]
|
|
205
|
+
# Enable Pyflakes `E` and `F` codes by default.
|
|
206
|
+
ignore = []
|
|
207
|
+
select = ["E", "F"]
|
|
208
|
+
|
|
209
|
+
# Allow unused variables when underscore-prefixed.
|
|
210
|
+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
|
211
|
+
|
|
212
|
+
[tool.ruff.format]
|
|
213
|
+
# Like Black, use double quotes for strings.
|
|
214
|
+
quote-style = "double"
|
|
215
|
+
|
|
216
|
+
# Like Black, indent with spaces, rather than tabs.
|
|
217
|
+
indent-style = "space"
|
|
218
|
+
|
|
219
|
+
# Like Black, respect magic trailing commas.
|
|
220
|
+
skip-magic-trailing-comma = false
|
|
221
|
+
|
|
222
|
+
# Like Black, automatically detect the appropriate line ending.
|
|
223
|
+
line-ending = "auto"
|
|
224
|
+
|
|
225
|
+
# Enable auto-formatting of code examples in docstrings. Markdown,
|
|
226
|
+
# reStructuredText code/literal blocks and doctests are all supported.
|
|
227
|
+
#
|
|
228
|
+
# This is currently disabled by default, but it is planned for this
|
|
229
|
+
# to be opt-out in the future.
|
|
230
|
+
docstring-code-format = true
|
|
231
|
+
|
|
232
|
+
# Set the line length limit used when formatting code snippets in
|
|
233
|
+
# docstrings.
|
|
234
|
+
#
|
|
235
|
+
# This only has an effect when the `docstring-code-format` setting is
|
|
236
|
+
# enabled.
|
|
237
|
+
docstring-code-line-length = "dynamic"
|
|
238
|
+
|
|
239
|
+
[tool.mypy]
|
|
240
|
+
disallow_untyped_calls = true
|
|
241
|
+
disallow_untyped_defs = true
|
|
242
|
+
follow_imports = "skip"
|
|
243
|
+
no_implicit_optional = true
|
|
244
|
+
show_column_numbers = true
|
|
245
|
+
warn_no_return = true
|
|
246
|
+
|
|
247
|
+
[tool.isort]
|
|
248
|
+
extend_skip = [".gitignore", ".pylintrc", "sonar-project.properties"]
|
|
249
|
+
|
|
250
|
+
[tool.semantic_release]
|
|
251
|
+
version_toml = ["pyproject.toml:project.version"] # changelog file
|
|
252
|
+
tag_format = "v{version}"
|
|
253
|
+
upload_to_vcs_release = true
|
|
254
|
+
|
|
255
|
+
[tool.semantic_release.changelog]
|
|
256
|
+
# Recommended patterns for conventional commits parser that is scope aware
|
|
257
|
+
exclude_commit_patterns = [
|
|
258
|
+
'''chore(?:\([^)]*?\))?: .+''',
|
|
259
|
+
'''ci(?:\([^)]*?\))?: .+''',
|
|
260
|
+
'''refactor(?:\([^)]*?\))?: .+''',
|
|
261
|
+
'''style(?:\([^)]*?\))?: .+''',
|
|
262
|
+
'''test(?:\([^)]*?\))?: .+''',
|
|
263
|
+
'''build\((?!deps\): .+)''',
|
|
264
|
+
'''Initial [Cc]ommit.*''',
|
|
265
|
+
]
|
|
266
|
+
mode = "update"
|
|
267
|
+
insertion_flag = "..\n All versions below are listed in reverse chronological order"
|
|
268
|
+
|
|
269
|
+
[tool.semantic_release.changelog.default_templates]
|
|
270
|
+
changelog_file = "mkdocs/docs/Changelog.md"
|
|
271
|
+
output_format = "md"
|
|
272
|
+
|
|
273
|
+
[tool.semantic_release.branches.main]
|
|
274
|
+
match = "(main|master)"
|
|
275
|
+
prerelease = false
|
|
276
|
+
|
|
277
|
+
[tool.semantic_release.commit_parser_options]
|
|
278
|
+
minor_tags = ["feat"]
|
|
279
|
+
patch_tags = [
|
|
280
|
+
"fix",
|
|
281
|
+
"perf",
|
|
282
|
+
"refactor",
|
|
283
|
+
"docs",
|
|
284
|
+
"style",
|
|
285
|
+
"test",
|
|
286
|
+
"chore",
|
|
287
|
+
"ci",
|
|
288
|
+
"build",
|
|
289
|
+
]
|
|
290
|
+
other_allowed_tags = [
|
|
291
|
+
"build",
|
|
292
|
+
"chore",
|
|
293
|
+
"ci",
|
|
294
|
+
"docs",
|
|
295
|
+
"style",
|
|
296
|
+
"refactor",
|
|
297
|
+
"test",
|
|
298
|
+
]
|
|
299
|
+
allowed_tags = [
|
|
300
|
+
"feat",
|
|
301
|
+
"fix",
|
|
302
|
+
"perf",
|
|
303
|
+
"build",
|
|
304
|
+
"chore",
|
|
305
|
+
"ci",
|
|
306
|
+
"docs",
|
|
307
|
+
"style",
|
|
308
|
+
"refactor",
|
|
309
|
+
"test",
|
|
310
|
+
]
|
|
311
|
+
default_bump_level = 0
|
|
312
|
+
parse_squash_commits = true
|
|
313
|
+
ignore_merge_commits = true
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
[tool.poe.tasks]
|
|
317
|
+
analyse-coverage = [
|
|
318
|
+
"coverage",
|
|
319
|
+
{ shell = "coverage xml -o coverage-report.xml", help = "Generate coverage for sonar qube" },
|
|
320
|
+
]
|
|
321
|
+
build = "uv build"
|
|
322
|
+
check-format = { cmd = "ruff format --check src test examples", help = "Check code format compliance" }
|
|
323
|
+
check-hook = "pre-commit run --all-files"
|
|
324
|
+
check-lint = { cmd = "ruff check src test ", help = "run static analysis checks" }
|
|
325
|
+
check-sort-imports = { cmd = "isort . --sg=old --check-only --profile black", help = "check imports are sorted" }
|
|
326
|
+
check-static-analysis = ["check-lint", "check-types"]
|
|
327
|
+
check-style = ["check-sort-imports", "check-format"]
|
|
328
|
+
check-types = { cmd = "mypy -p src --ignore-missing-imports", help = "check type hint annotations" }
|
|
329
|
+
coverage = { shell = "pytest test -m 'not slow and not serial' -n auto --cov-report xml --cov=mother test --junit-xml=xunit-test.xml", help = "Generate coverage report (xml)" }
|
|
330
|
+
dist-test = [
|
|
331
|
+
"build",
|
|
332
|
+
{ shell = "cd dist && ../test/test-dist.bash `uv run --with tomli python -c \"import tomli; print('mother_ml-' + tomli.load(open('../pyproject.toml','rb'))['project']['version'] + '-py3-none-any.whl')\"`", help = "check build package in its own environment" },
|
|
333
|
+
]
|
|
334
|
+
docs = { shell = "cd mkdocs; mkdocs build", help = "Build documentation" }
|
|
335
|
+
format = { cmd = "ruff format src test examples", help = "Perform code style format" }
|
|
336
|
+
install-hook = "pre-commit install"
|
|
337
|
+
lint = { cmd = "ruff check src test --fix", help = "Run linter on src and test folder" }
|
|
338
|
+
serve-coverage = [
|
|
339
|
+
"coverage",
|
|
340
|
+
{ shell = "coverage html -d coverage-html && cd coverage-html; python -m http.server --bind 127.0.0.1", help = "Generate coverage html report" },
|
|
341
|
+
]
|
|
342
|
+
serve-docs = { shell = "cd mkdocs; JUPYTER_PLATFORM_DIRS=1 mkdocs serve", help = "Serve project html documentation" }
|
|
343
|
+
sort-imports = { cmd = "isort . --sg=old --profile black", help = "apply import sort ordering" }
|
|
344
|
+
style = ["sort-imports", "format"]
|
|
345
|
+
test-unit = { shell = "pytest test -m 'not slow and not serial' -n auto && pytest test -m 'serial and not slow' -n 0" }
|
|
346
|
+
test-slow = { shell = "pytest test -m 'slow' -n auto" }
|
|
347
|
+
|
|
348
|
+
[build-system]
|
|
349
|
+
requires = ["uv_build>=0.11.1,<0.12.0","setuptools>=76.0.0"]
|
|
350
|
+
build-backend = "uv_build"
|
|
351
|
+
|
|
352
|
+
[tool.uv.build-backend]
|
|
353
|
+
module-name = "mother"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""
|
|
2
|
+
A description of the package
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from single_source import VersionNotFoundError, get_version
|
|
8
|
+
|
|
9
|
+
# from mother.feature_generation.core import FeatureGenerator
|
|
10
|
+
|
|
11
|
+
path_to_pyproject_dir = Path(__file__).parent.parent
|
|
12
|
+
try:
|
|
13
|
+
__version__ = get_version(__name__, path_to_pyproject_dir, fail=True)
|
|
14
|
+
except VersionNotFoundError:
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class MotherModelException(Exception):
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class MotherUnsupportedFeature(Exception):
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class MotherPreprocessingException(Exception):
|
|
27
|
+
pass
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import io
|
|
2
|
+
import logging
|
|
3
|
+
import re
|
|
4
|
+
import sys
|
|
5
|
+
import typing
|
|
6
|
+
from functools import lru_cache
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
import numpy.typing as npt
|
|
10
|
+
from rdkit import Chem, rdBase
|
|
11
|
+
from rdkit.Chem import rdMolDescriptors
|
|
12
|
+
|
|
13
|
+
module_logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@lru_cache
|
|
17
|
+
def maccs(mol: Chem.Mol) -> np.ndarray:
|
|
18
|
+
"""
|
|
19
|
+
Generates MACCS fingerprint for a molecule and finds atom indices
|
|
20
|
+
for non-zero fingerprint bits
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
mol
|
|
25
|
+
rdkit.Chem.Mol Molecule to generate MACCS fingerprint
|
|
26
|
+
maccs_col
|
|
27
|
+
string denoting the column for MACCS
|
|
28
|
+
|
|
29
|
+
Returns
|
|
30
|
+
-------
|
|
31
|
+
np.ndarray of the fingerprint
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
fingerprint: npt.NDArray
|
|
35
|
+
with RaiseRDKitErrors():
|
|
36
|
+
fingerprint = np.array(rdMolDescriptors.GetMACCSKeysFingerprint(mol))
|
|
37
|
+
|
|
38
|
+
return fingerprint
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@lru_cache
|
|
42
|
+
def calculate_descriptor(func: typing.Callable, mol: Chem.Mol) -> typing.Union[np.int32, np.float32]:
|
|
43
|
+
"""
|
|
44
|
+
Runs a rdkit descriptor function for a molecule
|
|
45
|
+
|
|
46
|
+
Parameters
|
|
47
|
+
----------
|
|
48
|
+
func: function object to run
|
|
49
|
+
mol: rdkit.Chem.Mol Molecule
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
The calculated value for the descriptor
|
|
54
|
+
|
|
55
|
+
"""
|
|
56
|
+
with RaiseRDKitErrors():
|
|
57
|
+
result = func(mol)
|
|
58
|
+
|
|
59
|
+
# Mitigating infinite values
|
|
60
|
+
result = np.nan if np.isinf(result) else result
|
|
61
|
+
|
|
62
|
+
# Mitigating values higher or lower than 32 bit float
|
|
63
|
+
# this is due the oddities in
|
|
64
|
+
# "imputer = SimpleImputer(missing_values=np.nan, strategy='constant', fill_value=np.finfo(np.float64).min)"
|
|
65
|
+
# because this is setting nan values to the minimum of float64, thus to
|
|
66
|
+
# float_info = np.finfo(np.float32)
|
|
67
|
+
# result = float_info.max if result > float_info.max else result
|
|
68
|
+
# result = float_info.min if result < float_info.min else result
|
|
69
|
+
|
|
70
|
+
return result
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class RDKitException(Exception):
|
|
74
|
+
pass
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class RaiseRDKitErrors:
|
|
78
|
+
"""
|
|
79
|
+
Context manager to raise RDKitExceptions when rdkit is failing with
|
|
80
|
+
a semi silent "None" and a message on stderr.
|
|
81
|
+
|
|
82
|
+
Examples
|
|
83
|
+
--------
|
|
84
|
+
>>> import rdkit.Chem
|
|
85
|
+
>>> with RaiseRDKitErrors():
|
|
86
|
+
>>> rdkit.Chem.MolFromSmiles(r"CHC")
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
def __init__(self) -> None:
|
|
90
|
+
self.saved_stderr = None
|
|
91
|
+
self.stderr = None
|
|
92
|
+
|
|
93
|
+
def __enter__(self) -> None:
|
|
94
|
+
self.saved_stderr = sys.stderr
|
|
95
|
+
self.stderr = sys.stderr = io.StringIO()
|
|
96
|
+
rdBase.LogToPythonStderr()
|
|
97
|
+
|
|
98
|
+
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
|
|
99
|
+
sys.stderr = self.saved_stderr
|
|
100
|
+
stderr = self.stderr.getvalue()
|
|
101
|
+
keywords: typing.List[str] = ["error", "can't"] # List of keywords to search for
|
|
102
|
+
if stderr != "":
|
|
103
|
+
if any(keyword in stderr.lower() for keyword in keywords): # Check for any keyword in stderr
|
|
104
|
+
raise RDKitException(self.clean_error_msg(stderr))
|
|
105
|
+
elif "warning" in stderr.lower():
|
|
106
|
+
module_logger.warning(stderr)
|
|
107
|
+
else:
|
|
108
|
+
module_logger.debug(stderr)
|
|
109
|
+
|
|
110
|
+
@staticmethod
|
|
111
|
+
def clean_error_msg(stderr) -> str:
|
|
112
|
+
regex = re.compile(r"(\[\d\d:\d\d:\d\d]\s?)")
|
|
113
|
+
stderr = regex.sub("", stderr)
|
|
114
|
+
stderr = stderr.replace("\n", " ")
|
|
115
|
+
stderr = stderr.strip()
|
|
116
|
+
return stderr
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def handle_rdkit_exception(col_id: typing.Any, name: str, exception: RDKitException) -> None:
|
|
120
|
+
"""
|
|
121
|
+
Handles rdkit exceptions by logging, appending them to the error column
|
|
122
|
+
and setting the success column to false
|
|
123
|
+
|
|
124
|
+
Parameters
|
|
125
|
+
----------
|
|
126
|
+
row: pd.DataFrame row with a column containing success and error columns as labeled by cols
|
|
127
|
+
name: str Prefix for the error message (usually name of the offending function)
|
|
128
|
+
cols: ColumnNames object
|
|
129
|
+
exception: the raised mother.chem.RDKitException
|
|
130
|
+
|
|
131
|
+
Returns
|
|
132
|
+
-------
|
|
133
|
+
pd.Series with the updated column
|
|
134
|
+
|
|
135
|
+
"""
|
|
136
|
+
msg = f"{name} failed for compound {col_id}: {exception}"
|
|
137
|
+
module_logger.error(msg)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from mother.cv.config import (
|
|
2
|
+
CVSettings,
|
|
3
|
+
CVtype,
|
|
4
|
+
GenericCVModel,
|
|
5
|
+
TanimotoSimilarityParams,
|
|
6
|
+
TimeSeriesParams,
|
|
7
|
+
)
|
|
8
|
+
from mother.cv.core import DefaultGrouping, TanimotoGroupingFromMols, TimeSeriesGrouping
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"TanimotoSimilarityParams",
|
|
12
|
+
"TanimotoGroupingFromMols",
|
|
13
|
+
"CVtype",
|
|
14
|
+
"GenericCVModel",
|
|
15
|
+
"CVSettings",
|
|
16
|
+
"TimeSeriesParams",
|
|
17
|
+
"TimeSeriesGrouping",
|
|
18
|
+
"DefaultGrouping",
|
|
19
|
+
]
|