3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
9 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11 * Copyright (c) 2001-2009, The GROMACS development team,
12 * check out http://www.gromacs.org for more information.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * If you want to redistribute modifications, please consider that
20 * scientific software is very special. Version control is crucial -
21 * bugs must be traceable. We will be happy to consider code for
22 * inclusion in the official distribution, but derived work must not
23 * be called official GROMACS. Details are found in the README & COPYING
24 * files - if they are missing, get the official version at www.gromacs.org.
26 * To help us fund GROMACS development, we humbly ask that you cite
27 * the papers on the package - you can find them in the top README file.
29 * For more info, check our website at http://www.gromacs.org
32 * \brief Testing/debugging tool for the selection engine.
50 gmx_ana_selcollection_t
*sc
;
54 dump_frame(t_topology
* top
, t_trxframe
* fr
, t_pbc
* pbc
,
55 int nr
, gmx_ana_selection_t
*sel
[], void *data
)
57 t_dumpdata
*d
= (t_dumpdata
*)data
;
60 fprintf(stderr
, "\n");
63 gmx_ana_selcollection_print_tree(stderr
, d
->sc
, TRUE
);
65 for (g
= 0; g
< nr
; ++g
)
67 gmx_ana_index_dump(sel
[g
]->g
, g
, d
->nmaxind
);
68 fprintf(stderr
, " Positions (%d pcs):\n", sel
[g
]->p
.nr
);
70 if (d
->nmaxind
>= 0 && n
> d
->nmaxind
)
74 for (i
= 0; i
< n
; ++i
)
76 fprintf(stderr
, " (%.2f,%.2f,%.2f) r=%d, m=%d, b=%d-%d\n",
77 sel
[g
]->p
.x
[i
][XX
], sel
[g
]->p
.x
[i
][YY
], sel
[g
]->p
.x
[i
][ZZ
],
78 sel
[g
]->p
.m
.refid
[i
], sel
[g
]->p
.m
.mapid
[i
],
79 sel
[g
]->p
.m
.mapb
.index
[i
]+1,
80 sel
[g
]->p
.m
.mapb
.index
[i
+1]);
84 fprintf(stderr
, " ...\n");
87 fprintf(stderr
, "\n");
92 print_selections(int nr
, gmx_ana_selection_t
**sel
, int nmaxind
)
96 fprintf(stderr
, "\nSelections:\n");
97 for (g
= 0; g
< nr
; ++g
)
100 gmx_ana_selection_print_info(sel
[g
]);
101 fprintf(stderr
, " ");
102 gmx_ana_index_dump(sel
[g
]->g
, g
, nmaxind
);
104 fprintf(stderr
, " Block (size=%d):", sel
[g
]->p
.m
.mapb
.nr
);
105 if (!sel
[g
]->p
.m
.mapb
.index
)
107 fprintf(stderr
, " (null)");
111 n
= sel
[g
]->p
.m
.mapb
.nr
;
112 if (nmaxind
>= 0 && n
> nmaxind
)
114 for (i
= 0; i
<= n
; ++i
)
115 fprintf(stderr
, " %d", sel
[g
]->p
.m
.mapb
.index
[i
]);
116 if (n
< sel
[g
]->p
.m
.mapb
.nr
)
117 fprintf(stderr
, " ...");
119 fprintf(stderr
, "\n");
122 if (nmaxind
>= 0 && n
> nmaxind
)
124 fprintf(stderr
, " RefId:");
125 if (!sel
[g
]->p
.m
.refid
)
127 fprintf(stderr
, " (null)");
131 for (i
= 0; i
< n
; ++i
)
132 fprintf(stderr
, " %d", sel
[g
]->p
.m
.refid
[i
]);
133 if (n
< sel
[g
]->p
.m
.nr
)
134 fprintf(stderr
, " ...");
136 fprintf(stderr
, "\n");
138 fprintf(stderr
, " MapId:");
139 if (!sel
[g
]->p
.m
.mapid
)
141 fprintf(stderr
, " (null)");
145 for (i
= 0; i
< n
; ++i
)
146 fprintf(stderr
, " %d", sel
[g
]->p
.m
.mapid
[i
]);
147 if (n
< sel
[g
]->p
.m
.nr
)
148 fprintf(stderr
, " ...");
150 fprintf(stderr
, "\n");
152 fprintf(stderr
, "\n");
156 gmx_test_selection(int argc
, char *argv
[])
158 const char *desc
[] = {
159 "This is a test program for selections.",
162 bool bMaskOnly
= FALSE
;
163 bool bFrameTree
= FALSE
;
167 {"-mask", FALSE
, etBOOL
, {&bMaskOnly
},
168 "Test position mask functionality"},
169 {"-frtree", FALSE
, etBOOL
, {&bFrameTree
},
170 "Print the whole evaluation tree for each frame"},
171 {"-nref", FALSE
, etINT
, {&nref
},
172 "Number of reference selections to ask for"},
173 {"-pmax", FALSE
, etINT
, {&nmaxind
},
174 "Maximum number of indices to print in lists (-1 = print all)"},
178 {efDAT
, "-o", "debug", ffOPTWR
},
184 gmx_ana_selection_t
**sel
;
187 #define NFILE asize(fnm)
189 CopyRight(stderr
, argv
[0]);
191 gmx_ana_traj_create(&trj
, ANA_DEBUG_SELECTION
| ANA_USER_SELINIT
| ANA_USE_FULLGRPS
);
192 gmx_ana_get_selcollection(trj
, &d
.sc
);
193 gmx_ana_set_nanagrps(trj
, -1);
194 parse_trjana_args(trj
, &argc
, argv
, 0,
195 NFILE
, fnm
, asize(pa
), pa
, asize(desc
), desc
, 0, NULL
,
199 gmx_ana_add_flags(trj
, ANA_USE_POSMASK
);
200 gmx_ana_selcollection_set_outpostype(d
.sc
, NULL
, TRUE
);
202 gmx_ana_set_nrefgrps(trj
, nref
);
203 gmx_ana_init_selections(trj
);
204 gmx_ana_get_ngrps(trj
, &ngrps
);
205 gmx_ana_get_anagrps(trj
, &sel
);
207 d
.bFrameTree
= bFrameTree
;
210 print_selections(ngrps
, sel
, d
.nmaxind
);
212 gmx_ana_do(trj
, 0, &dump_frame
, &d
);
214 print_selections(ngrps
, sel
, d
.nmaxind
);
216 gmx_ana_traj_free(trj
);
222 main(int argc
, char *argv
[])
224 gmx_test_selection(argc
, argv
);