# vermouth.gmx.itp module¶

Handle the ITP file format from Gromacs.

vermouth.gmx.itp.write_molecule_itp(molecule, outfile, header=(), moltype=None, post_section_lines=None, pre_section_lines=None)[source]

Write a molecule in ITP format.

The molecule must have a nrexcl attribute. Each atom in the molecule must have at least the following keys: atype, resid, resname, atomname, and charge_group. Atoms can also have a charge and a mass key.

If the moltype argument is not provided, then the molecule must have a “moltype” meta attribute.

Parameters: molecule (Molecule) – The molecule to write. See above for the minimal information the molecule must contain. outfile (io.TextIOBase) – The file in which to write. header (collections.abc.Iterable[str]) – List of lines to write as comment at the beginning of the file. The comment character and the new line should not be included as they will be added in the function. moltype (str, optional) – The molecule type. If set to None (default), the molecule type is read from the “moltype” key of molecule.meta. post_section_lines (dict[str, collections.abc.Iterable[str]], optional) – List of lines to write at the end of some sections of the file. The argument is passed as a dict with the keys being the name of the sections, and the values being the lists of lines. If the argument is set to None, the lines will be read from the “post_section_lines” key of molecule.meta. pre_section_lines (dict[str, collections.abc.Iterable[str]], optional) – List of lines to write at the beginning of some sections, just after the section header. The argument is formatted in the same way as post_section_lines. If the argument is set to None, the lines will be read from the “post_section_lines” key of molecule.meta. ValueError – The molecule is missing required information.