Skip to content

Commit

Permalink
Merge pull request #153 from andthum/fix/trajectory-unwrapping-fix
Browse files Browse the repository at this point in the history
Fix some errors introduced by PR #151
  • Loading branch information
andthum authored Mar 10, 2023
2 parents 53d7780 + 229f6d5 commit 6738d00
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 72 deletions.
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
"cSpell.ignoreWords": [
"Andreas",
"Autoregressive",
"BLANKLINE",
"CBAR",
"CODEQL",
"Correlogram",
"Corrensstraße",
"Cython",
"EDRFILE",
"GROMACS",
"GitHub",
"GitLab",
"Gromacs",
Expand All @@ -35,6 +37,7 @@
"amin",
"andthum",
"arange",
"arccos",
"argmax",
"argparse",
"asarray",
Expand All @@ -49,6 +52,8 @@
"autoupdate",
"basex",
"basey",
"biggl",
"biggr",
"bincount",
"binwidth",
"biomolecular",
Expand All @@ -65,6 +70,7 @@
"columnspacing",
"commited",
"confint",
"copyto",
"cumav",
"cumsum",
"currentmodule",
Expand All @@ -75,6 +81,7 @@
"dtrj",
"dtype",
"edgecolor",
"einsum",
"errorbar",
"ezavod",
"facecolor",
Expand Down Expand Up @@ -117,7 +124,9 @@
"mdabackend",
"mdacli",
"mdadist",
"mdamath",
"mdanalysis",
"mdtools",
"mdtplt",
"mksh",
"modindex",
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ graft src
prune .github
prune .vscode
prune docs/buid
prune **/_sphinx_autosummary
prune **/_sphinx_autosummary*
prune misc
prune **__pycache__

Expand Down
16 changes: 6 additions & 10 deletions scripts/structure/rmsd_trj_trj.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@
"--weights",
dest="WEIGHTS",
type=str,
nargs=2,
required=False,
choices=("masses", "charges"),
default=None,
Expand Down Expand Up @@ -331,13 +330,6 @@
n_frames_tot=u[i].trajectory.n_frames,
)
)
if any(fr[-1] != frames[0][-1] for fr in frames):
print("\n")
for i, fr in enumerate(frames):
print("Trajectory {}: {} frames".format(i + 1, fr[-1]))
raise ValueError(
"You must read the same number of frames from all trajectories."
)

if args.WEIGHTS is None:
weights = None
Expand All @@ -354,6 +346,10 @@
print("First frame to read: {:>8d}".format(fr[0]))
print("Last frame to read: {:>8d}".format(fr[1]))
print("Read every n-th frame: {:>8d}".format(fr[2]))
if any(fr[-1] != frames[0][-1] for fr in frames):
raise ValueError(
"You must read the same number of frames from all trajectories."
)
timer = datetime.now()
times = np.full(frames[0][-1], np.nan, dtype=np.float64)
rmsd = np.full((frames[0][-1], 3), np.nan, dtype=np.float64)
Expand Down Expand Up @@ -402,13 +398,13 @@
timer = datetime.now()
rmsd_tot = np.sqrt(np.sum(rmsd, axis=-1))
header = (
"Root Mean Square Deviation (RMSD) between two trajectories for each"
"Root Mean Square Deviation (RMSD) between two trajectories for each\n"
"frame. The first trajectory is the reference trajectory.\n"
"\n"
"\n"
)
for i, sl in enumerate(SEL):
header += (
"\n"
"Trajectory {}:"
"Selection: '{}'\n"
"Compound: {}\n".format(i + 1, " ".join(sl), args.CMP[i])
Expand Down
13 changes: 7 additions & 6 deletions scripts/trajectory/unwrap_trj.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@
)
sel.positions = pos_w_prev
else:
pos_w_prev = sel.positions
pos_u_prev = pos_w_prev
box_prev = ts.dimensions
pos_w_prev = np.copy(sel.positions)
pos_u_prev = np.copy(pos_w_prev)
box_prev = np.copy(ts.dimensions)

if args.TOPFILE_OUT is not None:
mdt.fh.backup(args.TOPFILE_OUT)
Expand All @@ -349,11 +349,12 @@
method=args.METHOD,
out=out,
out_tmp=out_tmp,
dtype=np.float64,
)
pos_w_prev[:] = sel.positions
np.copyto(pos_w_prev, sel.positions)
sel.positions = pos_u
pos_u_prev[:] = pos_u
box_prev[:] = ts.dimensions
np.copyto(pos_u_prev, pos_u)
np.copyto(box_prev, ts.dimensions)
w.write(sel)
# ProgressBar update.
trj.set_postfix_str(
Expand Down
Loading

0 comments on commit 6738d00

Please sign in to comment.