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 Implementation of the \p same selection method.
41 #include <indexutil.h>
42 #include <selmethod.h>
45 * Data structure for the \p same selection method.
47 * All angle values are in the units of radians.
51 /*! \brief Input group. */
55 /*! \brief Allocates data for the \p same selection method. */
57 init_data_same(int npar
, gmx_ana_selparam_t
*param
);
58 /*! \brief Initializes the \p same selection method. */
60 init_same(t_topology
*top
, int npar
, gmx_ana_selparam_t
*param
, void *data
);
61 /*! \brief Frees the data allocated for the \p same selection method. */
63 free_data_same(void *data
);
64 /*! \brief Initializes the evaluation of the \p same selection method for a frame. */
66 init_frame_same(t_topology
*top
, t_trxframe
*fr
, t_pbc
*pbc
, void *data
);
67 /*! \brief Evaluates the \p same selection method. */
69 evaluate_same(t_topology
*top
, t_trxframe
*fr
, t_pbc
*pbc
,
70 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
72 /*! \brief Enum array for the \p same selection method. */
73 static char *same_enum
[] = { NULL
, "residue", NULL
};
75 /*! \brief Parameters for the \p same selection method. */
76 static gmx_ana_selparam_t smparams_same
[] = {
77 {NULL
, {STR_VALUE
, 1, {same_enum
}}, NULL
, SPAR_ENUMVAL
},
78 {"as", {GROUP_VALUE
, 1, {NULL
}}, NULL
, SPAR_DYNAMIC
},
81 /*! \internal \brief Selection method data for the \p same method. */
82 gmx_ana_selmethod_t sm_same
= {
83 "same", GROUP_VALUE
, SMETH_REQTOP
,
84 asize(smparams_same
), smparams_same
,
93 {"same residue as ATOM_EXPR", 0, NULL
},
97 * \param[in] npar Not used (should be 2).
98 * \param[in,out] param Method parameters (should point to
99 * \ref smparams_same).
100 * \returns Pointer to the allocated data (\ref t_methoddata_same).
103 init_data_same(int npar
, gmx_ana_selparam_t
*param
)
105 t_methoddata_same
*data
;
108 gmx_ana_index_clear(&data
->g
);
109 param
[1].val
.u
.g
= &data
->g
;
114 * \param data Data to free (should point to a \ref t_methoddata_same).
117 free_data_same(void *data
)
119 t_methoddata_same
*d
= (t_methoddata_same
*)data
;
121 gmx_ana_index_deinit(&d
->g
);
125 * See sel_updatefunc() for description of the parameters.
126 * \p data should point to a \c t_methoddata_same.
128 * Calculates which atoms in \p g are in the same residues as the atoms in
129 * \c t_methoddata_same::g.
132 evaluate_same(t_topology
*top
, t_trxframe
*fr
, t_pbc
*pbc
,
133 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
)
135 t_methoddata_same
*d
= (t_methoddata_same
*)data
;
140 while (i
< d
->g
.isize
)
142 resind
= top
->atoms
.atom
[d
->g
.index
[i
]].resind
;
143 /* Find the first atom in the current residue */
144 while (top
->atoms
.atom
[g
->index
[j
]].resind
< resind
) ++j
;
145 /* Copy all the atoms in the residue to the output */
146 while (j
< g
->isize
&& top
->atoms
.atom
[g
->index
[j
]].resind
== resind
)
148 out
->u
.g
->index
[out
->u
.g
->isize
++] = g
->index
[j
];
151 /* Skip the rest of the atoms in the residue */
153 while (i
< d
->g
.isize
&& top
->atoms
.atom
[d
->g
.index
[i
]].resind
== resind
) ++i
;