Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mm/dd/yy richardjgowers, kain88-de, lilyminium, p-j-smith, bdice, joaomcteixeira
* 0.21.0

Fixes
* MOL2Writer now accepts both Universes and AtomgGroups (Issue #2717)
* Use user-provided `remark` in `XYZWriter` (Issue #2692)
* Added more informative error messages about topology attributes
(Issue #2565)
Expand Down
2 changes: 2 additions & 0 deletions package/MDAnalysis/coordinates/MOL2.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ def encode_block(self, obj):
----------
obj : AtomGroup or Universe
"""
# Issue 2717
obj = obj.atoms
traj = obj.universe.trajectory
ts = traj.ts

Expand Down
17 changes: 17 additions & 0 deletions testsuite/MDAnalysisTests/coordinates/test_mol2.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from numpy.testing import (
assert_equal, assert_array_equal,
assert_array_almost_equal, TestCase,
assert_almost_equal
)

from MDAnalysisTests.datafiles import (
Expand Down Expand Up @@ -190,3 +191,19 @@ def test_mol2_multi_write(tmpdir):
u = mda.Universe(mol2_molecules)
u.atoms[:4].write('group1.mol2')
u.atoms[:4].write('group1.mol2')


def test_mol2_universe_write(tmpdir):
# see Issue 2717
with tmpdir.as_cwd():
outfile = 'test.mol2'

u = mda.Universe(mol2_comments_header)

with mda.Writer(outfile) as W:
W.write(u)

u2 = mda.Universe(outfile)

assert_almost_equal(u.atoms.positions, u2.atoms.positions)
assert_almost_equal(u.dimensions, u2.dimensions)