xpm File Processing Script Tutorial

When outputting two-dimensional matrix data, GROMACS often uses xpm format files. Although files in this format can be converted to ps image format using xpm2ps and then viewed, after all, there is one more command, which is not very convenient. We need to find a way to directly double-click to view the xpm file, just like viewing other image formats. xpm is a picture format, and some picture viewing programs support this format, such as irfanview that I want to use here. But the xpm format given by GROMACS has a lot of annotations for drawing, which will cause irfanview to recognize Error, so what we have to do is to delete these comments, and then use irfanview to view. The script we want to share here, in addition to the most basic viewing functions, has two other functions:

✓ Change the color mapping method of the data, a total of 8 color mapping methods are supported.

✓ Convert xpms data to xyz data for drawing with other programs.

Of course, for the second requirement, the most direct way is to directly let GROMACS output the original data. But many GROMACS commands do not have this option, so we have to restore the original data from xpm. The accuracy of the data obtained in this way is of course limited, but it is enough for drawing.

Script

The premise of using this script is to install the most basic bash operating environment.

Under Windows, in order to achieve the purpose of double-clicking and viewing, we also need to change the opening method of xpm to an executable program. This executable program is implemented as a batch program xpm.bat. Its function is to call bash. This script changes the color mapping of the original xpm file of GROMACS, and then converts it into a temporary file recognized by irfanview, then opens it with irfanview, and finally deletes the temporary file. When using it, please change the path of irfanview to your own path.

Example

Take the covariance matrix output by gmx covar as an example. The first in the figure below is the GROMACS default blue and white color mapping, followed by 5 different rainbow color mappings. The first in the last line is the python default viridis. The second is the default parula of matlab, and the third is the Diverging-CoolWarm commonly used in the literature.

xpm File Processing Script TutorialFigure 1. The first is the GROMACS default blue and white color mapping, followed by 7 different rainbow color mappings.

* For Research Use Only.
Inquiry