@@ -314,7 +314,7 @@ def make_mc_report(identifier, results, directory, diagram_file, chart_file):
314314 launch_word_processor (output_file )
315315
316316
317- def main (structure , work_directory , library , csdrefcode ):
317+ def main (structure , work_directory , failure_directory , library , csdrefcode ):
318318 # This loads up the CSD if a refcode is requested, otherwise loads the structural file supplied
319319 if csdrefcode :
320320 try :
@@ -369,11 +369,9 @@ def main(structure, work_directory, library, csdrefcode):
369369 diagram_file = make_diagram (api_molecule , work_directory )
370370 chart_file = make_mc_chart (mc_hbp_screen , directory , api_molecule )
371371 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 )))
377375
378376
379377if __name__ == '__main__' :
@@ -411,9 +409,10 @@ def main(structure, work_directory, library, csdrefcode):
411409 parser .add_argument ('-c' , '--coformer_library' , type = str ,
412410 help = 'the directory of the desired coformer library' ,
413411 default = ccdc_coformers_dir )
412+ parser .add_argument ('-f' , '--failure_directory' , type = str ,
413+ help = 'The location where the failures file should be generated' )
414414
415415 args = parser .parse_args ()
416-
417416 refcode = False
418417
419418 if not os .path .isfile (args .input_structure ):
@@ -428,4 +427,4 @@ def main(structure, work_directory, library, csdrefcode):
428427 if not os .path .isdir (args .coformer_library ):
429428 parser .error ('%s - library not found.' % args .coformer_library )
430429
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