Check frame atom count before evaluating selections
authorTeemu Murtola <teemu.murtola@gmail.com>
Sun, 3 Aug 2014 04:16:54 +0000 (07:16 +0300)
committerTeemu Murtola <teemu.murtola@gmail.com>
Sun, 3 Aug 2014 07:01:19 +0000 (10:01 +0300)
commit214499dc4df201d09f11fd565d24eefd06f5649f
tree611cd6fde4a5f2fcb4484174ffdb86504d3ed220
parent0ec11cc5b26f454d74369235fe9b381d2a61bc84
Check frame atom count before evaluating selections

Several tools work even if passed a trajectory that only contains a
subset of the atoms specified in the topology.  The selections work as
well, provided that the selections don't need to access other atoms.
It may be a bit unclear what the selections need for evaluation, though.
Now the selections report an error if the trajectory does not contain
the necessary atoms; previously, it would most likely just crash.
I'm not 100% sure that the check catches all possible cases, but at
least for the majority of the cases it will provide significantly better
feedback.

Currently, it is only possible to pass the first N atoms, as supporting
anything else would require significant changes elsewhere as well, but
the check itself would be straightforward to adapt if the implementation
gets otherwise done (just replace the std::max operations with unions).

Change-Id: I5d9bf68567ba8634bb81b82a6833c0d398a40bdb
src/gromacs/selection/compiler.cpp
src/gromacs/selection/indexutil.cpp
src/gromacs/selection/indexutil.h
src/gromacs/selection/poscalc.cpp
src/gromacs/selection/poscalc.h
src/gromacs/selection/selectioncollection-impl.h
src/gromacs/selection/selectioncollection.cpp
src/gromacs/selection/selmethod.h
src/gromacs/selection/tests/selectioncollection.cpp