PFASGroups 3.2.2__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.
- pfasgroups-3.2.2/HalogenGroups/__init__.py +246 -0
- pfasgroups-3.2.2/PFASGroups/ComponentsSolverModel.py +977 -0
- pfasgroups-3.2.2/PFASGroups/HalogenGroupModel.py +810 -0
- pfasgroups-3.2.2/PFASGroups/PFASDefinitionModel.py +393 -0
- pfasgroups-3.2.2/PFASGroups/PFASEmbeddings.py +3315 -0
- pfasgroups-3.2.2/PFASGroups/__init__.py +21 -0
- pfasgroups-3.2.2/PFASGroups/cli.py +618 -0
- pfasgroups-3.2.2/PFASGroups/core.py +415 -0
- pfasgroups-3.2.2/PFASGroups/data/Halogen_groups_smarts.json +9024 -0
- pfasgroups-3.2.2/PFASGroups/data/PFAS_definitions_smarts.json +170 -0
- pfasgroups-3.2.2/PFASGroups/data/component_smarts.json +4 -0
- pfasgroups-3.2.2/PFASGroups/data/component_smarts_halogens.json +142 -0
- pfasgroups-3.2.2/PFASGroups/data/diatomic_bonds_dict.json +12802 -0
- pfasgroups-3.2.2/PFASGroups/draw_mols.py +374 -0
- pfasgroups-3.2.2/PFASGroups/embeddings.py +150 -0
- pfasgroups-3.2.2/PFASGroups/fragmentation.py +548 -0
- pfasgroups-3.2.2/PFASGroups/generate_homologues.py +256 -0
- pfasgroups-3.2.2/PFASGroups/generate_mol.py +656 -0
- pfasgroups-3.2.2/PFASGroups/generate_paper_figures.py +266 -0
- pfasgroups-3.2.2/PFASGroups/getter.py +111 -0
- pfasgroups-3.2.2/PFASGroups/homologue_series.py +473 -0
- pfasgroups-3.2.2/PFASGroups/parser.py +942 -0
- pfasgroups-3.2.2/PFASGroups/prioritise.py +439 -0
- pfasgroups-3.2.2/PFASGroups.egg-info/PKG-INFO +724 -0
- pfasgroups-3.2.2/PFASGroups.egg-info/SOURCES.txt +58 -0
- pfasgroups-3.2.2/PFASGroups.egg-info/dependency_links.txt +1 -0
- pfasgroups-3.2.2/PFASGroups.egg-info/entry_points.txt +3 -0
- pfasgroups-3.2.2/PFASGroups.egg-info/requires.txt +15 -0
- pfasgroups-3.2.2/PFASGroups.egg-info/top_level.txt +2 -0
- pfasgroups-3.2.2/PKG-INFO +724 -0
- pfasgroups-3.2.2/README.md +683 -0
- pfasgroups-3.2.2/pyproject.toml +99 -0
- pfasgroups-3.2.2/setup.cfg +14 -0
- pfasgroups-3.2.2/tests/test_bde_resistance.py +356 -0
- pfasgroups-3.2.2/tests/test_component_fractions.py +74 -0
- pfasgroups-3.2.2/tests/test_component_ratios.py +62 -0
- pfasgroups-3.2.2/tests/test_comprehensive_metrics.py +47 -0
- pfasgroups-3.2.2/tests/test_database_integration.py +114 -0
- pfasgroups-3.2.2/tests/test_definition_comparison.py +216 -0
- pfasgroups-3.2.2/tests/test_fingerprints_vs_txppfas.py +883 -0
- pfasgroups-3.2.2/tests/test_fraction_analysis.py +31 -0
- pfasgroups-3.2.2/tests/test_generate_homologues.py +494 -0
- pfasgroups-3.2.2/tests/test_halogen_groups_smarts.py +257 -0
- pfasgroups-3.2.2/tests/test_linker_smarts.py +46 -0
- pfasgroups-3.2.2/tests/test_metrics.py +23 -0
- pfasgroups-3.2.2/tests/test_metrics_detailed.py +26 -0
- pfasgroups-3.2.2/tests/test_n_spacer_ring_size.py +154 -0
- pfasgroups-3.2.2/tests/test_pfasstructv5.py +198 -0
- pfasgroups-3.2.2/tests/test_prioritise.py +442 -0
- pfasgroups-3.2.2/tests/test_readme_and_docs_examples.py +680 -0
- pfasgroups-3.2.2/tests/test_results_fingerprint.py +256 -0
- pfasgroups-3.2.2/tests/test_results_model.py +50 -0
- pfasgroups-3.2.2/tests/test_results_sql.py +450 -0
- pfasgroups-3.2.2/tests/test_run_groups_definitions_tests.py +517 -0
- pfasgroups-3.2.2/tests/test_smarts_atom_count.py +24 -0
- pfasgroups-3.2.2/tests/test_smarts_matching.py +24 -0
- pfasgroups-3.2.2/tests/test_smarts_precompute.py +11 -0
- pfasgroups-3.2.2/tests/test_summary.py +37 -0
- pfasgroups-3.2.2/tests/test_telomer_validation.py +20 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"""HalogenGroups - Multi-halogen analysis package.
|
|
2
|
+
|
|
3
|
+
This package extends PFASGroups to support all halogens (F, Cl, Br, I) by
|
|
4
|
+
default. When imported as ``HalogenGroups``, all public functions default to
|
|
5
|
+
``halogens=['F', 'Cl', 'Br', 'I']``, whereas ``PFASGroups`` defaults to
|
|
6
|
+
``halogens='F'`` (fluorine only).
|
|
7
|
+
|
|
8
|
+
Examples
|
|
9
|
+
--------
|
|
10
|
+
>>> from HalogenGroups import parse_smiles # defaults to all halogens
|
|
11
|
+
>>> from PFASGroups import parse_smiles # defaults to F only
|
|
12
|
+
"""
|
|
13
|
+
import functools
|
|
14
|
+
from typing import Union, List, Optional, Any, Iterable, Dict
|
|
15
|
+
|
|
16
|
+
# ---------------------------------------------------------------------------
|
|
17
|
+
# Re-export everything from PFASGroups that does not need default overriding.
|
|
18
|
+
# ---------------------------------------------------------------------------
|
|
19
|
+
from PFASGroups import (
|
|
20
|
+
HalogenGroup,
|
|
21
|
+
PFASDefinition,
|
|
22
|
+
ComponentsSolver,
|
|
23
|
+
rdkit_disable_log,
|
|
24
|
+
HALOGEN_GROUPS_FILE,
|
|
25
|
+
parse_mol,
|
|
26
|
+
parse_groups_in_mol,
|
|
27
|
+
parse_from_database,
|
|
28
|
+
setup_halogen_groups_database,
|
|
29
|
+
load_HalogenGroups,
|
|
30
|
+
plot_mol,
|
|
31
|
+
plot_mols,
|
|
32
|
+
plot_HalogenGroups,
|
|
33
|
+
get_componentSMARTSs,
|
|
34
|
+
get_HalogenGroups,
|
|
35
|
+
get_compiled_HalogenGroups,
|
|
36
|
+
get_compiled_PFASGroups,
|
|
37
|
+
get_PFASDefinitions,
|
|
38
|
+
generate_homologues,
|
|
39
|
+
HomologueSeries,
|
|
40
|
+
HomologueEntry,
|
|
41
|
+
generate_degradation_products,
|
|
42
|
+
MoleculeResult,
|
|
43
|
+
PFASEmbedding,
|
|
44
|
+
prioritise_molecules,
|
|
45
|
+
prioritize_molecules,
|
|
46
|
+
get_priority_statistics,
|
|
47
|
+
FINGERPRINT_PRESETS,
|
|
48
|
+
EMBEDDING_PRESETS,
|
|
49
|
+
)
|
|
50
|
+
from PFASGroups import (
|
|
51
|
+
parse_smiles as _parse_smiles_base,
|
|
52
|
+
parse_mols as _parse_mols_base,
|
|
53
|
+
PFASEmbeddingSet as _PFASEmbeddingSet,
|
|
54
|
+
generate_fingerprint as _generate_fingerprint_base,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
__version__ = "3.1.0"
|
|
58
|
+
|
|
59
|
+
_ALL_HALOGENS = ['F', 'Cl', 'Br', 'I']
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# ---------------------------------------------------------------------------
|
|
63
|
+
# PFASEmbeddingSet subclass — kept for backward compatibility.
|
|
64
|
+
# halogens are already baked in at parse time; to_array() does not re-parse.
|
|
65
|
+
# ---------------------------------------------------------------------------
|
|
66
|
+
|
|
67
|
+
class PFASEmbeddingSet(_PFASEmbeddingSet):
|
|
68
|
+
"""PFASEmbeddingSet with all-halogens default in to_fingerprint().
|
|
69
|
+
|
|
70
|
+
Identical to ``PFASGroups.PFASEmbeddingSet`` except that the deprecated
|
|
71
|
+
:meth:`to_fingerprint` records that all four halogens were used.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
def to_fingerprint(
|
|
75
|
+
self,
|
|
76
|
+
*,
|
|
77
|
+
group_selection: str = 'all',
|
|
78
|
+
component_metrics: Optional[List[str]] = None,
|
|
79
|
+
selected_group_ids: Optional[List[int]] = None,
|
|
80
|
+
halogens: Optional[Union[str, List[str]]] = None,
|
|
81
|
+
saturation: Optional[str] = 'per',
|
|
82
|
+
molecule_metrics: Optional[List[str]] = None,
|
|
83
|
+
pfas_groups: Optional[List[Dict]] = None,
|
|
84
|
+
preset: Optional[str] = None,
|
|
85
|
+
count_mode: Optional[str] = None,
|
|
86
|
+
graph_metrics: Optional[List[str]] = None,
|
|
87
|
+
**kwargs,
|
|
88
|
+
):
|
|
89
|
+
"""Deprecated — use :meth:`to_array` instead.
|
|
90
|
+
|
|
91
|
+
``halogens`` is accepted for backward compatibility but has no effect:
|
|
92
|
+
the halogen filter is applied at parse time (in :func:`parse_smiles`),
|
|
93
|
+
not at embedding time.
|
|
94
|
+
"""
|
|
95
|
+
return super().to_fingerprint(
|
|
96
|
+
group_selection=group_selection,
|
|
97
|
+
component_metrics=component_metrics,
|
|
98
|
+
selected_group_ids=selected_group_ids,
|
|
99
|
+
halogens=halogens or _ALL_HALOGENS,
|
|
100
|
+
saturation=saturation,
|
|
101
|
+
molecule_metrics=molecule_metrics,
|
|
102
|
+
pfas_groups=pfas_groups,
|
|
103
|
+
preset=preset,
|
|
104
|
+
count_mode=count_mode,
|
|
105
|
+
graph_metrics=graph_metrics,
|
|
106
|
+
**kwargs,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
# Backward-compatible alias
|
|
111
|
+
ResultsModel = PFASEmbeddingSet
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# ---------------------------------------------------------------------------
|
|
115
|
+
# Wrapper functions with all-halogens defaults
|
|
116
|
+
# ---------------------------------------------------------------------------
|
|
117
|
+
|
|
118
|
+
def parse_smiles(smiles, *, bycomponent=False, output_format='list',
|
|
119
|
+
limit_effective_graph_resistance=None,
|
|
120
|
+
compute_component_metrics=True,
|
|
121
|
+
halogens=None, form=None, saturation=None, **kwargs):
|
|
122
|
+
"""Parse SMILES string(s), defaulting to all halogens.
|
|
123
|
+
|
|
124
|
+
Identical to ``PFASGroups.parse_smiles`` except the default for
|
|
125
|
+
``halogens`` is ``None`` (no filter = all halogens: F, Cl, Br, I)
|
|
126
|
+
instead of ``'F'``.
|
|
127
|
+
|
|
128
|
+
Parameters
|
|
129
|
+
----------
|
|
130
|
+
smiles : str or list of str
|
|
131
|
+
halogens : str or list of str or None, default None
|
|
132
|
+
``None`` → all halogens (F, Cl, Br, I).
|
|
133
|
+
Pass ``'F'`` to restrict to fluorine only.
|
|
134
|
+
|
|
135
|
+
See Also
|
|
136
|
+
--------
|
|
137
|
+
PFASGroups.parse_smiles : fluorine-only default version.
|
|
138
|
+
"""
|
|
139
|
+
result = _parse_smiles_base(
|
|
140
|
+
smiles,
|
|
141
|
+
bycomponent=bycomponent,
|
|
142
|
+
output_format=output_format,
|
|
143
|
+
limit_effective_graph_resistance=limit_effective_graph_resistance,
|
|
144
|
+
compute_component_metrics=compute_component_metrics,
|
|
145
|
+
halogens=halogens,
|
|
146
|
+
form=form,
|
|
147
|
+
saturation=saturation,
|
|
148
|
+
**kwargs,
|
|
149
|
+
)
|
|
150
|
+
# Wrap result in HalogenGroups PFASEmbeddingSet so that to_fingerprint()
|
|
151
|
+
# also defaults to all halogens.
|
|
152
|
+
if isinstance(result, _PFASEmbeddingSet):
|
|
153
|
+
return PFASEmbeddingSet(result)
|
|
154
|
+
return result
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def parse_mols(mols, *, output_format='list', include_PFAS_definitions=True,
|
|
158
|
+
limit_effective_graph_resistance=None,
|
|
159
|
+
compute_component_metrics=True,
|
|
160
|
+
halogens=None, form=None, saturation=None, **kwargs):
|
|
161
|
+
"""Parse RDKit molecule(s), defaulting to all halogens.
|
|
162
|
+
|
|
163
|
+
Identical to ``PFASGroups.parse_mols`` except the default for
|
|
164
|
+
``halogens`` is ``None`` (no filter = all halogens: F, Cl, Br, I)
|
|
165
|
+
instead of ``'F'``.
|
|
166
|
+
|
|
167
|
+
Parameters
|
|
168
|
+
----------
|
|
169
|
+
mols : list of rdkit.Chem.Mol
|
|
170
|
+
halogens : str or list of str or None, default None
|
|
171
|
+
``None`` → all halogens (F, Cl, Br, I).
|
|
172
|
+
|
|
173
|
+
See Also
|
|
174
|
+
--------
|
|
175
|
+
PFASGroups.parse_mols : fluorine-only default version.
|
|
176
|
+
"""
|
|
177
|
+
result = _parse_mols_base(
|
|
178
|
+
mols,
|
|
179
|
+
output_format=output_format,
|
|
180
|
+
include_PFAS_definitions=include_PFAS_definitions,
|
|
181
|
+
limit_effective_graph_resistance=limit_effective_graph_resistance,
|
|
182
|
+
compute_component_metrics=compute_component_metrics,
|
|
183
|
+
halogens=halogens,
|
|
184
|
+
form=form,
|
|
185
|
+
saturation=saturation,
|
|
186
|
+
**kwargs,
|
|
187
|
+
)
|
|
188
|
+
if isinstance(result, _PFASEmbeddingSet):
|
|
189
|
+
return PFASEmbeddingSet(result)
|
|
190
|
+
return result
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def generate_fingerprint(smiles, *, selected_groups=None, representation='vector',
|
|
194
|
+
component_metrics=None,
|
|
195
|
+
halogens: Optional[Union[str, List[str]]] = None,
|
|
196
|
+
saturation: Optional[str] = 'per',
|
|
197
|
+
count_mode=None,
|
|
198
|
+
**kwargs):
|
|
199
|
+
"""Generate halogen-group fingerprints, defaulting to all halogens.
|
|
200
|
+
|
|
201
|
+
Identical to ``PFASGroups.generate_fingerprint`` except the default for
|
|
202
|
+
``halogens`` is ``['F', 'Cl', 'Br', 'I']`` (stacked vector) instead of
|
|
203
|
+
``'F'``.
|
|
204
|
+
|
|
205
|
+
Parameters
|
|
206
|
+
----------
|
|
207
|
+
smiles : str or list of str
|
|
208
|
+
halogens : str or list of str, default ['F', 'Cl', 'Br', 'I']
|
|
209
|
+
Halogens to include.
|
|
210
|
+
|
|
211
|
+
See Also
|
|
212
|
+
--------
|
|
213
|
+
PFASGroups.generate_fingerprint : fluorine-only default version.
|
|
214
|
+
"""
|
|
215
|
+
if halogens is None:
|
|
216
|
+
halogens = _ALL_HALOGENS
|
|
217
|
+
return _generate_fingerprint_base(
|
|
218
|
+
smiles,
|
|
219
|
+
selected_groups=selected_groups,
|
|
220
|
+
representation=representation,
|
|
221
|
+
component_metrics=component_metrics,
|
|
222
|
+
halogens=halogens,
|
|
223
|
+
saturation=saturation,
|
|
224
|
+
count_mode=count_mode,
|
|
225
|
+
**kwargs,
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
# ---------------------------------------------------------------------------
|
|
230
|
+
# __all__
|
|
231
|
+
# ---------------------------------------------------------------------------
|
|
232
|
+
__all__ = [
|
|
233
|
+
'HalogenGroup', 'PFASDefinition', 'ComponentsSolver',
|
|
234
|
+
'rdkit_disable_log', 'HALOGEN_GROUPS_FILE',
|
|
235
|
+
'parse_smiles', 'parse_mols', 'parse_mol', 'parse_groups_in_mol',
|
|
236
|
+
'parse_from_database', 'setup_halogen_groups_database', 'load_HalogenGroups',
|
|
237
|
+
'plot_HalogenGroups', 'plot_mol', 'plot_mols',
|
|
238
|
+
'get_componentSMARTSs', 'get_HalogenGroups', 'get_compiled_HalogenGroups',
|
|
239
|
+
'get_compiled_PFASGroups', 'get_PFASDefinitions',
|
|
240
|
+
'generate_fingerprint',
|
|
241
|
+
'FINGERPRINT_PRESETS', 'EMBEDDING_PRESETS',
|
|
242
|
+
'generate_homologues', 'HomologueSeries', 'HomologueEntry',
|
|
243
|
+
'generate_degradation_products',
|
|
244
|
+
'PFASEmbedding', 'PFASEmbeddingSet', 'ResultsModel', 'MoleculeResult',
|
|
245
|
+
'prioritise_molecules', 'prioritize_molecules', 'get_priority_statistics',
|
|
246
|
+
]
|