@@ -190,19 +190,27 @@ def format_scores(scores, das, d_type):
190
190
return formatted_scores
191
191
192
192
193
- def get_mc_scores (propensities , identifier ):
193
+ def get_mc_scores (propensities , identifier , ignore_intra : bool ):
194
194
# Calculates the multi-component scores from the individual HBP calculation
195
195
AA_propensities = []
196
196
BB_propensities = []
197
197
AB_propensities = []
198
198
BA_propensities = []
199
+ AA_intra_propensities = []
200
+ BB_intra_propensities = []
199
201
200
202
for p in propensities :
203
+ if ignore_intra and not p .is_intermolecular :
204
+ continue
201
205
t = "%s_d" % p .donor_label .split (" " )[0 ], "%s_a" % p .acceptor_label .split (" " )[0 ]
202
206
if '_A_' in t [0 ] and '_A_' in t [1 ]:
203
207
AA_propensities .append (p .propensity )
208
+ if not p .is_intermolecular :
209
+ AA_intra_propensities .append (p .propensity )
204
210
elif '_B_' in t [0 ] and '_B_' in t [1 ]:
205
211
BB_propensities .append (p .propensity )
212
+ if not p .is_intermolecular :
213
+ BB_intra_propensities .append (p .propensity )
206
214
elif '_A_' in t [0 ] and '_B_' in t [1 ]:
207
215
AB_propensities .append (p .propensity )
208
216
elif '_B_' in t [0 ] and '_A_' in t [1 ]:
@@ -212,10 +220,12 @@ def get_mc_scores(propensities, identifier):
212
220
max_AB = max (AB_propensities ) if len (AB_propensities ) > 0 else 0.0
213
221
max_BA = max (BA_propensities ) if len (BA_propensities ) > 0 else 0.0
214
222
max_list = [max_AA , max_BB , max_AB , max_BA ]
215
- max_keys = ['A:A' , 'B:B' , 'A:B' , 'B:A' ]
216
223
max_mc = max (max_list [2 ], max_list [3 ])
217
224
max_sc = max (max_list [0 ], max_list [1 ])
218
225
226
+ max_keys = ['A:A*' , 'B:B*' , 'A:B' , 'B:A' ] if max_sc in AA_intra_propensities or max_sc in BB_intra_propensities \
227
+ else ['A:A' , 'B:B' , 'A:B' , 'B:A' ]
228
+
219
229
return [round ((max_mc - max_sc ), 2 ),
220
230
max_keys [max_list .index (max (max_list ))],
221
231
round (max_mc , 2 ),
@@ -323,7 +333,7 @@ def make_mc_report(identifier, results, directory, diagram_file, chart_file):
323
333
launch_word_processor (output_file )
324
334
325
335
326
- def main (structure , work_directory , failure_directory , library , csdrefcode , force_run ):
336
+ def main (structure , work_directory , failure_directory , library , csdrefcode , ignore_intra , force_run ):
327
337
# This loads up the CSD if a refcode is requested, otherwise loads the structural file supplied
328
338
if csdrefcode :
329
339
try :
@@ -371,10 +381,9 @@ def main(structure, work_directory, failure_directory, library, csdrefcode, forc
371
381
propensities , donors , acceptors = hbp_calculator .calculate ()
372
382
coordination_scores = coordination_scores_calc (crystal , directory )
373
383
pair_output (crystal .identifier , propensities , donors , acceptors , coordination_scores , directory )
384
+ mc_dictionary [coformer_name ] = get_mc_scores (propensities , crystal .identifier , ignore_intra )
374
385
with open (os .path .join (directory , "success.json" ), "w" ) as file :
375
- tdata = get_mc_scores (propensities , crystal .identifier )
376
- json .dump (tdata , file )
377
- mc_dictionary [coformer_name ] = get_mc_scores (propensities , crystal .identifier )
386
+ json .dump (mc_dictionary [coformer_name ], file )
378
387
except Exception as error_message :
379
388
print ("Propensity calculation failure for %s!" % coformer_name )
380
389
error_string = f"{ coformer_name } : { error_message } "
@@ -429,7 +438,8 @@ def main(structure, work_directory, failure_directory, library, csdrefcode, forc
429
438
default = ccdc_coformers_dir )
430
439
parser .add_argument ('-f' , '--failure_directory' , type = str ,
431
440
help = 'The location where the failures file should be generated' )
432
-
441
+ parser .add_argument ('-i' , '--ignore_intra' , type = bool , action = 'store_true' , default = False ,
442
+ help = 'Ignore intramolecular hydrogen bonds when ranking pairs' )
433
443
parser .add_argument ('--force_run_disordered' , action = "store_true" ,
434
444
help = 'Forces running the script on disordered entries. (NOT RECOMMENDED)' , default = False )
435
445
@@ -447,4 +457,4 @@ def main(structure, work_directory, failure_directory, library, csdrefcode, forc
447
457
parser .error ('%s - library not found.' % args .coformer_library )
448
458
449
459
main (args .input_structure , args .directory , args .failure_directory , args .coformer_library , refcode ,
450
- args .force_run_disordered )
460
+ args .ignore_intra , args . force_run_disordered )
0 commit comments