Remove -sub option from trjconv
[alexxy/gromacs.git] / docs / user-guide / cmdline.rst
1 .. _gmx-cmdline:
2
3 Command-line reference
4 ======================
5
6 .. toctree::
7    :hidden:
8    :glob:
9
10    /onlinehelp/gmx
11    /onlinehelp/gmx-*
12
13 |Gromacs| includes many tools for preparing, running and analyzing
14 molecular dynamics simulations. These are all structured as part of a single
15 :command:`gmx` wrapper binary, and invoked with commands like :command:`gmx grompp`.
16 :ref:`mdrun <gmx mdrun>` is the only other binary that
17 :ref:`can be built <building just the mdrun binary>`; in the normal
18 build it can be run with :command:`gmx mdrun`. Documentation for these can
19 be found at the respective sections below, as well as on man pages (e.g.,
20 :manpage:`gmx-grompp(1)`) and with :samp:`gmx help {command}` or
21 :samp:`gmx {command} -h`.
22
23 If you've installed an MPI version of |Gromacs|, by default the
24 :command:`gmx` binary is called :command:`gmx_mpi` and you should adapt
25 accordingly.
26
27 Command-line interface and conventions
28 --------------------------------------
29
30 All |Gromacs| commands require an option before any arguments (i.e., all
31 command-line arguments need to be preceded by an argument starting with a
32 dash, and values not starting with a dash are arguments to the preceding
33 option).  Most options, except for boolean flags, expect an argument (or
34 multiple in some cases) after the option name.
35 The argument must be a separate command-line argument, i.e., separated by
36 space, as in ``-f traj.xtc``.  If more than one argument needs to be given to
37 an option, they should be similarly separated from each other.
38 Some options also have default arguments, i.e., just specifying the option
39 without any argument uses the default argument.
40 If an option is not specified at all, a default value is used; in the case of
41 optional files, the default might be not to use that file (see below).
42
43 All |Gromacs| command options start with a single dash, whether they are
44 single- or multiple-letter options.  However, two dashes are also recognized
45 (starting from 5.1).
46
47 In addition to command-specific options, some options are handled by the
48 :command:`gmx` wrapper, and can be specified for any command.  See
49 :doc:`wrapper binary help </onlinehelp/gmx>` for the list of such options.
50 These options are recognized both before the command name (e.g.,
51 :command:`gmx -quiet grompp`) as well as after the command name (e.g.,
52 :command:`gmx grompp -quiet`).
53 There is also a ``-hidden`` option that can be specified in combination with
54 ``-h`` to show help for advanced/developer-targeted options.
55
56 Most analysis commands can process a trajectory with fewer atoms than the
57 run input or structure file, but only if the trajectory consists of the
58 first *n* atoms of the run input or structure file.
59
60 Handling specific types of command-line options
61 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62
63 boolean options
64   Boolean flags can be specified like ``-pbc`` and negated like ``-nopbc``.
65   It is also possible to use an explicit value like ``-pbc no`` and
66   ``-pbc yes``.
67 file name options
68   Options that accept files names have features that support using default file
69   names (where the default file name is specific to that option):
70
71   * If a required option is not set, the default is used.
72   * If an option is marked optional, the file is not used unless the option
73     is set (or other conditions make the file required).
74   * If an option is set, and no file name is provided, the default is used.
75
76   All such options will accept file names without a file extension.
77   The extension is automatically appended in such a case.
78   When multiple input formats are accepted, such as a generic structure format,
79   the directory will be searched for files of each type with the supplied or
80   default name. When no file with a recognized extension is found, an error is given.
81   For output files with multiple formats, a default file type will be used.
82
83   Some file formats can also be read from compressed (:file:`.Z` or
84   :file:`.gz`) formats.
85 enum options
86   Enumerated options (enum) should be used with one of the arguments listed in
87   the option description. The argument may be abbreviated, and the first match
88   to the shortest argument in the list will be selected.
89 vector options
90   Some options accept a vector of values.  Either 1 or 3 parameters can be
91   supplied; when only one parameter is supplied the two other values are also
92   set to this value.
93 selection options
94   See :doc:`/onlinehelp/selections`.
95
96 Commands by name
97 ----------------
98
99 .. include:: /fragments/byname.rst
100
101 Commands by topic
102 -----------------
103
104 .. include:: /fragments/bytopic.rst
105
106 Special topics
107 --------------
108
109 The information in these topics is also accessible through
110 :samp:`gmx help {topic}` on the command line.
111
112 Selection syntax and usage
113 ^^^^^^^^^^^^^^^^^^^^^^^^^^
114
115 .. toctree::
116
117    /onlinehelp/selections
118
119 .. _command-changes:
120
121 Command changes between versions
122 --------------------------------
123
124 Starting from |Gromacs| 5.0, some of the analysis commands (and a few other
125 commands as well) have changed significantly.
126
127 One main driver for this has been that many new tools mentioned below now
128 accept selections through one or more command-line options instead of prompting
129 for a static index group.  To take full advantage of selections, the interface
130 to the commands has changed somewhat, and some previous command-line options
131 are no longer present as the same effect can be achieved with suitable
132 selections.
133 Please see :doc:`/onlinehelp/selections` additional information on how to use
134 selections.
135
136 In the process, some old analysis commands have been removed in favor of more
137 powerful functionality that is available through an alternative tool.
138 For removed or replaced commands, this page documents how to perform the same
139 tasks with new tools.
140 For new commands, a brief note on the available features is given.  See the
141 linked help for the new commands for a full description.
142
143 This section lists only major changes; minor changes like additional/removed
144 options or bug fixes are not typically included.
145
146 For more information about changed features, please check out the
147 :ref:`release notes <release-notes>`.
148
149 Version 2020
150 ^^^^^^^^^^^^
151
152 gmx convert-trj
153 ...............
154
155 **new**
156
157 :ref:`gmx convert-trj` has been introduced as a selection-enabled alternative
158 for exchanging trajectory file format (previously done in :ref:`gmx trjconv`).
159
160 gmx extract-cluster
161 ...................
162
163 **new**
164
165 :ref:`gmx extract-cluster` has been introduced as a selection-enabled way to
166 write sub-trajectories based on the output from a cluster analysis. The 
167 corresponding option **-sub** in :ref:`gmx trjconv` has been removed.
168
169 Version 2018
170 ^^^^^^^^^^^^
171
172 gmx trajectory
173 ..............
174
175 **new**
176
177 :ref:`gmx trajectory` has been introduced as a selection-enabled version of
178 :ref:`gmx traj`.  It supports output of coordinates, velocities, and/or forces
179 for positions calculated for selections.
180
181 Version 2016
182 ^^^^^^^^^^^^
183
184 Analysis on arbitrary subsets of atoms
185 ......................................
186
187 Tools implemented in the new analysis framework can now operate upon trajectories
188 that match only a subset of the atoms in the input structure file.
189
190 gmx insert-molecules
191 ....................
192
193 **improved**
194
195 :ref:`gmx insert-molecules` has gained an option ``-replace`` that makes it
196 possible to insert molecules into a solvated configuration, replacing any
197 overlapping solvent atoms.  In a fully solvated box, it is also possible to
198 insert into a certain region of the solvent only by selecting a subset of the
199 solvent atoms (``-replace`` takes a selection that can also contain expressions
200 like ``not within 1 of ...``).
201
202 gmx rdf
203 .......
204
205 **improved**
206
207 The normalization for the output RDF can now also be the radial number density.
208
209 gmx genconf
210 ...........
211
212 **simplified**
213
214 Removed ``-block``, ``-sort`` and ``-shuffle``.
215
216 Version 5.1
217 ^^^^^^^^^^^
218
219 General
220 .......
221
222 Symbolic links from 5.0 are no longer supported.  The only way to invoke a
223 command is through :samp:`gmx {<command>}`.
224
225 gmx pairdist
226 ............
227
228 **new**
229
230 :ref:`gmx pairdist` has been introduced as a selection-enabled replacement for
231 :ref:`gmx mindist` (``gmx mindist`` still exists unchanged).  It can calculate
232 min/max pairwise distances between a pair of selections, including, e.g.,
233 per-residue minimum distances or distances from a single point to a set of
234 residue-centers-of-mass.
235
236 gmx rdf
237 .......
238
239 **rewritten**
240
241 :ref:`gmx rdf` has been rewritten for 5.1 to use selections for specifying the
242 points from which the RDFs are calculated.  The interface is mostly the same,
243 except that there are new command-line options to specify the selections.
244 The following additional changes have been made:
245
246 * ``-com`` and ``-rdf`` options have been removed.  Equivalent functionality is
247   available through selections:
248
249   * ``-com`` can be replaced with a :samp:`com of {<selection>}` as the
250     reference selection.
251   * ``-rdf`` can be replaced with a suitable set of selections (e.g.,
252     :samp:`res_com of {<selection>}`) and/or using ``-seltype``.
253
254 * ``-rmax`` option is added to specify a cutoff for the RDFs.  If set to a
255   value that is significantly smaller than half the box size, it can speed up
256   the calculation significantly if a grid-based neighborhood search can be
257   used.
258 * ``-hq`` and ``-fade`` options have been removed, as they are simply
259   postprocessing steps on the raw numbers that can be easily done after the
260   analysis.
261
262 Version 5.0
263 ^^^^^^^^^^^
264
265 General
266 .......
267
268 Version 5.0 introduced the :command:`gmx` wrapper binary.
269 For backwards compatibility, this version still creates symbolic links by default for
270 old tools: e.g., ``g_order <options>`` is equivalent to ``gmx order <options>``, and
271 ``g_order`` is simply a symbolic link on the file system.
272
273 g_bond
274 ......
275
276 **replaced**
277
278 This tool has been removed in 5.0. A replacement is :ref:`gmx distance`.
279
280 You can provide your existing index file to :ref:`gmx distance`, and it will
281 calculate the same distances.  The differences are:
282
283 * ``-blen`` and ``-tol`` options have different default values.
284 * You can control the output histogram with ``-binw``.
285 * ``-aver`` and ``-averdist`` options are not present.  Instead, you can choose
286   between the different things to calculate using ``-oav`` (corresponds to
287   ``-d`` with ``-averdist``), ``-oall`` (corresponds to ``-d`` without
288   ``-averdist``), ``-oh`` (corresponds to ``-o`` with ``-aver``), and
289   ``-oallstat`` (corresponds to ``-l`` without ``-aver``).
290
291 You can produce any combination of output files.  Compared to ``g_bond``,
292 ``gmx distance -oall`` is currently missing labels for the output columns.
293
294 g_dist
295 ......
296
297 **replaced**
298
299 This tool has been removed in 5.0.  A replacement is :ref:`gmx distance` (for
300 most options) or :ref:`gmx select` (for ``-dist`` or ``-lt``).
301
302 If you had index groups A and B in :file:`index.ndx` for ``g_dist``, you can use the
303 following command to compute the same distance with ``gmx distance``::
304
305   gmx distance -n index.ndx -select 'com of group "A" plus com of group "B"' -oxyz -oall
306
307 The ``-intra`` switch is replaced with ``-nopbc``.
308
309 If you used ``-dist D``, you can do the same calculation with ``gmx select``::
310
311   gmx select -n index.ndx -select 'group "B" and within D of com of group "A"' -on/-oi/-os/-olt
312
313 You can select the output option that best suits your post-processing needs
314 (``-olt`` is a replacement for ``g_dist -dist -lt``)
315
316 gmx distance
317 ............
318
319 **new**
320
321 :ref:`gmx distance` has been introduced as a selection-enabled replacement for
322 various tools that computed distances between fixed pairs of atoms (or
323 centers-of-mass of groups).  It has a combination of the features of ``g_bond``
324 and ``g_dist``, allowing computation of one or multiple distances, either
325 between atom-atom pairs or centers-of-mass of groups, and providing a
326 combination of output options that were available in one of the tools.
327
328 gmx gangle
329 ..........
330
331 **new**
332
333 :ref:`gmx gangle` has been introduced as a selection-enabled replacement for
334 ``g_sgangle``.  In addition to supporting atom-atom vectors, centers-of-mass
335 can be used as endpoints of the vectors, and there are a few additional angle
336 types that can be calculated.  The command also has basic support for
337 calculating normal angles between three atoms and/or centers-of-mass, making it
338 a partial replacement for :ref:`gmx angle` as well.
339
340 gmx protonate
341 .............
342
343 **replaced**
344
345 This was a very old tool originally written for united atom force fields,
346 where it was necessary to generate all hydrogens after running a trajectory
347 in order to calculate e.g. distance restraint violations. The functionality
348 to simply protonate a structure is available in :ref:`gmx pdb2gmx`. 
349 If there is significant interest, we might reintroduce it after moving to new
350 topology formats in the future.
351
352 gmx freevolume
353 ..............
354
355 **new**
356
357 This tool has been introduced in 5.0.  It uses a Monte Carlo sampling method to
358 calculate the fraction of free volume within the box (using a probe of a given
359 size).
360
361 g_sas
362 .....
363
364 **rewritten**
365
366 This tool has been rewritten in 5.0, and renamed to :ref:`gmx sasa` (the
367 underlying surface area calculation algorithm is still the same).
368
369 The main difference in the new tool is support for selections.  Instead of
370 prompting for an index group, a (potentially dynamic) selection for the
371 calculation can be given with ``-surface``.  Any number of output groups can be
372 given with ``-output``, allowing multiple parts of the surface area to be
373 computed in a single run.  The total area of the ``-surface`` group is now
374 always calculated.
375
376 The tool no longer automatically divides the surface into hydrophobic and
377 hydrophilic areas, and there is no ``-f_index`` option.  The same effects can
378 be obtained by defining suitable selections for ``-output``.  If you want
379 output that contains the same numbers as with the old tool for a calculation
380 group ``A`` and output group ``B``, you can use ::
381
382   gmx sasa -surface 'group "A"' -output '"Hydrophobic" group "A" and charge {-0.2 to 0.2}; "Hydrophilic" group "B" and not charge {-0.2 to 0.2}; "Total" group "B"'
383
384 Solvation free energy estimates are now calculated only if separately requested
385 with ``-odg``, and are written into a separate file.
386
387 Output option ``-i`` for a position restraint file is not currently implemented
388 in the new tool, but would not be very difficult to add if requested.
389
390 g_sgangle
391 .........
392
393 **replaced**
394
395 This tool has been removed in 5.0.  A replacement is :ref:`gmx gangle` (for
396 angle calculation) and :ref:`gmx distance` (for ``-od``, ``-od1``, ``-od2``).
397
398 If you had index groups A and B in index.ndx for ``g_sgangle``, you can use the
399 following command to compute the same angle with ``gmx gangle``::
400
401   gmx gangle -n index.ndx -g1 vector/plane -group1 'group "A"' -g2 vector/plane -group2 'group "B"' -oav
402
403 You need to select either ``vector`` or ``plane`` for the ``-g1`` and ``-g2``
404 options depending on which one your index groups specify.
405
406 If you only had a single index group A in index.ndx and you used ``g_sgangle``
407 ``-z`` or ``-one``, you can use::
408
409   gmx gangle -n index.ndx -g1 vector/plane -group1 'group "A"' -g2 z/t0 -oav
410
411 For the distances, you can use :ref:`gmx distance` to compute one or more
412 distances as you want.  Both distances between centers of groups or individual
413 atoms are supported using the new selection syntax.
414
415 genbox
416 ......
417
418 This tool has been split to :ref:`gmx solvate` and :ref:`gmx insert-molecules`.
419
420 tpbconv
421 .......
422
423 This tool has been renamed :ref:`gmx convert-tpr`.