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!

Dear lanselibai,
Did this strategy worked and in the ligand.top file how you disable the following section. why you add ligand 26 in the last line?

There were 26 copies of the ligand molecule inserted into the system.

Thank you for your reply. Got the point. But how we can manually edit the topol.top file and ligand.top file so no further syntax error will not appear. For your reference I have upload the ligand. top file. Please let me know if you need dany further information.
UNL_GMX.top (442 Bytes)
o

Just make sure that the order of the interaction definitions are correct.
I would suggest reading the thread at Including parameters of a new molecule in gromacs topology files as well as https://manual.gromacs.org/documentation/current/reference-manual/topologies/topology-file-formats.html and GROMACS File Formats: Understanding topology, itp, and gro files - Compchems.