Skip to content

Commit 479a8a1

Browse files
authored
Prepare release (#9)
* prepare release * fix conflict version and prepare release
1 parent 4aa9601 commit 479a8a1

File tree

4 files changed

+6
-155
lines changed

4 files changed

+6
-155
lines changed

Test/SynUtils/test_chemutils.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22
from rdkit import Chem
33
from pathlib import Path
44
from syntemp.SynUtils.chemutils import (
5-
normalize_molecule,
6-
canonicalize_tautomer,
7-
salts_remover,
8-
reionize_charges,
9-
uncharge_molecule,
10-
assign_stereochemistry,
11-
fragments_remover,
125
remove_hydrogens_and_sanitize,
136
)
147

@@ -21,45 +14,6 @@ def setUp(self):
2114
self.caffeine_smiles = "CN1C=NC2=C1C(=O)N(C(=O)N2C)C"
2215
self.mol = Chem.MolFromSmiles(self.caffeine_smiles)
2316

24-
def test_normalize_molecule(self):
25-
normalized_mol = normalize_molecule(self.mol)
26-
self.assertIsInstance(normalized_mol, Chem.Mol)
27-
28-
def test_canonicalize_tautomer(self):
29-
canonical_tautomer = canonicalize_tautomer(self.mol)
30-
self.assertIsInstance(canonical_tautomer, Chem.Mol)
31-
32-
def test_salts_remover(self):
33-
# Using a molecule with a known salt
34-
mol_with_salt = Chem.MolFromSmiles("CC(=O)O.[Na+]")
35-
salt_removed_mol = salts_remover(mol_with_salt)
36-
self.assertNotEqual(
37-
Chem.MolToSmiles(salt_removed_mol), Chem.MolToSmiles(mol_with_salt)
38-
)
39-
40-
def test_reionize_charges(self):
41-
reionized_mol = reionize_charges(self.mol)
42-
self.assertIsInstance(reionized_mol, Chem.Mol)
43-
44-
def test_uncharge_molecule(self):
45-
charged_mol = Chem.AddHs(Chem.MolFromSmiles("[NH4+].[Cl-]"))
46-
uncharged_mol = uncharge_molecule(charged_mol)
47-
self.assertEqual(Chem.rdmolops.GetFormalCharge(uncharged_mol), 0)
48-
49-
def test_assign_stereochemistry(self):
50-
mol_with_stereo = Chem.MolFromSmiles("C[C@H](O)[C@@H](O)C")
51-
assign_stereochemistry(mol_with_stereo)
52-
self.assertEqual(
53-
len(Chem.FindMolChiralCenters(mol_with_stereo, includeUnassigned=True)), 2
54-
)
55-
56-
def test_fragments_remover(self):
57-
mol_with_fragments = Chem.MolFromSmiles("CCO.OCC")
58-
largest_fragment = fragments_remover(mol_with_fragments)
59-
self.assertEqual(
60-
largest_fragment.GetNumAtoms(), 3
61-
) # Expecting the ethyl alcohol fragment
62-
6317
def test_remove_hydrogens_and_sanitize(self):
6418
mol_with_h = Chem.AddHs(self.mol)
6519
cleaned_mol = remove_hydrogens_and_sanitize(mol_with_h)

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ dependencies = [
2727
"chytorch==1.60",
2828
"chytorch-rxnmap==1.4",
2929
"torchdata==0.7.1",
30-
"rdkit>=2023.9.5",
30+
"rdkit>=2024.3.3",
3131
"networkx>=3.3",
3232
"seaborn>=0.13.2",
3333
"joblib>=1.3.2",
34-
"synrbl>=0.0.24",
34+
"synrbl>=0.0.25",
3535
]
3636

3737
[project.urls]

requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ chython==1.75
88
chytorch==1.60
99
chytorch-rxnmap==1.4
1010
torchdata==0.7.1
11-
rdkit>=2023.9.5
11+
rdkit>=2024.3.3
1212
networkx>=3.3
13-
seaborn==0.13.2
14-
joblib==1.3.2
15-
synrbl>=0.0.24
13+
seaborn>=0.13.2
14+
joblib>=1.3.2
15+
synrbl>=0.0.25

syntemp/SynUtils/chemutils.py

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import re
22
from rdkit import Chem
3-
from rdkit.Chem.MolStandardize import normalize, tautomer, charge
4-
from rdkit.Chem.SaltRemover import SaltRemover
53
from rdkit.Chem import rdmolops
64
from rdkit.Chem.MolStandardize import rdMolStandardize
75
from rdkit.Chem.rdMolDescriptors import CalcMolFormula
@@ -10,107 +8,6 @@
108
from itertools import combinations_with_replacement
119

1210

13-
def normalize_molecule(mol: Chem.Mol) -> Chem.Mol:
14-
"""
15-
Normalize a molecule using RDKit's Normalizer.
16-
17-
Args:
18-
mol (Chem.Mol): RDKit Mol object to be normalized.
19-
20-
Returns:
21-
Chem.Mol: Normalized RDKit Mol object.
22-
"""
23-
return normalize.Normalizer().normalize(mol)
24-
25-
26-
def canonicalize_tautomer(mol: Chem.Mol) -> Chem.Mol:
27-
"""
28-
Canonicalize the tautomer of a molecule using RDKit's TautomerCanonicalizer.
29-
30-
Args:
31-
- mol (Chem.Mol): RDKit Mol object.
32-
33-
Returns:
34-
- Chem.Mol: Mol object with canonicalized tautomer.
35-
"""
36-
return tautomer.TautomerCanonicalizer().canonicalize(mol)
37-
38-
39-
def salts_remover(mol: Chem.Mol) -> Chem.Mol:
40-
"""
41-
Remove salt fragments from a molecule using RDKit's SaltRemover.
42-
43-
Args:
44-
- mol (Chem.Mol): RDKit Mol object.
45-
46-
Returns:
47-
- Chem.Mol: Mol object with salts removed.
48-
"""
49-
remover = SaltRemover()
50-
return remover.StripMol(mol)
51-
52-
53-
def reionize_charges(mol: Chem.Mol) -> Chem.Mol:
54-
"""
55-
Adjust molecule to its most likely ionic state using RDKit's Reionizer.
56-
57-
Args:
58-
- mol: RDKit Mol object.
59-
60-
Returns:
61-
- Mol object with reionized charges.
62-
"""
63-
return charge.Reionizer().reionize(mol)
64-
65-
66-
def uncharge_molecule(mol: Chem.Mol) -> Chem.Mol:
67-
"""
68-
Neutralize a molecule by removing counter-ions using RDKit's Uncharger.
69-
70-
Args:
71-
mol: RDKit Mol object.
72-
73-
Returns:
74-
Neutralized Mol object.
75-
"""
76-
uncharger = rdMolStandardize.Uncharger()
77-
return uncharger.uncharge(mol)
78-
79-
80-
def assign_stereochemistry(
81-
mol: Chem.Mol, cleanIt: bool = True, force: bool = True
82-
) -> None:
83-
"""
84-
Assigns stereochemistry to a molecule using RDKit's AssignStereochemistry.
85-
86-
Args:
87-
mol: RDKit Mol object.
88-
cleanIt: Flag indicating whether to clean the molecule.
89-
Default is True.
90-
force: Flag indicating
91-
whether to force stereochemistry assignment.
92-
Default is True.
93-
94-
Returns:
95-
None
96-
"""
97-
Chem.AssignStereochemistry(mol, cleanIt=cleanIt, force=force)
98-
99-
100-
def fragments_remover(mol: Chem.Mol) -> Chem.Mol:
101-
"""
102-
Remove small fragments from a molecule, keeping only the largest one.
103-
104-
Args:
105-
mol (Chem.Mol): RDKit Mol object.
106-
107-
Returns:
108-
Chem.Mol: Mol object with small fragments removed.
109-
"""
110-
frags = Chem.GetMolFrags(mol, asMols=True, sanitizeFrags=True)
111-
return max(frags, default=None, key=lambda m: m.GetNumAtoms())
112-
113-
11411
def remove_hydrogens_and_sanitize(mol: Chem.Mol) -> Chem.Mol:
11512
"""
11613
Remove explicit hydrogens and sanitize a molecule.

0 commit comments

Comments
 (0)