2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2009, The GROMACS development team,
6 * check out http://www.gromacs.org for more information.
7 * Copyright (c) 2012, by the GROMACS development team, led by
8 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9 * others, as listed in the AUTHORS file in the top-level source
10 * directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
39 * \brief Testing/debugging tool for the selection engine.
57 gmx_ana_selcollection_t *sc;
61 dump_frame(t_topology * top, t_trxframe * fr, t_pbc * pbc,
62 int nr, gmx_ana_selection_t *sel[], void *data)
64 t_dumpdata *d = (t_dumpdata *)data;
67 fprintf(stderr, "\n");
70 gmx_ana_selcollection_print_tree(stderr, d->sc, TRUE);
72 for (g = 0; g < nr; ++g)
74 gmx_ana_index_dump(sel[g]->g, g, d->nmaxind);
75 fprintf(stderr, " Positions (%d pcs):\n", sel[g]->p.nr);
77 if (d->nmaxind >= 0 && n > d->nmaxind)
81 for (i = 0; i < n; ++i)
83 fprintf(stderr, " (%.2f,%.2f,%.2f) r=%d, m=%d, b=%d-%d\n",
84 sel[g]->p.x[i][XX], sel[g]->p.x[i][YY], sel[g]->p.x[i][ZZ],
85 sel[g]->p.m.refid[i], sel[g]->p.m.mapid[i],
86 sel[g]->p.m.mapb.index[i]+1,
87 sel[g]->p.m.mapb.index[i+1]);
91 fprintf(stderr, " ...\n");
94 fprintf(stderr, "\n");
99 print_selections(int nr, gmx_ana_selection_t **sel, int nmaxind)
103 fprintf(stderr, "\nSelections:\n");
104 for (g = 0; g < nr; ++g)
106 fprintf(stderr, " ");
107 gmx_ana_selection_print_info(sel[g]);
108 fprintf(stderr, " ");
109 gmx_ana_index_dump(sel[g]->g, g, nmaxind);
111 fprintf(stderr, " Block (size=%d):", sel[g]->p.m.mapb.nr);
112 if (!sel[g]->p.m.mapb.index)
114 fprintf(stderr, " (null)");
118 n = sel[g]->p.m.mapb.nr;
119 if (nmaxind >= 0 && n > nmaxind)
121 for (i = 0; i <= n; ++i)
122 fprintf(stderr, " %d", sel[g]->p.m.mapb.index[i]);
123 if (n < sel[g]->p.m.mapb.nr)
124 fprintf(stderr, " ...");
126 fprintf(stderr, "\n");
129 if (nmaxind >= 0 && n > nmaxind)
131 fprintf(stderr, " RefId:");
132 if (!sel[g]->p.m.refid)
134 fprintf(stderr, " (null)");
138 for (i = 0; i < n; ++i)
139 fprintf(stderr, " %d", sel[g]->p.m.refid[i]);
140 if (n < sel[g]->p.m.nr)
141 fprintf(stderr, " ...");
143 fprintf(stderr, "\n");
145 fprintf(stderr, " MapId:");
146 if (!sel[g]->p.m.mapid)
148 fprintf(stderr, " (null)");
152 for (i = 0; i < n; ++i)
153 fprintf(stderr, " %d", sel[g]->p.m.mapid[i]);
154 if (n < sel[g]->p.m.nr)
155 fprintf(stderr, " ...");
157 fprintf(stderr, "\n");
159 fprintf(stderr, "\n");
163 gmx_test_selection(int argc, char *argv[])
165 const char *desc[] = {
166 "This is a test program for selections.",
169 gmx_bool bMaskOnly = FALSE;
170 gmx_bool bFrameTree = FALSE;
171 gmx_bool bDebugCompile = FALSE;
175 {"-mask", FALSE, etBOOL, {&bMaskOnly},
176 "Test position mask functionality"},
177 {"-compdebug", FALSE, etBOOL, {&bDebugCompile},
178 "Print intermediate trees during compilation"},
179 {"-frtree", FALSE, etBOOL, {&bFrameTree},
180 "Print the whole evaluation tree for each frame"},
181 {"-nref", FALSE, etINT, {&nref},
182 "Number of reference selections to ask for"},
183 {"-pmax", FALSE, etINT, {&nmaxind},
184 "Maximum number of indices to print in lists (-1 = print all)"},
188 {efDAT, "-o", "debug", ffOPTWR},
194 gmx_ana_selection_t **sel;
197 #define NFILE asize(fnm)
199 CopyRight(stderr, argv[0]);
201 gmx_ana_traj_create(&trj, ANA_DEBUG_SELECTION | ANA_USER_SELINIT | ANA_USE_FULLGRPS);
202 gmx_ana_get_selcollection(trj, &d.sc);
203 gmx_ana_set_nanagrps(trj, -1);
204 parse_trjana_args(trj, &argc, argv, 0,
205 NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL,
209 gmx_ana_add_flags(trj, ANA_USE_POSMASK);
210 gmx_ana_selcollection_set_outpostype(d.sc, NULL, TRUE);
212 gmx_ana_selcollection_set_compile_debug(d.sc, bDebugCompile);
213 gmx_ana_set_nrefgrps(trj, nref);
214 gmx_ana_init_selections(trj);
215 gmx_ana_get_ngrps(trj, &ngrps);
216 gmx_ana_get_anagrps(trj, &sel);
218 d.bFrameTree = bFrameTree;
221 print_selections(ngrps, sel, d.nmaxind);
223 gmx_ana_do(trj, 0, &dump_frame, &d);
225 print_selections(ngrps, sel, d.nmaxind);
227 gmx_ana_traj_free(trj);
228 done_filenms(NFILE, fnm);
234 main(int argc, char *argv[])
236 gmx_test_selection(argc, argv);