In the 2021 release, support for cyclic molecules was added to pdb2gmx. But pdb2gmx does not detect cyclic molecules over periodic boundary conditions.
If you know how to apply diffs to source code, the changes below should add support for PBC, but I haven’t tested this myself.
diff --git a/src/gromacs/gmxpreprocess/pdb2gmx.cpp b/src/gromacs/gmxpreprocess/pdb2gmx.cpp
index 6153e72b3e..44b0335e5a 100644
--- a/src/gromacs/gmxpreprocess/pdb2gmx.cpp
+++ b/src/gromacs/gmxpreprocess/pdb2gmx.cpp
@@ -2549,7 +2549,7 @@ int pdb2gmx::run()
top_file2 = top_file;
}
- pdb2top(top_file2, posre_fn.c_str(), molname.c_str(), pdba, &x, &atype, &symtab, rtpFFDB,
+ pdb2top(top_file2, posre_fn.c_str(), molname.c_str(), pdba, &x, box, &atype, &symtab, rtpFFDB,
restp_chain, hb_chain, bAllowMissing_, bVsites_, bVsiteAromatics_, ffdir_, mHmult_,
ssbonds, long_bond_dist_, short_bond_dist_, bDeuterate_, bChargeGroups_, bCmap_,
bRenumRes_, bRTPresname_, cc->cyclicBondsIndex, logger);
diff --git a/src/gromacs/gmxpreprocess/pdb2top.cpp b/src/gromacs/gmxpreprocess/pdb2top.cpp
index 351168fdc1..2a6de9a746 100644
--- a/src/gromacs/gmxpreprocess/pdb2top.cpp
+++ b/src/gromacs/gmxpreprocess/pdb2top.cpp
@@ -63,6 +63,7 @@
#include "gromacs/gmxpreprocess/toputil.h"
#include "gromacs/math/functions.h"
#include "gromacs/math/vec.h"
+#include "gromacs/pbcutil/pbc.h"
#include "gromacs/topology/residuetypes.h"
#include "gromacs/topology/symtab.h"
#include "gromacs/utility/binaryinformation.h"
@@ -754,6 +755,7 @@ static void at2bonds(InteractionsOfType* psb,
gmx::ArrayRef<MoleculePatchDatabase> globalPatches,
t_atoms* atoms,
gmx::ArrayRef<const gmx::RVec> x,
+ matrix box,
real long_bond_dist,
real short_bond_dist,
gmx::ArrayRef<const int> cyclicBondsIndex,
@@ -765,6 +767,9 @@ static void at2bonds(InteractionsOfType* psb,
long_bond_dist2 = gmx::square(long_bond_dist);
short_bond_dist2 = gmx::square(short_bond_dist);
+ t_pbc pbc;
+ set_pbc(&pbc, PbcType::Unset, box);
+
if (debug)
{
ptr = "bond";
@@ -789,7 +794,9 @@ static void at2bonds(InteractionsOfType* psb,
int aj = search_atom(patch.aj().c_str(), i, atoms, ptr, TRUE, cyclicBondsIndex);
if (ai != -1 && aj != -1)
{
- real dist2 = distance2(x[ai], x[aj]);
+ rvec dx;
+ pbc_dx(&pbc, x[ai], x[aj], dx);
+ real dist2 = norm2(dx);
if (dist2 > long_bond_dist2)
{
@@ -1483,6 +1490,7 @@ void pdb2top(FILE* top_file,
const char* molname,
t_atoms* atoms,
std::vector<gmx::RVec>* x,
+ matrix box,
PreprocessingAtomTypes* atype,
t_symtab* tab,
gmx::ArrayRef<const PreprocessResidue> rtpFFDB,
@@ -1514,7 +1522,7 @@ void pdb2top(FILE* top_file,
ResidueType rt;
/* Make bonds */
- at2bonds(&(plist[F_BONDS]), globalPatches, atoms, *x, long_bond_dist, short_bond_dist,
+ at2bonds(&(plist[F_BONDS]), globalPatches, atoms, *x, box, long_bond_dist, short_bond_dist,
cyclicBondsIndex, logger);
/* specbonds: disulphide bonds & heme-his */
diff --git a/src/gromacs/gmxpreprocess/pdb2top.h b/src/gromacs/gmxpreprocess/pdb2top.h
index 77d7f4b8cd..cd1243bc81 100644
--- a/src/gromacs/gmxpreprocess/pdb2top.h
+++ b/src/gromacs/gmxpreprocess/pdb2top.h
@@ -150,6 +150,7 @@ void pdb2top(FILE* top_file,
const char* molname,
t_atoms* atoms,
std::vector<gmx::RVec>* x,
+ matrix box,
PreprocessingAtomTypes* atype,
t_symtab* tab,
gmx::ArrayRef<const PreprocessResidue> rtpFFDB,