@@ -118,8 +118,9 @@ def fragment_and_process(self, bonds):
118
118
bonds (list): bonds to process.
119
119
"""
120
120
# Try to split the principle:
121
+ fragments : list [MoleculeGraph ] = []
121
122
try :
122
- frags = self .mol_graph .split_molecule_subgraphs (bonds , allow_reverse = True )
123
+ fragments = self .mol_graph .split_molecule_subgraphs (bonds , allow_reverse = True )
123
124
frag_success = True
124
125
125
126
except MolGraphSplitError :
@@ -166,7 +167,7 @@ def fragment_and_process(self, bonds):
166
167
# We shouldn't ever encounter more than one good entry.
167
168
raise RuntimeError ("There should only be one valid ring opening fragment! Exiting..." )
168
169
elif len (bonds ) == 2 :
169
- raise RuntimeError ("Should only be trying to break two bonds if multibreak is true ! Exiting..." )
170
+ raise RuntimeError ("Should only be trying to break two bonds if multibreak=True ! Exiting..." )
170
171
else :
171
172
raise ValueError ("No reason to try and break more than two bonds at once! Exiting..." )
172
173
frag_success = False
@@ -176,19 +177,19 @@ def fragment_and_process(self, bonds):
176
177
# As above, we begin by making sure we haven't already encountered an identical pair of fragments:
177
178
frags_done = False
178
179
for frag_pair in self .done_frag_pairs :
179
- if frag_pair [0 ].isomorphic_to (frags [0 ]):
180
- if frag_pair [1 ].isomorphic_to (frags [1 ]):
180
+ if frag_pair [0 ].isomorphic_to (fragments [0 ]):
181
+ if frag_pair [1 ].isomorphic_to (fragments [1 ]):
181
182
frags_done = True
182
183
break
183
- elif frag_pair [1 ].isomorphic_to (frags [0 ]) and frag_pair [0 ].isomorphic_to (frags [1 ]):
184
+ elif frag_pair [1 ].isomorphic_to (fragments [0 ]) and frag_pair [0 ].isomorphic_to (fragments [1 ]):
184
185
frags_done = True
185
186
break
186
187
if not frags_done :
187
188
# If we haven't, we save this pair and search for the relevant fragment entries:
188
- self .done_frag_pairs += [frags ]
189
+ self .done_frag_pairs += [fragments ]
189
190
n_entries_for_this_frag_pair = 0
190
- frag1_entries = self .search_fragment_entries (frags [0 ])
191
- frag2_entries = self .search_fragment_entries (frags [1 ])
191
+ frag1_entries = self .search_fragment_entries (fragments [0 ])
192
+ frag2_entries = self .search_fragment_entries (fragments [1 ])
192
193
frag1_charges_found = []
193
194
frag2_charges_found = []
194
195
# We then check for our expected charges of each fragment:
@@ -200,14 +201,14 @@ def fragment_and_process(self, bonds):
200
201
frag2_charges_found += [frag2 ["initial_molecule" ]["charge" ]]
201
202
# If we're missing some of either, tell the user:
202
203
if len (frag1_charges_found ) < len (self .expected_charges ):
203
- bb = BabelMolAdaptor (frags [0 ].molecule )
204
+ bb = BabelMolAdaptor (fragments [0 ].molecule )
204
205
pb_mol = bb .pybel_mol
205
206
smiles = pb_mol .write ("smi" ).split ()[0 ]
206
207
for charge in self .expected_charges :
207
208
if charge not in frag1_charges_found :
208
209
warnings .warn (f"Missing { charge = } for fragment { smiles } " )
209
210
if len (frag2_charges_found ) < len (self .expected_charges ):
210
- bb = BabelMolAdaptor (frags [1 ].molecule )
211
+ bb = BabelMolAdaptor (fragments [1 ].molecule )
211
212
pb_mol = bb .pybel_mol
212
213
smiles = pb_mol .write ("smi" ).split ()[0 ]
213
214
for charge in self .expected_charges :
0 commit comments