Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AlignTraj Writer kwargs fix #4565

Merged
merged 9 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Fixes
* Fix doctest errors of lib/picklable_file_io.py (Issue #3925, PR #4371)
* Fix deploy action to use the correct version of the pypi upload action.
* Fix groups.py doctests using sphinx directives (Issue #3925, PR #4374)
* Fix `MDAnalysis.analysis.align.AlignTraj` not accepting writer kwargs
ljwoods2 marked this conversation as resolved.
Show resolved Hide resolved
(Issue #4564, PR #4565)

Enhancements
* Added a tqdm progress bar for `MDAnalysis.analysis.pca.PCA.transform()`
Expand Down
3 changes: 2 additions & 1 deletion package/MDAnalysis/analysis/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ def __init__(self, mobile, reference, select='all', filename=None,
for the remainder of the Python session. If ``mobile.trajectory`` is
already a :class:`MemoryReader` then it is *always* treated as if
``in_memory`` had been set to ``True``.
- Writer ``**kwargs`` will be passed to the constructed `mda.Writer`.
ljwoods2 marked this conversation as resolved.
Show resolved Hide resolved

.. versionchanged:: 1.0.0
Default ``filename`` has now been changed to the current directory.
Expand Down Expand Up @@ -819,7 +820,7 @@ def __init__(self, mobile, reference, select='all', filename=None,
# with self.filename == None (in_memory), the NullWriter is chosen
# (which just ignores input) and so only the in_memory trajectory is
# retained
self._writer = mda.Writer(self.filename, natoms)
self._writer = mda.Writer(self.filename, natoms, **kwargs)

self._weights = get_weights(self.ref_atoms, weights)

Expand Down
10 changes: 10 additions & 0 deletions testsuite/MDAnalysisTests/analysis/test_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,16 @@ def test_AlignTraj_in_memory(self, universe, reference, tmpdir):
self._assert_rmsd(reference, universe, 0, 6.929083044751061)
self._assert_rmsd(reference, universe, -1, 0.0)

def test_AlignTraj_writer_kwargs(self, universe, reference, tmpdir):
# Issue 4564
with tmpdir.as_cwd():
aligner = align.AlignTraj(universe, reference,
select='protein and name CA',
filename='aligned_traj.xtc',
precision=2,
in_memory=False).run()
assert_equal(aligner._writer.precision, 2)

def _assert_rmsd(self, reference, fitted, frame, desired, weights=None):
fitted.trajectory[frame]
rmsd = rms.rmsd(reference.atoms.positions, fitted.atoms.positions,
Expand Down
Loading