@@ -314,7 +314,7 @@ 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 , library , csdrefcode ):
317
+ def main (structure , work_directory , failure_directory , library , csdrefcode ):
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 :
@@ -369,11 +369,9 @@ def main(structure, work_directory, library, csdrefcode):
369
369
diagram_file = make_diagram (api_molecule , work_directory )
370
370
chart_file = make_mc_chart (mc_hbp_screen , directory , api_molecule )
371
371
make_mc_report (structure , mc_hbp_screen , work_directory , diagram_file , chart_file )
372
- with open ("failures.txt" , 'w' ) as file :
373
- # Iterate through the array
374
- for element in failures :
375
- # Write each element to the file followed by a newline character
376
- file .write (element + '\n ' )
372
+ if failure_directory is not None :
373
+ with open (os .path .join (failure_directory , 'failures.txt' ), 'w' , encoding = 'utf-8' , newline = '' ) as file :
374
+ file .write ('\n ' .join (map (str , failures )))
377
375
378
376
379
377
if __name__ == '__main__' :
@@ -411,9 +409,10 @@ def main(structure, work_directory, library, csdrefcode):
411
409
parser .add_argument ('-c' , '--coformer_library' , type = str ,
412
410
help = 'the directory of the desired coformer library' ,
413
411
default = ccdc_coformers_dir )
412
+ parser .add_argument ('-f' , '--failure_directory' , type = str ,
413
+ help = 'The location where the failures file should be generated' )
414
414
415
415
args = parser .parse_args ()
416
-
417
416
refcode = False
418
417
419
418
if not os .path .isfile (args .input_structure ):
@@ -428,4 +427,4 @@ def main(structure, work_directory, library, csdrefcode):
428
427
if not os .path .isdir (args .coformer_library ):
429
428
parser .error ('%s - library not found.' % args .coformer_library )
430
429
431
- main (args .input_structure , args .directory , args .coformer_library , refcode )
430
+ main (args .input_structure , args .directory , args .failure_directory , args . coformer_library , refcode )
0 commit comments