fpembed 0.1.3__tar.gz → 0.1.4__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.
- {fpembed-0.1.3/src/fpembed.egg-info → fpembed-0.1.4}/PKG-INFO +7 -3
- {fpembed-0.1.3 → fpembed-0.1.4}/README.md +5 -1
- {fpembed-0.1.3 → fpembed-0.1.4}/pyproject.toml +2 -2
- {fpembed-0.1.3 → fpembed-0.1.4}/src/fpembed/__init__.py +1 -1
- {fpembed-0.1.3 → fpembed-0.1.4}/src/fpembed/generator.py +28 -2
- {fpembed-0.1.3 → fpembed-0.1.4/src/fpembed.egg-info}/PKG-INFO +7 -3
- {fpembed-0.1.3 → fpembed-0.1.4}/src/fpembed.egg-info/requires.txt +1 -1
- {fpembed-0.1.3 → fpembed-0.1.4}/tests/test_generator.py +47 -1
- {fpembed-0.1.3 → fpembed-0.1.4}/LICENSE +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/setup.cfg +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/src/fpembed/compression.py +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/src/fpembed/compression_blockwise.py +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/src/fpembed/compression_projection.py +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/src/fpembed/hashing.py +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/src/fpembed/py.typed +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/src/fpembed/smiles_utils.py +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/src/fpembed.egg-info/SOURCES.txt +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/src/fpembed.egg-info/dependency_links.txt +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/src/fpembed.egg-info/top_level.txt +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/tests/test_cache.py +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/tests/test_compression.py +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/tests/test_compression_blockwise.py +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/tests/test_compression_projection.py +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/tests/test_fingerprints.py +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/tests/test_hashing.py +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/tests/test_properties.py +0 -0
- {fpembed-0.1.3 → fpembed-0.1.4}/tests/test_smiles_utils.py +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fpembed
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: Generalized fingerprint embedding library
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Requires-Python: >=3.9
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
License-File: LICENSE
|
|
9
|
-
Requires-Dist: scikit-fingerprints
|
|
9
|
+
Requires-Dist: scikit-fingerprints==2.0.0
|
|
10
10
|
Requires-Dist: selfies>=2.2.0
|
|
11
11
|
Provides-Extra: app
|
|
12
12
|
Requires-Dist: nicegui>=3.8.0; extra == "app"
|
|
@@ -20,7 +20,7 @@ Dynamic: license-file
|
|
|
20
20
|
|
|
21
21
|
# FPembed - Generalized Molecular Fingerprint Embeddings
|
|
22
22
|
|
|
23
|
-
A lightweight Python package for generating compressed molecular fingerprint embeddings, backed by [scikit-fingerprints](https://github.com/scikit-fingerprints/scikit-fingerprints). Supports
|
|
23
|
+
A lightweight Python package for generating compressed molecular fingerprint embeddings, backed by [scikit-fingerprints](https://github.com/scikit-fingerprints/scikit-fingerprints). Supports ten binary fingerprint types through a single unified class.
|
|
24
24
|
|
|
25
25
|
FPembed compresses standard molecular fingerprints using weighted binary masking, producing compact float vectors suitable for machine-learning models. The package accepts SMILES, SELFIES, and RDKit Mol objects as input.
|
|
26
26
|
|
|
@@ -53,6 +53,10 @@ Original concept repository: [MMLabCodes/eMFP](https://github.com/MMLabCodes/eMF
|
|
|
53
53
|
| RDKit | `rdkit` | `min_path` (1), `max_path` (7) |
|
|
54
54
|
| Layered | `layered` | `min_path` (1), `max_path` (7) |
|
|
55
55
|
| Pattern | `pattern` | (none) |
|
|
56
|
+
| Avalon | `avalon` | (none) |
|
|
57
|
+
| SECFP | `secfp` | `radius` (default 3) |
|
|
58
|
+
| MHFP | `mhfp` | `radius` (default 3) |
|
|
59
|
+
| MAP4 | `map` | `radius` (default 2) |
|
|
56
60
|
|
|
57
61
|
## Compression Methods
|
|
58
62
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# FPembed - Generalized Molecular Fingerprint Embeddings
|
|
2
2
|
|
|
3
|
-
A lightweight Python package for generating compressed molecular fingerprint embeddings, backed by [scikit-fingerprints](https://github.com/scikit-fingerprints/scikit-fingerprints). Supports
|
|
3
|
+
A lightweight Python package for generating compressed molecular fingerprint embeddings, backed by [scikit-fingerprints](https://github.com/scikit-fingerprints/scikit-fingerprints). Supports ten binary fingerprint types through a single unified class.
|
|
4
4
|
|
|
5
5
|
FPembed compresses standard molecular fingerprints using weighted binary masking, producing compact float vectors suitable for machine-learning models. The package accepts SMILES, SELFIES, and RDKit Mol objects as input.
|
|
6
6
|
|
|
@@ -33,6 +33,10 @@ Original concept repository: [MMLabCodes/eMFP](https://github.com/MMLabCodes/eMF
|
|
|
33
33
|
| RDKit | `rdkit` | `min_path` (1), `max_path` (7) |
|
|
34
34
|
| Layered | `layered` | `min_path` (1), `max_path` (7) |
|
|
35
35
|
| Pattern | `pattern` | (none) |
|
|
36
|
+
| Avalon | `avalon` | (none) |
|
|
37
|
+
| SECFP | `secfp` | `radius` (default 3) |
|
|
38
|
+
| MHFP | `mhfp` | `radius` (default 3) |
|
|
39
|
+
| MAP4 | `map` | `radius` (default 2) |
|
|
36
40
|
|
|
37
41
|
## Compression Methods
|
|
38
42
|
|
|
@@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "fpembed"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.4"
|
|
8
8
|
description = "Generalized fingerprint embedding library"
|
|
9
9
|
requires-python = ">=3.9"
|
|
10
10
|
dependencies = [
|
|
11
|
-
"scikit-fingerprints
|
|
11
|
+
"scikit-fingerprints==2.0.0",
|
|
12
12
|
"selfies>=2.2.0",
|
|
13
13
|
]
|
|
14
14
|
readme = "README.md"
|
|
@@ -20,7 +20,7 @@ from fpembed.compression import compress_fingerprint
|
|
|
20
20
|
from fpembed.smiles_utils import parse_smiles, canonicalize_smiles
|
|
21
21
|
from fpembed.hashing import fp_params_hash
|
|
22
22
|
|
|
23
|
-
__version__ = "0.1.
|
|
23
|
+
__version__ = "0.1.4"
|
|
24
24
|
|
|
25
25
|
__all__ = [
|
|
26
26
|
"EmbeddedFingerprintGenerator",
|
|
@@ -11,10 +11,14 @@ import numpy.typing as npt
|
|
|
11
11
|
from rdkit import Chem
|
|
12
12
|
from skfp.fingerprints import (
|
|
13
13
|
AtomPairFingerprint,
|
|
14
|
+
AvalonFingerprint,
|
|
14
15
|
ECFPFingerprint,
|
|
15
16
|
LayeredFingerprint,
|
|
17
|
+
MAPFingerprint,
|
|
18
|
+
MHFPFingerprint,
|
|
16
19
|
PatternFingerprint,
|
|
17
20
|
RDKitFingerprint,
|
|
21
|
+
SECFPFingerprint,
|
|
18
22
|
TopologicalTorsionFingerprint,
|
|
19
23
|
)
|
|
20
24
|
|
|
@@ -22,6 +26,8 @@ from fpembed.compression import (
|
|
|
22
26
|
compress_fingerprint,
|
|
23
27
|
_is_power_of_two,
|
|
24
28
|
_ALL_METHODS,
|
|
29
|
+
_BLOCKWISE_METHODS,
|
|
30
|
+
_VALID_PARAMS,
|
|
25
31
|
_validate_method_params,
|
|
26
32
|
_DEFAULT_SEED,
|
|
27
33
|
)
|
|
@@ -42,6 +48,7 @@ _EMPTY_CACHE_INFO = CacheInfo(hits=0, misses=0, maxsize=0, currsize=0)
|
|
|
42
48
|
|
|
43
49
|
_SUPPORTED_FP_TYPES = (
|
|
44
50
|
"ecfp", "atom_pair", "topological_torsion", "rdkit", "layered", "pattern",
|
|
51
|
+
"avalon", "secfp", "mhfp", "map",
|
|
45
52
|
)
|
|
46
53
|
|
|
47
54
|
|
|
@@ -74,14 +81,33 @@ def _build_skfp(fp_type: str, fp_size: int, fp_params: dict) -> Any:
|
|
|
74
81
|
fp_size=fp_size, min_path=fp_params.get("min_path", 1),
|
|
75
82
|
max_path=fp_params.get("max_path", 7), n_jobs=1,
|
|
76
83
|
)
|
|
84
|
+
if fp_type == "avalon":
|
|
85
|
+
return AvalonFingerprint(fp_size=fp_size, count=False, n_jobs=1)
|
|
86
|
+
if fp_type == "secfp":
|
|
87
|
+
return SECFPFingerprint(
|
|
88
|
+
fp_size=fp_size, radius=fp_params.get("radius", 3),
|
|
89
|
+
min_radius=fp_params.get("min_radius", 1), n_jobs=1,
|
|
90
|
+
)
|
|
91
|
+
if fp_type == "mhfp":
|
|
92
|
+
return MHFPFingerprint(
|
|
93
|
+
fp_size=fp_size, radius=fp_params.get("radius", 3),
|
|
94
|
+
min_radius=fp_params.get("min_radius", 1),
|
|
95
|
+
variant="bit", n_jobs=1,
|
|
96
|
+
)
|
|
97
|
+
if fp_type == "map":
|
|
98
|
+
return MAPFingerprint(
|
|
99
|
+
fp_size=fp_size, radius=fp_params.get("radius", 2),
|
|
100
|
+
variant="binary", n_jobs=1,
|
|
101
|
+
)
|
|
77
102
|
return PatternFingerprint(fp_size=fp_size, n_jobs=1)
|
|
78
103
|
|
|
79
104
|
|
|
80
105
|
class EmbeddedFingerprintGenerator:
|
|
81
106
|
"""Unified fingerprint generator backed by scikit-fingerprints.
|
|
82
107
|
|
|
83
|
-
Supports
|
|
84
|
-
rdkit, layered, pattern
|
|
108
|
+
Supports ten fp_types: ecfp, atom_pair, topological_torsion,
|
|
109
|
+
rdkit, layered, pattern, avalon, secfp, mhfp, map.
|
|
110
|
+
Compression via log-space weighted mask.
|
|
85
111
|
"""
|
|
86
112
|
|
|
87
113
|
__slots__ = (
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fpembed
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: Generalized fingerprint embedding library
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Requires-Python: >=3.9
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
License-File: LICENSE
|
|
9
|
-
Requires-Dist: scikit-fingerprints
|
|
9
|
+
Requires-Dist: scikit-fingerprints==2.0.0
|
|
10
10
|
Requires-Dist: selfies>=2.2.0
|
|
11
11
|
Provides-Extra: app
|
|
12
12
|
Requires-Dist: nicegui>=3.8.0; extra == "app"
|
|
@@ -20,7 +20,7 @@ Dynamic: license-file
|
|
|
20
20
|
|
|
21
21
|
# FPembed - Generalized Molecular Fingerprint Embeddings
|
|
22
22
|
|
|
23
|
-
A lightweight Python package for generating compressed molecular fingerprint embeddings, backed by [scikit-fingerprints](https://github.com/scikit-fingerprints/scikit-fingerprints). Supports
|
|
23
|
+
A lightweight Python package for generating compressed molecular fingerprint embeddings, backed by [scikit-fingerprints](https://github.com/scikit-fingerprints/scikit-fingerprints). Supports ten binary fingerprint types through a single unified class.
|
|
24
24
|
|
|
25
25
|
FPembed compresses standard molecular fingerprints using weighted binary masking, producing compact float vectors suitable for machine-learning models. The package accepts SMILES, SELFIES, and RDKit Mol objects as input.
|
|
26
26
|
|
|
@@ -53,6 +53,10 @@ Original concept repository: [MMLabCodes/eMFP](https://github.com/MMLabCodes/eMF
|
|
|
53
53
|
| RDKit | `rdkit` | `min_path` (1), `max_path` (7) |
|
|
54
54
|
| Layered | `layered` | `min_path` (1), `max_path` (7) |
|
|
55
55
|
| Pattern | `pattern` | (none) |
|
|
56
|
+
| Avalon | `avalon` | (none) |
|
|
57
|
+
| SECFP | `secfp` | `radius` (default 3) |
|
|
58
|
+
| MHFP | `mhfp` | `radius` (default 3) |
|
|
59
|
+
| MAP4 | `map` | `radius` (default 2) |
|
|
56
60
|
|
|
57
61
|
## Compression Methods
|
|
58
62
|
|
|
@@ -17,7 +17,12 @@ VALID_SMILES = [
|
|
|
17
17
|
]
|
|
18
18
|
INVALID_SMILES = ["not_a_molecule", "XYZ123", "C(C(C", "12345"]
|
|
19
19
|
VALID_SELFIES = ["[C][C][O]", "[C][=C][C][=C][C][=C][Ring1][=Branch1]", "[C][C][=Branch1][C][=O][O]"]
|
|
20
|
-
|
|
20
|
+
# @spec:049-T04.1
|
|
21
|
+
# @spec:049-T04.3
|
|
22
|
+
FP_TYPES = [
|
|
23
|
+
"ecfp", "atom_pair", "topological_torsion", "rdkit", "layered", "pattern",
|
|
24
|
+
"avalon", "secfp", "mhfp", "map",
|
|
25
|
+
]
|
|
21
26
|
|
|
22
27
|
|
|
23
28
|
# ===================================================================
|
|
@@ -114,6 +119,47 @@ class TestConstruction:
|
|
|
114
119
|
assert gen._projection_cache is None
|
|
115
120
|
|
|
116
121
|
|
|
122
|
+
# ===================================================================
|
|
123
|
+
# New fingerprint types — targeted tests
|
|
124
|
+
# @spec:049-T04.2
|
|
125
|
+
# ===================================================================
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class TestNewFingerprintTypes:
|
|
129
|
+
@pytest.mark.fast
|
|
130
|
+
def test_avalon_no_params(self) -> None:
|
|
131
|
+
"""Avalon with empty fp_params produces valid output."""
|
|
132
|
+
gen = EmbeddedFingerprintGenerator(fp_type="avalon", fp_size=2048, compression=16, fp_params={})
|
|
133
|
+
mol = Chem.MolFromSmiles("CCO")
|
|
134
|
+
fp = gen.GetFingerprintAsNumPy(mol)
|
|
135
|
+
assert fp.shape == (128,)
|
|
136
|
+
assert fp.dtype == np.float64
|
|
137
|
+
|
|
138
|
+
@pytest.mark.fast
|
|
139
|
+
def test_secfp_custom_radius(self) -> None:
|
|
140
|
+
"""Non-default radius is actually passed through to the skfp instance."""
|
|
141
|
+
gen = EmbeddedFingerprintGenerator(
|
|
142
|
+
fp_type="secfp", fp_size=2048, compression=16, fp_params={"radius": 4}
|
|
143
|
+
)
|
|
144
|
+
assert gen._skfp_fp.radius == 4
|
|
145
|
+
|
|
146
|
+
@pytest.mark.fast
|
|
147
|
+
def test_mhfp_variant_hardcoded(self) -> None:
|
|
148
|
+
"""variant='bit' is hardcoded — user-supplied variant in fp_params is ignored."""
|
|
149
|
+
gen = EmbeddedFingerprintGenerator(
|
|
150
|
+
fp_type="mhfp", fp_size=2048, compression=16, fp_params={"variant": "raw_hashes"}
|
|
151
|
+
)
|
|
152
|
+
assert gen._skfp_fp.variant == "bit"
|
|
153
|
+
|
|
154
|
+
@pytest.mark.fast
|
|
155
|
+
def test_map_variant_hardcoded(self) -> None:
|
|
156
|
+
"""variant='binary' is hardcoded — user-supplied variant in fp_params is ignored."""
|
|
157
|
+
gen = EmbeddedFingerprintGenerator(
|
|
158
|
+
fp_type="map", fp_size=2048, compression=16, fp_params={"variant": "minhash"}
|
|
159
|
+
)
|
|
160
|
+
assert gen._skfp_fp.variant == "binary"
|
|
161
|
+
|
|
162
|
+
|
|
117
163
|
# ===================================================================
|
|
118
164
|
# Fingerprint methods
|
|
119
165
|
# ===================================================================
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|