chython 2.19__cp313-cp313-win_amd64.whl
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.
- chython/__init__.py +35 -0
- chython/_functions.py +95 -0
- chython/_java.py +57 -0
- chython/algorithms/__init__.py +18 -0
- chython/algorithms/_isomorphism.cp313-win_amd64.pyd +0 -0
- chython/algorithms/_isomorphism.pyx +189 -0
- chython/algorithms/_rings.cp313-win_amd64.pyd +0 -0
- chython/algorithms/_rings.pyx +478 -0
- chython/algorithms/aromatics/__init__.py +27 -0
- chython/algorithms/aromatics/_rules.py +124 -0
- chython/algorithms/aromatics/kekule.py +532 -0
- chython/algorithms/aromatics/test/__init__.py +18 -0
- chython/algorithms/aromatics/test/test_kekule.py +160 -0
- chython/algorithms/aromatics/test/test_thiele.py +263 -0
- chython/algorithms/aromatics/thiele.py +222 -0
- chython/algorithms/calculate2d/__init__.py +23 -0
- chython/algorithms/calculate2d/clean2d.js +1 -0
- chython/algorithms/calculate2d/molecule.py +191 -0
- chython/algorithms/calculate2d/reaction.py +75 -0
- chython/algorithms/conformers.py +106 -0
- chython/algorithms/depict.py +596 -0
- chython/algorithms/fingerprints/__init__.py +43 -0
- chython/algorithms/fingerprints/linear.py +202 -0
- chython/algorithms/fingerprints/morgan.py +132 -0
- chython/algorithms/fingerprints/test/__init__.py +18 -0
- chython/algorithms/fingerprints/test/test_linear.py +127 -0
- chython/algorithms/fingerprints/test/test_morgan.py +79 -0
- chython/algorithms/groups/__init__.py +212 -0
- chython/algorithms/groups/_functional.py +290 -0
- chython/algorithms/groups/_oxidations.py +70 -0
- chython/algorithms/groups/_protective.py +964 -0
- chython/algorithms/groups/_reactions.py +809 -0
- chython/algorithms/groups/_reductions.py +88 -0
- chython/algorithms/groups/_transformations.py +278 -0
- chython/algorithms/groups/test/__init__.py +18 -0
- chython/algorithms/groups/test/test_deprotection.py +108 -0
- chython/algorithms/groups/test/test_reactions.py +377 -0
- chython/algorithms/isomorphism.py +664 -0
- chython/algorithms/mapping/__init__.py +188 -0
- chython/algorithms/mapping/_groups.py +94 -0
- chython/algorithms/mapping/_reactions.py +72 -0
- chython/algorithms/mapping/attention.py +266 -0
- chython/algorithms/mapping/reconstruct.py +346 -0
- chython/algorithms/mcs.py +201 -0
- chython/algorithms/morgan.py +77 -0
- chython/algorithms/rings.py +178 -0
- chython/algorithms/smiles.py +597 -0
- chython/algorithms/standardize/__init__.py +30 -0
- chython/algorithms/standardize/_groups.py +958 -0
- chython/algorithms/standardize/_isomers.py +330 -0
- chython/algorithms/standardize/_metal_organics.py +189 -0
- chython/algorithms/standardize/_reagents.py +44 -0
- chython/algorithms/standardize/_salts.py +68 -0
- chython/algorithms/standardize/molecule.py +475 -0
- chython/algorithms/standardize/reaction.py +384 -0
- chython/algorithms/standardize/resonance.py +191 -0
- chython/algorithms/standardize/salts.py +128 -0
- chython/algorithms/standardize/saturation.py +373 -0
- chython/algorithms/standardize/test/__init__.py +18 -0
- chython/algorithms/standardize/test/test_canonicalize.py +66 -0
- chython/algorithms/standardize/test/test_groups.py +146 -0
- chython/algorithms/standardize/test/test_isomers.py +198 -0
- chython/algorithms/stereo.py +1215 -0
- chython/algorithms/tautomers/__init__.py +167 -0
- chython/algorithms/tautomers/_acid.py +59 -0
- chython/algorithms/tautomers/_base.py +116 -0
- chython/algorithms/tautomers/_keto_enol.py +107 -0
- chython/algorithms/tautomers/acid_base.py +208 -0
- chython/algorithms/tautomers/heteroarenes.py +103 -0
- chython/algorithms/tautomers/keto_enol.py +143 -0
- chython/algorithms/tautomers/test/__init__.py +18 -0
- chython/algorithms/tautomers/test/test_tautomers.py +80 -0
- chython/algorithms/test/__init__.py +18 -0
- chython/algorithms/test/test_isomorphism.py +58 -0
- chython/algorithms/test/test_smiles.py +76 -0
- chython/algorithms/x3dom.py +350 -0
- chython/containers/__init__.py +48 -0
- chython/containers/_pack_v2.cp313-win_amd64.pyd +0 -0
- chython/containers/_pack_v2.pyx +271 -0
- chython/containers/_unpack_v0v2.cp313-win_amd64.pyd +0 -0
- chython/containers/_unpack_v0v2.pyx +302 -0
- chython/containers/bonds.py +255 -0
- chython/containers/cgr.py +115 -0
- chython/containers/chimera.py +63 -0
- chython/containers/graph.py +199 -0
- chython/containers/molecule.py +817 -0
- chython/containers/query.py +71 -0
- chython/containers/rdkit.py +183 -0
- chython/containers/reaction.py +324 -0
- chython/containers/test/__init__.py +18 -0
- chython/containers/test/test_molecule.py +117 -0
- chython/containers/test/test_pack.py +60 -0
- chython/containers/test/test_rdkit.py +70 -0
- chython/containers/test/test_reaction.py +40 -0
- chython/exceptions.py +114 -0
- chython/files/MRVrw.py +532 -0
- chython/files/PDBrw.py +255 -0
- chython/files/RDFrw.py +309 -0
- chython/files/SDFrw.py +221 -0
- chython/files/__init__.py +30 -0
- chython/files/_convert.py +207 -0
- chython/files/_mapping.py +117 -0
- chython/files/_xyz.cp313-win_amd64.pyd +0 -0
- chython/files/_xyz.pyx +74 -0
- chython/files/daylight/__init__.py +24 -0
- chython/files/daylight/parser.py +157 -0
- chython/files/daylight/smarts.py +107 -0
- chython/files/daylight/smiles.py +260 -0
- chython/files/daylight/test/__init__.py +18 -0
- chython/files/daylight/test/test_daylight_smarts.py +289 -0
- chython/files/daylight/test/test_daylight_smiles.py +101 -0
- chython/files/daylight/test/test_parser.py +118 -0
- chython/files/daylight/test/test_tokenize.py +77 -0
- chython/files/daylight/tokenize.py +376 -0
- chython/files/libinchi/__init__.py +22 -0
- chython/files/libinchi/libinchi.dll +0 -0
- chython/files/libinchi/wrapper.py +554 -0
- chython/files/mdl/__init__.py +25 -0
- chython/files/mdl/emol.py +251 -0
- chython/files/mdl/erxn.py +67 -0
- chython/files/mdl/mol.py +186 -0
- chython/files/mdl/read.py +223 -0
- chython/files/mdl/rxn.py +67 -0
- chython/files/mdl/stereo.py +63 -0
- chython/files/mdl/write.py +201 -0
- chython/files/opsin.py +35 -0
- chython/files/test/__init__.py +0 -0
- chython/files/test/test_inchi.py +27 -0
- chython/files/test/test_mrv.py +47 -0
- chython/files/test/test_sdf_rdf.py +64 -0
- chython/files/test/test_xyz.py +20 -0
- chython/files/xyz.py +78 -0
- chython/periodictable/__init__.py +69 -0
- chython/periodictable/base/__init__.py +25 -0
- chython/periodictable/base/dynamic.py +149 -0
- chython/periodictable/base/element.py +451 -0
- chython/periodictable/base/groups.py +90 -0
- chython/periodictable/base/periods.py +46 -0
- chython/periodictable/base/query.py +473 -0
- chython/periodictable/base/vector.py +119 -0
- chython/periodictable/groupI.py +252 -0
- chython/periodictable/groupII.py +223 -0
- chython/periodictable/groupIII.py +1154 -0
- chython/periodictable/groupIV.py +210 -0
- chython/periodictable/groupIX.py +196 -0
- chython/periodictable/groupV.py +192 -0
- chython/periodictable/groupVI.py +183 -0
- chython/periodictable/groupVII.py +162 -0
- chython/periodictable/groupVIII.py +161 -0
- chython/periodictable/groupX.py +166 -0
- chython/periodictable/groupXI.py +164 -0
- chython/periodictable/groupXII.py +158 -0
- chython/periodictable/groupXIII.py +239 -0
- chython/periodictable/groupXIV.py +262 -0
- chython/periodictable/groupXV.py +276 -0
- chython/periodictable/groupXVI.py +457 -0
- chython/periodictable/groupXVII.py +324 -0
- chython/periodictable/groupXVIII.py +260 -0
- chython/periodictable/test/__init__.py +0 -0
- chython/periodictable/test/test_element.py +100 -0
- chython/reactor/__init__.py +24 -0
- chython/reactor/base.py +222 -0
- chython/reactor/reactor.py +177 -0
- chython/reactor/test/__init__.py +18 -0
- chython/reactor/test/test_reactor.py +40 -0
- chython/reactor/test/test_transformer.py +78 -0
- chython/reactor/transformer.py +72 -0
- chython/utils/__init__.py +50 -0
- chython/utils/free_wilson.py +114 -0
- chython/utils/grid.py +130 -0
- chython/utils/retro.py +139 -0
- chython-2.19.dist-info/METADATA +105 -0
- chython-2.19.dist-info/RECORD +175 -0
- chython-2.19.dist-info/WHEEL +4 -0
- chython-2.19.dist-info/licenses/LICENSE +165 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright 2017-2026 Ramil Nugmanov <nougmanoff@protonmail.com>
|
|
4
|
+
# This file is part of chython.
|
|
5
|
+
#
|
|
6
|
+
# chython is free software; you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
8
|
+
# the Free Software Foundation; either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Lesser General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
17
|
+
# along with this program; if not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
#
|
|
19
|
+
from collections import defaultdict, deque
|
|
20
|
+
from functools import cached_property
|
|
21
|
+
from typing import Any
|
|
22
|
+
from ._rings import sssr
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Rings:
|
|
26
|
+
__slots__ = ()
|
|
27
|
+
|
|
28
|
+
@cached_property
|
|
29
|
+
def sssr(self) -> list[tuple[int, ...]]:
|
|
30
|
+
"""
|
|
31
|
+
Smallest Set of Smallest Rings. Special bonds ignored.
|
|
32
|
+
|
|
33
|
+
Based on idea of PID matrices from:
|
|
34
|
+
Lee, C. J., Kang, Y.-M., Cho, K.-H., & No, K. T. (2009).
|
|
35
|
+
A robust method for searching the smallest set of smallest rings with a path-included distance matrix.
|
|
36
|
+
Proceedings of the National Academy of Sciences of the United States of America, 106(41), 17355–17358.
|
|
37
|
+
https://doi.org/10.1073/pnas.0813040106
|
|
38
|
+
|
|
39
|
+
:return rings atoms numbers
|
|
40
|
+
"""
|
|
41
|
+
if self.rings_count:
|
|
42
|
+
return sssr(_skin_graph(self.not_special_connectivity), self.rings_count)
|
|
43
|
+
return []
|
|
44
|
+
|
|
45
|
+
@cached_property
|
|
46
|
+
def atoms_rings(self) -> dict[int, list[tuple[int, ...]]]:
|
|
47
|
+
"""
|
|
48
|
+
A dictionary with atom numbers as keys and a list of tuples (representing SSSR rings) as values.
|
|
49
|
+
"""
|
|
50
|
+
rings = defaultdict(list)
|
|
51
|
+
for r in self.sssr:
|
|
52
|
+
for n in r:
|
|
53
|
+
rings[n].append(r)
|
|
54
|
+
return dict(rings)
|
|
55
|
+
|
|
56
|
+
@cached_property
|
|
57
|
+
def atoms_rings_sizes(self) -> dict[int, set[int]]:
|
|
58
|
+
"""
|
|
59
|
+
Sizes of SSSR rings containing atom.
|
|
60
|
+
"""
|
|
61
|
+
return {n: {len(r) for r in rs} for n, rs in self.atoms_rings.items()}
|
|
62
|
+
|
|
63
|
+
@cached_property
|
|
64
|
+
def rings_count(self) -> int:
|
|
65
|
+
"""
|
|
66
|
+
SSSR rings count. Ignored rings with special bonds.
|
|
67
|
+
"""
|
|
68
|
+
bonds = self.not_special_connectivity
|
|
69
|
+
return sum(len(x) for x in bonds.values()) // 2 - len(bonds) + len(_connected_components(bonds))
|
|
70
|
+
|
|
71
|
+
@cached_property
|
|
72
|
+
def not_special_connectivity(self) -> dict[int, set[int]]:
|
|
73
|
+
"""
|
|
74
|
+
Graph connectivity without special bonds.
|
|
75
|
+
"""
|
|
76
|
+
bonds = {}
|
|
77
|
+
for n, ms in self._bonds.items():
|
|
78
|
+
bonds[n] = ngb = set()
|
|
79
|
+
for m, b in ms.items():
|
|
80
|
+
if b != 8:
|
|
81
|
+
ngb.add(m)
|
|
82
|
+
return bonds
|
|
83
|
+
|
|
84
|
+
@cached_property
|
|
85
|
+
def connected_components(self) -> list[set[int]]:
|
|
86
|
+
"""
|
|
87
|
+
Isolated components of single graph. E.g. salts as ion pair.
|
|
88
|
+
"""
|
|
89
|
+
return _connected_components(self._bonds)
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
def connected_components_count(self) -> int:
|
|
93
|
+
"""
|
|
94
|
+
Number of components in graph
|
|
95
|
+
"""
|
|
96
|
+
return len(self.connected_components)
|
|
97
|
+
|
|
98
|
+
@cached_property
|
|
99
|
+
def skin_graph(self) -> dict[int, set[int]]:
|
|
100
|
+
"""
|
|
101
|
+
Graph without terminal atoms. Only rings and linkers
|
|
102
|
+
"""
|
|
103
|
+
return _skin_graph(self._bonds)
|
|
104
|
+
|
|
105
|
+
@cached_property
|
|
106
|
+
def rings_graph(self) -> dict[int, set[int]]:
|
|
107
|
+
"""
|
|
108
|
+
Graph of rings. Linkers are not included. Special bonds are considered.
|
|
109
|
+
"""
|
|
110
|
+
bonds = {n: ms.copy() for n, ms in self.skin_graph.items()}
|
|
111
|
+
if not bonds:
|
|
112
|
+
return {}
|
|
113
|
+
|
|
114
|
+
in_rings = set()
|
|
115
|
+
atoms = set(bonds)
|
|
116
|
+
while atoms:
|
|
117
|
+
stack = deque([(atoms.pop(), 0, 0)])
|
|
118
|
+
path = []
|
|
119
|
+
seen = set()
|
|
120
|
+
while stack:
|
|
121
|
+
c, p, d = stack.pop()
|
|
122
|
+
if len(path) > d:
|
|
123
|
+
path = path[:d]
|
|
124
|
+
if c in in_rings:
|
|
125
|
+
continue
|
|
126
|
+
path.append(c)
|
|
127
|
+
seen.add(c)
|
|
128
|
+
|
|
129
|
+
d += 1
|
|
130
|
+
for n in bonds[c]:
|
|
131
|
+
if n == p:
|
|
132
|
+
continue
|
|
133
|
+
elif n in seen:
|
|
134
|
+
in_rings.update(path[path.index(n):])
|
|
135
|
+
else:
|
|
136
|
+
stack.append((n, c, d))
|
|
137
|
+
|
|
138
|
+
atoms.difference_update(seen)
|
|
139
|
+
for n in bonds.keys() - in_rings:
|
|
140
|
+
for m in bonds.pop(n):
|
|
141
|
+
bonds[m].discard(n)
|
|
142
|
+
return bonds
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def _connected_components(bonds: dict[int, set[int] | dict[int, Any]]) -> list[set[int]]:
|
|
146
|
+
atoms = set(bonds)
|
|
147
|
+
components = []
|
|
148
|
+
while atoms:
|
|
149
|
+
start = atoms.pop()
|
|
150
|
+
seen = {start}
|
|
151
|
+
queue = deque([start])
|
|
152
|
+
while queue:
|
|
153
|
+
current = queue.popleft()
|
|
154
|
+
for i in bonds[current]:
|
|
155
|
+
if i not in seen:
|
|
156
|
+
queue.append(i)
|
|
157
|
+
seen.add(i)
|
|
158
|
+
components.append(seen)
|
|
159
|
+
atoms.difference_update(seen)
|
|
160
|
+
return components
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def _skin_graph(bonds: dict[int, set[int] | dict[int, Any]]) -> dict[int, set[int]]:
|
|
164
|
+
"""
|
|
165
|
+
Graph without terminal nodes. Only rings and linkers
|
|
166
|
+
"""
|
|
167
|
+
bonds = {n: set(ms) for n, ms in bonds.items() if ms}
|
|
168
|
+
while True: # skip not-cycle chains
|
|
169
|
+
try:
|
|
170
|
+
n = next(n for n, ms in bonds.items() if len(ms) <= 1)
|
|
171
|
+
except StopIteration:
|
|
172
|
+
break
|
|
173
|
+
for m in bonds.pop(n):
|
|
174
|
+
bonds[m].discard(n)
|
|
175
|
+
return bonds
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
__all__ = ['Rings']
|