Skip to content

Commit 986c314

Browse files
authored
Merge pull request #87 from CCPBioSim/86-indexing-error-in-creating-dihedral-histograms
Fixing an off by one indexing error when slicing trajectories.
2 parents 54446d2 + bdb09c7 commit 986c314

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CodeEntropy/config/arg_config_manager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
},
2626
"end": {
2727
"type": int,
28-
"help": "Stop analysing the trajectory at this frame index",
28+
"help": (
29+
"Stop analysing the trajectory at this frame index. This is "
30+
"the frame index of the last frame to be included, so for example"
31+
"if start=0 and end=500 there would be 501 frames analysed. The "
32+
"default -1 will include the last frame."
33+
),
2934
"default": -1,
3035
},
3136
"step": {

CodeEntropy/main_mcc.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,17 @@ def main():
127127
if step is None:
128128
step = 1
129129
# Count number of frames, easy if not slicing
130+
# MDAnalysis trajectory slicing only includes up to end-1
131+
# This works the way we want it to if the whole trajectory is being included
130132
if start == 0 and end == -1 and step == 1:
133+
end = len(u.trajectory)
131134
number_frames = len(u.trajectory)
132135
elif end == -1:
133136
end = len(u.trajectory)
134-
number_frames = math.floor((end - start) / step) + 1
137+
number_frames = math.floor((end - start) / step)
135138
else:
136-
number_frames = math.floor((end - start) / step) + 1
139+
end = end + 1
140+
number_frames = math.floor((end - start) / step)
137141
logger.debug(f"Number of Frames: {number_frames}")
138142

139143
# Create pandas data frame for results

0 commit comments

Comments
 (0)