From 0e3f327aabae2ea8e66e2b765d04284677747ecc Mon Sep 17 00:00:00 2001 From: joshkamm Date: Wed, 14 Aug 2024 03:39:28 -0400 Subject: [PATCH] #73 sort transition_states.xyz by energy --- src/conformational_sampling/gsm.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/conformational_sampling/gsm.py b/src/conformational_sampling/gsm.py index 2671b8f..45b48d6 100644 --- a/src/conformational_sampling/gsm.py +++ b/src/conformational_sampling/gsm.py @@ -86,6 +86,11 @@ def aggregate_transition_states(): list(pb.readfile('xyz', str(ts_opt_path))) for ts_opt_path in ts_opt_paths ] transition_states = [ts_opt[-1] for ts_opt in ts_opts] + # sort transition states by energy, which pybel reads from the 2nd line of the + # XYZ file and puts in its title variable + transition_states = sorted( + transition_states, key=lambda pybel_mol: float(pybel_mol.title) + ) with pb.Outputfile('xyz', 'transition_states.xyz', overwrite=True) as out_file: for transition_state in transition_states: out_file.write(transition_state)