Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_do_dssp.c
index 23a755db0c763b25a1e17a5ca993981b85d47ff6..610f52a10e9642de15147dba777f50f5168226f2 100644 (file)
@@ -2,12 +2,11 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * 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.
- * Copyright (c) 2012, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * 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
  * 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,
@@ -75,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
@@ -180,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).
@@ -214,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++)
     {
@@ -329,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);
     }
 }
 
@@ -354,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",
@@ -428,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);
 }
@@ -436,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",
@@ -464,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."
     };
@@ -496,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;
@@ -523,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);
@@ -621,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)
@@ -640,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);
@@ -654,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.");
@@ -684,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);
 
@@ -698,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))
     {
@@ -714,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);
@@ -738,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;
 }