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,2013, 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 API for handling selection (the \c gmx_ana_selection_t structure and related functions).
41 * There should be no need to use the data structures or call the
42 * functions in this file directly unless using the selection routines outside
43 * the main trajectory analysis API.
49 #include "indexutil.h"
56 /** Information for a collection of selections. */
57 typedef struct gmx_ana_selcollection_t gmx_ana_selcollection_t
;
59 struct gmx_ana_poscalc_coll_t
;
61 /** Defines the type of covered fraction. */
64 CFRAC_NONE
, /**< No covered fraction (everything covered). */
65 CFRAC_SOLIDANGLE
/**< Fraction of a solid (3D) angle covered. */
69 * Describes a single selection.
71 typedef struct gmx_ana_selection_t
73 /** Name of the selection. */
75 /** The actual selection string. */
77 /** Selected positions. */
79 /** Masses associated with the positions. */
81 /** Charges associated with the positions. */
83 /** Pointer to the index group that holds the selected atoms. */
84 struct gmx_ana_index_t
*g
;
85 /** TRUE if the value can change as a function of time. */
87 /** Type of the covered fraction. */
88 e_coverfrac_t cfractype
;
89 /** TRUE if the covered fraction depends on the frame. */
91 /** Covered fraction of the selection for the current frame. */
93 /** The average covered fraction (over the trajectory). */
97 * Pointer to the root of the selection element tree (internal use only).
100 * This field is NULL if the selection has been loaded directly from an
103 struct t_selelem
*selelem
;
104 /** Original masses of all possible positions (internal use only). */
106 /** Original charges of all possible positions (internal use only). */
108 } gmx_ana_selection_t
;
110 /** Frees the memory allocated for a selection. */
112 gmx_ana_selection_free(gmx_ana_selection_t
*sel
);
113 /** Returns the name of a selection. */
115 gmx_ana_selection_name(gmx_ana_selection_t
*sel
);
116 /** Prints out the selection information. */
118 gmx_ana_selection_print_info(gmx_ana_selection_t
*sel
);
119 /** Initializes the information for covered fraction. */
121 gmx_ana_selection_init_coverfrac(gmx_ana_selection_t
*sel
, e_coverfrac_t type
);
123 /** Creates a new empty selection collection. */
125 gmx_ana_selcollection_create(gmx_ana_selcollection_t
**sc
,
126 struct gmx_ana_poscalc_coll_t
*pcc
);
127 /** Frees the memory allocated for a selection collection. */
129 gmx_ana_selcollection_free(gmx_ana_selcollection_t
*sc
);
130 /** Sets the default reference position handling for a selection collection. */
132 gmx_ana_selcollection_set_refpostype(gmx_ana_selcollection_t
*sc
, const char *type
);
133 /** Sets the default output position handling for a selection collection. */
135 gmx_ana_selcollection_set_outpostype(gmx_ana_selcollection_t
*sc
,
136 const char *type
, gmx_bool bMaskOnly
);
137 /** Request evaluation of velocities for selections. */
139 gmx_ana_selcollection_set_veloutput(gmx_ana_selcollection_t
*sc
,
141 /** Request evaluation of forces for selections. */
143 gmx_ana_selcollection_set_forceoutput(gmx_ana_selcollection_t
*sc
,
145 /** Sets the topology for a selection collection. */
147 gmx_ana_selcollection_set_topology(gmx_ana_selcollection_t
*sc
, t_topology
*top
,
149 /** Returns the number of selections specified by a selection collection. */
151 gmx_ana_selcollection_get_count(gmx_ana_selcollection_t
*sc
);
152 /** Returns a selection by index. */
153 gmx_ana_selection_t
*
154 gmx_ana_selcollection_get_selection(gmx_ana_selcollection_t
*sc
, int i
);
155 /** Returns TRUE if the collection requires topology information for evaluation. */
157 gmx_ana_selcollection_requires_top(gmx_ana_selcollection_t
*sc
);
158 /** Prints a human-readable version of the internal selection element tree. */
160 gmx_ana_selcollection_print_tree(FILE *fp
, gmx_ana_selcollection_t
*sc
, gmx_bool bValues
);
161 /** Prints the selection strings into an XVGR file as comments. */
163 xvgr_selcollection(FILE *fp
, gmx_ana_selcollection_t
*sc
,
164 const output_env_t oenv
);
167 /** Parses selection(s) from standard input. */
169 gmx_ana_selcollection_parse_stdin(gmx_ana_selcollection_t
*sc
, int nr
,
170 gmx_ana_indexgrps_t
*grps
,
171 gmx_bool bInteractive
);
172 /** Parses selection(s) from a file. */
174 gmx_ana_selcollection_parse_file(gmx_ana_selcollection_t
*sc
, const char *fnm
,
175 gmx_ana_indexgrps_t
*grps
);
176 /** Parses selection(s) from a string. */
178 gmx_ana_selcollection_parse_str(gmx_ana_selcollection_t
*sc
, const char *str
,
179 gmx_ana_indexgrps_t
*grps
);
182 /** Set debugging flag for selection compilation. */
184 gmx_ana_selcollection_set_compile_debug(gmx_ana_selcollection_t
*sc
, gmx_bool bDebug
);
185 /** Prepares the selections for evaluation and performs some optimizations. */
187 gmx_ana_selcollection_compile(gmx_ana_selcollection_t
*sc
);
190 /** Evaluates the selection. */
192 gmx_ana_selcollection_evaluate(gmx_ana_selcollection_t
*sc
,
193 t_trxframe
*fr
, t_pbc
*pbc
);
194 /** Evaluates the largest possible index groups from dynamic selections. */
196 gmx_ana_selcollection_evaluate_fin(gmx_ana_selcollection_t
*sc
, int nframes
);