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,117 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from chython import smiles, MoleculeContainer
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def test_smiles_parse_ethanol():
|
|
6
|
+
mol = smiles('CCO')
|
|
7
|
+
assert len(mol) == 3
|
|
8
|
+
assert str(mol) == 'CCO'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_smiles_parse_benzene():
|
|
12
|
+
mol = smiles('c1ccccc1')
|
|
13
|
+
assert len(mol) == 6
|
|
14
|
+
assert str(mol) == 'c1ccccc1'
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_molecule_equality():
|
|
18
|
+
mol1 = smiles('CCO')
|
|
19
|
+
mol2 = smiles('OCC')
|
|
20
|
+
assert mol1 == mol2
|
|
21
|
+
assert hash(mol1) == hash(mol2)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_molecule_inequality():
|
|
25
|
+
mol1 = smiles('CCO')
|
|
26
|
+
mol2 = smiles('CC=O')
|
|
27
|
+
assert mol1 != mol2
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_brutto():
|
|
31
|
+
mol = smiles('CC(=O)Oc1ccccc1C(=O)O') # aspirin
|
|
32
|
+
assert mol.brutto == {'C': 9, 'H': 8, 'O': 4}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_molecular_mass():
|
|
36
|
+
mol = smiles('O') # water
|
|
37
|
+
mass = mol.molecular_mass
|
|
38
|
+
assert 16 < mass < 20
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_rings():
|
|
42
|
+
mol = smiles('c1ccc2ccccc2c1') # naphthalene
|
|
43
|
+
assert mol.rings_count == 2
|
|
44
|
+
assert len(mol.sssr) == 2
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_aromatic_rings():
|
|
48
|
+
mol = smiles('c1ccccc1')
|
|
49
|
+
assert len(mol.aromatic_rings) == 1
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_connected_components():
|
|
53
|
+
mol = smiles('[Cl-].[Na+]')
|
|
54
|
+
assert mol.connected_components_count == 2
|
|
55
|
+
parts = mol.split()
|
|
56
|
+
assert len(parts) == 2
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_add_atom_bond():
|
|
60
|
+
mol = MoleculeContainer()
|
|
61
|
+
n1 = mol.add_atom('C')
|
|
62
|
+
n2 = mol.add_atom('C')
|
|
63
|
+
n3 = mol.add_atom('O')
|
|
64
|
+
mol.add_bond(n1, n2, 1)
|
|
65
|
+
mol.add_bond(n2, n3, 1)
|
|
66
|
+
assert str(mol) == 'CCO'
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def test_implicit_hydrogens():
|
|
70
|
+
mol = smiles('C') # methane
|
|
71
|
+
atom = mol.atom(next(iter(mol)))
|
|
72
|
+
assert atom.implicit_hydrogens == 4
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_copy():
|
|
76
|
+
mol = smiles('CCO')
|
|
77
|
+
mol2 = mol.copy()
|
|
78
|
+
assert str(mol) == str(mol2)
|
|
79
|
+
assert mol is not mol2
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def test_substructure():
|
|
83
|
+
mol = smiles('Cc1ccccc1') # toluene
|
|
84
|
+
atoms = list(mol)
|
|
85
|
+
ring_atoms = atoms[1:]
|
|
86
|
+
sub = mol.substructure(ring_atoms)
|
|
87
|
+
assert len(sub) == 6
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_union():
|
|
91
|
+
mol1 = smiles('C')
|
|
92
|
+
mol2 = smiles('O')
|
|
93
|
+
merged = mol1.union(mol2, remap=True)
|
|
94
|
+
assert len(merged) == 2
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def test_explicify_implicify():
|
|
98
|
+
mol = smiles('C')
|
|
99
|
+
n_before = len(mol)
|
|
100
|
+
mol.explicify_hydrogens()
|
|
101
|
+
assert len(mol) == 5 # C + 4H
|
|
102
|
+
mol.implicify_hydrogens()
|
|
103
|
+
assert len(mol) == n_before
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def test_pickle():
|
|
107
|
+
from pickle import loads, dumps
|
|
108
|
+
mol = smiles('c1ccccc1')
|
|
109
|
+
data = dumps(mol)
|
|
110
|
+
mol2 = loads(data)
|
|
111
|
+
assert str(mol) == str(mol2)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def test_format_specifiers():
|
|
115
|
+
mol = smiles('[CH3:1][OH:2]')
|
|
116
|
+
s_map = format(mol, 'm')
|
|
117
|
+
assert ':1]' in s_map or ':2]' in s_map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from chython import smiles, MoleculeContainer, ReactionContainer, unpack
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def test_molecule_pack_unpack():
|
|
6
|
+
mol = smiles('c1ccccc1')
|
|
7
|
+
data = mol.pack()
|
|
8
|
+
mol2 = MoleculeContainer.unpack(data)
|
|
9
|
+
assert str(mol) == str(mol2)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_molecule_pack_uncompressed():
|
|
13
|
+
mol = smiles('CCO')
|
|
14
|
+
data = mol.pack(compressed=False)
|
|
15
|
+
mol2 = unpack(data, compressed=False)
|
|
16
|
+
assert str(mol) == str(mol2)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def test_molecule_bytes():
|
|
20
|
+
mol = smiles('[Cu+2]')
|
|
21
|
+
data = bytes(mol)
|
|
22
|
+
mol2 = unpack(data)
|
|
23
|
+
assert str(mol) == str(mol2)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_pack_preserves_coordinates():
|
|
27
|
+
mol = smiles('CCO')
|
|
28
|
+
mol.clean2d()
|
|
29
|
+
data = mol.pack()
|
|
30
|
+
mol2 = MoleculeContainer.unpack(data)
|
|
31
|
+
for n in mol:
|
|
32
|
+
assert abs(mol.atom(n).x - mol2.atom(n).x) < 0.01
|
|
33
|
+
assert abs(mol.atom(n).y - mol2.atom(n).y) < 0.01
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_pack_preserves_charge():
|
|
37
|
+
mol = smiles('[NH4+]')
|
|
38
|
+
data = mol.pack()
|
|
39
|
+
mol2 = unpack(data)
|
|
40
|
+
assert str(mol) == str(mol2)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_pack_preserves_isotope():
|
|
44
|
+
mol = smiles('[2H]C([2H])([2H])[2H]')
|
|
45
|
+
data = mol.pack()
|
|
46
|
+
mol2 = unpack(data)
|
|
47
|
+
assert str(mol) == str(mol2)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_reaction_pack_unpack():
|
|
51
|
+
rxn = smiles('[CH3:1][OH:2]>>[CH3:1][NH2:3]')
|
|
52
|
+
data = rxn.pack()
|
|
53
|
+
rxn2 = ReactionContainer.unpack(data)
|
|
54
|
+
assert str(rxn) == str(rxn2)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def test_pack_len():
|
|
58
|
+
mol = smiles('CCCCC')
|
|
59
|
+
data = mol.pack(compressed=False)
|
|
60
|
+
assert MoleculeContainer.pack_len(data, compressed=False) == 5
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright 2025, 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 chython import smiles, from_rdkit_molecule
|
|
20
|
+
from pytest import mark
|
|
21
|
+
from rdkit import Chem
|
|
22
|
+
from rdkit.Chem import AllChem
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
data = [
|
|
26
|
+
'CCO',
|
|
27
|
+
'C/C=C/C',
|
|
28
|
+
'C[C@H](O)CC',
|
|
29
|
+
'C\C=C/O[C@@H]1OC[C@@H](Oc2ccccc2)[C@@H](O)[C@H]1O\C=C\C',
|
|
30
|
+
'[nH]1cccc1',
|
|
31
|
+
'C\C=C\C=C',
|
|
32
|
+
'C[C@@H](O)[C@H](O)[C@H](C)O'
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
@mark.parametrize('source', data)
|
|
36
|
+
def test_to_rdkit(source):
|
|
37
|
+
mol = smiles(source)
|
|
38
|
+
rd_mol = mol.to_rdkit(keep_mapping=False)
|
|
39
|
+
rd_mol_mapping = mol.to_rdkit(keep_mapping=True)
|
|
40
|
+
|
|
41
|
+
assert format(smiles(Chem.MolToSmiles(rd_mol)), 'h') == format(mol, 'h')
|
|
42
|
+
assert format(smiles(Chem.MolToSmiles(rd_mol_mapping)), 'm') == format(mol, 'm')
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@mark.parametrize('source', data)
|
|
46
|
+
def test_from_rdkit(source):
|
|
47
|
+
assert format(from_rdkit_molecule(Chem.MolFromSmiles(source)), 'h') == format(smiles(source), 'h')
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_coordinates():
|
|
51
|
+
rd_mol = smiles('CCO').to_rdkit(keep_mapping=False)
|
|
52
|
+
|
|
53
|
+
AllChem.Compute2DCoords(rd_mol)
|
|
54
|
+
mol = from_rdkit_molecule(rd_mol)
|
|
55
|
+
assert any(a.x for _, a in mol.atoms())
|
|
56
|
+
|
|
57
|
+
rd_mol_h = Chem.AddHs(rd_mol)
|
|
58
|
+
AllChem.EmbedMolecule(rd_mol_h)
|
|
59
|
+
rd_mol_nh = Chem.RemoveHs(rd_mol_h)
|
|
60
|
+
|
|
61
|
+
mol = from_rdkit_molecule(rd_mol_nh)
|
|
62
|
+
assert hasattr(mol, '_conformers')
|
|
63
|
+
assert isinstance(mol._conformers, list)
|
|
64
|
+
assert len(mol._conformers) == 1
|
|
65
|
+
assert isinstance(mol._conformers[0], dict)
|
|
66
|
+
assert len(mol._conformers[0]) == 3
|
|
67
|
+
assert all(tuple(x) for x in mol._conformers[0].values())
|
|
68
|
+
assert all(len(x) == 3 for x in mol._conformers[0].values())
|
|
69
|
+
assert all(isinstance(x, float) for x in mol._conformers[0].values() for x in x)
|
|
70
|
+
assert any(x for x in mol._conformers[0].values() for x in x)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from chython import smiles
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def test_reaction_parse():
|
|
6
|
+
rxn = smiles('[CH3:1][OH:2]>>[CH3:1][NH2:3]')
|
|
7
|
+
assert len(rxn.reactants) == 1
|
|
8
|
+
assert len(rxn.products) == 1
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_reaction_components():
|
|
12
|
+
rxn = smiles('CCO.CC(=O)O>>CCOC(=O)C.O')
|
|
13
|
+
assert len(rxn.reactants) == 2
|
|
14
|
+
assert len(rxn.products) == 2
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_reaction_equality():
|
|
18
|
+
rxn1 = smiles('[CH3:1][OH:2]>>[CH3:1][NH2:3]')
|
|
19
|
+
rxn2 = smiles('[CH3:1][OH:2]>>[CH3:1][NH2:3]')
|
|
20
|
+
assert rxn1 == rxn2
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_reaction_canonicalize():
|
|
24
|
+
rxn = smiles('CCO.CC(=O)O>>CCOC(=O)C.O')
|
|
25
|
+
rxn.canonicalize()
|
|
26
|
+
assert str(rxn)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_reaction_molecules():
|
|
30
|
+
rxn = smiles('[CH3:1][OH:2]>>[CH3:1][NH2:3]')
|
|
31
|
+
mols = list(rxn.molecules())
|
|
32
|
+
assert len(mols) == 2
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_reaction_pickle():
|
|
36
|
+
from pickle import loads, dumps
|
|
37
|
+
rxn = smiles('[CH3:1][OH:2]>>[CH3:1][NH2:3]')
|
|
38
|
+
data = dumps(rxn)
|
|
39
|
+
rxn2 = loads(data)
|
|
40
|
+
assert str(rxn) == str(rxn2)
|
chython/exceptions.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
|
|
20
|
+
|
|
21
|
+
class EmptyMolecule(ValueError):
|
|
22
|
+
"""
|
|
23
|
+
Molecule without atoms
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class EmptyReaction(ValueError):
|
|
28
|
+
"""
|
|
29
|
+
Reaction without molecules
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class MappingError(ValueError):
|
|
34
|
+
"""
|
|
35
|
+
Atom-to-Atom mapping invalid
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class AtomNotFound(KeyError):
|
|
40
|
+
"""
|
|
41
|
+
Bad atom number
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class BondNotFound(KeyError):
|
|
46
|
+
"""
|
|
47
|
+
Bad atoms numbers
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class NotChiral(KeyError):
|
|
52
|
+
"""
|
|
53
|
+
Atom not chiral
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class IsChiral(KeyError):
|
|
58
|
+
"""
|
|
59
|
+
Atom already chiral
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class InvalidAromaticRing(ValueError):
|
|
64
|
+
"""
|
|
65
|
+
Aromatic ring has impossible Kekule structure
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ValenceError(Exception):
|
|
70
|
+
"""
|
|
71
|
+
Atom has valence error
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class IncorrectSmiles(ValueError):
|
|
76
|
+
"""
|
|
77
|
+
SMILES string invalid
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class IncorrectSmarts(IncorrectSmiles):
|
|
82
|
+
"""
|
|
83
|
+
SMARTS string invalid or unsupported
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class ImplementationError(Exception):
|
|
88
|
+
"""
|
|
89
|
+
Algorithm has errors. Please send example of structure to author for analyze.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class BufferOverflow(BufferError):
|
|
94
|
+
"""
|
|
95
|
+
Parser buffer overflow
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class InvalidV2000(ValueError):
|
|
100
|
+
"""
|
|
101
|
+
Invalid V2000
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class InvalidCharge(ValueError):
|
|
106
|
+
"""
|
|
107
|
+
Invalid MDL charge
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class InvalidMolBlock(ValueError):
|
|
112
|
+
"""
|
|
113
|
+
Invalid MDL MOL
|
|
114
|
+
"""
|