Convert remainder of the selection code to use gmx_mtop_t.
Part of #1862.
Change-Id: Icb1c4a30cc5456e64ed2d73f93ca4a7d6dbfbfbd
* is prevented by using \ref SEL_METHODINIT and \ref SEL_OUTINIT flags.
*/
static void
-init_method(const SelectionTreeElementPointer &sel, t_topology *top, int isize)
+init_method(const SelectionTreeElementPointer &sel, const gmx_mtop_t *top, int isize)
{
/* Find out whether there are any atom-valued parameters */
bool bAtomVal = false;
void
_gmx_sel_evaluate_init(gmx_sel_evaluate_t *data,
gmx_sel_mempool_t *mp, gmx_ana_index_t *gall,
- t_topology *top, t_trxframe *fr, t_pbc *pbc)
+ const gmx_mtop_t *top, t_trxframe *fr, t_pbc *pbc)
{
data->mp = mp;
data->gall = gall;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2016, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "selelem.h"
struct gmx_ana_index_t;
+struct gmx_mtop_t;
struct gmx_sel_mempool_t;
struct t_pbc;
-struct t_topology;
struct t_trxframe;
/*! \internal \brief
/** Index group that contains all the atoms. */
gmx_ana_index_t *gall;
/** Topology information. */
- t_topology *top;
+ const gmx_mtop_t *top;
/** Current frame. */
t_trxframe *fr;
/** PBC data. */
void
_gmx_sel_evaluate_init(gmx_sel_evaluate_t *data,
gmx_sel_mempool_t *mp, gmx_ana_index_t *gall,
- t_topology *top, t_trxframe *fr, t_pbc *pbc);
+ const gmx_mtop_t *top, t_trxframe *fr, t_pbc *pbc);
/** Evaluates the children of a general selection element. */
void
_gmx_sel_evaluate_children(gmx_sel_evaluate_t *data,
#include "gromacs/selection/nbsearch.h"
#include "gromacs/selection/position.h"
+#include "gromacs/topology/mtop_lookup.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
*
* Does not throw if enough space has been reserved for the output vectors.
*/
-void computeMassesAndCharges(const t_topology *top, const gmx_ana_pos_t &pos,
+void computeMassesAndCharges(const gmx_mtop_t *top, const gmx_ana_pos_t &pos,
std::vector<real> *masses,
std::vector<real> *charges)
{
GMX_ASSERT(top != NULL, "Should not have been called with NULL topology");
masses->clear();
charges->clear();
+ int molb = 0;
for (int b = 0; b < pos.count(); ++b)
{
real mass = 0.0;
real charge = 0.0;
for (int i = pos.m.mapb.index[b]; i < pos.m.mapb.index[b+1]; ++i)
{
- const int index = pos.m.mapb.a[i];
- mass += top->atoms.atom[index].m;
- charge += top->atoms.atom[index].q;
+ const int index = pos.m.mapb.a[i];
+ const t_atom &atom = mtopGetAtomParameters(top, index, &molb);
+ mass += atom.m;
+ charge += atom.q;
}
masses->push_back(mass);
charges->push_back(charge);
}
void
-SelectionData::initializeMassesAndCharges(const t_topology *top)
+SelectionData::initializeMassesAndCharges(const gmx_mtop_t *top)
{
GMX_ASSERT(posMass_.empty() && posCharge_.empty(),
"Should not be called more than once");
void
-SelectionData::refreshMassesAndCharges(const t_topology *top)
+SelectionData::refreshMassesAndCharges(const gmx_mtop_t *top)
{
if (top != NULL && isDynamic() && !hasFlag(efSelection_DynamicMask))
{
void
-SelectionData::restoreOriginalPositions(const t_topology *top)
+SelectionData::restoreOriginalPositions(const gmx_mtop_t *top)
{
if (isDynamic())
{
#include "gromacs/utility/gmxassert.h"
struct gmx_mtop_t;
-struct t_topology;
namespace gmx
{
*
* Strong exception safety guarantee.
*/
- void initializeMassesAndCharges(const t_topology *top);
+ void initializeMassesAndCharges(const gmx_mtop_t *top);
/*! \brief
* Updates masses and charges after dynamic selection has been
* evaluated.
*
* Called by SelectionEvaluator.
*/
- void refreshMassesAndCharges(const t_topology *top);
+ void refreshMassesAndCharges(const gmx_mtop_t *top);
/*! \brief
* Updates the covered fraction after a selection has been evaluated.
*
* \a rootElement_ object.
* Called by SelectionEvaluator::evaluateFinal().
*/
- void restoreOriginalPositions(const t_topology *top);
+ void restoreOriginalPositions(const gmx_mtop_t *top);
private:
//! Name of the selection.
#include "poscalc.h"
#include "selelem.h"
+struct gmx_mtop_t;
struct gmx_sel_mempool_t;
struct t_pbc;
-struct t_topology;
struct t_trxframe;
namespace gmx
char **varstrs;
/** Topology for the collection. */
- t_topology *top;
+ const gmx_mtop_t *top;
/** Index group that contains all the atoms. */
gmx_ana_index_t gall;
/** Memory pool used for selection evaluation. */
}
//! Checks whether the given topology properties are available.
-void checkTopologyProperties(const t_topology *top,
+void checkTopologyProperties(const gmx_mtop_t *top,
const SelectionTopologyProperties &props)
{
if (top == NULL)
}
return;
}
- if (props.needsMasses && !top->atoms.haveMass)
+ if (props.needsMasses && !gmx_mtop_has_masses(top))
{
GMX_THROW(InconsistentInputError("Selection requires mass information, but it is not available in the topology"));
}
{
GMX_RELEASE_ASSERT(natoms > 0 || top != NULL,
"The number of atoms must be given if there is no topology");
+ checkTopologyProperties(top, requiredTopologyProperties());
// Get the number of atoms from the topology if it is not given.
if (natoms <= 0)
{
gmx_ana_selcollection_t *sc = &impl_->sc_;
// Do this first, as it allocates memory, while the others don't throw.
gmx_ana_index_init_simple(&sc->gall, natoms);
- // TODO: Adapt to use mtop throughout.
- if (top != nullptr)
- {
- snew(sc->top, 1);
- *sc->top = gmx_mtop_t_to_t_topology(top, false);
- checkTopologyProperties(sc->top, requiredTopologyProperties());
- }
- else
- {
- checkTopologyProperties(nullptr, requiredTopologyProperties());
- }
+ sc->top = top;
sc->pcc.setTopology(top);
}
struct gmx_ana_index_t;
struct gmx_ana_pos_t;
struct gmx_ana_selcollection_t;
+struct gmx_mtop_t;
struct t_pbc;
-struct t_topology;
struct t_trxframe;
namespace gmx
struct SelMethodEvalContext
{
//! Initializes the context with given values.
- SelMethodEvalContext(const t_topology *top, t_trxframe *fr, const t_pbc *pbc)
+ SelMethodEvalContext(const gmx_mtop_t *top, t_trxframe *fr, const t_pbc *pbc)
: top(top), fr(fr), pbc(pbc)
{
}
* Can be NULL if \ref SMETH_REQTOP or \ref SMETH_REQMASS is not set for
* the method.
*/
- const t_topology *top;
+ const gmx_mtop_t *top;
/*! \brief
* Trajectory frame.
*
* This function may be called multiple times for the same method if the
* method takes parameters with \ref SPAR_ATOMVAL set.
*/
-typedef void (*sel_initfunc)(t_topology *top, int npar,
+typedef void (*sel_initfunc)(const gmx_mtop_t *top, int npar,
gmx_ana_selparam_t *param, void *data);
/*! \brief
* Initializes output data structure.
* This function may be called multiple times for the same method if the
* method takes parameters with \ref SPAR_ATOMVAL set.
*/
-typedef void (*sel_outinitfunc)(t_topology *top, gmx_ana_selvalue_t *out,
+typedef void (*sel_outinitfunc)(const gmx_mtop_t *top, gmx_ana_selvalue_t *out,
void *data);
/*! \brief
* Frees the internal data.
* \returns 0 if the input data is valid, -1 on error.
*/
static void
-init_compare(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+init_compare(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/** Frees the memory allocated for comparison expression evaluation. */
static void
free_data_compare(void *data);
}
static void
-init_compare(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
+init_compare(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_compare *d = (t_methoddata_compare *)data;
int n1, n2;
* Also checks that the cutoff is valid.
*/
static void
-init_common(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+init_common(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/** Frees the data allocated for a distance-based selection method. */
static void
free_data_common(void *data);
}
static void
-init_common(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
+init_common(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_distance *d = static_cast<t_methoddata_distance *>(data);
* and allocates memory for the bins used during the evaluation.
*/
static void
-init_insolidangle(t_topology * top, int npar, gmx_ana_selparam_t * param, void *data);
+init_insolidangle(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t * param, void *data);
/** Frees the data allocated for the \p insolidangle selection method. */
static void
free_data_insolidangle(void *data);
}
static void
-init_insolidangle(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t * /* param */, void *data)
+init_insolidangle(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t * /* param */, void *data)
{
t_methoddata_insolidangle *surf = (t_methoddata_insolidangle *)data;
int i, c;
* \param[in] data Should point to \ref t_methoddata_kwint.
*/
static void
-init_kwint(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+init_kwint(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/*! \brief
* Initializes data for real keyword evaluation.
*
* \returns 0 (the initialization always succeeds).
*/
static void
-init_kwreal(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+init_kwreal(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/*! \brief
* Initializes data for string keyword evaluation.
*
* \param[in] data Should point to t_methoddata_kwstr.
*/
static void
-init_kwstr(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+init_kwstr(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/** Frees the memory allocated for string keyword evaluation. */
static void
free_data_kwstr(void *data);
* Calls the initialization method of the wrapped keyword.
*/
static void
-init_kweval(t_topology *top, int npar, gmx_ana_selparam_t * param, void *data);
+init_kweval(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t * param, void *data);
/*! \brief
* Initializes output for keyword evaluation in an arbitrary group.
*
* \returns 0 for success.
*/
static void
-init_output_kweval(t_topology *top, gmx_ana_selvalue_t *out, void *data);
+init_output_kweval(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data);
/** Frees the data allocated for keyword evaluation in an arbitrary group. */
static void
free_data_kweval(void *data);
}
static void
-init_kwint(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
+init_kwint(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_kwint *d = (t_methoddata_kwint *)data;
}
static void
-init_kwreal(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
+init_kwreal(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_kwreal *d = (t_methoddata_kwreal *)data;
}
static void
-init_kwstr(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
+init_kwstr(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_kwstr *d = static_cast<t_methoddata_kwstr *>(data);
********************************************************************/
static void
-init_kweval(t_topology *top, int /* npar */, gmx_ana_selparam_t * /* param */, void *data)
+init_kweval(const gmx_mtop_t *top, int /* npar */, gmx_ana_selparam_t * /* param */, void *data)
{
t_methoddata_kweval *d = static_cast<t_methoddata_kweval *>(data);
}
static void
-init_output_kweval(t_topology * /* top */, gmx_ana_selvalue_t *out, void *data)
+init_output_kweval(const gmx_mtop_t * /* top */, gmx_ana_selvalue_t *out, void *data)
{
t_methoddata_kweval *d = static_cast<t_methoddata_kweval *>(data);
* \returns 0 if everything is successful, -1 on error.
*/
static void
-init_merge(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+init_merge(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/** Initializes output for the \p merge selection modifier. */
static void
-init_output_merge(t_topology *top, gmx_ana_selvalue_t *out, void *data);
+init_output_merge(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data);
/** Initializes output for the \p plus selection modifier. */
static void
-init_output_plus(t_topology *top, gmx_ana_selvalue_t *out, void *data);
+init_output_plus(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data);
/** Frees the memory allocated for the merging selection modifiers. */
static void
free_data_merge(void *data);
}
static void
-init_merge(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t * /* param */, void *data)
+init_merge(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t * /* param */, void *data)
{
t_methoddata_merge *d = (t_methoddata_merge *)data;
* \param[in,out] data Should point to \c t_methoddata_merge.
*/
static void
-init_output_common(t_topology *top, gmx_ana_selvalue_t *out, void *data)
+init_output_common(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
{
t_methoddata_merge *d = (t_methoddata_merge *)data;
* \param[in,out] data Should point to \c t_methoddata_merge.
*/
static void
-init_output_merge(t_topology *top, gmx_ana_selvalue_t *out, void *data)
+init_output_merge(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
{
t_methoddata_merge *d = (t_methoddata_merge *)data;
int i, j;
* \param[in,out] data Should point to \c t_methoddata_merge.
*/
static void
-init_output_plus(t_topology *top, gmx_ana_selvalue_t *out, void *data)
+init_output_plus(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
{
t_methoddata_merge *d = (t_methoddata_merge *)data;
int i;
* \returns 0 if the input permutation is valid, -1 on error.
*/
static void
-init_permute(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+init_permute(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/*! \brief
* Initializes output for the \p permute selection modifier.
*
* \param[in,out] data Should point to \c t_methoddata_permute.
*/
static void
-init_output_permute(t_topology *top, gmx_ana_selvalue_t *out, void *data);
+init_output_permute(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data);
/** Frees the memory allocated for the \p permute selection modifier. */
static void
free_data_permute(void *data);
}
static void
-init_permute(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
+init_permute(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_permute *d = (t_methoddata_permute *)data;
int i;
}
static void
-init_output_permute(t_topology * /* top */, gmx_ana_selvalue_t *out, void *data)
+init_output_permute(const gmx_mtop_t * /* top */, gmx_ana_selvalue_t *out, void *data)
{
t_methoddata_permute *d = (t_methoddata_permute *)data;
int i, j, b;
* externally using _gmx_selelem_set_kwpos_type().
*/
static void
-init_kwpos(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+init_kwpos(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/*! \brief
* Initializes the \p cog selection method.
*
* \returns 0 on success, a non-zero error code on error.
*/
static void
-init_cog(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+init_cog(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/*! \brief
* Initializes the \p cog selection method.
*
* \returns 0 on success, a non-zero error code on error.
*/
static void
-init_com(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+init_com(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/*! \brief
* Initializes output for position evaluation selection methods.
*
* \returns 0 for success.
*/
static void
-init_output_pos(t_topology *top, gmx_ana_selvalue_t *out, void *data);
+init_output_pos(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data);
/** Frees the data allocated for position evaluation selection methods. */
static void
free_data_pos(void *data);
}
static void
-init_kwpos(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
+init_kwpos(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_pos *d = (t_methoddata_pos *)data;
}
static void
-init_cog(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
+init_cog(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_pos *d = (t_methoddata_pos *)data;
}
static void
-init_com(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
+init_com(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_pos *d = (t_methoddata_pos *)data;
}
static void
-init_output_pos(t_topology * /* top */, gmx_ana_selvalue_t *out, void *data)
+init_output_pos(const gmx_mtop_t * /* top */, gmx_ana_selvalue_t *out, void *data)
{
t_methoddata_pos *d = (t_methoddata_pos *)data;
* \returns 0 on success, -1 on failure.
*/
static void
-init_same(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+init_same(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/** Frees the data allocated for the \p same selection method. */
static void
free_data_same(void *data);
}
static void
-init_same(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
+init_same(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_same *d = (t_methoddata_same *)data;
#include <cctype>
#include "gromacs/selection/position.h"
+#include "gromacs/topology/mtop_lookup.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/exceptions.h"
+#include "gromacs/utility/gmxassert.h"
#include "selmethod.h"
* If molecule information is not found, also prints an error message.
*/
static void
-check_molecules(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+check_molecules(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/** Evaluates the \p molindex selection keyword. */
static void
evaluate_molindex(const gmx::SelMethodEvalContext &context,
* \param data Not used.
*/
static void
-check_atomtype(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+check_atomtype(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/** Evaluates the \p atomtype selection keyword. */
static void
evaluate_atomtype(const gmx::SelMethodEvalContext &context,
* \param data Not used.
*/
static void
-check_charge(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+check_charge(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/** Evaluates the \p charge selection keyword. */
static void
evaluate_charge(const gmx::SelMethodEvalContext &context,
* If PDB info is not found, also prints an error message.
*/
static void
-check_pdbinfo(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
+check_pdbinfo(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data);
/** Evaluates the \p altloc selection keyword. */
static void
evaluate_altloc(const gmx::SelMethodEvalContext &context,
evaluate_resnr(const gmx::SelMethodEvalContext &context,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void * /* data */)
{
- int i;
- int resind;
-
- out->nr = g->isize;
- for (i = 0; i < g->isize; ++i)
+ out->nr = g->isize;
+ int molb = 0;
+ for (int i = 0; i < g->isize; ++i)
{
- resind = context.top->atoms.atom[g->index[i]].resind;
- out->u.i[i] = context.top->atoms.resinfo[resind].nr;
+ mtopGetAtomAndResidueName(context.top, g->index[i], &molb,
+ nullptr, &out->u.i[i], nullptr, nullptr);
}
}
evaluate_resindex(const gmx::SelMethodEvalContext &context,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void * /* data */)
{
- int i;
-
- out->nr = g->isize;
- for (i = 0; i < g->isize; ++i)
+ out->nr = g->isize;
+ int molb = 0;
+ for (int i = 0; i < g->isize; ++i)
{
- out->u.i[i] = context.top->atoms.atom[g->index[i]].resind + 1;
+ int resind;
+ mtopGetAtomAndResidueName(context.top, g->index[i], &molb,
+ nullptr, nullptr, nullptr, &resind);
+ out->u.i[i] = resind + 1;
}
}
static void
-check_molecules(t_topology *top, int /* npar */, gmx_ana_selparam_t * /* param */, void * /* data */)
+check_molecules(const gmx_mtop_t *top, int /* npar */, gmx_ana_selparam_t * /* param */, void * /* data */)
{
bool bOk;
evaluate_atomname(const gmx::SelMethodEvalContext &context,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void * /* data */)
{
- int i;
-
out->nr = g->isize;
- for (i = 0; i < g->isize; ++i)
+ int molb = 0;
+ for (int i = 0; i < g->isize; ++i)
{
- out->u.s[i] = *context.top->atoms.atomname[g->index[i]];
+ const char *atom_name;
+ mtopGetAtomAndResidueName(context.top, g->index[i], &molb,
+ &atom_name, nullptr, nullptr, nullptr);
+ out->u.s[i] = const_cast<char *>(atom_name);
}
}
evaluate_pdbatomname(const gmx::SelMethodEvalContext &context,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void * /* data */)
{
- int i;
-
out->nr = g->isize;
- for (i = 0; i < g->isize; ++i)
+ int molb = 0;
+ for (int i = 0; i < g->isize; ++i)
{
- char *s = context.top->atoms.pdbinfo[g->index[i]].atomnm;
+ const char *s = mtopGetAtomPdbInfo(context.top, g->index[i], &molb).atomnm;
while (std::isspace(*s))
{
++s;
}
- out->u.s[i] = s;
+ out->u.s[i] = const_cast<char *>(s);
}
}
static void
-check_atomtype(t_topology *top, int /* npar */, gmx_ana_selparam_t * /* param */, void * /* data */)
+check_atomtype(const gmx_mtop_t *top, int /* npar */, gmx_ana_selparam_t * /* param */, void * /* data */)
{
- bool bOk;
-
- bOk = (top != NULL && (top->atoms.haveType));
- if (!bOk)
+ if (!gmx_mtop_has_atomtypes(top))
{
GMX_THROW(gmx::InconsistentInputError("Atom types not available in topology"));
}
evaluate_atomtype(const gmx::SelMethodEvalContext &context,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void * /* data */)
{
- int i;
-
out->nr = g->isize;
- for (i = 0; i < g->isize; ++i)
+ int molb = 0;
+ for (int i = 0; i < g->isize; ++i)
{
- out->u.s[i] = *context.top->atoms.atomtype[g->index[i]];
+ int atomIndexInMolecule;
+ mtopGetMolblockIndex(context.top, g->index[i], &molb,
+ nullptr, &atomIndexInMolecule);
+ const gmx_moltype_t &moltype = context.top->moltype[context.top->molblock[molb].type];
+ out->u.s[i] = *moltype.atoms.atomtype[atomIndexInMolecule];
}
}
evaluate_resname(const gmx::SelMethodEvalContext &context,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void * /* data */)
{
- int i;
- int resind;
-
out->nr = g->isize;
- for (i = 0; i < g->isize; ++i)
+ int molb = 0;
+ for (int i = 0; i < g->isize; ++i)
{
- resind = context.top->atoms.atom[g->index[i]].resind;
- out->u.s[i] = *context.top->atoms.resinfo[resind].name;
+ out->u.s[i] = *mtopGetResidueInfo(context.top, g->index[i], &molb).name;
}
}
evaluate_insertcode(const gmx::SelMethodEvalContext &context,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void * /* data */)
{
- int i;
- int resind;
-
out->nr = g->isize;
- for (i = 0; i < g->isize; ++i)
+ int molb = 0;
+ for (int i = 0; i < g->isize; ++i)
{
- resind = context.top->atoms.atom[g->index[i]].resind;
- out->u.s[i][0] = context.top->atoms.resinfo[resind].ic;
+ out->u.s[i][0] = mtopGetResidueInfo(context.top, g->index[i], &molb).ic;
}
}
evaluate_chain(const gmx::SelMethodEvalContext &context,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void * /* data */)
{
- int i;
- int resind;
-
out->nr = g->isize;
- for (i = 0; i < g->isize; ++i)
+ int molb = 0;
+ for (int i = 0; i < g->isize; ++i)
{
- resind = context.top->atoms.atom[g->index[i]].resind;
- out->u.s[i][0] = context.top->atoms.resinfo[resind].chainid;
+ out->u.s[i][0] = mtopGetResidueInfo(context.top, g->index[i], &molb).chainid;
}
}
evaluate_mass(const gmx::SelMethodEvalContext &context,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void * /* data */)
{
- GMX_RELEASE_ASSERT(context.top != nullptr && context.top->atoms.haveMass,
+ GMX_RELEASE_ASSERT(gmx_mtop_has_masses(context.top),
"Masses not available for evaluation");
out->nr = g->isize;
+ int molb = 0;
for (int i = 0; i < g->isize; ++i)
{
- out->u.r[i] = context.top->atoms.atom[g->index[i]].m;
+ out->u.r[i] = mtopGetAtomMass(context.top, g->index[i], &molb);
}
}
static void
-check_charge(t_topology *top, int /* npar */, gmx_ana_selparam_t * /* param */, void * /* data */)
+check_charge(const gmx_mtop_t *top, int /* npar */, gmx_ana_selparam_t * /* param */, void * /* data */)
{
- bool bOk;
-
- bOk = (top != NULL && top->atoms.haveCharge);
- if (!bOk)
+ if (!gmx_mtop_has_charges(top))
{
GMX_THROW(gmx::InconsistentInputError("Charges not available in topology"));
}
evaluate_charge(const gmx::SelMethodEvalContext &context,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void * /* data */)
{
- int i;
-
out->nr = g->isize;
- for (i = 0; i < g->isize; ++i)
+ int molb = 0;
+ for (int i = 0; i < g->isize; ++i)
{
- out->u.r[i] = context.top->atoms.atom[g->index[i]].q;
+ out->u.r[i] = mtopGetAtomParameters(context.top, g->index[i], &molb).q;
}
}
static void
-check_pdbinfo(t_topology *top, int /* npar */, gmx_ana_selparam_t * /* param */, void * /* data */)
+check_pdbinfo(const gmx_mtop_t *top, int /* npar */, gmx_ana_selparam_t * /* param */, void * /* data */)
{
- bool bOk;
-
- bOk = (top != NULL && top->atoms.havePdbInfo);
- if (!bOk)
+ if (!gmx_mtop_has_pdbinfo(top))
{
GMX_THROW(gmx::InconsistentInputError("PDB info not available in topology"));
}
evaluate_altloc(const gmx::SelMethodEvalContext &context,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void * /* data */)
{
- int i;
-
out->nr = g->isize;
- for (i = 0; i < g->isize; ++i)
+ int molb = 0;
+ for (int i = 0; i < g->isize; ++i)
{
- out->u.s[i][0] = context.top->atoms.pdbinfo[g->index[i]].altloc;
+ out->u.s[i][0] = mtopGetAtomPdbInfo(context.top, g->index[i], &molb).altloc;
}
}
evaluate_occupancy(const gmx::SelMethodEvalContext &context,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void * /* data */)
{
- int i;
-
out->nr = g->isize;
- for (i = 0; i < g->isize; ++i)
+ int molb = 0;
+ for (int i = 0; i < g->isize; ++i)
{
- out->u.r[i] = context.top->atoms.pdbinfo[g->index[i]].occup;
+ out->u.r[i] = mtopGetAtomPdbInfo(context.top, g->index[i], &molb).occup;
}
}
evaluate_betafactor(const gmx::SelMethodEvalContext &context,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void * /* data */)
{
- int i;
-
out->nr = g->isize;
- for (i = 0; i < g->isize; ++i)
+ int molb = 0;
+ for (int i = 0; i < g->isize; ++i)
{
- out->u.r[i] = context.top->atoms.pdbinfo[g->index[i]].bfac;
+ out->u.r[i] = mtopGetAtomPdbInfo(context.top, g->index[i], &molb).bfac;
}
}
return mtop->nmoltype == 0 || mtop->moltype[0].atoms.haveCharge;
}
+bool gmx_mtop_has_atomtypes(const gmx_mtop_t *mtop)
+{
+ if (mtop == nullptr)
+ {
+ return false;
+ }
+ return mtop->nmoltype == 0 || mtop->moltype[0].atoms.haveType;
+}
+
+bool gmx_mtop_has_pdbinfo(const gmx_mtop_t *mtop)
+{
+ if (mtop == nullptr)
+ {
+ return false;
+ }
+ return mtop->nmoltype == 0 || mtop->moltype[0].atoms.havePdbInfo;
+}
+
static void pr_grps(FILE *fp, const char *title, const t_grps grps[], char **grpname[])
{
int i, j;
bool gmx_mtop_has_masses(const gmx_mtop_t *mtop);
bool gmx_mtop_has_charges(const gmx_mtop_t *mtop);
+bool gmx_mtop_has_atomtypes(const gmx_mtop_t *mtop);
+bool gmx_mtop_has_pdbinfo(const gmx_mtop_t *mtop);
void pr_mtop(FILE *fp, int indent, const char *title, const gmx_mtop_t *mtop,
gmx_bool bShowNumbers);