sapiopycommons 2024.9.10a328__py3-none-any.whl → 2024.9.12a329__py3-none-any.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.
Potentially problematic release.
This version of sapiopycommons might be problematic. Click here for more details.
- sapiopycommons/chem/IndigoMolecules.py +0 -1
- sapiopycommons/chem/Molecules.py +19 -77
- sapiopycommons/multimodal/multimodal_data.py +3 -6
- {sapiopycommons-2024.9.10a328.dist-info → sapiopycommons-2024.9.12a329.dist-info}/METADATA +1 -1
- {sapiopycommons-2024.9.10a328.dist-info → sapiopycommons-2024.9.12a329.dist-info}/RECORD +7 -7
- {sapiopycommons-2024.9.10a328.dist-info → sapiopycommons-2024.9.12a329.dist-info}/WHEEL +0 -0
- {sapiopycommons-2024.9.10a328.dist-info → sapiopycommons-2024.9.12a329.dist-info}/licenses/LICENSE +0 -0
|
@@ -9,7 +9,6 @@ indigo.setOption("ignore-stereochemistry-errors", True)
|
|
|
9
9
|
indigo.setOption("render-stereo-style", "ext")
|
|
10
10
|
indigo.setOption("aromaticity-model", "generic")
|
|
11
11
|
indigo.setOption("render-coloring", True)
|
|
12
|
-
indigo.setOption("molfile-saving-mode", "3000")
|
|
13
12
|
indigo_inchi = IndigoInchi(indigo);
|
|
14
13
|
|
|
15
14
|
|
sapiopycommons/chem/Molecules.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# Author Yechen Qiao
|
|
2
2
|
# Common Molecule Utilities for Molecule Transfers with Sapio
|
|
3
|
-
from typing import cast
|
|
4
3
|
|
|
5
4
|
from rdkit import Chem
|
|
6
5
|
from rdkit.Chem import Crippen, MolToInchi
|
|
@@ -21,25 +20,6 @@ tautomer_params.tautomerReassignStereo = False
|
|
|
21
20
|
tautomer_params.tautomerRemoveIsotopicHs = True
|
|
22
21
|
enumerator = rdMolStandardize.TautomerEnumerator(tautomer_params)
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
def get_enhanced_stereo_reg_hash(mol: Mol, enhanced_stereo: bool) -> str:
|
|
26
|
-
"""
|
|
27
|
-
Get the Registration Hash for the molecule by the current registration configuration.
|
|
28
|
-
When we are running if we are canonicalization of tautomers or cleaning up any other way, do they first before calling.
|
|
29
|
-
:param mol: The molecule to obtain hash for.
|
|
30
|
-
:param canonical_tautomer: Whether the registry system canonicalize the tautomers.
|
|
31
|
-
:param enhanced_stereo: Whether we are computing enhanced stereo at all.
|
|
32
|
-
:return: The enhanced stereo hash.
|
|
33
|
-
"""
|
|
34
|
-
if enhanced_stereo:
|
|
35
|
-
from rdkit.Chem.RegistrationHash import GetMolLayers, GetMolHash, HashScheme
|
|
36
|
-
layers = GetMolLayers(mol, enable_tautomer_hash_v2=True)
|
|
37
|
-
hash_scheme: HashScheme = HashScheme.TAUTOMER_INSENSITIVE_LAYERS
|
|
38
|
-
return GetMolHash(layers, hash_scheme=hash_scheme)
|
|
39
|
-
else:
|
|
40
|
-
return ""
|
|
41
|
-
|
|
42
|
-
|
|
43
23
|
def neutralize_atoms(mol) -> Mol:
|
|
44
24
|
"""
|
|
45
25
|
Neutralize atoms per https://baoilleach.blogspot.com/2019/12/no-charge-simple-approach-to.html
|
|
@@ -106,6 +86,7 @@ def mol_to_img(mol_str: str) -> str:
|
|
|
106
86
|
return renderer.renderToString(mol)
|
|
107
87
|
|
|
108
88
|
|
|
89
|
+
|
|
109
90
|
def mol_to_sapio_partial_pojo(mol: Mol):
|
|
110
91
|
"""
|
|
111
92
|
Get the minimum information about molecule to Sapio, just its SMILES, V3000, and image data.
|
|
@@ -115,7 +96,7 @@ def mol_to_sapio_partial_pojo(mol: Mol):
|
|
|
115
96
|
Chem.SanitizeMol(mol)
|
|
116
97
|
mol.UpdatePropertyCache()
|
|
117
98
|
smiles = Chem.MolToSmiles(mol)
|
|
118
|
-
molBlock = Chem.MolToMolBlock(mol
|
|
99
|
+
molBlock = Chem.MolToMolBlock(mol)
|
|
119
100
|
img = mol_to_img(mol)
|
|
120
101
|
molecule = dict()
|
|
121
102
|
molecule["smiles"] = smiles
|
|
@@ -124,52 +105,23 @@ def mol_to_sapio_partial_pojo(mol: Mol):
|
|
|
124
105
|
return molecule
|
|
125
106
|
|
|
126
107
|
|
|
127
|
-
def
|
|
128
|
-
"""
|
|
129
|
-
Return the SHA1 CXS Smiles hash for the canonical, isomeric CXS SMILES of the molecule.
|
|
130
|
-
"""
|
|
131
|
-
if not enhanced_stereo:
|
|
132
|
-
return ""
|
|
133
|
-
import hashlib
|
|
134
|
-
return hashlib.sha1(Chem.MolToCXSmiles(mol, canonical=True, isomericSmiles=True).encode()).hexdigest()
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
def get_has_or_group(mol: Mol, enhanced_stereo: bool) -> bool:
|
|
138
|
-
"""
|
|
139
|
-
Return true if and only if: enhanced stereochemistry is enabled and there is at least one OR group in mol.
|
|
140
|
-
"""
|
|
141
|
-
if not enhanced_stereo:
|
|
142
|
-
return False
|
|
143
|
-
from rdkit.Chem import StereoGroup_vect, STEREO_OR
|
|
144
|
-
stereo_groups: StereoGroup_vect = mol.GetStereoGroups()
|
|
145
|
-
for stereo_group in stereo_groups:
|
|
146
|
-
if stereo_group.GetGroupType() == STEREO_OR:
|
|
147
|
-
return True
|
|
148
|
-
return False
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
def mol_to_sapio_substance(mol: Mol, include_stereoisomers=False,
|
|
108
|
+
def mol_to_sapio_substance(mol: Mol, include_stereoisomers: bool = False,
|
|
152
109
|
normalize: bool = False, remove_salt: bool = False, make_images: bool = False,
|
|
153
|
-
salt_def: str | None = None, canonical_tautomer: bool = True
|
|
154
|
-
enhanced_stereo: bool = False, remove_atom_map: bool = True):
|
|
110
|
+
salt_def: str | None = None, canonical_tautomer: bool = True):
|
|
155
111
|
"""
|
|
156
112
|
Convert a molecule in RDKit to a molecule POJO in Sapio.
|
|
157
113
|
|
|
158
114
|
:param mol: The molecule in RDKit.
|
|
115
|
+
:param include_stereoisomers: If true, will compute all stereoisomer permutations of this molecule.
|
|
159
116
|
:param normalize If true, will normalize the functional groups and return normalized result.
|
|
160
117
|
:param remove_salt If true, we will remove salts iteratively from the molecule before returning their data.
|
|
161
118
|
We will also populate desaltedList with molecules we deleted.
|
|
162
|
-
:param make_images Whether to make images as part of the result without having another script to resolve it.
|
|
163
119
|
:param salt_def: if not none, specifies custom salt to be used during the desalt process.
|
|
164
120
|
:param canonical_tautomer: if True, we will attempt to compute canonical tautomer for the molecule. Slow!
|
|
165
121
|
This is needed for a registry. Note it stops after enumeration of 1000.
|
|
166
|
-
:param enhanced_stereo: If enabled, enhanced stereo hash will be produced.
|
|
167
|
-
:param remove_atom_map: When set, clear all atom AAM maps that were set had it been merged into some reactions earlier.
|
|
168
122
|
:return: The molecule POJO for Sapio.
|
|
169
123
|
"""
|
|
170
124
|
molecule = dict()
|
|
171
|
-
if remove_atom_map:
|
|
172
|
-
[a.SetAtomMapNum(0) for a in mol.GetAtoms()]
|
|
173
125
|
Chem.SanitizeMol(mol)
|
|
174
126
|
mol.UpdatePropertyCache()
|
|
175
127
|
Chem.GetSymmSSSR(mol)
|
|
@@ -205,7 +157,7 @@ def mol_to_sapio_substance(mol: Mol, include_stereoisomers=False,
|
|
|
205
157
|
exactMass = Descriptors.ExactMolWt(mol)
|
|
206
158
|
molFormula = rdMolDescriptors.CalcMolFormula(mol)
|
|
207
159
|
charge = Chem.GetFormalCharge(mol)
|
|
208
|
-
molBlock = Chem.MolToMolBlock(mol
|
|
160
|
+
molBlock = Chem.MolToMolBlock(mol)
|
|
209
161
|
|
|
210
162
|
molecule["cLogP"] = cLogP
|
|
211
163
|
molecule["tpsa"] = tpsa
|
|
@@ -229,38 +181,28 @@ def mol_to_sapio_substance(mol: Mol, include_stereoisomers=False,
|
|
|
229
181
|
# We need to test the INCHI can be loaded back to indigo.
|
|
230
182
|
indigo_mol = indigo.loadMolecule(molBlock)
|
|
231
183
|
indigo_mol.aromatize()
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
molecule["inchiKey"] = Chem.MolToInchiKey(mol_copy)
|
|
238
|
-
else:
|
|
239
|
-
indigo_inchi.resetOptions()
|
|
240
|
-
indigo_inchi_str = indigo_inchi.getInchi(indigo_mol)
|
|
241
|
-
molecule["inchi"] = indigo_inchi_str
|
|
242
|
-
indigo_inchi_key_str = indigo_inchi.getInchiKey(indigo_inchi_str)
|
|
243
|
-
molecule["inchiKey"] = indigo_inchi_key_str
|
|
184
|
+
indigo_inchi.resetOptions()
|
|
185
|
+
indigo_inchi_str = indigo_inchi.getInchi(indigo_mol)
|
|
186
|
+
molecule["inchi"] = indigo_inchi_str
|
|
187
|
+
indigo_inchi_key_str = indigo_inchi.getInchiKey(indigo_inchi_str)
|
|
188
|
+
molecule["inchiKey"] = indigo_inchi_key_str
|
|
244
189
|
molecule["smiles"] = indigo_mol.smiles()
|
|
245
|
-
molecule["reg_hash"] = get_enhanced_stereo_reg_hash(mol, enhanced_stereo=enhanced_stereo)
|
|
246
|
-
molecule["cxsmiles_hash"] = get_cxs_smiles_hash(mol, enhanced_stereo=enhanced_stereo)
|
|
247
|
-
molecule["has_or_group"] = get_has_or_group(mol, enhanced_stereo=enhanced_stereo)
|
|
248
190
|
|
|
191
|
+
if include_stereoisomers and has_chiral_centers(mol):
|
|
192
|
+
stereoisomers = find_all_possible_stereoisomers(mol, only_unassigned=False, try_embedding=False, unique=True)
|
|
193
|
+
molecule["stereoisomers"] = [mol_to_sapio_partial_pojo(x) for x in stereoisomers]
|
|
249
194
|
return molecule
|
|
250
195
|
|
|
251
196
|
|
|
252
|
-
def mol_to_sapio_compound(mol: Mol, include_stereoisomers
|
|
197
|
+
def mol_to_sapio_compound(mol: Mol, include_stereoisomers: bool = False,
|
|
253
198
|
salt_def: str | None = None, resolve_canonical: bool = True,
|
|
254
|
-
make_images: bool = False, canonical_tautomer: bool = True
|
|
255
|
-
remove_atom_map: bool = True):
|
|
199
|
+
make_images: bool = False, canonical_tautomer: bool = True):
|
|
256
200
|
ret = dict()
|
|
257
|
-
ret['originalMol'] = mol_to_sapio_substance(mol, include_stereoisomers
|
|
201
|
+
ret['originalMol'] = mol_to_sapio_substance(mol, include_stereoisomers,
|
|
258
202
|
normalize=False, remove_salt=False, make_images=make_images,
|
|
259
|
-
canonical_tautomer=canonical_tautomer
|
|
260
|
-
enhanced_stereo=enhanced_stereo, remove_atom_map=remove_atom_map)
|
|
203
|
+
canonical_tautomer=canonical_tautomer)
|
|
261
204
|
if resolve_canonical:
|
|
262
205
|
ret['canonicalMol'] = mol_to_sapio_substance(mol, include_stereoisomers=False,
|
|
263
206
|
normalize=True, remove_salt=True, make_images=make_images,
|
|
264
|
-
salt_def=salt_def, canonical_tautomer=canonical_tautomer
|
|
265
|
-
enhanced_stereo=enhanced_stereo, remove_atom_map=remove_atom_map)
|
|
207
|
+
salt_def=salt_def, canonical_tautomer=canonical_tautomer)
|
|
266
208
|
return ret
|
|
@@ -38,9 +38,6 @@ class PyMolecule:
|
|
|
38
38
|
normError: str | None
|
|
39
39
|
desaltError: str | None
|
|
40
40
|
desaltedList: list[str] | None
|
|
41
|
-
registrationHash: str | None
|
|
42
|
-
hasOrGroup: bool
|
|
43
|
-
CXSMILESHash: str | None
|
|
44
41
|
|
|
45
42
|
|
|
46
43
|
@dataclass
|
|
@@ -103,9 +100,9 @@ class PyMoleculeLoaderResult:
|
|
|
103
100
|
compoundList: the compounds successfully loaded.
|
|
104
101
|
errorList: an error record is added here for each one we failed to load in Sapio.
|
|
105
102
|
"""
|
|
106
|
-
compoundByStr: dict[str, PyCompound]
|
|
107
|
-
compoundList: list[PyCompound]
|
|
108
|
-
errorList: list[ChemLoadingError]
|
|
103
|
+
compoundByStr: dict[str, PyCompound]
|
|
104
|
+
compoundList: list[PyCompound]
|
|
105
|
+
errorList: list[ChemLoadingError]
|
|
109
106
|
|
|
110
107
|
|
|
111
108
|
@dataclass
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: sapiopycommons
|
|
3
|
-
Version: 2024.9.
|
|
3
|
+
Version: 2024.9.12a329
|
|
4
4
|
Summary: Official Sapio Python API Utilities Package
|
|
5
5
|
Project-URL: Homepage, https://github.com/sapiosciences
|
|
6
6
|
Author-email: Jonathan Steck <jsteck@sapiosciences.com>, Yechen Qiao <yqiao@sapiosciences.com>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
sapiopycommons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
sapiopycommons/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
sapiopycommons/callbacks/callback_util.py,sha256=7gUyJ-i3Owdy9bdQSOYKX_AgNRaT0PTbdhulA59tNys,63616
|
|
4
|
-
sapiopycommons/chem/IndigoMolecules.py,sha256=
|
|
5
|
-
sapiopycommons/chem/Molecules.py,sha256=
|
|
4
|
+
sapiopycommons/chem/IndigoMolecules.py,sha256=QqFDi9CKERj6sn_ZwVcS2xZq4imlkaTeCrpq1iNcEJA,1992
|
|
5
|
+
sapiopycommons/chem/Molecules.py,sha256=t80IsQBPJ9mwE8ZxnWomAGrZDhdsOuPvLaTPb_N6jGU,8639
|
|
6
6
|
sapiopycommons/chem/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
sapiopycommons/customreport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
sapiopycommons/customreport/column_builder.py,sha256=sS_wZYOR72rs3syTNjwCVP4h8M8N0b0burkTxFQItVU,3019
|
|
@@ -33,7 +33,7 @@ sapiopycommons/general/sapio_links.py,sha256=o9Z-8y2rz6AI0Cy6tq58ElPge9RBnisGc9N
|
|
|
33
33
|
sapiopycommons/general/storage_util.py,sha256=ovmK_jN7v09BoX07XxwShpBUC5WYQOM7dbKV_VeLXJU,8892
|
|
34
34
|
sapiopycommons/general/time_util.py,sha256=sXThADCRAQDWYDD9C5CdhcKYIt3qOaVNyZfGBR7HW9A,8701
|
|
35
35
|
sapiopycommons/multimodal/multimodal.py,sha256=A1QsC8QTPmgZyPr7KtMbPRedn2Ie4WIErodUvQ9otgU,6724
|
|
36
|
-
sapiopycommons/multimodal/multimodal_data.py,sha256=
|
|
36
|
+
sapiopycommons/multimodal/multimodal_data.py,sha256=p_caXW0vrURkzDHHspUptEI7lVFpZUrmyF7foz2fAvA,14983
|
|
37
37
|
sapiopycommons/processtracking/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
38
|
sapiopycommons/processtracking/endpoints.py,sha256=w5bziI2xC7450M95rCF8JpRwkoni1kEDibyAux9B12Q,10848
|
|
39
39
|
sapiopycommons/recordmodel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -44,7 +44,7 @@ sapiopycommons/rules/on_save_rule_handler.py,sha256=Rkqvph20RbNq6m-RF4fbvCP-YfD2
|
|
|
44
44
|
sapiopycommons/webhook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
45
|
sapiopycommons/webhook/webhook_handlers.py,sha256=jwc4xu-wwl8haS5k1dENZ1UIYK9GQk74TAo3CGxMW9U,16583
|
|
46
46
|
sapiopycommons/webhook/webservice_handlers.py,sha256=1J56zFI0pWl5MHoNTznvcZumITXgAHJMluj8-2BqYEw,3315
|
|
47
|
-
sapiopycommons-2024.9.
|
|
48
|
-
sapiopycommons-2024.9.
|
|
49
|
-
sapiopycommons-2024.9.
|
|
50
|
-
sapiopycommons-2024.9.
|
|
47
|
+
sapiopycommons-2024.9.12a329.dist-info/METADATA,sha256=NJjODPDzDTejcy86PBjgUeErLBrcElY1jfRsZ6hJl5Q,3176
|
|
48
|
+
sapiopycommons-2024.9.12a329.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
49
|
+
sapiopycommons-2024.9.12a329.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
|
|
50
|
+
sapiopycommons-2024.9.12a329.dist-info/RECORD,,
|
|
File without changes
|
{sapiopycommons-2024.9.10a328.dist-info → sapiopycommons-2024.9.12a329.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|