GROMACS topologies¶
MoleculeTopology
dataclass
¶
Represents the topology of a molecule within a GROMACS simulation.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the molecule. |
number_elements |
int
|
The number of elements (atoms) in the molecule. |
Source code in martignac/parsers/gromacs_topologies.py
Topology
dataclass
¶
Represents the overall topology of a molecular system in a GROMACS simulation.
This class encapsulates the system's name, the molecules present within the system, and any include files necessary for the simulation. It provides methods to parse topology files (.top), update molecule counts based on a given .gro file, and output a new topology file.
Attributes:
Name | Type | Description |
---|---|---|
system |
str
|
A descriptive name for the system. |
molecules |
list[MoleculeTopology]
|
A list of |
includes |
list[str]
|
A list of paths to additional topology files to be included in the simulation. |
Methods:
Name | Description |
---|---|
parse_top_file |
str) -> "Topology":
Class method to parse a GROMACS topology file (.top) and return a |
update_counts_against_gro |
str) -> None: Updates the molecule counts in the topology based on the actual counts found in a .gro file. |
output_top |
str) -> None: Writes the topology to a new .top file, including all molecules, system name, and include files. |
Source code in martignac/parsers/gromacs_topologies.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
append_all_includes_to_top(main_top, others)
¶
Combines the include files from multiple Topology instances into a single Topology instance.
This function takes a main Topology instance and a list of other Topology instances, then combines all unique include file paths from these instances into the main Topology instance. The main Topology's include list is first cleared to ensure no duplicates from its original includes, and then it is populated with unique includes from all provided Topology instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
main_top |
Topology
|
The main Topology instance to which all unique include file paths from other Topology instances will be added. |
required |
others |
list[Topology]
|
A list of other Topology instances from which to gather all unique include file paths. |
required |
Returns:
Name | Type | Description |
---|---|---|
Topology |
Topology
|
The updated main Topology instance with a combined list of unique include file paths. |
Source code in martignac/parsers/gromacs_topologies.py
combine_multiple_topology_files(topology_files, system_name)
¶
Combines multiple GROMACS topology files into a single Topology instance.
This function parses multiple topology (.top) files, each representing a part of a molecular system, and combines them into a single Topology instance. It aggregates all molecules and include files from each topology file, ensuring no duplicates in the include files. The system name for the combined topology is specified by the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
topology_files |
list[str]
|
A list of paths to the topology files to be combined. |
required |
system_name |
str
|
The name to assign to the combined system. |
required |
Returns:
Name | Type | Description |
---|---|---|
Topology |
Topology
|
An instance of the Topology class representing the combined topology of all input files. |