2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
37 * Implements simple keyword selection methods.
39 * \author Teemu Murtola <teemu.murtola@gmail.com>
40 * \ingroup module_selection
46 #include "gromacs/topology/mtop_lookup.h"
47 #include "gromacs/topology/topology.h"
48 #include "gromacs/utility/arraysize.h"
49 #include "gromacs/utility/exceptions.h"
50 #include "gromacs/utility/gmxassert.h"
53 #include "selmethod.h"
54 #include "selmethod_impl.h"
56 /** Evaluates the \p all selection keyword. */
58 evaluate_all(const gmx::SelMethodEvalContext
&context
,
59 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
60 /** Evaluates the \p none selection keyword. */
62 evaluate_none(const gmx::SelMethodEvalContext
&context
,
63 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
64 /** Evaluates the \p atomnr selection keyword. */
66 evaluate_atomnr(const gmx::SelMethodEvalContext
&context
,
67 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
68 /** Evaluates the \p resnr selection keyword. */
70 evaluate_resnr(const gmx::SelMethodEvalContext
&context
,
71 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
72 /** Evaluates the \p resindex selection keyword. */
74 evaluate_resindex(const gmx::SelMethodEvalContext
&context
,
75 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
77 * Checks whether molecule information is present in the topology.
79 * \param[in] top Topology structure.
80 * \param npar Not used.
81 * \param param Not used.
82 * \param data Not used.
83 * \returns 0 if molecule info is present in the topology, -1 otherwise.
85 * If molecule information is not found, also prints an error message.
88 check_molecules(const gmx_mtop_t
*top
, int npar
, gmx_ana_selparam_t
*param
, void *data
);
89 /** Evaluates the \p molindex selection keyword. */
91 evaluate_molindex(const gmx::SelMethodEvalContext
&context
,
92 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
93 /** Evaluates the \p atomname selection keyword. */
95 evaluate_atomname(const gmx::SelMethodEvalContext
&context
,
96 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
97 /** Evaluates the \p pdbatomname selection keyword. */
99 evaluate_pdbatomname(const gmx::SelMethodEvalContext
&context
,
100 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
102 * Checks whether atom types are present in the topology.
104 * \param[in] top Topology structure.
105 * \param npar Not used.
106 * \param param Not used.
107 * \param data Not used.
110 check_atomtype(const gmx_mtop_t
*top
, int npar
, gmx_ana_selparam_t
*param
, void *data
);
111 /** Evaluates the \p atomtype selection keyword. */
113 evaluate_atomtype(const gmx::SelMethodEvalContext
&context
,
114 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
115 /** Evaluates the \p insertcode selection keyword. */
117 evaluate_insertcode(const gmx::SelMethodEvalContext
&context
,
118 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
119 /** Evaluates the \p chain selection keyword. */
121 evaluate_chain(const gmx::SelMethodEvalContext
&context
,
122 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
123 /** Evaluates the \p mass selection keyword. */
125 evaluate_mass(const gmx::SelMethodEvalContext
&context
,
126 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
128 * Checks whether charges are present in the topology.
130 * \param[in] top Topology structure.
131 * \param npar Not used.
132 * \param param Not used.
133 * \param data Not used.
136 check_charge(const gmx_mtop_t
*top
, int npar
, gmx_ana_selparam_t
*param
, void *data
);
137 /** Evaluates the \p charge selection keyword. */
139 evaluate_charge(const gmx::SelMethodEvalContext
&context
,
140 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
142 * Checks whether PDB info is present in the topology.
144 * \param[in] top Topology structure.
145 * \param npar Not used.
146 * \param param Not used.
147 * \param data Not used.
148 * \returns 0 if PDB info is present in the topology, -1 otherwise.
150 * If PDB info is not found, also prints an error message.
153 check_pdbinfo(const gmx_mtop_t
*top
, int npar
, gmx_ana_selparam_t
*param
, void *data
);
154 /** Evaluates the \p altloc selection keyword. */
156 evaluate_altloc(const gmx::SelMethodEvalContext
&context
,
157 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
158 /** Evaluates the \p occupancy selection keyword. */
160 evaluate_occupancy(const gmx::SelMethodEvalContext
&context
,
161 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
162 /** Evaluates the \p betafactor selection keyword. */
164 evaluate_betafactor(const gmx::SelMethodEvalContext
&context
,
165 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
166 /** Evaluates the \p resname selection keyword. */
168 evaluate_resname(const gmx::SelMethodEvalContext
&context
,
169 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void *data
);
171 /** Evaluates the \p x selection keyword. */
173 evaluate_x(const gmx::SelMethodEvalContext
&context
,
174 gmx_ana_pos_t
*pos
, gmx_ana_selvalue_t
*out
, void *data
);
175 /** Evaluates the \p y selection keyword. */
177 evaluate_y(const gmx::SelMethodEvalContext
&context
,
178 gmx_ana_pos_t
*pos
, gmx_ana_selvalue_t
*out
, void *data
);
179 /** Evaluates the \p z selection keyword. */
181 evaluate_z(const gmx::SelMethodEvalContext
&context
,
182 gmx_ana_pos_t
*pos
, gmx_ana_selvalue_t
*out
, void *data
);
184 //! Help title for atom name selection keywords.
185 static const char helptitle_atomname
[] = "Selecting atoms by name";
186 //! Help text for atom name selection keywords.
187 static const char *const help_atomname
[] = {
195 "These keywords select atoms by name. [TT]name[tt] selects atoms using",
196 "the GROMACS atom naming convention.",
197 "For input formats other than PDB, the atom names are matched exactly",
198 "as they appear in the input file. For PDB files, 4 character atom names",
199 "that start with a digit are matched after moving the digit to the end",
200 "(e.g., to match 3HG2 from a PDB file, use [TT]name HG23[tt]).",
201 "[TT]pdbname[tt] can only be used with a PDB input file, and selects",
202 "atoms based on the exact name given in the input file, without the",
203 "transformation described above.[PAR]",
205 "[TT]atomname[tt] and [TT]pdbatomname[tt] are synonyms for the above two",
209 //! Help title for residue index selection keywords.
210 static const char helptitle_resindex
[] = "Selecting atoms by residue number";
211 //! Help text for residue index selection keywords.
212 static const char *const help_resindex
[] = {
220 "[TT]resnr[tt] selects atoms using the residue numbering in the input",
221 "file. [TT]resid[tt] is synonym for this keyword for VMD compatibility.",
223 "[TT]resindex N[tt] selects the [TT]N[tt] th residue starting from the",
224 "beginning of the input file. This is useful for uniquely identifying",
225 "residues if there are duplicate numbers in the input file (e.g., in",
227 "[TT]residue[tt] is a synonym for [TT]resindex[tt]. This allows",
228 "[TT]same residue as[tt] to work as expected."
231 /** Selection method data for \p all selection keyword. */
232 gmx_ana_selmethod_t sm_all
= {
233 "all", GROUP_VALUE
, 0,
245 /** Selection method data for \p none selection keyword. */
246 gmx_ana_selmethod_t sm_none
= {
247 "none", GROUP_VALUE
, 0,
259 /** Selection method data for \p atomnr selection keyword. */
260 gmx_ana_selmethod_t sm_atomnr
= {
261 "atomnr", INT_VALUE
, 0,
273 /** Selection method data for \p resnr selection keyword. */
274 gmx_ana_selmethod_t sm_resnr
= {
275 "resnr", INT_VALUE
, SMETH_REQTOP
,
285 {nullptr, helptitle_resindex
, asize(help_resindex
), help_resindex
}
288 /** Selection method data for \p resindex selection keyword. */
289 gmx_ana_selmethod_t sm_resindex
= {
290 "resindex", INT_VALUE
, SMETH_REQTOP
,
300 {nullptr, helptitle_resindex
, asize(help_resindex
), help_resindex
}
303 /** Selection method data for \p molindex selection keyword. */
304 gmx_ana_selmethod_t sm_molindex
= {
305 "molindex", INT_VALUE
, SMETH_REQTOP
,
317 /** Selection method data for \p atomname selection keyword. */
318 gmx_ana_selmethod_t sm_atomname
= {
319 "atomname", STR_VALUE
, SMETH_REQTOP
,
329 {nullptr, helptitle_atomname
, asize(help_atomname
), help_atomname
}
332 /** Selection method data for \p pdbatomname selection keyword. */
333 gmx_ana_selmethod_t sm_pdbatomname
= {
334 "pdbatomname", STR_VALUE
, SMETH_REQTOP
,
342 &evaluate_pdbatomname
,
344 {nullptr, helptitle_atomname
, asize(help_atomname
), help_atomname
}
347 /** Selection method data for \p atomtype selection keyword. */
348 gmx_ana_selmethod_t sm_atomtype
= {
349 "atomtype", STR_VALUE
, SMETH_REQTOP
,
361 /** Selection method data for \p resname selection keyword. */
362 gmx_ana_selmethod_t sm_resname
= {
363 "resname", STR_VALUE
, SMETH_REQTOP
,
375 /** Selection method data for \p chain selection keyword. */
376 gmx_ana_selmethod_t sm_insertcode
= {
377 "insertcode", STR_VALUE
, SMETH_REQTOP
| SMETH_CHARVAL
,
385 &evaluate_insertcode
,
389 /** Selection method data for \p chain selection keyword. */
390 gmx_ana_selmethod_t sm_chain
= {
391 "chain", STR_VALUE
, SMETH_REQTOP
| SMETH_CHARVAL
,
403 /** Selection method data for \p mass selection keyword. */
404 gmx_ana_selmethod_t sm_mass
= {
405 "mass", REAL_VALUE
, SMETH_REQMASS
,
417 /** Selection method data for \p charge selection keyword. */
418 gmx_ana_selmethod_t sm_charge
= {
419 "charge", REAL_VALUE
, SMETH_REQTOP
,
431 /** Selection method data for \p chain selection keyword. */
432 gmx_ana_selmethod_t sm_altloc
= {
433 "altloc", STR_VALUE
, SMETH_REQTOP
| SMETH_CHARVAL
,
445 /** Selection method data for \p occupancy selection keyword. */
446 gmx_ana_selmethod_t sm_occupancy
= {
447 "occupancy", REAL_VALUE
, SMETH_REQTOP
,
459 /** Selection method data for \p betafactor selection keyword. */
460 gmx_ana_selmethod_t sm_betafactor
= {
461 "betafactor", REAL_VALUE
, SMETH_REQTOP
,
469 &evaluate_betafactor
,
473 /** Selection method data for \p x selection keyword. */
474 gmx_ana_selmethod_t sm_x
= {
475 "x", REAL_VALUE
, SMETH_DYNAMIC
,
487 /** Selection method data for \p y selection keyword. */
488 gmx_ana_selmethod_t sm_y
= {
489 "y", REAL_VALUE
, SMETH_DYNAMIC
,
501 /** Selection method data for \p z selection keyword. */
502 gmx_ana_selmethod_t sm_z
= {
503 "z", REAL_VALUE
, SMETH_DYNAMIC
,
516 * See sel_updatefunc() for description of the parameters.
517 * \p data is not used.
519 * Copies \p g to \p out->u.g.
522 evaluate_all(const gmx::SelMethodEvalContext
& /*context*/,
523 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
525 gmx_ana_index_copy(out
->u
.g
, g
, false);
529 * See sel_updatefunc() for description of the parameters.
530 * \p data is not used.
532 * Returns an empty \p out->u.g.
535 evaluate_none(const gmx::SelMethodEvalContext
& /*context*/,
536 gmx_ana_index_t
* /* g */, gmx_ana_selvalue_t
*out
, void * /* data */)
542 * See sel_updatefunc() for description of the parameters.
543 * \p data is not used.
545 * Returns the indices for each atom in \p out->u.i.
548 evaluate_atomnr(const gmx::SelMethodEvalContext
& /*context*/,
549 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
554 for (i
= 0; i
< g
->isize
; ++i
)
556 out
->u
.i
[i
] = g
->index
[i
] + 1;
561 * See sel_updatefunc() for description of the parameters.
562 * \p data is not used.
564 * Returns the residue numbers for each atom in \p out->u.i.
567 evaluate_resnr(const gmx::SelMethodEvalContext
&context
,
568 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
572 for (int i
= 0; i
< g
->isize
; ++i
)
574 mtopGetAtomAndResidueName(context
.top
, g
->index
[i
], &molb
,
575 nullptr, &out
->u
.i
[i
], nullptr, nullptr);
580 * See sel_updatefunc() for description of the parameters.
581 * \p data is not used.
583 * Returns the residue indices for each atom in \p out->u.i.
586 evaluate_resindex(const gmx::SelMethodEvalContext
&context
,
587 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
591 for (int i
= 0; i
< g
->isize
; ++i
)
594 mtopGetAtomAndResidueName(context
.top
, g
->index
[i
], &molb
,
595 nullptr, nullptr, nullptr, &resind
);
596 out
->u
.i
[i
] = resind
+ 1;
601 check_molecules(const gmx_mtop_t
*top
, int /* npar */, gmx_ana_selparam_t
* /* param */, void * /* data */)
605 bOk
= (top
!= nullptr && top
->haveMoleculeIndices
);
608 GMX_THROW(gmx::InconsistentInputError("Molecule information not available in topology"));
613 * See sel_updatefunc() for description of the parameters.
614 * \p data is not used.
616 * Returns the molecule indices for each atom in \p out->u.i.
619 evaluate_molindex(const gmx::SelMethodEvalContext
&context
,
620 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
624 for (int i
= 0; i
< g
->isize
; ++i
)
626 out
->u
.i
[i
] = mtopGetMoleculeIndex(context
.top
, g
->index
[i
], &molb
) + 1;
631 * See sel_updatefunc() for description of the parameters.
632 * \p data is not used.
634 * Returns the atom name for each atom in \p out->u.s.
637 evaluate_atomname(const gmx::SelMethodEvalContext
&context
,
638 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
642 for (int i
= 0; i
< g
->isize
; ++i
)
644 const char *atom_name
;
645 mtopGetAtomAndResidueName(context
.top
, g
->index
[i
], &molb
,
646 &atom_name
, nullptr, nullptr, nullptr);
647 out
->u
.s
[i
] = const_cast<char *>(atom_name
);
652 * See sel_updatefunc() for description of the parameters.
653 * \p data is not used.
655 * Returns the PDB atom name for each atom in \p out->u.s.
658 evaluate_pdbatomname(const gmx::SelMethodEvalContext
&context
,
659 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
663 for (int i
= 0; i
< g
->isize
; ++i
)
665 const char *s
= mtopGetAtomPdbInfo(context
.top
, g
->index
[i
], &molb
).atomnm
;
666 while (std::isspace(*s
))
670 out
->u
.s
[i
] = const_cast<char *>(s
);
675 check_atomtype(const gmx_mtop_t
*top
, int /* npar */, gmx_ana_selparam_t
* /* param */, void * /* data */)
677 if (!gmx_mtop_has_atomtypes(top
))
679 GMX_THROW(gmx::InconsistentInputError("Atom types not available in topology"));
684 * See sel_updatefunc() for description of the parameters.
685 * \p data is not used.
687 * Returns the atom type for each atom in \p out->u.s.
688 * Segfaults if atom types are not found in the topology.
691 evaluate_atomtype(const gmx::SelMethodEvalContext
&context
,
692 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
696 for (int i
= 0; i
< g
->isize
; ++i
)
698 int atomIndexInMolecule
;
699 mtopGetMolblockIndex(context
.top
, g
->index
[i
], &molb
,
700 nullptr, &atomIndexInMolecule
);
701 const gmx_moltype_t
&moltype
= context
.top
->moltype
[context
.top
->molblock
[molb
].type
];
702 out
->u
.s
[i
] = *moltype
.atoms
.atomtype
[atomIndexInMolecule
];
707 * See sel_updatefunc() for description of the parameters.
708 * \p data is not used.
710 * Returns the residue name for each atom in \p out->u.s.
713 evaluate_resname(const gmx::SelMethodEvalContext
&context
,
714 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
718 for (int i
= 0; i
< g
->isize
; ++i
)
720 out
->u
.s
[i
] = *mtopGetResidueInfo(context
.top
, g
->index
[i
], &molb
).name
;
725 * See sel_updatefunc() for description of the parameters.
726 * \p data is not used.
728 * Returns the insertion code for each atom in \p out->u.s.
731 evaluate_insertcode(const gmx::SelMethodEvalContext
&context
,
732 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
736 for (int i
= 0; i
< g
->isize
; ++i
)
738 out
->u
.s
[i
][0] = mtopGetResidueInfo(context
.top
, g
->index
[i
], &molb
).ic
;
743 * See sel_updatefunc() for description of the parameters.
744 * \p data is not used.
746 * Returns the chain for each atom in \p out->u.s.
749 evaluate_chain(const gmx::SelMethodEvalContext
&context
,
750 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
754 for (int i
= 0; i
< g
->isize
; ++i
)
756 out
->u
.s
[i
][0] = mtopGetResidueInfo(context
.top
, g
->index
[i
], &molb
).chainid
;
761 * See sel_updatefunc() for description of the parameters.
762 * \p data is not used.
764 * Returns the mass for each atom in \p out->u.r.
767 evaluate_mass(const gmx::SelMethodEvalContext
&context
,
768 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
770 GMX_RELEASE_ASSERT(gmx_mtop_has_masses(context
.top
),
771 "Masses not available for evaluation");
774 for (int i
= 0; i
< g
->isize
; ++i
)
776 out
->u
.r
[i
] = mtopGetAtomMass(context
.top
, g
->index
[i
], &molb
);
782 check_charge(const gmx_mtop_t
*top
, int /* npar */, gmx_ana_selparam_t
* /* param */, void * /* data */)
784 if (!gmx_mtop_has_charges(top
))
786 GMX_THROW(gmx::InconsistentInputError("Charges not available in topology"));
791 * See sel_updatefunc() for description of the parameters.
792 * \p data is not used.
794 * Returns the charge for each atom in \p out->u.r.
797 evaluate_charge(const gmx::SelMethodEvalContext
&context
,
798 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
802 for (int i
= 0; i
< g
->isize
; ++i
)
804 out
->u
.r
[i
] = mtopGetAtomParameters(context
.top
, g
->index
[i
], &molb
).q
;
809 check_pdbinfo(const gmx_mtop_t
*top
, int /* npar */, gmx_ana_selparam_t
* /* param */, void * /* data */)
811 if (!gmx_mtop_has_pdbinfo(top
))
813 GMX_THROW(gmx::InconsistentInputError("PDB info not available in topology"));
818 * See sel_updatefunc() for description of the parameters.
819 * \p data is not used.
821 * Returns the alternate location identifier for each atom in \p out->u.s.
824 evaluate_altloc(const gmx::SelMethodEvalContext
&context
,
825 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
829 for (int i
= 0; i
< g
->isize
; ++i
)
831 out
->u
.s
[i
][0] = mtopGetAtomPdbInfo(context
.top
, g
->index
[i
], &molb
).altloc
;
836 * See sel_updatefunc() for description of the parameters.
837 * \p data is not used.
839 * Returns the occupancy numbers for each atom in \p out->u.r.
840 * Segfaults if PDB info is not found in the topology.
843 evaluate_occupancy(const gmx::SelMethodEvalContext
&context
,
844 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
848 for (int i
= 0; i
< g
->isize
; ++i
)
850 out
->u
.r
[i
] = mtopGetAtomPdbInfo(context
.top
, g
->index
[i
], &molb
).occup
;
855 * See sel_updatefunc() for description of the parameters.
856 * \p data is not used.
858 * Returns the B-factors for each atom in \p out->u.r.
859 * Segfaults if PDB info is not found in the topology.
862 evaluate_betafactor(const gmx::SelMethodEvalContext
&context
,
863 gmx_ana_index_t
*g
, gmx_ana_selvalue_t
*out
, void * /* data */)
867 for (int i
= 0; i
< g
->isize
; ++i
)
869 out
->u
.r
[i
] = mtopGetAtomPdbInfo(context
.top
, g
->index
[i
], &molb
).bfac
;
874 * Internal utility function for position keyword evaluation.
876 * \param[out] out Output array.
877 * \param[in] pos Position data to use instead of atomic coordinates.
878 * \param[in] d Coordinate index to evaluate (\p XX, \p YY or \p ZZ).
880 * This function is used internally by evaluate_x(), evaluate_y() and
881 * evaluate_z() to do the actual evaluation.
884 evaluate_coord(real out
[], gmx_ana_pos_t
*pos
, int d
)
886 for (int i
= 0; i
< pos
->count(); ++i
)
888 out
[i
] = pos
->x
[i
][d
];
890 // TODO: Make this more efficient by directly extracting the coordinates
891 // from the frame coordinates for atomic positions instead of going through
892 // a position calculation.
896 * See sel_updatefunc_pos() for description of the parameters.
897 * \p data is not used.
899 * Returns the \p x coordinate for each position in \p out->u.r.
902 evaluate_x(const gmx::SelMethodEvalContext
& /*context*/,
903 gmx_ana_pos_t
*pos
, gmx_ana_selvalue_t
*out
, void * /*data*/)
905 out
->nr
= pos
->count();
906 evaluate_coord(out
->u
.r
, pos
, XX
);
910 * See sel_updatefunc() for description of the parameters.
911 * \p data is not used.
913 * Returns the \p y coordinate for each position in \p out->u.r.
916 evaluate_y(const gmx::SelMethodEvalContext
& /*context*/,
917 gmx_ana_pos_t
*pos
, gmx_ana_selvalue_t
*out
, void * /*data*/)
919 out
->nr
= pos
->count();
920 evaluate_coord(out
->u
.r
, pos
, YY
);
924 * See sel_updatefunc() for description of the parameters.
925 * \p data is not used.
927 * Returns the \p z coordinate for each position in \p out->u.r.
930 evaluate_z(const gmx::SelMethodEvalContext
& /*context*/,
931 gmx_ana_pos_t
*pos
, gmx_ana_selvalue_t
*out
, void * /*data*/)
933 out
->nr
= pos
->count();
934 evaluate_coord(out
->u
.r
, pos
, ZZ
);