How to update topology file after insert-molecules?

GROMACS version:2021
GROMACS modification: /No
Here post your question

To insert the ligand, I put ligand.gro, ligand.top, ligand.itp files to the working directory (correct?). Then I use:
gmx insert-molecules -f protein_newbox.gro -nmol 26 -ci ligand.gro -o protein_ligand.gro

This only results in a new gro file, while the topol.top file is not updated. I will need to manually add certain lines to the topol.top file to reflect the adding of ligands. How to do this exactly? What else do I need to do?

Why there is not a way to automatically update the topol.top file for insert-molecules, e.g. -p topol.top?

You can manually do this in topol.top file. Go to ligand.top, type #include “ligand.itp” to add your forcefield file. Also, go to the number of molecules section, type name ref and the number of molecules

Thank you. What I have done is

(protein.pdb, ligand.gro, ligand.top, ligand.itp are in the working directory)

    gmx pdb2gmx -f protein.pdb -o protein_processed.gro -water tip3p -ignh -merge interactive
    gmx editconf -f protein_processed.gro -o protein_newbox.gro -c -d 1.0 -bt dodecahedron
    gmx insert-molecules -f protein_newbox.gro -nmol 26 -ci ligand.gro -o protein_ligand.gro

) in the ligand.top, go to [ molecules ], change “nmols” to 26
) in the ligand.top, #include "ligand.itp" is already there

gmx solvate -cp protein_ligand.gro -cs spc216.gro -o protein_solv.gro -p topol.top
gmx grompp -f ions.mdp -c protein_solv.gro -p topol.top -o ions.tpr -maxwarn 1

But I got error:

Fatal error:
number of coordinates in coordinate file (protein_solv.gro, 332025)
             does not match topology (topol.top, 331167)

So I think I need to manually modify the topol.top, instead of ligand.top? How to do it?

I think I got the solution.

Add
#include "ligand.itp"
under
#include "amber14sb.ff/forcefield.itp"

Add
#include "ligand.top"
before
#include "amber14sb.ff/tip3p.itp"

Add
ligand 26
to the last line

Then, in the ligand.top, disable the sections of [defaults], #include "ligand.itp", [molecules]

That’s the better approach. After using the insert molecules command, you gotta manual edit your topology file!