@@ -150,20 +150,13 @@ def fragment_and_process(self, bonds):
150
150
# If we still have no good entries, something must have gone wrong with the calculations:
151
151
if len (good_entries ) == 0 :
152
152
bb = BabelMolAdaptor .from_molecule_graph (RO_frag )
153
- pbmol = bb .pybel_mol
154
- smiles = pbmol .write ("smi" ).split ()[0 ]
153
+ pb_mol = bb .pybel_mol
154
+ smiles = pb_mol .write ("smi" ).split ()[0 ]
155
155
specie = nx .get_node_attributes (self .mol_graph .graph , "specie" )
156
156
print (
157
- "Missing ring opening fragment resulting from the breakage of "
158
- + specie [bonds [0 ][0 ]]
159
- + " "
160
- + specie [bonds [0 ][1 ]]
161
- + " bond "
162
- + str (bonds [0 ][0 ])
163
- + " "
164
- + str (bonds [0 ][1 ])
165
- + " which would yield a molecule with this SMILES string: "
166
- + smiles
157
+ f"Missing ring opening fragment resulting from the breakage of { specie [bonds [0 ][0 ]]} "
158
+ f"{ specie [bonds [0 ][1 ]]} bond { bonds [0 ][0 ]} { bonds [0 ][1 ]} which would yield a "
159
+ f"molecule with this SMILES string: { smiles } "
167
160
)
168
161
elif len (good_entries ) == 1 :
169
162
# If we have only one good entry, format it and add it to the list that will eventually return:
@@ -207,18 +200,18 @@ def fragment_and_process(self, bonds):
207
200
# If we're missing some of either, tell the user:
208
201
if len (frag1_charges_found ) < len (self .expected_charges ):
209
202
bb = BabelMolAdaptor (frags [0 ].molecule )
210
- pbmol = bb .pybel_mol
211
- smiles = pbmol .write ("smi" ).split ()[0 ]
203
+ pb_mol = bb .pybel_mol
204
+ smiles = pb_mol .write ("smi" ).split ()[0 ]
212
205
for charge in self .expected_charges :
213
206
if charge not in frag1_charges_found :
214
- print ("Missing charge " + str ( charge ) + " for fragment " + smiles )
207
+ print (f "Missing charge { charge } for fragment { smiles } " )
215
208
if len (frag2_charges_found ) < len (self .expected_charges ):
216
209
bb = BabelMolAdaptor (frags [1 ].molecule )
217
- pbmol = bb .pybel_mol
218
- smiles = pbmol .write ("smi" ).split ()[0 ]
210
+ pb_mol = bb .pybel_mol
211
+ smiles = pb_mol .write ("smi" ).split ()[0 ]
219
212
for charge in self .expected_charges :
220
213
if charge not in frag2_charges_found :
221
- print ("Missing charge " + str ( charge ) + " for fragment " + smiles )
214
+ print (f "Missing charge { charge } for fragment { smiles } " )
222
215
# Now we attempt to pair fragments with the right total charge, starting with only fragments with no
223
216
# structural change:
224
217
for frag1 in frag1_entries [0 ]: # 0 -> no structural change
@@ -282,21 +275,16 @@ def filter_fragment_entries(self, fragment_entries):
282
275
for entry in fragment_entries :
283
276
# Check and make sure that PCM dielectric is consistent with principle:
284
277
if "pcm_dielectric" in self .molecule_entry :
278
+ err_msg = (
279
+ f"Principle molecule has a PCM dielectric of { self .molecule_entry ['pcm_dielectric' ]} "
280
+ " but a fragment entry has [[placeholder]] PCM dielectric! Please only pass fragment entries"
281
+ " with PCM details consistent with the principle entry. Exiting..."
282
+ )
285
283
if "pcm_dielectric" not in entry :
286
- raise RuntimeError (
287
- "Principle molecule has a PCM dielectric of "
288
- + str (self .molecule_entry ["pcm_dielectric" ])
289
- + " but a fragment entry has no PCM dielectric! Please only pass fragment entries"
290
- " with PCM details consistent with the principle entry. Exiting..."
291
- )
284
+ raise RuntimeError (err_msg .replace ("[[placeholder]]" , "no" ))
292
285
if entry ["pcm_dielectric" ] != self .molecule_entry ["pcm_dielectric" ]:
293
- raise RuntimeError (
294
- "Principle molecule has a PCM dielectric of "
295
- + str (self .molecule_entry ["pcm_dielectric" ])
296
- + " but a fragment entry has a different PCM dielectric! Please only pass"
297
- " fragment entries with PCM details consistent with the principle entry."
298
- " Exiting..."
299
- )
286
+ raise RuntimeError (err_msg .replace ("[[placeholder]]" , "a different" ))
287
+
300
288
# Build initial and final molgraphs:
301
289
entry ["initial_molgraph" ] = MoleculeGraph .with_local_env_strategy (
302
290
Molecule .from_dict (entry ["initial_molecule" ]), OpenBabelNN ()
0 commit comments