Skip to content
Closed
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
2 changes: 2 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ mm/dd/yy richardjgowers, kain88-de, lilyminium, p-j-smith, bdice, joaomcteixeira
* 0.21.0

Fixes
* fixed LammpsDumpParser failing on files with >5 fields in atom lines
(PR #2333)
* Handle exception when PDBWriter is trying to remove an invalid StringIO
(Issue #2512)
* Clarifies density_from_Universe docs and adds user warning (Issue #2372)
Expand Down
7 changes: 5 additions & 2 deletions package/MDAnalysis/coordinates/LAMMPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ class DumpReader(base.ReaderBase):
"""Reads the default `LAMMPS dump format`_

Expects trajectories produced by the default 'atom' style dump.
The id of the atom must be the first field, and the coordinates
must be the last 3 fields.

Will automatically convert positions from their scaled/fractional
representation to their real values.
Expand Down Expand Up @@ -563,9 +565,10 @@ def _read_next_timestep(self):

f.readline() # ITEM ATOMS etc
for i in range(self.n_atoms):
idx, _, xs, ys, zs = f.readline().split()
fields = f.readline().split()

indices[i] = idx
indices[i] = fields[0]
xs, ys, zs = fields[-3:]
ts.positions[i] = xs, ys, zs

order = np.argsort(indices)
Expand Down
13 changes: 8 additions & 5 deletions package/MDAnalysis/topology/LAMMPSParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,12 @@ def _parse_box(self, header):


class LammpsDumpParser(TopologyReaderBase):
"""Parses Lammps ascii dump files in 'atom' format
"""Parses Lammps ascii dump files in 'atom' format.

The id of the atom must be the first field, and the atom types
must be the second field.

Only reads atom ids. Sets all masses to 1.0.
Sets all masses to 1.0.

.. versionadded:: 0.19.0
"""
Expand All @@ -619,10 +622,10 @@ def parse(self, **kwargs):

fin.readline() # ITEM ATOMS
for i in range(natoms):
idx, atype, _, _, _ = fin.readline().split()
fields = fin.readline().split()

indices[i] = idx
types[i] = atype
indices[i] = fields[0]
types[i] = fields[1]

order = np.argsort(indices)
indices = indices[order]
Expand Down
Binary file not shown.
2 changes: 2 additions & 0 deletions testsuite/MDAnalysisTests/datafiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"LAMMPShyd", "LAMMPShyd2",
"LAMMPSdata_deletedatoms", # with deleted atoms
"LAMMPSDUMP",
"LAMMPSDUMP_long", # lammpsdump file with extra columns
"unordered_res", # pdb file with resids non sequential
"GMS_ASYMOPT", # GAMESS C1 optimization
"GMS_SYMOPT", # GAMESS D4h optimization
Expand Down Expand Up @@ -440,6 +441,7 @@
LAMMPShyd2 = resource_filename(__name__, "data/lammps/hydrogen-class1.data2")
LAMMPSdata_deletedatoms = resource_filename(__name__, 'data/lammps/deletedatoms.data')
LAMMPSDUMP = resource_filename(__name__, "data/lammps/wat.lammpstrj.bz2")
LAMMPSDUMP_long = resource_filename(__name__, "data/lammps/wat.lammpstrj_long.bz2")

unordered_res = resource_filename(__name__, "data/unordered_res.pdb")

Expand Down
5 changes: 5 additions & 0 deletions testsuite/MDAnalysisTests/topology/test_lammpsdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
LAMMPShyd2,
LAMMPSdata_deletedatoms,
LAMMPSDUMP,
LAMMPSDUMP_long,
)


Expand Down Expand Up @@ -270,3 +271,7 @@ def test_id_ordering(self):
u = mda.Universe(self.ref_filename, format='LAMMPSDUMP')
# the 4th in file has id==13, but should have been sorted
assert u.atoms[3].id == 4

class TestDumpParserLong(TestDumpParser):

ref_filename = LAMMPSDUMP_long