Don't require matching names between rtp and tdb files
authorErik Lindahl <erik@kth.se>
Sun, 31 Dec 2017 14:03:05 +0000 (15:03 +0100)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 2 Jan 2018 11:24:40 +0000 (12:24 +0100)
This was only documented in the source. It's a remnant
from the days when all force fields were in the same
directory, and no longer necessary. With this change we
will properly match all termini to all amino acids.

Fixes #2026, #2027.

Change-Id: Ie7bf8e65892281cc2744146a5525be0c4afdcecf

src/gromacs/gmxpreprocess/pdb2gmx.cpp
src/gromacs/gmxpreprocess/ter_db.cpp
src/gromacs/gmxpreprocess/ter_db.h

index 670f0c7a664693f39163474d3eb5f7baa4adfe6e..84acd1810ae84731b7736990b7fdfb83535f980f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -1871,9 +1871,8 @@ int gmx_pdb2gmx(int argc, char *argv[])
             /* First the N terminus */
             if (nNtdb > 0)
             {
-                tdblist = filter_ter(nrtp, restp, nNtdb, ntdb,
+                tdblist = filter_ter(nNtdb, ntdb,
                                      *pdba->resinfo[cc->r_start[i]].name,
-                                     *pdba->resinfo[cc->r_start[i]].rtp,
                                      &ntdblist);
                 if (ntdblist == 0)
                 {
@@ -1910,9 +1909,8 @@ int gmx_pdb2gmx(int argc, char *argv[])
             /* And the C terminus */
             if (nCtdb > 0)
             {
-                tdblist = filter_ter(nrtp, restp, nCtdb, ctdb,
+                tdblist = filter_ter(nCtdb, ctdb,
                                      *pdba->resinfo[cc->r_end[i]].name,
-                                     *pdba->resinfo[cc->r_end[i]].rtp,
                                      &ntdblist);
                 if (ntdblist == 0)
                 {
index 079726dc03d044d545a0bcd9bbc5d12daaa42d0f..ab6e078edec7464397867b3b5462d66358e452f5 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -434,10 +434,8 @@ int read_ter_db(const char *ffdir, char ter,
     return ntb;
 }
 
-t_hackblock **filter_ter(int nrtp, t_restp rtp[],
-                         int nb, t_hackblock tb[],
+t_hackblock **filter_ter(int nb, t_hackblock tb[],
                          const char *resname,
-                         const char *rtpname,
                          int *nret)
 {
     // TODO Four years later, no force fields have ever used this, so decide status of this feature
@@ -462,15 +460,11 @@ t_hackblock **filter_ter(int nrtp, t_restp rtp[],
      * Remember to free the list when you are done with it...
      */
 
-    t_restp     *   restp;
     int             i, j, n, none_idx;
     gmx_bool        found;
-    char           *rtpname_match, *s;
+    char           *s;
     t_hackblock   **list;
 
-    rtpname_match = search_rtp(rtpname, nrtp, rtp);
-    restp         = get_restp(rtpname_match, nrtp, rtp);
-
     n    = 0;
     list = nullptr;
 
@@ -480,13 +474,7 @@ t_hackblock **filter_ter(int nrtp, t_restp rtp[],
         found = FALSE;
         do
         {
-            /* The residue name should appear in a tdb file with the same base name
-             * as the file containing the rtp entry.
-             * This makes termini selection for different molecule types
-             * much cleaner.
-             */
-            if (gmx_strcasecmp(restp->filebase, tb[i].filebase) == 0 &&
-                gmx_strncasecmp(resname, s, 3) == 0)
+            if (gmx_strncasecmp(resname, s, 3) == 0)
             {
                 found = TRUE;
                 srenew(list, n+1);
@@ -516,49 +504,41 @@ t_hackblock **filter_ter(int nrtp, t_restp rtp[],
     for (i = 0; i < nb; i++)
     {
         s = tb[i].name;
-        /* The residue name should appear in a tdb file with the same base name
-         * as the file containing the rtp entry.
-         * This makes termini selection for different molecule types
-         * much cleaner.
-         */
-        if (gmx_strcasecmp(restp->filebase, tb[i].filebase) == 0)
+        if (!gmx_strcasecmp("None", s))
         {
-            if (!gmx_strcasecmp("None", s))
-            {
-                none_idx = i;
-            }
-            else
+            none_idx = i;
+        }
+        else
+        {
+            /* Time to see if there's a generic terminus that matches.
+               Is there a hyphen? */
+            char *c = strchr(s, '-');
+
+            /* A conjunction hyphen normally indicates a residue-specific
+               terminus, which is named like "GLY-COOH". A generic terminus
+               won't have a hyphen. */
+            bool bFoundAnyHyphen = (c != nullptr);
+            /* '-' as the last character indicates charge, so if that's
+               the only one found e.g. "COO-", then it was not a conjunction
+               hyphen, so this is a generic terminus */
+            bool bOnlyFoundChargeHyphen = (bFoundAnyHyphen &&
+                                           *(c+1) == '\0');
+            /* Thus, "GLY-COO-" is not recognized as a generic terminus. */
+            bool bFoundGenericTerminus = !bFoundAnyHyphen || bOnlyFoundChargeHyphen;
+            if (bFoundGenericTerminus)
             {
-                /* Time to see if there's a generic terminus that matches.
-                   Is there a hyphen? */
-                char *c = strchr(s, '-');
-
-                /* A conjunction hyphen normally indicates a residue-specific
-                   terminus, which is named like "GLY-COOH". A generic terminus
-                   won't have a hyphen. */
-                bool bFoundAnyHyphen = (c != nullptr);
-                /* '-' as the last character indicates charge, so if that's
-                   the only one found e.g. "COO-", then it was not a conjunction
-                   hyphen, so this is a generic terminus */
-                bool bOnlyFoundChargeHyphen = (bFoundAnyHyphen &&
-                                               *(c+1) == '\0');
-                /* Thus, "GLY-COO-" is not recognized as a generic terminus. */
-                bool bFoundGenericTerminus = !bFoundAnyHyphen || bOnlyFoundChargeHyphen;
-                if (bFoundGenericTerminus)
+                /* Check that we haven't already added a residue-specific version
+                 * of this terminus.
+                 */
+                for (j = 0; j < n && strstr((*list[j]).name, s) == nullptr; j++)
                 {
-                    /* Check that we haven't already added a residue-specific version
-                     * of this terminus.
-                     */
-                    for (j = 0; j < n && strstr((*list[j]).name, s) == nullptr; j++)
-                    {
-                        ;
-                    }
-                    if (j == n)
-                    {
-                        srenew(list, n+1);
-                        list[n] = &(tb[i]);
-                        n++;
-                    }
+                    ;
+                }
+                if (j == n)
+                {
+                    srenew(list, n+1);
+                    list[n] = &(tb[i]);
+                    n++;
                 }
             }
         }
index b861e42d58ecdac70562055af3443be908647d7a..50ef9bf6caa071f6a32d80e113cb79243780c230 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2011,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2011,2014,2015,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -46,10 +46,8 @@ int read_ter_db(const char *ffdir, char ter,
                 t_hackblock **tbptr, gpp_atomtype_t atype);
 /* Read database for N&C terminal hacking */
 
-t_hackblock **filter_ter(int nrtp, t_restp rtp[],
-                         int nb, t_hackblock tb[],
+t_hackblock **filter_ter(int nb, t_hackblock tb[],
                          const char *resname,
-                         const char *rtpname,
                          int *nret);
 /* Return a list of pointers to blocks that match residue name */