Skip to content

Commit

Permalink
Merge branch 'dev' into feature/xyzReader_performance
Browse files Browse the repository at this point in the history
  • Loading branch information
97gamjak committed Jun 4, 2024
2 parents ef1c5db + c201f35 commit 254e3df
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions PQAnalysis/io/traj_file/trajectory_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ def frame_generator(
# Read the lines of the file using tqdm for progress bar
for line in self.file:

# Break the generator if the trajectory_stop is reached
if trajectory_stop <= frame_index:
return

stripped_line = line.strip()
if stripped_line == "" or not stripped_line[0].isdigit():
frame_lines.append(line)
Expand All @@ -239,10 +243,7 @@ def frame_generator(

# Check if the number of frames yielded is equal to the
# total number of frames
if not (
frame_index < trajectory_start or
frame_index >= trajectory_stop
):
if frame_index >= trajectory_start:
yield frame # only yield the frame if it is within the range
progress_bar.update(
1
Expand All @@ -267,11 +268,9 @@ def frame_generator(

last_cell = frame.cell

# Check if the number of frames yielded is equal to the total number of frames
if not (
frame_index < trajectory_start or
frame_index >= trajectory_stop
):
# Check if the number of frames yielded is equal to the
# total number of frames
if frame_index >= trajectory_start:
yield frame # only yield the frame if it is within the range
progress_bar.update(1) # update the progress bar

Expand Down

0 comments on commit 254e3df

Please sign in to comment.