@@ -314,14 +314,18 @@ def make_mc_report(identifier, results, directory, diagram_file, chart_file):
314
314
launch_word_processor (output_file )
315
315
316
316
317
- def main (structure , work_directory , failure_directory , library , csdrefcode ):
317
+ def main (structure , work_directory , failure_directory , library , csdrefcode , force_run ):
318
318
# This loads up the CSD if a refcode is requested, otherwise loads the structural file supplied
319
319
if csdrefcode :
320
320
try :
321
321
crystal = io .CrystalReader ('CSD' ).crystal (structure )
322
322
except RuntimeError :
323
323
print ('Error! %s is not in the database!' % structure )
324
324
quit ()
325
+ if io .CrystalReader ('CSD' ).entry (structure ).has_disorder and not force_run :
326
+ raise RuntimeError ("Disorder can cause undefined behaviour. It is not advisable to run this "
327
+ "script on disordered entries.\n To force this script to run on disordered entries"
328
+ " use the flag --force_run_disordered." )
325
329
else :
326
330
crystal = io .CrystalReader (structure )[0 ]
327
331
@@ -358,10 +362,12 @@ def main(structure, work_directory, failure_directory, library, csdrefcode):
358
362
tdata = get_mc_scores (propensities , crystal .identifier )
359
363
json .dump (tdata , file )
360
364
mc_dictionary [coformer_name ] = get_mc_scores (propensities , crystal .identifier )
361
- except RuntimeError :
365
+ except RuntimeError as error_message :
362
366
print ("Propensity calculation failure for %s!" % coformer_name )
367
+ error_string = f"{ coformer_name } : { error_message } "
368
+ warnings .warn (error_string )
363
369
mc_dictionary [coformer_name ] = ["N/A" , "N/A" , "N/A" , "N/A" , "N/A" , crystal .identifier ]
364
- failures .append (coformer_name )
370
+ failures .append (error_string )
365
371
366
372
# Make sense of the outputs of all the calculations
367
373
mc_hbp_screen = sorted (mc_dictionary .items (), key = lambda e : 0 if e [1 ][0 ] == 'N/A' else e [1 ][0 ], reverse = True )
@@ -411,6 +417,9 @@ def main(structure, work_directory, failure_directory, library, csdrefcode):
411
417
parser .add_argument ('-f' , '--failure_directory' , type = str ,
412
418
help = 'The location where the failures file should be generated' )
413
419
420
+ parser .add_argument ('--force_run_disordered' , action = "store_true" ,
421
+ help = 'Forces running the script on disordered entries. (NOT RECOMMENDED)' , default = False )
422
+
414
423
args = parser .parse_args ()
415
424
refcode = False
416
425
args .directory = os .path .abspath (args .directory )
@@ -424,4 +433,5 @@ def main(structure, work_directory, failure_directory, library, csdrefcode):
424
433
if not os .path .isdir (args .coformer_library ):
425
434
parser .error ('%s - library not found.' % args .coformer_library )
426
435
427
- main (args .input_structure , args .directory , args .failure_directory , args .coformer_library , refcode )
436
+ main (args .input_structure , args .directory , args .failure_directory , args .coformer_library , refcode ,
437
+ args .force_run_disordered )
0 commit comments