Skip to content

Commit

Permalink
RyeReader now handles confs with velocities removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Poppleton committed Dec 15, 2022
1 parent dd54952 commit 6542715
Show file tree
Hide file tree
Showing 4 changed files with 1,353 additions and 844 deletions.
15 changes: 13 additions & 2 deletions analysis/src/oxDNA_analysis_tools/UTILS/RyeReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def get_confs(top_info:TopInfo, traj_info:TrajInfo, start_conf:int, n_confs:int)
indexes = traj_info.idxs
traj_file = traj_info.path
n_bases = top_info.nbases
return cget_confs(indexes, traj_file, start_conf, n_confs, n_bases)
incl_v = traj_info.incl_v
return cget_confs(indexes, traj_file, start_conf, n_confs, n_bases, incl_v)

####################################################################################
########## FILE PARSERS ##########
Expand Down Expand Up @@ -188,7 +189,17 @@ def get_traj_info(traj : str) -> TrajInfo:
with open(traj+".pyidx","wb") as file:
file.write(pickle.dumps(idxs))

return TrajInfo(traj,len(idxs),idxs)
# Check if velocities are present in the trajectory
with open(traj) as f:
for _ in range(3):
f.readline()
nline = f.readline().split()
if len(nline) == 15:
incl_v = 1
if len(nline) == 9:
incl_v = 0

return TrajInfo(traj,len(idxs),idxs, incl_v)

def describe(top : str, traj : str) -> Tuple[TopInfo, TrajInfo]:
"""
Expand Down
2 changes: 2 additions & 0 deletions analysis/src/oxDNA_analysis_tools/UTILS/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ class TrajInfo:
path (str) : The path to the trajectory file
nconfs (int) : The number of configurations in the trajectory
idxs (List[ConfInfo]) : A list of ConfInfo objects locating configurations in the trajectory
incl_v (bool) : Are the velocities included in the trajectory?
"""
path : str
nconfs : int
idxs : List[ConfInfo]
incl_v : bool

@dataclass
class Configuration:
Expand Down
Loading

0 comments on commit 6542715

Please sign in to comment.