Skip to content

Commit 0ec9d26

Browse files
committed
Added --failure_directory argument
1 parent d3359eb commit 0ec9d26

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

scripts/multi_component_hydrogen_bond_propensity/multi_component_hydrogen_bond_propensity_report.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

379377
if __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

Comments
 (0)