Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_do_dssp.c
index 61c141c305fda8f2f9a7bad6d9d40ce0566237e1..610f52a10e9642de15147dba777f50f5168226f2 100644 (file)
@@ -1,60 +1,61 @@
-/*  -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
+/*
+ * 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) 2012,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 "sysstuff.h"
-#include "typedefs.h"
-#include "string2.h"
-#include "strdb.h"
-#include "macros.h"
-#include "smalloc.h"
-#include "mshift.h"
-#include "statutil.h"
-#include "copyrite.h"
-#include "pdbio.h"
-#include "gmx_fatal.h"
-#include "xvgr.h"
-#include "matio.h"
-#include "index.h"
-#include "gstat.h"
-#include "tpxio.h"
-#include "viewit.h"
-
+#include "gmxpre.h"
+
+#include "config.h"
+
+#include <stdlib.h>
+
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/fileio/matio.h"
+#include "gromacs/fileio/pdbio.h"
+#include "gromacs/fileio/strdb.h"
+#include "gromacs/fileio/tpxio.h"
+#include "gromacs/fileio/trxio.h"
+#include "gromacs/fileio/xvgr.h"
+#include "gromacs/gmxana/gstat.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/legacyheaders/viewit.h"
+#include "gromacs/pbcutil/rmpbc.h"
+#include "gromacs/topology/index.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
 
 static int strip_dssp(char *dsspfile, int nres,
                       gmx_bool bPhobres[], real t,
@@ -73,7 +74,7 @@ static int strip_dssp(char *dsspfile, int nres,
     real            iaccf, iaccb;
     t_xpmelmt       c;
 
-    tapeout = ffopen(dsspfile, "r");
+    tapeout = gmx_ffopen(dsspfile, "r");
 
     /* Skip header */
     do
@@ -178,7 +179,7 @@ static int strip_dssp(char *dsspfile, int nres,
     {
         fprintf(fTArea, "%10g  %10g  %10g\n", t, 0.01*iaccb, 0.01*iaccf);
     }
-    ffclose(tapeout);
+    gmx_ffclose(tapeout);
 
     /* Return the number of lines found in the dssp file (i.e. number
      * of redidues plus chain separator lines).
@@ -212,7 +213,7 @@ static void check_oo(t_atoms *atoms)
 
     int   i;
 
-    OOO = strdup("O");
+    OOO = gmx_strdup("O");
 
     for (i = 0; (i < atoms->nr); i++)
     {
@@ -327,12 +328,12 @@ void write_sas_mat(const char *fn, real **accr, int nframe, int nres, t_matrix *
                 hi = max(hi, accr[i][j]);
             }
         }
-        fp   = ffopen(fn, "w");
+        fp   = gmx_ffopen(fn, "w");
         nlev = hi-lo+1;
         write_xpm(fp, 0, "Solvent Accessible Surface", "Surface (A^2)",
                   "Time", "Residue Index", nframe, nres,
                   mat->axis_x, mat->axis_y, accr, lo, hi, rlo, rhi, &nlev);
-        ffclose(fp);
+        gmx_ffclose(fp);
     }
 }
 
@@ -352,7 +353,7 @@ void analyse_ss(const char *outfile, t_matrix *mat, const char *ss_string,
     leg[0] = "Structure";
     for (s = 0; s < (size_t)mat->nmap; s++)
     {
-        leg[s+1] = strdup(map[s].desc);
+        leg[s+1] = gmx_strdup(map[s].desc);
     }
 
     fp = xvgropen(outfile, "Secondary Structure",
@@ -426,7 +427,7 @@ void analyse_ss(const char *outfile, t_matrix *mat, const char *ss_string,
     }
     fprintf(fp, "\n");
 
-    ffclose(fp);
+    gmx_ffclose(fp);
     sfree(leg);
     sfree(count);
 }
@@ -434,11 +435,11 @@ void analyse_ss(const char *outfile, t_matrix *mat, const char *ss_string,
 int gmx_do_dssp(int argc, char *argv[])
 {
     const char        *desc[] = {
-        "[TT]do_dssp[tt] ",
+        "[THISMODULE] ",
         "reads a trajectory file and computes the secondary structure for",
         "each time frame ",
         "calling the dssp program. If you do not have the dssp program,",
-        "get it from http://swift.cmbi.ru.nl/gv/dssp. [TT]do_dssp[tt] assumes ",
+        "get it from http://swift.cmbi.ru.nl/gv/dssp. [THISMODULE] assumes ",
         "that the dssp executable is located in ",
         "[TT]/usr/local/bin/dssp[tt]. If this is not the case, then you should",
         "set an environment variable [TT]DSSP[tt] pointing to the dssp",
@@ -462,10 +463,10 @@ int gmx_do_dssp(int argc, char *argv[])
         "absolute values (A^2) and in fractions of the maximal accessible",
         "surface of a residue. The maximal accessible surface is defined as",
         "the accessible surface of a residue in a chain of glycines.",
-        "[BB]Note[bb] that the program [TT]g_sas[tt] can also compute SAS",
+        "[BB]Note[bb] that the program [gmx-sas] can also compute SAS",
         "and that is more efficient.[PAR]",
         "Finally, this program can dump the secondary structure in a special file",
-        "[TT]ssdump.dat[tt] for usage in the program [TT]g_chi[tt]. Together",
+        "[TT]ssdump.dat[tt] for usage in the program [gmx-chi]. Together",
         "these two programs can be used to analyze dihedral properties as a",
         "function of secondary structure type."
     };
@@ -494,7 +495,7 @@ int gmx_do_dssp(int argc, char *argv[])
     gmx_bool          *bPhbres, bDoAccSurf;
     real               t;
     int                i, j, natoms, nframe = 0;
-    matrix             box;
+    matrix             box = {{0}};
     int                gnx;
     char              *grpnm, *ss_str;
     atom_id           *index;
@@ -521,9 +522,12 @@ int gmx_do_dssp(int argc, char *argv[])
     };
 #define NFILE asize(fnm)
 
-    parse_common_args(&argc, argv,
-                      PCA_CAN_TIME | PCA_CAN_VIEW | PCA_TIME_UNIT | PCA_BE_NICE,
-                      NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL, &oenv);
+    if (!parse_common_args(&argc, argv,
+                           PCA_CAN_TIME | PCA_CAN_VIEW | PCA_TIME_UNIT,
+                           NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL, &oenv))
+    {
+        return 0;
+    }
     fnSCount   = opt2fn("-sc", NFILE, fnm);
     fnArea     = opt2fn_null("-a", NFILE, fnm);
     fnTArea    = opt2fn_null("-ta", NFILE, fnm);
@@ -619,8 +623,7 @@ int gmx_do_dssp(int argc, char *argv[])
     }
 
     mat.map  = NULL;
-    mat.nmap = getcmap(libopen(opt2fn("-map", NFILE, fnm)),
-                       opt2fn("-map", NFILE, fnm), &(mat.map));
+    mat.nmap = readcmap(opt2fn("-map", NFILE, fnm), &(mat.map));
 
     natoms = read_first_x(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &t, &x, box);
     if (natoms > atoms->nr)
@@ -638,7 +641,7 @@ int gmx_do_dssp(int argc, char *argv[])
     accr  = NULL;
     naccr = 0;
 
-    gpbc = gmx_rmpbc_init(&top.idef, ePBC, natoms, box);
+    gpbc = gmx_rmpbc_init(&top.idef, ePBC, natoms);
     do
     {
         t = output_env_conv_time(oenv, t);
@@ -652,9 +655,9 @@ int gmx_do_dssp(int argc, char *argv[])
             }
         }
         gmx_rmpbc(gpbc, natoms, box, x);
-        tapein = ffopen(pdbfile, "w");
+        tapein = gmx_ffopen(pdbfile, "w");
         write_pdbfile_indexed(tapein, NULL, atoms, x, ePBC, box, ' ', -1, gnx, index, NULL, TRUE);
-        ffclose(tapein);
+        gmx_ffclose(tapein);
 
 #ifdef GMX_NO_SYSTEM
         printf("Warning-- No calls to system(3) supported on this platform.");
@@ -682,12 +685,12 @@ int gmx_do_dssp(int argc, char *argv[])
         remove(pdbfile);
         nframe++;
     }
-    while (read_next_x(oenv, status, &t, natoms, x, box));
+    while (read_next_x(oenv, status, &t, x, box));
     fprintf(stderr, "\n");
     close_trj(status);
     if (fTArea)
     {
-        ffclose(fTArea);
+        gmx_ffclose(fTArea);
     }
     gmx_rmpbc_done(gpbc);
 
@@ -696,7 +699,7 @@ int gmx_do_dssp(int argc, char *argv[])
     ss        = opt2FILE("-o", NFILE, fnm, "w");
     mat.flags = 0;
     write_xpm_m(ss, mat);
-    ffclose(ss);
+    gmx_ffclose(ss);
 
     if (opt2bSet("-ssdump", NFILE, fnm))
     {
@@ -712,7 +715,7 @@ int gmx_do_dssp(int argc, char *argv[])
             ss_str[i] = '\0';
             fprintf(ss, "%s\n", ss_str);
         }
-        ffclose(ss);
+        gmx_ffclose(ss);
         sfree(ss_str);
     }
     analyse_ss(fnSCount, &mat, ss_string, oenv);
@@ -736,13 +739,11 @@ int gmx_do_dssp(int argc, char *argv[])
             {
                 fprintf(acc, "%5d  %10g %10g\n", i+1, av_area[i], norm_av_area[i]);
             }
-            ffclose(acc);
+            gmx_ffclose(acc);
         }
     }
 
     view_all(oenv, NFILE, fnm);
 
-    thanx(stderr);
-
     return 0;
 }