MDAnalysis Command Line Interface (CLI)

The Logo of the MDAnalysis command line interface

We are happy to announce the first version of a command-line interface (CLI) of MDAnalysis! The CLI allows users to calculate radial distribution functions (RDF), Root-mean-square deviations (RMSD), and many more directly from the command line. For example, extracting the RDF between the water oxygens is just one line of code

mda interrdf -s topol.tpr -f traj.trr -g1 "name OW" -g2 "name OW"

For a detailed synopsis and a list of all available modules check the sections below as well as the documentation or the repository.

Providing easier access to the library for day-to-day analysis, mdacli is not only for the MDAnalysis community but also perfect for non-Python users. The project evolved from the experiences of @joaomcteixeira in TaurenMD and from @PiCoCentauri in MAICoS.

Installation

Install mdacli from PyPI

pip install mdacli

A Conda build will be released soon.

Examples

To use mdacli, after installation open your terminal and run

mda -h

This command provides a list of all available modules similar to the in the documentation. The synopsis for calculating a radial distribution function (RDF) between two groups is given by

mda interrdf -h

A sample water trajectory is provided of rigid SPC/E water is provided testfiles. topol.tpr is a GROMACS topolgy file and traj.trr the corresponding trajectory. The oxygen-oxygen RDF can be calculated using

mda interrdf -s topol.tpr -f traj.trr -g1 "name OW" -g2 "name OW"

The oxygens are selected with the -g1 and -g2 flags. More verbose output is achieved by using the -v flag. Even more, information is provided with the --debug flag. All warnings of the run can also be directly stored to a log file using the --logfile flag

mda --debug --logfile rdf.log interrdf -v -s topol.tpr -f traj.trr -g1 "name OW" -g2 "name OW"

The results of each analysis are stored by default in the current directory. The output directory can be changed with the -o flag and an additional prefix can be set using the -pre flag.

The results of the RDF calculations are two .csv files. The actual RDF is saved in the 2nd and 3rd columns of InterRDF_count_bins_rdf.csv. The header rows of each file provide information about the stored data. Simple results such as bare numbers or strings are stored as JSON dumps. More complex data such as 4 or higher-dimensional arrays are saved as a bunch of CSV files zipped together.

Contributions

Contributions are always welcome on Github. Not only in the form of code contributions via pull requests but also issues, especially since the project is in an early development phase.

Motivation and Background

The CLI was developed since we were facing the same problem in the labs regularly. New students/scientists start writing their analysis scripts and face the same challenges and problems i.e.

Some of these problems can be solved by using the MDAnalysis.analysis.base.AnalysisBase class of MDA. However, this class is limited to Python. A generic CLI wrapper for all classes based on the AnalysisBase could therefore help people to analyze their simulation data with the least effort. With this approach, it is easier to use for MDA-users since they just stay within their known universe with known selection commands and results structures. An existing framework makes it also more attractive for users and developers to write their analysis using the base.AnalysisBase. For more technical details visit the documentation.

@PicoCentauri and @joaomcteixeira