Using NAMD with harmonic restraints

In this post I will explain how to restraint the whole protein for running a MD using NAMD.

For applying harmonic restraints in NAMD we need to generate a PDB file of the system in which we indicate the atoms that we want to be restrained and the force to be applied.

NAMD will read the file and will look for the values in the column specified in the variable conskcol in the configuration file. If we specify the B-Factors column (with a B), it will just take in acount this column and will assign the value in it to the force of the restraint for the corresponding atom. If one atom should not be restrained, then the value of the corresponding B-Factor should be set to zero. This can also be done on column x, y, z or occupancy. (Check NAMD manual).

For changing the BFactors column only to the protein the easiest way is to do it with Biskit like:

import Biskit as bi
pdb = bi.PDBModel('ELAS_ISO_s1.pdb')
pdb['temperature_factor'] *= 0.
                               # First set all values to zero by multiplying
pdb['temperature_factor'][pdb.maskProtein()] = 40.  # Then set the values of the protein atoms to the desired Force
pdb.writePdb('s1restraints.pdb')

Now, to set up the input configuration file, we have to add the folowing block:

constraints  on
consexp       2     (default)
consref         s1restraints.pdb    # NAMD will take the coordinates of reference also from the PDB we generated as we didn't touch the XYZ columns
conskfile      s1restraints.pdb     # Here it will just read the column specified next

conskcol      B                         # Here the column (it can be X, Y, Z, O or B)

With some extra parameters, It is also possible to restraint just one component of the coordinates (X only for instance) to keep atoms in the same plane). But we don't care about it now.

We are DONE! Ready to launch the simulation ;)