A library to handle the reading and writing of a gro file.
pip install groio
import groio
#Read a gro file
title, atoms, box = groio.parse_file("filin.gro")
#Write a gro file
with open("filout.gro", "w") as f:
for line in groio.write_gro(title, output_atoms, box):
print(line, end='', file=f)
#Renumber the atoms to avoid number above 100 000
atoms = groio.renumber(atoms)
The function parse_file
returns :
title
: the title of the system as written on line 1 of the file as a stringatoms
: a list of atom, each atom is stored as a dictionarybox
: the box description as written on the last line as a string
- Unit tests are available through nosetests python module.
- nosetests tests/test_groio.py