alanwilter / acpype

OFFICIAL: AnteChamber PYthon Parser interfacE
https://alanwilter.github.io/acpype/
GNU General Public License v3.0
201 stars 46 forks source link

'1-4 pairs were missing' warning when parsing the converted topology with ParmED #85

Closed meneshail closed 1 year ago

meneshail commented 1 year ago

Hi,

I am using acpype to convert my amber topologies to GROMACS format with the command acpype -x <.rst7> -p <.prmtop> -d -a amber. The conversion runs successfully.

But when I tried to parse the generated GROMACS topology file using ParmED with commands like parmed.load_file(top_file, xyz = gro_file), the parser warns about 'GromacsWarning: 114447 1-4 pairs were missing from the [ pairs ] section and were set to zero; make sure you know what you're doing!'.

After a manual check of the <.top> file and the source code of the parser, I found that there are exactly 114447 rows of pair interactions under the section [ pairs_nb ], but there is no [ pairs ] section in my converted <.top> file. Therefore, the ParmED parser neglects the [ pairs_nb ] section and finds no [ pairs ] section, which leads to such a warning. After renaming the [ pairs_nb ] to [ pairs ] and rerunning the parser, the warning is no longer prompted.

So my questions are,

  1. Is it an intentional behavior to name the 1-4 pair interactions under section [ pairs_nb ], but not [ pairs ]? Will this section of topology still be used in the GROMACS MD engine?
  2. If I want ParmED to read my <.top> file correctly, is it necessary to rename the section [ pairs_nb ] to [ pairs ]?

Thanks for providing this convenient and powerful tool! Yuyang

alanwilter commented 1 year ago

I need to check but it could be just GMX renaming things and ACPYPE needs to catch up or ParmEd issue. You can ask about ParmED at AmberMD mailing list.

meneshail commented 1 year ago

Thanks for the speedy reply! After checking your code now I could see what's happening. There should have been a normal [ pairs ] section, but since I have nonuniform 1-4 scale factors from the GLYCAM06 force field, an additional patch is implemented as below: https://github.com/alanwilter/acpype/blob/f0bdfe831ac82fee4569bb9834a0d26b84293560/acpype/topol.py#L205-L222

The patch basically does these things:

  1. Write a new pair interaction section with self.print_gmx_pairs() (this will be the [ pairs_nb ] section)
  2. Find where the original [ pairs ] section is in the buffer.
  3. Modify the first row of <.top>, setting gen-pairs from 'yes' to 'no'
  4. Skip the original [ pairs ] section, and insert the new [ pairs_nb ] at the same place

So if I don't get it wrong, the replacement of the [ pairs ] section with the [ pairs_nb ] section is pretty much an intentional operation? The use of [ pairs_nb ] is because we need to pass different scale factors to different interactions, and the removal of [ pairs ] section is because we don't want the interactions to be computed twice?

alanwilter commented 1 year ago

Indeed, it was intentional.

The details are here:

BERNARDI, A., FALLER, R., REITH, D., and KIRSCHNER, K. N. ACPYPE update for nonuniform 1–4 scale factors: Conversion of the GLYCAM06 force field from AMBER to GROMACS. SoftwareX 10 (2019), 100241. Doi: 10.1016/j.softx.2019.100241

meneshail commented 1 year ago

I see. Thanks again!