* \author Teemu Murtola <teemu.murtola@gmail.com>
* \ingroup module_selection
*/
+#include "gmxpre.h"
+
#include "selectioncollection.h"
#include <cctype>
#include <boost/shared_ptr.hpp>
+#include "gromacs/fileio/trx.h"
#include "gromacs/legacyheaders/oenv.h"
-
#include "gromacs/onlinehelp/helpmanager.h"
#include "gromacs/onlinehelp/helpwritercontext.h"
#include "gromacs/options/basicoptions.h"
#include "gromacs/options/options.h"
#include "gromacs/selection/selection.h"
+#include "gromacs/selection/selhelp.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/file.h"
#include "parser.h"
#include "poscalc.h"
#include "scanner.h"
-#include "selection.h"
#include "selectioncollection-impl.h"
#include "selelem.h"
-#include "selhelp.h"
#include "selmethod.h"
#include "symrec.h"
*/
SelectionCollection::Impl::Impl()
- : debugLevel_(0), bExternalGroupsSet_(false), grps_(NULL)
+ : maxAtomIndex_(0), debugLevel_(0), bExternalGroupsSet_(false), grps_(NULL)
{
sc_.nvars = 0;
sc_.varstrs = NULL;
const internal::SelectionData &sel = **iter;
if (sel.hasFlag(efSelection_OnlyAtoms))
{
- if (sel.type() != INDEX_ATOM)
+ if (!sel.hasOnlyAtoms())
{
std::string message = formatString(
"Selection '%s' does not evaluate to individual atoms. "
void
SelectionCollection::evaluate(t_trxframe *fr, t_pbc *pbc)
{
+ if (fr->natoms <= impl_->maxAtomIndex_)
+ {
+ std::string message = formatString(
+ "Trajectory has less atoms (%d) than what is required for "
+ "evaluating the provided selections (atoms up to index %d "
+ "are required).", fr->natoms, impl_->maxAtomIndex_ + 1);
+ GMX_THROW(InconsistentInputError(message));
+ }
impl_->sc_.pcc.initFrame();
SelectionEvaluator evaluator;