MacrocycleWizard 0.1.0__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.
- MacrocycleWizard/CreateFig/FigGenerator.py +316 -0
- MacrocycleWizard/CreateFig/__init__.py +10 -0
- MacrocycleWizard/MolD/__init__.py +65 -0
- MacrocycleWizard/MolD/base.py +467 -0
- MacrocycleWizard/MolD/basic/GroupA.py +64 -0
- MacrocycleWizard/MolD/basic/__init__.py +5 -0
- MacrocycleWizard/MolD/calculator.py +211 -0
- MacrocycleWizard/MolD/general/GroupH.py +458 -0
- MacrocycleWizard/MolD/general/GroupI.py +219 -0
- MacrocycleWizard/MolD/general/GroupJ.py +643 -0
- MacrocycleWizard/MolD/general/GroupK.py +92 -0
- MacrocycleWizard/MolD/general/__init__.py +8 -0
- MacrocycleWizard/MolD/specific/GroupB.py +363 -0
- MacrocycleWizard/MolD/specific/GroupC.py +132 -0
- MacrocycleWizard/MolD/specific/GroupD.py +426 -0
- MacrocycleWizard/MolD/specific/GroupE.py +343 -0
- MacrocycleWizard/MolD/specific/GroupF.py +222 -0
- MacrocycleWizard/MolD/specific/GroupG.py +80 -0
- MacrocycleWizard/MolD/specific/__init__.py +10 -0
- MacrocycleWizard/Onion/Onion.py +1115 -0
- MacrocycleWizard/Onion/__init__.py +11 -0
- MacrocycleWizard/__init__.py +219 -0
- MacrocycleWizard/base.py +467 -0
- macrocyclewizard-0.1.0.dist-info/METADATA +407 -0
- macrocyclewizard-0.1.0.dist-info/RECORD +28 -0
- macrocyclewizard-0.1.0.dist-info/WHEEL +5 -0
- macrocyclewizard-0.1.0.dist-info/licenses/LICENSE +21 -0
- macrocyclewizard-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"""MacrocycleWizard/MolD/general/GroupI.py """
|
|
2
|
+
"""
|
|
3
|
+
Group I: Heteroatom related MolD for Overall Macrocycle Molecules
|
|
4
|
+
"""
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
from rdkit import Chem
|
|
7
|
+
from ..base import MacrocycleCalculator
|
|
8
|
+
from rdkit.Chem.Lipinski import HeavyAtomCount
|
|
9
|
+
from rdkit.Chem import Descriptors
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class GroupI(MacrocycleCalculator):
|
|
14
|
+
"""
|
|
15
|
+
In the overall molecule layer only count N,O,S,P.
|
|
16
|
+
As F and Cl is not likely to be in macrocycle ring.So we only count them in Group E.
|
|
17
|
+
"""
|
|
18
|
+
def get_I01_Heteroatom_to_Heavy_Atom_Ratio(self):
|
|
19
|
+
I01_Heteroatom_to_Heavy_Atom_Ratio = []
|
|
20
|
+
for mol, ha in tqdm(zip(self.mols, self.HA)):
|
|
21
|
+
hetero_atmo = Chem.rdMolDescriptors.CalcNumHeteroatoms(mol) if mol is not None else 0
|
|
22
|
+
hetero_atmo_ratio = hetero_atmo / ha if ha > 0 else 0.0
|
|
23
|
+
I01_Heteroatom_to_Heavy_Atom_Ratio.append(hetero_atmo_ratio)
|
|
24
|
+
return I01_Heteroatom_to_Heavy_Atom_Ratio
|
|
25
|
+
|
|
26
|
+
def get_I02_Total_N_to_O_Ratio(self):
|
|
27
|
+
"""
|
|
28
|
+
Calculate the ratio of all N atmos over O (TotalN+1)/(TotalO+1)
|
|
29
|
+
Plus 1 to avoid divide 0
|
|
30
|
+
"""
|
|
31
|
+
I02_Total_N_to_O_Ratio = []
|
|
32
|
+
for mol in tqdm(self.mols):
|
|
33
|
+
num_nitrogens = 0
|
|
34
|
+
num_oxygens = 0
|
|
35
|
+
for atom in mol.GetAtoms():
|
|
36
|
+
atomic_num = atom.GetAtomicNum()
|
|
37
|
+
if atomic_num == 7:
|
|
38
|
+
num_nitrogens += 1
|
|
39
|
+
elif atomic_num == 8:
|
|
40
|
+
num_oxygens += 1
|
|
41
|
+
ratio_total_n_to_o = (num_nitrogens + 1) / (num_oxygens + 1)
|
|
42
|
+
I02_Total_N_to_O_Ratio.append(ratio_total_n_to_o)
|
|
43
|
+
return I02_Total_N_to_O_Ratio
|
|
44
|
+
|
|
45
|
+
def get_I03_Total_Oxygen_to_Heavy_Atom_Ratio(self):
|
|
46
|
+
"""
|
|
47
|
+
Calculate normalised total oxygen count
|
|
48
|
+
"""
|
|
49
|
+
I03_Total_Oxygen_to_Heavy_Atom_Ratio = []
|
|
50
|
+
for mol, ha in tqdm(zip(self.mols, self.HA)):
|
|
51
|
+
atoms = mol.GetAtoms() if mol is not None else []
|
|
52
|
+
Oxygen = sum(1 for atom in atoms if atom.GetAtomicNum() == 8)
|
|
53
|
+
oxygen_ratio = Oxygen / ha if ha > 0 else 0.0
|
|
54
|
+
I03_Total_Oxygen_to_Heavy_Atom_Ratio.append(oxygen_ratio)
|
|
55
|
+
return I03_Total_Oxygen_to_Heavy_Atom_Ratio
|
|
56
|
+
|
|
57
|
+
def get_I04_Total_Nitrogen_to_Heavy_Atom_Ratio(self):
|
|
58
|
+
"""
|
|
59
|
+
Calculate normalised total nitrogen count
|
|
60
|
+
"""
|
|
61
|
+
I04_Total_Nitrogen_to_Heavy_Atom_Ratio = []
|
|
62
|
+
for mol, ha in tqdm(zip(self.mols, self.HA)):
|
|
63
|
+
atoms = mol.GetAtoms() if mol is not None else []
|
|
64
|
+
Nitrogen = sum(1 for atom in atoms if atom.GetAtomicNum() == 7)
|
|
65
|
+
nitrogen_ratio = Nitrogen / ha if ha > 0 else 0.0
|
|
66
|
+
I04_Total_Nitrogen_to_Heavy_Atom_Ratio.append(nitrogen_ratio)
|
|
67
|
+
return I04_Total_Nitrogen_to_Heavy_Atom_Ratio
|
|
68
|
+
|
|
69
|
+
def get_I05_Total_Sulfur_to_Heavy_Atom_Ratio(self):
|
|
70
|
+
"""
|
|
71
|
+
Calculate normalised total sulfur count
|
|
72
|
+
"""
|
|
73
|
+
I05_Total_Sulfur_to_Heavy_Atom_Ratio = []
|
|
74
|
+
for mol, ha in tqdm(zip(self.mols, self.HA)):
|
|
75
|
+
atoms = mol.GetAtoms() if mol is not None else []
|
|
76
|
+
Sulfur = sum(1 for atom in atoms if atom.GetAtomicNum() == 16)
|
|
77
|
+
sulfur_ratio = Sulfur / ha if ha > 0 else 0.0
|
|
78
|
+
I05_Total_Sulfur_to_Heavy_Atom_Ratio.append(sulfur_ratio)
|
|
79
|
+
return I05_Total_Sulfur_to_Heavy_Atom_Ratio
|
|
80
|
+
|
|
81
|
+
def get_I06_Total_Phosphorus_to_Heavy_Atom_Ratio(self):
|
|
82
|
+
"""
|
|
83
|
+
Calculate normalised total phosphorus count
|
|
84
|
+
"""
|
|
85
|
+
I06_Total_Phosphorus_to_Heavy_Atom_Ratio = []
|
|
86
|
+
for mol, ha in tqdm(zip(self.mols, self.HA)):
|
|
87
|
+
atoms = mol.GetAtoms() if mol is not None else []
|
|
88
|
+
Phosphorus = sum(1 for atom in atoms if atom.GetAtomicNum() == 15)
|
|
89
|
+
phosphorus_ratio = Phosphorus / ha if ha > 0 else 0.0
|
|
90
|
+
I06_Total_Phosphorus_to_Heavy_Atom_Ratio.append(phosphorus_ratio)
|
|
91
|
+
return I06_Total_Phosphorus_to_Heavy_Atom_Ratio
|
|
92
|
+
|
|
93
|
+
def get_I07_Other_Heteroatom_to_Heavy_Atom_Ratio(self):
|
|
94
|
+
"""
|
|
95
|
+
Calculate normalised count of other heteroatoms
|
|
96
|
+
(excluding H, C, N, O, S, P, Cl, F)
|
|
97
|
+
"""
|
|
98
|
+
I07_Other_Heteroatom_to_Heavy_Atom_Ratio = []
|
|
99
|
+
# Define atomic numbers to exclude: H(1), C(6), N(7), O(8), F(9), P(15), S(16), Cl(17)
|
|
100
|
+
excluded_atoms = {1, 6, 7, 8, 9, 15, 16, 17}
|
|
101
|
+
|
|
102
|
+
for mol, ha in tqdm(zip(self.mols, self.HA)):
|
|
103
|
+
atoms = mol.GetAtoms() if mol is not None else []
|
|
104
|
+
# Count atoms that are NOT in the excluded set
|
|
105
|
+
other_heteroatoms = sum(1 for atom in atoms
|
|
106
|
+
if atom.GetAtomicNum() not in excluded_atoms)
|
|
107
|
+
other_heteroatom_ratio = other_heteroatoms / ha if ha > 0 else 0.0
|
|
108
|
+
I07_Other_Heteroatom_to_Heavy_Atom_Ratio.append(other_heteroatom_ratio)
|
|
109
|
+
|
|
110
|
+
return I07_Other_Heteroatom_to_Heavy_Atom_Ratio
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def get_I08_Heteroatom_with_More_than_Two_Connections_Count(self):
|
|
115
|
+
"""
|
|
116
|
+
Count number of heteroatoms with more (not including 2) than 2 connections
|
|
117
|
+
"""
|
|
118
|
+
I08_Heteroatom_with_More_than_Two_Connections_Count = []
|
|
119
|
+
for mol in tqdm(self.mols):
|
|
120
|
+
count = 0
|
|
121
|
+
for atom in mol.GetAtoms():
|
|
122
|
+
# Check if it's a heteroatom (not C or H)
|
|
123
|
+
if atom.GetSymbol() not in ['C', 'H']:
|
|
124
|
+
# Calculate total connections
|
|
125
|
+
total_connections = 0
|
|
126
|
+
for bond in atom.GetBonds():
|
|
127
|
+
bond_type = bond.GetBondType()
|
|
128
|
+
if bond_type == Chem.BondType.SINGLE:
|
|
129
|
+
total_connections += 1
|
|
130
|
+
elif bond_type == Chem.BondType.DOUBLE:
|
|
131
|
+
total_connections += 2
|
|
132
|
+
elif bond_type == Chem.BondType.TRIPLE:
|
|
133
|
+
total_connections += 3
|
|
134
|
+
elif bond_type == Chem.BondType.AROMATIC:
|
|
135
|
+
total_connections += 1.5
|
|
136
|
+
|
|
137
|
+
if total_connections > 2:
|
|
138
|
+
count += 1
|
|
139
|
+
|
|
140
|
+
I08_Heteroatom_with_More_than_Two_Connections_Count.append(count)
|
|
141
|
+
|
|
142
|
+
return I08_Heteroatom_with_More_than_Two_Connections_Count
|
|
143
|
+
|
|
144
|
+
def get_I09_Carbon_Atom_Connected_to_at_Least_Two_Heteroatoms_Count(self):
|
|
145
|
+
"""
|
|
146
|
+
Count number of carbon atoms connected to at least 2 heteroatoms
|
|
147
|
+
"""
|
|
148
|
+
I09_Carbon_Atom_Connected_to_at_Least_Two_Heteroatoms_Count = []
|
|
149
|
+
for mol in tqdm(self.mols):
|
|
150
|
+
count = 0
|
|
151
|
+
for atom in mol.GetAtoms():
|
|
152
|
+
# Check if it's a carbon atom
|
|
153
|
+
if atom.GetSymbol() == 'C':
|
|
154
|
+
# Count heteroatom neighbors
|
|
155
|
+
heteroatom_neighbors = 0
|
|
156
|
+
for neighbor in atom.GetNeighbors():
|
|
157
|
+
if neighbor.GetSymbol() not in ['C', 'H']:
|
|
158
|
+
heteroatom_neighbors += 1
|
|
159
|
+
|
|
160
|
+
if heteroatom_neighbors >= 2:
|
|
161
|
+
count += 1
|
|
162
|
+
|
|
163
|
+
I09_Carbon_Atom_Connected_to_at_Least_Two_Heteroatoms_Count.append(count)
|
|
164
|
+
|
|
165
|
+
return I09_Carbon_Atom_Connected_to_at_Least_Two_Heteroatoms_Count
|
|
166
|
+
|
|
167
|
+
def get_I10_Bond_Connecting_Two_Heteroatoms_Count(self):
|
|
168
|
+
"""
|
|
169
|
+
Count number of bonds connecting 2 heteroatoms
|
|
170
|
+
"""
|
|
171
|
+
I10_Bond_Connecting_Two_Heteroatoms_Count = []
|
|
172
|
+
for mol in tqdm(self.mols):
|
|
173
|
+
count = 0
|
|
174
|
+
for bond in mol.GetBonds():
|
|
175
|
+
begin_atom = bond.GetBeginAtom()
|
|
176
|
+
end_atom = bond.GetEndAtom()
|
|
177
|
+
|
|
178
|
+
# Check if both atoms are heteroatoms
|
|
179
|
+
if (begin_atom.GetSymbol() not in ['C', 'H'] and
|
|
180
|
+
end_atom.GetSymbol() not in ['C', 'H']):
|
|
181
|
+
count += 1
|
|
182
|
+
|
|
183
|
+
I10_Bond_Connecting_Two_Heteroatoms_Count.append(count)
|
|
184
|
+
|
|
185
|
+
return I10_Bond_Connecting_Two_Heteroatoms_Count
|
|
186
|
+
|
|
187
|
+
def get_I11_Carbon_Carbon_Bond_Each_Carbon_with_Heteroatom_Count(self):
|
|
188
|
+
"""
|
|
189
|
+
Count number of carbon-carbon bonds when each carbon contains at least one heteroatom neighbor
|
|
190
|
+
"""
|
|
191
|
+
I11_Carbon_Carbon_Bond_Each_Carbon_with_Heteroatom_Count = []
|
|
192
|
+
for mol in tqdm(self.mols):
|
|
193
|
+
count = 0
|
|
194
|
+
for bond in mol.GetBonds():
|
|
195
|
+
begin_atom = bond.GetBeginAtom()
|
|
196
|
+
end_atom = bond.GetEndAtom()
|
|
197
|
+
|
|
198
|
+
# Check if both atoms are carbon
|
|
199
|
+
if begin_atom.GetSymbol() == 'C' and end_atom.GetSymbol() == 'C':
|
|
200
|
+
# Check if begin_atom has at least one heteroatom neighbor
|
|
201
|
+
begin_has_hetero = False
|
|
202
|
+
for neighbor in begin_atom.GetNeighbors():
|
|
203
|
+
if neighbor.GetSymbol() not in ['C', 'H']:
|
|
204
|
+
begin_has_hetero = True
|
|
205
|
+
break
|
|
206
|
+
|
|
207
|
+
# Check if end_atom has at least one heteroatom neighbor
|
|
208
|
+
end_has_hetero = False
|
|
209
|
+
for neighbor in end_atom.GetNeighbors():
|
|
210
|
+
if neighbor.GetSymbol() not in ['C', 'H']:
|
|
211
|
+
end_has_hetero = True
|
|
212
|
+
break
|
|
213
|
+
|
|
214
|
+
if begin_has_hetero and end_has_hetero:
|
|
215
|
+
count += 1
|
|
216
|
+
|
|
217
|
+
I11_Carbon_Carbon_Bond_Each_Carbon_with_Heteroatom_Count.append(count)
|
|
218
|
+
|
|
219
|
+
return I11_Carbon_Carbon_Bond_Each_Carbon_with_Heteroatom_Count
|