Tutorials

Using the help system

Run MolTwister and type ‘help’, followe by enter. This will display a list of available commands. The ‘load’ command is an example of a command without subcommands. Type ‘help load’ to see the help text for this command. The ‘calculate’ command is an example of a command with subcommands. Type ‘help calculate’ to see the list of available subcommands. To see the help text for the ‘vacf’ subcommand, type ‘help calculate vacf’.

The commands are described by using angle brackets, <>, to denote placeholders for parameter values. I.e., the angle brackets are not part of the commands, unless explicitly specified. The parameter values must always be in the order given in the help text. Any word not given inside the angle brackets are to be included, as is, when writing the command. Square brackets, [], are not to be included in the command, unless explicitly specified. Parameters inside square brackets are considered as optional.

Go through various commands in the help system and find examples of the above notations.

Note that the commands are also listed under the ‘List of commands’ section in this online documentation.

Creating a water molecule PDB

Open MolTwister and execute the following sequence of commands:

add atom H1 at 0 0 0
add atom O from atom 0 dist 0.96
add atom H2 from bond 0 1 angle 104.5 0.0 dist 0.96
genbonds

This will create a hydrogen atom called H1 (where the leading H yields a hydrogen atom) at (x, y, z)=(0, 0, 0), with index 0. Then an oxygen atom, called O, is added a distance 0.96 Angstrom away from the atom with index 0. Finally, a hydrogen atom, called H2, is added from the bond defined between the atoms with index 0 (H1) and index 1 (O), at an angle of 104.5 degrees and a dihedral angle of 0.0 degrees, a distance 0.96 Angstrom from O. The bonds are generated by a call to genbonds.

We can measure the distances and angles to check that everything is as we expect. Type in the following commands:

measure bondlength id 0 1
measure bondlength id 1 
measure angle id 0 1 2

Note that a physical bond does not have to be present to use the measure command. For example, the distance between H1 (index 0) and H2 (index 2) can be found by:

measure bondlength id 0 2

To create the PDB file content, write:

print pdb

However, to write this to a file, the pipe symbol can be used, as follows:

print pdb > my_water.pdb

You can now check that the PDB file is there by using the ll command (or the usual ls command). To chech the contents it is possible to use vim my_water.pdb, if Vim is installed.

Creating liquid water

Open MolTwister and make sure that you have the my_water.pdb file created in the above tutorial (or a similar PDB file). Execute the following commands:

load my_water.pdb
sel all
copy sel 10 10 10 3.0 3.0 3.0
autoscale
genbonds

This will load the PDB file into MolTwister, select all atoms of the water molecule and then copy that selection 10 times in the x, y and z directions with a distance of 3 Angstrom in each of the directions. Finally, autoscale is used to zoom in on the entire system, followed by the creation of bonds for each of the water molecules.

Creating a MolTwister script

Create a file called gen_my_water_mol.script and write the following contents:

exec("add atom H1 at 0 0 0");
exec("add atom O from atom 0 dist 0.96");
exec("add atom H2 from bond 0 1 angle 104.5 0.0 dist 0.96");
exec("genbonds");

Now, run the following command in MolTwister:

load gen_my_water_mol.script

This will create a water molecule, by calling each of the commands given in the file, in sequence.

Creating a MolTwister Python script

Create a Python script called gen_cube.py that contains (requires Python3):

import moltwister as mt

for i in range(0, 10):
    for j in range(0, 10):
        for k in range (0, 10):
            x = i*3.0
            y = j*4.0
            z = k*1.5
            mt.mt_exec(f"add atom O at {x} {y} {z}")

mt.mt_exec("autoscale")

Then, execute the following command in MolTwister:

load gen_cube.py