Skip to content

Commit

Permalink
add box to molecule when parsing gro files
Browse files Browse the repository at this point in the history
  • Loading branch information
fgrunewald committed Apr 25, 2023
1 parent 99a936f commit 954cd36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions vermouth/gmx/gro.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ def read_gro(file_name, exclude=('SOL',), ignh=False):

molecule.add_node(idx, **properties)
idx += 1
box = np.array(line.strip().split(), dtype=float)
# not pretty but the parser is out of touch with the rest of the parsing
# infrastructure already
molecule.box = box

return molecule


Expand Down
2 changes: 1 addition & 1 deletion vermouth/tests/gmx/test_gro.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def test_read_gro(gro_reference, exclude, ignh): # pylint: disable=redefined-ou
molecule = gro.read_gro(filename, exclude=exclude, ignh=ignh)
pprint(list(molecule.nodes.items()))
assert_molecule_equal(molecule, reference)

assert all(molecule.box == np.array([10.0, 11.1, 12.2]))

def test_read_gro_wrong_atom_number(gro_wrong_length): # pylint: disable=redefined-outer-name
"""
Expand Down

0 comments on commit 954cd36

Please sign in to comment.