vermouth.gmx.itp_read module¶
Read GROMACS .itp files.
-
class
vermouth.gmx.itp_read.
ITPDirector
(force_field)[source]¶ Bases:
vermouth.parser_utils.SectionLineParser
class for reading itp files.
-
COMMENT_CHAR
= ';'¶
-
METH_DICT
= {('macros',): (<function SectionLineParser._macros>, {}), ('moleculetype',): (<function ITPDirector._block>, {}), ('moleculetype', 'angle_restraints'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'angle_restraints_z'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'angles'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'atoms'): (<function ITPDirector._block_atoms>, {}), ('moleculetype', 'bonds'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'constraints'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'dihedral_restraints'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'dihedrals'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'distance_restraints'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'exclusions'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'impropers'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'orientation_restraints'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'pairs'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'pairs_nb'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'position_restraints'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'settles'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'virtual_sites1'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'virtual_sites2'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'virtual_sites3'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'virtual_sites4'): (<function ITPDirector._interactions>, {}), ('moleculetype', 'virtual_sitesn'): (<function ITPDirector._interactions>, {})}¶
-
atom_idxs
= {'angle_restraints': [slice(0, 4, None)], 'angle_restraints_z': [0, 1], 'angles': [0, 1, 2], 'bonds': [0, 1], 'constraints': [0, 1], 'dihedral_restraints': [slice(0, 4, None)], 'dihedrals': [0, 1, 2, 3], 'distance_restraints': [0, 1], 'exclusions': [slice(None, None, None)], 'orientation_restraints': [0, 1], 'pairs': [0, 1], 'pairs_nb': [0, 1], 'position_restraints': [0], 'settles': [0], 'virtual_sites1': [0], 'virtual_sites2': [0, 1, 2], 'virtual_sites3': [0, 1, 2, 3], 'virtual_sites4': [slice(0, 5, None)], 'virtual_sitesn': [0, slice(2, None, None)]}¶
-
dispatch
(line)[source]¶ Looks at line to see what kind of line it is, and returns either
parse_header()
if line is a section header orvermouth.parser_utils.SectionLineParser.parse_section()
otherwise. Callsvermouth.parser_utils.SectionLineParser.is_section_header()
to see whether line is a section header or not.Parameters: line (str) – Returns: The method that should be used to parse line. Return type: collections.abc.Callable
-
finalize
(lineno=0)[source]¶ Called at the end of the file and checks that all pragmas are closed before calling the parent method.
-
finalize_section
(previous_section, ended_section)[source]¶ Called once a section is finished. It appends the current_links list to the links and update the block dictionary with current_block. Thereby it finishes reading a given section.
Parameters:
-
static
is_pragma
(line)[source]¶ Parameters: line (str) – A line of text. Returns: True
iff line is a def statement.Return type: bool
-
parse_header
(line, lineno=0)[source]¶ Parses a section header with line number lineno. Sets
vermouth.parser_utils.SectionLineParser.section
when applicable. Does not check whether line is a valid section header.Parameters: Returns: The result of calling
finalize_section()
, which is called if a section ends.Return type: Raises: KeyError
– If the section header is unknown.
-
parse_pragma
(line, lineno=0)[source]¶ Parses the beginning and end of define sections with line number lineno. Sets attr current_meta when applicable. Does check if ifdefs overlap.
Parameters: Returns: The result of calling
finalize_section()
, which is called if a section ends.Return type: Raises: IOError
– If the def sections are missformatted
-
-
vermouth.gmx.itp_read.
read_itp
(lines, force_field)[source]¶ Parses lines of itp format and adds the molecule as a block to force_field.
Parameters: - lines (list) – list of lines of an itp file
- force_field (
vermouth.forcefield.ForceField
) –