From fc807d6a18ad0206187484d9a44def696a139cb4 Mon Sep 17 00:00:00 2001 From: skfegan Date: Tue, 6 May 2025 13:41:56 +0100 Subject: [PATCH 1/5] Fixing an off by one indexing error when slicing trajectories. --- CodeEntropy/config/arg_config_manager.py | 2 +- CodeEntropy/main_mcc.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CodeEntropy/config/arg_config_manager.py b/CodeEntropy/config/arg_config_manager.py index 607bf36..465c87f 100644 --- a/CodeEntropy/config/arg_config_manager.py +++ b/CodeEntropy/config/arg_config_manager.py @@ -25,7 +25,7 @@ }, "end": { "type": int, - "help": "Stop analysing the trajectory at this frame index", + "help": "Stop analysing the trajectory at this frame index. This is the frame index of the last frame to be included, so for example if start=0 and end=500 there would be 501 frames analysed. The default -1 will include everything up to the last frame.", "default": -1, }, "step": { diff --git a/CodeEntropy/main_mcc.py b/CodeEntropy/main_mcc.py index e3cdc61..8fb5a4b 100644 --- a/CodeEntropy/main_mcc.py +++ b/CodeEntropy/main_mcc.py @@ -127,13 +127,17 @@ def main(): if step is None: step = 1 # Count number of frames, easy if not slicing + # MDAnalysis trajectory slicing only includes up to end-1 + # This works the way we want it to if the whole trajectory is being included if start == 0 and end == -1 and step == 1: + end = len(u.trajectory) number_frames = len(u.trajectory) elif end == -1: end = len(u.trajectory) - number_frames = math.floor((end - start) / step) + 1 + number_frames = math.floor((end - start) / step) else: - number_frames = math.floor((end - start) / step) + 1 + end = end + 1 + number_frames = math.floor((end - start) / step) logger.debug(f"Number of Frames: {number_frames}") # Create pandas data frame for results From 62b4bb79b8af0280a29fb7adff942124bfc66c67 Mon Sep 17 00:00:00 2001 From: skfegan Date: Tue, 6 May 2025 17:17:52 +0100 Subject: [PATCH 2/5] Improving long line --- CodeEntropy/config/arg_config_manager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CodeEntropy/config/arg_config_manager.py b/CodeEntropy/config/arg_config_manager.py index 465c87f..5688f75 100644 --- a/CodeEntropy/config/arg_config_manager.py +++ b/CodeEntropy/config/arg_config_manager.py @@ -25,7 +25,10 @@ }, "end": { "type": int, - "help": "Stop analysing the trajectory at this frame index. This is the frame index of the last frame to be included, so for example if start=0 and end=500 there would be 501 frames analysed. The default -1 will include everything up to the last frame.", + "help": ("Stop analysing the trajectory at this frame index. This is " + "the frame index of the last frame to be included, so for example" + "if start=0 and end=500 there would be 501 frames analysed. The " + "default -1 will include everything up to the last frame."), "default": -1, }, "step": { From 142ad0c729edb95afd779f517fcb72ba431eac10 Mon Sep 17 00:00:00 2001 From: skfegan Date: Wed, 7 May 2025 13:06:28 +0100 Subject: [PATCH 3/5] improving linting --- CodeEntropy/config/arg_config_manager.py | 3 ++- CodeEntropy/main_mcc.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CodeEntropy/config/arg_config_manager.py b/CodeEntropy/config/arg_config_manager.py index 5688f75..2f0d16b 100644 --- a/CodeEntropy/config/arg_config_manager.py +++ b/CodeEntropy/config/arg_config_manager.py @@ -28,7 +28,8 @@ "help": ("Stop analysing the trajectory at this frame index. This is " "the frame index of the last frame to be included, so for example" "if start=0 and end=500 there would be 501 frames analysed. The " - "default -1 will include everything up to the last frame."), + "default -1 will include everything up to the last frame." + ), "default": -1, }, "step": { diff --git a/CodeEntropy/main_mcc.py b/CodeEntropy/main_mcc.py index 8fb5a4b..caeadb8 100644 --- a/CodeEntropy/main_mcc.py +++ b/CodeEntropy/main_mcc.py @@ -134,7 +134,7 @@ def main(): number_frames = len(u.trajectory) elif end == -1: end = len(u.trajectory) - number_frames = math.floor((end - start) / step) + number_frames = math.floor((end - start) / step) else: end = end + 1 number_frames = math.floor((end - start) / step) From 92e52de0f5930cd4d824860c2c70feef79c11c7a Mon Sep 17 00:00:00 2001 From: skfegan Date: Wed, 7 May 2025 13:10:34 +0100 Subject: [PATCH 4/5] improving linting --- CodeEntropy/config/arg_config_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CodeEntropy/config/arg_config_manager.py b/CodeEntropy/config/arg_config_manager.py index 2f0d16b..ef1b3ec 100644 --- a/CodeEntropy/config/arg_config_manager.py +++ b/CodeEntropy/config/arg_config_manager.py @@ -29,7 +29,7 @@ "the frame index of the last frame to be included, so for example" "if start=0 and end=500 there would be 501 frames analysed. The " "default -1 will include everything up to the last frame." - ), + ), "default": -1, }, "step": { From bdb09c7e54206f857a4f4acbcf5f71964f8702d0 Mon Sep 17 00:00:00 2001 From: skfegan Date: Wed, 7 May 2025 13:14:09 +0100 Subject: [PATCH 5/5] improving linting --- CodeEntropy/config/arg_config_manager.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CodeEntropy/config/arg_config_manager.py b/CodeEntropy/config/arg_config_manager.py index ef1b3ec..89987b4 100644 --- a/CodeEntropy/config/arg_config_manager.py +++ b/CodeEntropy/config/arg_config_manager.py @@ -25,10 +25,11 @@ }, "end": { "type": int, - "help": ("Stop analysing the trajectory at this frame index. This is " - "the frame index of the last frame to be included, so for example" - "if start=0 and end=500 there would be 501 frames analysed. The " - "default -1 will include everything up to the last frame." + "help": ( + "Stop analysing the trajectory at this frame index. This is " + "the frame index of the last frame to be included, so for example" + "if start=0 and end=500 there would be 501 frames analysed. The " + "default -1 will include the last frame." ), "default": -1, },