Remove unnecessary config.h includes
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_editconf.c
index 272a6abc2687bb689ca124489f77aacc7341551f..c710ecfd1587ab6adbfd6d034f291453e88f00e0 100644 (file)
@@ -1,69 +1,67 @@
-/* -*- 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) 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 <math.h>
 #include <string.h>
-#include <ctype.h>
-#include "pdbio.h"
-#include "confio.h"
-#include "symtab.h"
-#include "smalloc.h"
-#include "macros.h"
-#include "copyrite.h"
-#include "statutil.h"
-#include "string2.h"
-#include "strdb.h"
-#include "index.h"
-#include "vec.h"
-#include "typedefs.h"
-#include "gbutil.h"
-#include "strdb.h"
-#include "physics.h"
-#include "atomprop.h"
-#include "tpxio.h"
-#include "pbc.h"
+
+#include "gromacs/fileio/pdbio.h"
+#include "gromacs/fileio/confio.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/fileio/strdb.h"
+#include "gromacs/topology/index.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/gmxlib/conformation-utilities.h"
+#include "gromacs/math/units.h"
+#include "gromacs/fileio/tpxio.h"
+#include "gromacs/fileio/trxio.h"
 #include "princ.h"
-#include "txtdump.h"
-#include "viewit.h"
-#include "rmpbc.h"
+#include "gromacs/legacyheaders/txtdump.h"
+#include "gromacs/legacyheaders/viewit.h"
 #include "gmx_ana.h"
 
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/pbcutil/rmpbc.h"
+#include "gromacs/topology/atomprop.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
+
 typedef struct
 {
     char sanm[12];
@@ -427,10 +425,8 @@ void visualize_box(FILE *out, int a0, int r0, matrix box, rvec gridsize)
 
         for (i = 0; i < nat; i++)
         {
-            fprintf(out, get_pdbformat(), "ATOM", a0 + i, "C", "BOX", 'K' + i
-                    / NCUCVERT, r0 + i, 10 * vert[i][XX], 10 * vert[i][YY], 10
-                    * vert[i][ZZ]);
-            fprintf(out, "\n");
+            gmx_fprintf_pdb_atomline(out, epdbATOM, a0 + i, "C", ' ', "BOX", 'K' + i / NCUCVERT, r0 + i, ' ',
+                                     10*vert[i][XX], 10*vert[i][YY], 10*vert[i][ZZ], 1.0, 0.0, "");
         }
 
         edge = compact_unitcell_edges();
@@ -454,10 +450,8 @@ void visualize_box(FILE *out, int a0, int r0, matrix box, rvec gridsize)
             {
                 for (x = 0; x <= 1; x++)
                 {
-                    fprintf(out, get_pdbformat(), "ATOM", a0 + i, "C", "BOX", 'K' + i
-                            / 8, r0 + i, x * 10 * box[XX][XX],
-                            y * 10 * box[YY][YY], z * 10 * box[ZZ][ZZ]);
-                    fprintf(out, "\n");
+                    gmx_fprintf_pdb_atomline(out, epdbATOM, a0 + i, "C", ' ', "BOX", 'K' + i/8, r0+i, ' ',
+                                             x * 10 * box[XX][XX], y * 10 * box[YY][YY], z * 10 * box[ZZ][ZZ], 1.0, 0.0, "");
                     i++;
                 }
             }
@@ -524,10 +518,9 @@ static void renum_resnr(t_atoms *atoms, int isize, const int *index,
 
 int gmx_editconf(int argc, char *argv[])
 {
-    const char
-                   *desc[] =
+    const char     *desc[] =
     {
-        "[TT]editconf[tt] converts generic structure format to [TT].gro[tt], [TT].g96[tt]",
+        "[THISMODULE] converts generic structure format to [TT].gro[tt], [TT].g96[tt]",
         "or [TT].pdb[tt].",
         "[PAR]",
         "The box can be modified with options [TT]-box[tt], [TT]-d[tt] and",
@@ -610,13 +603,13 @@ int gmx_editconf(int argc, char *argv[])
         "[PAR]",
         "To convert a truncated octrahedron file produced by a package which uses",
         "a cubic box with the corners cut off (such as GROMOS), use:[BR]",
-        "[TT]editconf -f in -rotate 0 45 35.264 -bt o -box veclen -o out[tt][BR]",
+        "[TT]gmx editconf -f in -rotate 0 45 35.264 -bt o -box veclen -o out[tt][BR]",
         "where [TT]veclen[tt] is the size of the cubic box times [SQRT]3[sqrt]/2."
     };
     const char     *bugs[] =
     {
         "For complex molecules, the periodicity removal routine may break down, "
-        "in that case you can use [TT]trjconv[tt]."
+        "in that case you can use [gmx-trjconv]."
     };
     static real     dist    = 0.0, rbox = 0.0, to_diam = 0.0;
     static gmx_bool bNDEF   = FALSE, bRMPBC = FALSE, bCenter = FALSE, bReadVDW =
@@ -746,8 +739,11 @@ int gmx_editconf(int argc, char *argv[])
     };
 #define NFILE asize(fnm)
 
-    parse_common_args(&argc, argv, PCA_CAN_VIEW, NFILE, fnm, NPA, pa,
-                      asize(desc), desc, asize(bugs), bugs, &oenv);
+    if (!parse_common_args(&argc, argv, PCA_CAN_VIEW, NFILE, fnm, NPA, pa,
+                           asize(desc), desc, asize(bugs), bugs, &oenv))
+    {
+        return 0;
+    }
 
     bIndex     = opt2bSet("-n", NFILE, fnm) || bNDEF;
     bMead      = opt2bSet("-mead", NFILE, fnm);
@@ -1271,9 +1267,9 @@ int gmx_editconf(int argc, char *argv[])
 
         if (outftp == efPDB)
         {
-            out = ffopen(outfile, "w");
+            out = gmx_ffopen(outfile, "w");
             write_pdbfile_indexed(out, title, &atoms, x, ePBC, box, ' ', 1, isize, index, conect, TRUE);
-            ffclose(out);
+            gmx_ffclose(out);
         }
         else
         {
@@ -1289,10 +1285,9 @@ int gmx_editconf(int argc, char *argv[])
 
         if ((outftp == efPDB) || (outftp == efPQR))
         {
-            out = ffopen(outfile, "w");
+            out = gmx_ffopen(outfile, "w");
             if (bMead)
             {
-                set_pdb_wide_format(TRUE);
                 fprintf(out, "REMARK    "
                         "The B-factors in this file hold atomic radii\n");
                 fprintf(out, "REMARK    "
@@ -1329,7 +1324,7 @@ int gmx_editconf(int argc, char *argv[])
                 visualize_box(out, bLegend ? atoms.nr+12 : atoms.nr,
                               bLegend ? atoms.nres = 12 : atoms.nres, box, visbox);
             }
-            ffclose(out);
+            gmx_ffclose(out);
         }
         else
         {
@@ -1340,7 +1335,5 @@ int gmx_editconf(int argc, char *argv[])
 
     do_view(oenv, outfile, NULL);
 
-    thanx(stderr);
-
     return 0;
 }