Moltemplate is a general cross-platform text-based molecule builder for LAMMPS and (the TCL version of) ESPResSo. Moltemplate was intended for building custom coarse-grained molecular models, but it can be used to prepare realistic all-atom simulations as well. It currently supports the OPLSAA, OPLSUA, LOPLS(2015), COMPASS, AMBER(GAFF,GAFF2), TraPPE(1998), force fields, the ATB database, and the MOLC, mW, ELBA(water), oxDNA2, and EFF molecular models (and others). Moltemplate is interoperable with ATB, VMD/topotools, PACKMOL, CellPACK, LigParGen, Vipster, NanoHub struc2lammpsdf, Open Babel and any other program that reads or generates LAMMPS data (.lmpdat) files. This repository includes approximately 50 examples. (New force fields and examples are added continually by users.)
The best way to learn how to use moltemplate is to find an example which is similar to the system that you wish to simulate and modify it. Some of the moltemplate examples are also demonstrated (with pictures) here.
All moltemplate users should probably read chapter 4 of the reference manual (It's only a few pages long. The first 3 chapters are optional.) In addition, there are also several talks/tutorials online.
moltemplate.sh [-atomstyle style] [-pdb/-xyz coord_file] [-vmd] system.lt
Additional suggestions and supporting code can be found at:
Moltemplate requires the Bourne-shell, and a recent version of python (2.7, 3.0 or higher), and can run on OS X, linux, or windows. (...if a suitable shell environment has been installed. See below.)
The numpy python module is also required.
This directory should contain 3 folders:
moltemplate/ <-- source code and force fields doc/ <-- the moltemplate reference manual examples/ <-- examples built with moltemplate
There are two ways to install moltemplate:
Installation using pip
If you are familiar with pip, then run the following command from within the directory where this README file is located:
pip install . --user
This will install moltemplate for a single user. On a shared computer, to install moltemplate system-wide, use:
sudo pip install .
Make sure that your default pip install bin directory is in your PATH. (This is usually something like ~/.local/bin/ or ~/anaconda3/bin/. If you have installed anaconda, this will be done for you automatically.) Later, you can uninstall moltemplate using:
pip uninstall moltemplate
If you continue to run into difficulty, try installing moltemplate into a temporary virtual environment by installing "virtualenv", downloading moltemplate (to "~/moltemplate" in the example below), and running these commands:
cd ~/moltemplate python -m venv venv #(or "virtualenv venv" if using python2) source venv/bin/activate pip install . #(now do something useful with moltemplate...)
(You will have to enter "source ~/moltemplate/venv/bin/activate" into a terminal beforehand every time you want to run moltemplate. Virtual environments are explained here If all this fails, then try installing moltemplate by manually updating your $PATH environment variable. Instructions for doing that are included below.
Alternatively, you can edit your $PATH environment variable manually to include the subdirectory where the "moltemplate.sh" script is located, as well as the subdirectory where most of the python scripts are located. Suppose the directory with this README file is named "moltemplate" and is located in your home directory:
If you use the BASH shell, typically you would edit your
~/.bashrc file (or
to contain the following lines:
export PATH="$PATH:$HOME/moltemplate/moltemplate" export PATH="$PATH:$HOME/moltemplate/moltemplate/scripts"
If you use the TCSH shell, typically you would edit your
~/.login files to contain the following lines:
setenv PATH "$PATH:$HOME/moltemplate/moltemplate" setenv PATH "$PATH:$HOME/moltemplate/moltemplate/scripts"
After making these changes, you may need to start a new terminal (shell) for the changes to take effect. If you do not know what a
PATH environment variable is and are curious, read:
(I receive this question often.)
(Warning: Do not install moltemplate this way if you are using "vipster", "cellpack2moltemplate", or other software that has a moltemplate python dependency. In order to be able to be able to run "import moltemplate" within python, as these programs do, moltemplate must be installed using pip or setuptools.)
WINDOWS installation suggestions
You can install both moltemplate and LAMMPS in windows, but you will first need to install the BASH shell environment on your computer. I recommend installing virtualbox in windows together with a (debian-based) linux distribution with a lightweight desktop such as xubuntu. Alternatively, if you are using Windows 10 or later, you can try installing the Windows Subsystem for Linux (WSL) (which is text only) or Hyper-V. Otherwise, if you are using an older version of windows, try installing CYGWIN instead.
To use LAMMPS and moltemplate, you will also need to install (and learn how to use) a text editor. (Word, Wordpad, and Notepad will not work.) If you are NOT using WSL, then you can use popular graphical text editors such as Atom, Sublime, Notepad++, VSCode, and the graphical versione of emacs and vim. (Don't use these editors to edit files within the WSL environment.) If you ARE using WSL then you are restricted to using non-graphical text editors which you can safely install and run from within the WSL terminal. These include: nano, ne, emacs (the text version), vim (the text version), and jove.
The remaining file, (ttree_lex.py), is a modified version of the shlex.py library, which was released using the PSF license. Hence ttree_lex.py must also use this license. (The PSF is not a copyleft license. It is similar to the BSD and MIT licenses and is compatible with the the GPL license.)
Moltemplate is currently funded by NIH grant T32-AI007354-29 (and previously by HSFP grant RGP0014/2014 and NSF grant 1056587).