Skip to content

Command-line interface (CLI) for headless batch mode

Command-line arguments offer a variety of options that generally override the corresponding parameters in the preferences. The CLI option for mzmine offers to run one batch file (-batch). This batch file can be easily generated by another script or can be a standardized batch file for an analytical method that is applied to multiple datasets.

The most convenient way to apply a batch file to other datasets is to specify the -input and -output arguments to process all import files and to redirect all outputs to another directory. See examples below for how to process all .mzML files in a folder and to redirect outputs to a new directory and base filename.

Selecting a user

Running mzmine in CLI mode requires a user with a valid license. There are three ways to provide one:

  • -cli-token "\<TOKEN>" (recommended for pipelines and servers): a token created in the mzio user account console under CLI tokens. Every run automatically claims a free license from your license pool, so parallel runs need one free license each. See CLI tokens for pipelines.
  • -login (web browser support required): signs in interactively and stores the user on this computer. The most recently active user is then automatically selected for mzmine processing. Without -batch, mzmine closes again after the login.
  • -user "path/to/user.mzuser4": uses a specific user file. Alternatively, provide only the user name, e.g. -user testuser, to use testuser.mzuser4 from your system USER directory under /.mzmine/users/. This is mainly intended for offline (airplane mode) licenses, which are bound to one computer and do not require an internet connection.

Use -list-users to print all users available on this computer together with their license state.

Note

Legacy .mzuser files from older mzmine versions use a different format and are rejected. Log in again via the graphical user interface, -login, or -cli-token to create a new user file.

Limiting the runtime

Use -max-runtime together with -batch to end a batch run after a maximum runtime, for example to stay within the time limit of a job scheduler or a cloud job like AWS lambda. When the time is reached, mzmine

  • cancels all running tasks,
  • returns the claimed license to the license pool
  • exits with exit code 124.

The runtime is measured from the start of mzmine, so the startup counts towards it. Provide whole numbers with a unit d (days), h (hours), m (minutes), or s (seconds), for example 90s, 45m, 2h, or 1d. Units can be combined with or without spaces, like 1h30m or 1h 30m. A number without unit is read as seconds, e.g., 90.

  • Decimal numbers like 1.5h are not supported, use 1h30m or 90m instead.
  • The maximum is 365 days.

An invalid value stops mzmine with an error message before any processing. Without -batch, the argument is ignored with a warning.

Exit code Meaning
0 the batch finished successfully
1 the batch failed or mzmine could not start it
124 the maximum runtime was reached

Warning

A run that reaches the maximum runtime is incomplete. Steps that did not finish, including exports at the end of the batch, produce no results. Leave enough margin for your data.

Tip

When a job scheduler (e.g., SLURM) or a cloud job enforces a time limit, set -max-runtime a few minutes below that limit. A process that is killed from outside may not be able to return its license, which then stays claimed until its claim expires.

Windows

For command-line mode, the mzmine_console.exe is preferred as it will print the logging output to the console.

An easy way to start mzmine with arguments is to create a shortcut to the mzmine.exe or the mzmine_console.exe, right-click, and define the target with additional arguments. This example runs mzmine in batch mode (headless), imports the specified batch file, overrides the memory management to none (which is the default), effectively using memory mapping to store and access spectral, centroid, and feature data from temporary files stored in the defined temp directory. By leaving out the memory or temp arguments, the values stored in the current preferences file will be used, or the default values if no preferences file was found.

Login to a user in command-line mode

# login in browser
"C:\Program Files\mzmine\mzmine_console.exe" -login

# list all users available on this computer
"C:\Program Files\mzmine\mzmine_console.exe" -list-users

Run headless with a CLI token (no interactive login)

"C:\Program Files\mzmine\mzmine_console.exe" -cli-token "TOKEN" -batch "D:\batch\my_batch_file.mzbatch" -input "D:\Data\*.mzML" -output "D:\Results\basename"

End the run after at most 3 hours, cancel all tasks and return the license

"C:\Program Files\mzmine\mzmine_console.exe" -cli-token "TOKEN" -batch "D:\batch\my_batch_file.mzbatch" -max-runtime 3h

Process all .mzML files in a folder by the provided batch file, redirect output files to results folder and use a base filename, various export modules add a specific suffix

"C:\Program Files\mzmine\mzmine_console.exe" -user "D:\user\testuser.mzuser4" -batch "D:\batch\my_batch_file.mzbatch" -input "D:\Data\*.mzML" -output "D:\Results\basename"

Defining the temp folder, otherwise uses the one specified in local configuration

"C:\Program Files\mzmine\mzmine_console.exe" -user "D:\user\testuser.mzuser4" -batch "D:\batch\my_batch_file.mzbatch" -temp "D:\tmpmzmine"

Start mzmine batch with memory mapping (DEFAULT)

"C:\Program Files\mzmine\mzmine_console.exe" -user "D:\user\testuser.mzuser4" -batch "D:\batch\my_batch_file.mzbatch" -memory none -temp "D:\tmpmzmine"

Start mzmine batch on machines with enough memory (RAM) with -memory all this will disable memory mapping to temporary files.

"C:\Program Files\mzmine\mzmine_console.exe" -user "D:\user\testuser.mzuser4" -batch "D:\batch\my_batch_file.mzbatch" -memory all -temp "D:\tmpmzmine"

macOS

If the app was installed to the Applications folder, run this command in the terminal to run a batch file:

/Applications/mzmine.app/Contents/MacOS/mzmine -user "path/to/testuser.mzuser4" -batch /path/to/batch_file.mzbatch

/Applications/mzmine.app/Contents/MacOS/mzmine -user "path/to/testuser.mzuser4" -batch /path/to/batch_file.mzbatch -input "/path/to/data/*.mzML"

Linux

If mzmine was installed (see instructions) correctly, run the code below to start mzmine in GUI mode or CLI batch mode:

/opt/mzmine/bin/mzmine
# some older versions or bad installations may be in:
# /opt/mzmine-linux-installer/bin/mzmine

# run headless with a CLI token
/opt/mzmine/bin/mzmine -cli-token "<TOKEN>" -batch /path/to/batch_file.mzbatch

# end the run after at most 3 h 50 min, e.g., within a 4 h job time limit
/opt/mzmine/bin/mzmine -cli-token "<TOKEN>" -batch /path/to/batch_file.mzbatch -max-runtime 3h50m

# or login in the browser once, then run a batch
/opt/mzmine/bin/mzmine -login
/opt/mzmine/bin/mzmine -batch /path/to/batch_file.mzbatch

Argument table

Argument Options (default) Description Available since
-v and -version no argument show version
-h and -help no argument show help
-u and -user a path, e.g., "D:\myuser.mzuser4", or a user name, e.g., testuser Path to an .mzuser4 file to login a user. This file is copied to the users directory. Alternatively, provide only the user name to use that user from the users directory. To obtain a user file, login in the mzmine graphical user interface (GUI) or claim an offline license in the mzio user account console. User files can be found in your system USER directory in /.mzmine/users/ after login. Legacy .mzuser files from older mzmine versions are rejected, login again to create a new user file. Intended for offline (airplane mode) licenses; for online users prefer -cli-token to automatically claim and release licenses from the floating pool.
-cli-token a token, e.g., "TOKEN" Login with a pregenerated token and automatically claim a license from the license pool for this run. Create the token in the mzio user account console under CLI tokens. Intended for headless runs such as CI pipelines or cloud jobs. Parallel runs each claim their own license. See CLI tokens. 4.11
-login no argument Use the command-line to login to a user. This will open the login website in the system internet browser, if supported. After successful login, a user file will be copied to your system USER directory in /.mzmine/users/. And the current user will be saved to the configuration. The created user file can be accessed with the -user argument on the next startup. Without -batch, mzmine closes again after the login.
-list-users no argument List all users available on this system. The users are read from the system USER directory /.mzmine/users/.
-b and -batch a path, e.g., "D:\batch.mzbatch" Path to batch file that will be run in command-line mode.
-max-runtime a duration, e.g., 45m, 2h, 1h30m, 1d Only with -batch: maximum runtime of mzmine, measured from its start. When the time is reached, mzmine cancels all tasks, returns the claimed license to the license pool and exits with exit code 124. Provide whole numbers with a unit d, h, m, or s. Units can be combined, e.g., 1h30m or 1h 30m. A number without unit is read as seconds. The maximum is 365 days. See Limiting the runtime.
-i and -input a txt file or glob pattern, e.g., "D:\Data*.mzML" input data files. Either defined in a .txt text file with one file per line or by glob pattern matching. To match all .mzML files in a path: -i "D:\Data\*.mzML"
-l and -libraries a txt file or glob pattern, e.g., "D:\Data*.json" spectral library files. Either defined in a .txt text file with one file per line or by glob pattern matching. To match all .json or .mgf files in a path: -libraries "D:\Data\*.json"
-o and -output An output path and base filename, e.g., "D:\basename" The base file name will be extended by default module names to export all files.
-m and -memory none, all, features, centroids, raw, masses_features Defines what data is kept in memory (RAM) or otherwise memory mapped to the temp directory. Generally this setting should be none. If memory is no issue this option might be set to all process all spectral and feature data in memory. The option masses_features keeps centroid mass lists and features in memory while memory mapping raw spectral data.
-t and -temp a path, e.g., "-temp "D:\tmpmzmine\" The defined directory should be on a fast drive (usually SSD > HDD > network drive) with enough free space. Local drives are usually preferred. mzmine uses memory mapping to efficiently store and access spectral and feature data. This can lead to a considerable temporary consumption of disk space. Make sure that the selected drive has enough space (maybe 20 GB + 1 GB/10 files; generously over estimated).
-p and -pref a path, e.g., "D:\config.mzconfig" An mzmine configuration file in xml format. The general preferences.
-threads int number of threads or 'auto' replace the preference parameter with either 'auto' to detect the number of available cores - or an int number of threads for processing.
-ignore-parameter-warnings no argument When a .mzbatch file from an older mzmine version was loaded that may have an influence on the mzmine processing, the cli mode will fail by default, printing a message of the affected parameters. If this argument is set, the warnings will be ignored and the batch will be run anyway. 4.6.14

Robin Schmid, Steffen Heuckeroth, omokshyna