Original entry published in CBDD Research Group Blog.
We have found ourselves several times in a situation where we have to parametrize compounds for running MDs.
In this blog entry, I will try to set up a protocol for parametrization of small molecules dihedrals for AMBER using Gaussian and sander (based on the tutorial found in this webpage).
If you want, you can download the excel file in the folder (energies_benzfuran.xls), which could be useful in organizing all partial results and automatic calculations and plots to check all the process.
Calculate reference with Gaussian.
Run sander with values ELE+VdW (without dihedral contribution).
Use a genetic algorithm to optimize dihedral values with respect to Gaussian reference.
Modify frcmod parameters with the ones found in step before.
Check with sander that the dihedral has the same profile as in Gaussian.
The molecule I want to parametrize is the following:
I have selected as an example the dihedral between benzene and furan rings, and the structure I will use to do so is the following:
As it can be seen, I have numbered the atoms starting from one end of the molecule, the benzene, followed by the rest of benzene atoms. Then, the furan ring and, finally, the hydrogen atoms following a similar order as the heavy atoms.
babel -imol2 <MOL>.mol2 -opdb <MOL>.pdb
This has to be done to facilitate the creation of gaussian input files, which must be in internal coordinates format.
- antechamber -i <MOL>_correct.mol2 -fi mol2 -o <MOL>.com -fo gzmat
In this case, I want to parametrize the dihedral angle between both rings, defined by atoms 3-4-7-8.
So, we will have to check that there is only one defined torsion for the selected dihedral. We will edit <MOL>.com to ensure it is OK (in our case, the dihedral angle will be defined by t8 parameter, see below).
Get reference energy profile:
Gaussian will be used to obtain the energy profile of this dihedral that will act as a reference.
To do so, we will rotate the dihedral from 0 to 360 degrees (with a step size of 5 degrees) and minimize the rest of the structure.
The input file for this job looks as follows (benz_furan.com):
- Opt=ModRedundant for allowing the dihedral angle scan to be calculated.
- t8=0. This is the dihedral angle we want to scan and it has been initialized at 0 degrees.
- 8 7 4 3 0.0 S 72 5.0. The dihedral we want to parametrize is defined by these atoms (8-7-4-3), the starting angle is 0.0 and we want it to scan (S) for 72 steps with a step-size of 5 degrees (from 0 to 360).
- g09 benz_furan.com benz_furan.log
The output file (benz_furan.log) will contain a final section, from which the results that we will use can be extracted:
1.- Get energy profile without any dihedral parameter
Geometry optimization and resp charges calculation for sander input:
After finishing Gaussian section, we will run sander to compare the results with the reference profile and optimize parameters to fit the data as best as possible.
First of all, we need to optimize and calculate resp charges for input structure. This will also be done with Gaussian:
- antechamber -i <MOL>.mol2 -fi mol2 -o <MOL>_opt.com -fo gcrt
Which will look like as follows, (benz_furan_opt.com), (note that we changed calculations keys -as charge calculation will be done in following steps. Here it will only optimize geometry):
- g09 <MOL>_opt.com <MOL>_opt.log
- antechamber -i <MOL>_opt.log -fi gout -o <MOL>_opt.mol2 -fo mol2
And, afterwards, we will use this optimized geometry to calculate the corresponding resp charges:
- antechamber -i <MOL>_opt.mol2 -fi mol2 -o <MOL>_opt_charges.com -fo gcrt
We will change the keys in this file, (benz_furan_opt_charges.com), to only calculate charges, without geometry optimization:
- g09 <MOL>_opt_charges.com <MOL>_opt_charges.log
When it has finished, we will convert the log output file (benz_furan_opt_charges.log) to mol2 (benz_furan_opt_charges.mol2) format, for example, and we will have the input for sander calculations (optimized geometry and with resp charges). Note here that flags have been added: “-at” to change atom typing to amber (if not writte, it will use gaff) and “-c” for changing charge type to resp:
- antechamber -i <MOL>_opt_charges.log -fi gout -o <MOL>_opt_charges.mol2 -fo mol2 -at amber -c resp
Final step to have a correct input structure file is to check the assigned atom types and change them, if desired. In our case, we changed a few of them in order to facilitate MD simulations (we had previously assigned them considering the full molecule. In this case, the substructure selected for parametrization will have the same atom types).
Note: In our case, we had an error afterwards because the optimized geometry from Gaussian had all atoms in the same coordinate plane and -I don’t know why- it rised an error when running sander. So, before going on, we used MOE (or any tool you like) to rotate a little (less than 1 degree) one of the rings in order to avoid having all atoms in same coordinate plane.
FRCMOD file creation and parameter definition
Once we have the input mol2 file in a correct format (benz_furan_opt_charges.mol2), we will use parmchk to check the atoms and atom types in our molecule and whether there are any missing parameters in the chosen forcefield (we will use amber parm99) or not (there will be).
- parmchk -i <MOL>_opt_charges.mol2 -f mol2 -o <MOL>.frcmod -p $AMBERHOME/dat/leap/parm/
To run the simulation, we will need to have in the folder the following files:
- benz_furan.mol2 –-> (benz_opt_charges.mol2 with the name changed to benz_furan.mol2 to facilitate scripts running) from optimization and charge calculation (correct plane coordinates in our case).
- benz_furan.frcmod –> as defined above (dihedral defined to 0).
- run_all_sander_param.sh –> script that will create all needed dihedral constraints files, will run sander minimisations for all the dihedral angles, will extract the values of the energies calculated and will also convert all steps to sd format in order to view all the structures in each step in any molecular viewer.
- sh run_all_sander_param.sh 3 4 7 8 benz_furan
- where 3 4 7 8 are the atoms forming the dihedral
- benz_furan is the root name for all files
After finishing, some files and folder will appear in your directory:
- benz_furan.tleap –> tleap job file for processing frcmod and mol2 files
- leap.log –> log of the tleap process. It is important to check that charge is correctly defined and no errors have arised.
- benz_furan.top benz_furan.off benz_furan.crd –> files from tleap for running sander.
- min.in –> minimisation input template.
- sander_energies.tab –> energies for each step in a tabular format.
- dih_tmp/ –> folder with the dihedral restraints files for each angle.
- out_<ROOTNAME>/ –> folder with the output *out and *crd files from sander.
- min_pdbs/ –> folder with the converted files to be viewed in a molecular viewer (for instance, “pymol min_pdbs/min_pdb_all.sd”)
Then, the script will open using “kwrite” a file with the 73 corresponding energies of all the dihedrals (if “kwrite” is not found in the computer, an error will rise. Just open file “sander_energies.tab” with any text viewer of your choice).
The same process as in Gaussian profile generation will be applied here (except energies conversion from Hartrees to Kcal/mol) –> calculate minimum energy and substract to each step to get relative energies.
If we plot these energies compared with Gaussian:
Therefore, in the next steps, we will use a genetic algorithm to optimize the dihedral parameters in frcmod file to get a sander profile the most similar to the Gaussian profile as possible.
2.- Use a genetic algorithm to optimize dihedral values with respect to Gaussian reference
In this section, we will optimize the dihedral values found in frcmod file using a genetic algorithm from python package “pyevolve” (you will have to download this package to run this script — running “sudo easy_install pyevolve” has worked for us):
To understand what it does, taking a view to this page could be really helpful. The main issue here is to know that the formula applied to calculate the dihedral energy is the following:
Etors = ( PK / IDIVF ) * ( 1 + cos( PN * phi – PHASE) )
Where PK, IDIVF, PN and PHASE are the values found in frcmod file:
X -CA-CC-X IDIVF PK PHASE PN
To sum up, it will create a population with random values of this parameters, will let it evolve for 5000 generations and will print out the values of all the parameters for the best chromosome.
So, as we know the values of the energy without the contribution of this “Etors” value, by selecting the values of these paremeters that make the sum of “Etors” and the -previously calculated in sander- VdW and ELE terms the most similar to the Gaussian reference, we will obtain the optimal values for IDIVF, PK, PHASE and PN.
To run this script, we will need one file with the energies of Gaussian reference (the relative ones, with the minimum substracted) and another with sander energies (same as for Gaussian, relative energies). Then, type (the two tab files are also available in the shared folder):
- python GA_minimum.py gaussian_relative_energies.tab sander_relative_energies.tab
And the output, in our case:
Hence, the values that are printed above are the values that we should add to the frcmod file to have a correct parametrization of the dihedral.
Note: In this case, as there are two functions we will have to add in the frcmod file a line in the way as follows (the “-” sign in front of PN means that there is another line that also defines the same dihedral. It is used when more than one function is needed to define the energy of a dihedral):
If we plot the fitted theoretical profile of the energy calculated above adding the contributions of the two functions optimized, we will get this plot:
3.- Modify frcmod file parameters with the ones found in step before
In this section, we will have to edit the frcmod file used in steps before and add the two lines got in the genetic algorithm optimization.
The frcmod file will be as follows:
remark goes hereMASSBOND[…]ANGLE[…]DIHEX -CA-CC-X 4 2.800 180.0 -2.000X -CA-CC-X 4 0.200 0.0 4.000X -CC-C*-X 4 10.000 180.0 2.000X -C*-C*-X 4 6.000 180.0 2.000X -OS-CC-X 2 21.000 180.0 2.000IMPROPER[…]NONBON
Please note here the “trick” between the PK/IDIVF calculated in the genetic algorithm and the one that is actually written in frcmod file. As the formula applied in the optimization “thinks” that there is only one possible dihedral combination (in our case, X-CA-CC-X represents 4 different combinations) the value of PK/IDIVF is considering only 1 dihedral. I don’t really know how to make me more clear, so I encourage you to deepen in this issue to get a better understanding.
So, what we have to do is to modify the IDIVF value to the one defined by our system (in our case 4 because there are 4 different combinations) and write the predicted PK/IDIVF value in genetic algorithm in the PK spot in the frcmod file.
Once this file is correctly updated (benz_furan_CORRECTED.frcmod), we can run again “run_all_sander_param.sh” the same as in the previous section (same mol2 file but updated frcmod file) and check that the resulting energy profile is indeed similar to the Gaussian reference.
4.- Check with sander that the dihedral has the same profile as in Gaussian
Just run again the script in a new folder containing the mol2 and the corrected benz_furan.frcmod file (be sure it is called like this, with the same rootname as always):
- sh run_all_sander_param.sh 3 4 7 8 benz_furan
The results will also be opened in a “kwrite” window. Copy all energies found in “sander_energies.tab” and plot them comparing with the previously calculated (gaussian, sander without dihedral and theoretically fitted):
And, as it can be seen, the sander profile with the changes in frcmod (green line) is almost equal to Gaussian and fitted ones (blue and yellow, respectively).
The last step should be to update the original molecule frcmod file with the values calculated in all this process and it should work!
I hope it is clear enough and you find this little tutorial as useful as I found it myself, otherwise don’t hesitate to contact me if you need anything!