Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / gmxana / dlist.c
index ef3c45f5156e31cf1178bbaa2e473f679461e829..b7578cef623f03e97c71f8f2dd82ae9b537ae70a 100644 (file)
@@ -1,53 +1,53 @@
 /*
+ * This file is part of the GROMACS molecular simulation package.
  *
- *                This source code is part of
- *
- *                 G   R   O   M   A   C   S
- *
- *          GROningen MAchine for Chemical Simulations
- *
- *                        VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2013,2014, 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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
  * of the License, or (at your option) any later version.
  *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
  *
- * For more info, check our website at http://www.gromacs.org
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
  *
- * And Hey:
- * Green Red Orange Magenta Azure Cyan Skyblue
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
  */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "gmxpre.h"
 
 #include <stdlib.h>
+#include <string.h>
 
-#include "string2.h"
-#include "smalloc.h"
-#include "gstat.h"
-#include "gmx_fatal.h"
-#include "index.h"
+#include "gromacs/gmxana/gstat.h"
+#include "gromacs/topology/residuetypes.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
 
 t_dlist *mk_dlist(FILE *log,
                   t_atoms *atoms, int *nlist,
                   gmx_bool bPhi, gmx_bool bPsi, gmx_bool bChi, gmx_bool bHChi,
-                  int maxchi, int r0, gmx_residuetype_t rt)
+                  int maxchi, int r0, gmx_residuetype_t *rt)
 {
     int       ires, i, j, k, ii;
     t_dihatms atm, prev;
@@ -56,7 +56,7 @@ t_dlist *mk_dlist(FILE *log,
     t_dlist  *dl;
 
     snew(dl, atoms->nres+1);
-    prev.C = prev.O = -1;
+    prev.C = prev.Cn[1] = -1; /* Keep the compiler quiet */
     for (i = 0; (i < edMax); i++)
     {
         nc[i] = 0;
@@ -68,7 +68,7 @@ t_dlist *mk_dlist(FILE *log,
         ires = atoms->atom[i].resind;
 
         /* Initiate all atom numbers to -1 */
-        atm.minC = atm.H = atm.N = atm.C = atm.O = atm.minO = -1;
+        atm.minC = atm.H = atm.N = atm.C = atm.O = atm.minCalpha = -1;
         for (j = 0; (j < MAXCHI+3); j++)
         {
             atm.Cn[j] = -1;
@@ -79,7 +79,8 @@ t_dlist *mk_dlist(FILE *log,
         while ((i < atoms->nr) && (atoms->atom[i].resind == ires))
         {
             if ((strcmp(*(atoms->atomname[i]), "H") == 0) ||
-                (strcmp(*(atoms->atomname[i]), "H1") == 0) )
+                (strcmp(*(atoms->atomname[i]), "H1") == 0) ||
+                (strcmp(*(atoms->atomname[i]), "HN") == 0) )
             {
                 atm.H = i;
             }
@@ -92,7 +93,9 @@ t_dlist *mk_dlist(FILE *log,
                 atm.C = i;
             }
             else if ((strcmp(*(atoms->atomname[i]), "O") == 0) ||
-                     (strcmp(*(atoms->atomname[i]), "O1") == 0))
+                     (strcmp(*(atoms->atomname[i]), "O1") == 0) ||
+                     (strcmp(*(atoms->atomname[i]), "OC1") == 0) ||
+                     (strcmp(*(atoms->atomname[i]), "OT1") == 0))
             {
                 atm.O = i;
             }
@@ -175,9 +178,10 @@ t_dlist *mk_dlist(FILE *log,
         {
             atm.minC = prev.C;
         }
-        if (prev.O != -1)
+        /* Alpha-carbon from previous residue */
+        if (prev.Cn[1] != -1)
         {
-            atm.minO = prev.O;
+            atm.minCalpha = prev.Cn[1];
         }
         prev = atm;
 
@@ -212,7 +216,7 @@ t_dlist *mk_dlist(FILE *log,
                     }
                 }
             }
-            if ((atm.minC != -1) && (atm.minO != -1))
+            if ((atm.minC != -1) && (atm.minCalpha != -1))
             {
                 nc[6]++;
             }
@@ -300,7 +304,7 @@ gmx_bool has_dihedral(int Dih, t_dlist *dl)
             b = ((dl->atm.N != -1) && (dl->atm.Cn[1] != -1) && (dl->atm.C != -1) && (dl->atm.O != -1));
             break;
         case edOmega:
-            b = ((dl->atm.minO != -1) && (dl->atm.minC != -1) && (dl->atm.N != -1) && (dl->atm.Cn[1] != -1));
+            b = ((dl->atm.minCalpha != -1) && (dl->atm.minC != -1) && (dl->atm.N != -1) && (dl->atm.Cn[1] != -1));
             break;
         case edChi1:
         case edChi2:
@@ -320,7 +324,7 @@ gmx_bool has_dihedral(int Dih, t_dlist *dl)
     return b;
 }
 
-static void pr_one_ro(FILE *fp, t_dlist *dl, int nDih, real dt)
+static void pr_one_ro(FILE *fp, t_dlist *dl, int nDih, real gmx_unused dt)
 {
     int k;
     for (k = 0; k < NROT; k++)
@@ -385,7 +389,7 @@ void pr_dlist(FILE *fp, int nl, t_dlist dl[], real dt, int printtype,
         }
         if (bOmega && has_dihedral(edOmega, &(dl[i])))
         {
-            fprintf(fp, " Omega [%5d,%5d,%5d,%5d]", 1+dl[i].atm.minO, 1+dl[i].atm.minC,
+            fprintf(fp, " Omega [%5d,%5d,%5d,%5d]", 1+dl[i].atm.minCalpha, 1+dl[i].atm.minC,
                     1+dl[i].atm.N, 1+dl[i].atm.Cn[1]);
             pr_props(fp, &dl[i], edOmega, dt);
         }