plumed / plumed2

Development version of plumed 2
https://www.plumed.org
GNU Lesser General Public License v3.0
323 stars 269 forks source link

Implemented NDX selector #1052

Closed GiovanniBussi closed 2 months ago

GiovanniBussi commented 3 months ago
Description

Currently we can do selections with MDAnalysis and mdtraj using something like:

DUMPATOMS ATOMS={@mda:{resid 3:5} @mda:{resnum 1}} FILE=test2.gro
DUMPATOMS ATOMS={@mdt:{protein and (backbone or resname ALA)}} FILE=test3.gro

We can also use GROMACS ndx file, but with a different syntax:

ndx1: GROUP NDX_FILE=test.ndx
ndx2: GROUP NDX_FILE=test.ndx NDX_GROUP=second
DUMPATOMS ATOMS=ndx1 FILE=nn1.xyz PRECISION=2
DUMPATOMS ATOMS=ndx2 FILE=nn2.xyz PRECISION=2

This is forcing to create new groups for each selection. In this pull request I add the possibility to directly use a selector in ATOMS= options. Basically, something identical to the previous input can be done with only two lines:

DUMPATOMS ATOMS=@ndx:test.ndx PRECISION=2
DUMPATOMS ATOMS={@ndx:{test.ndx second}} PRECISION=2

I think this is convenient because it is more compact, and also easy to remember since it is equivalent to @mda and @mdt selectors. Notice that, at variance with @mda and @mdt selectors, the new @ndx selector does not require python and other packages to be installed, since we are directly reading the index file in PLUMED.

The old syntax (with GROUP NDX_FILE) is still possible. To avoid duplicated code, the old syntax basically uses the new @ndx selector to pick atoms.

Target release

I would like my code to appear in release 2.10

codecov-commenter commented 3 months ago

Codecov Report

Attention: Patch coverage is 96.29630% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 83.32%. Comparing base (fea1660) to head (a06d8fc).

:exclamation: Current head a06d8fc differs from pull request most recent head c1f9290. Consider uploading reports for the commit c1f9290 to get more accurate results

Files Patch % Lines
src/core/ActionAtomistic.cpp 95.00% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1052 +/- ## ========================================== + Coverage 83.30% 83.32% +0.02% ========================================== Files 628 628 Lines 59990 60003 +13 ========================================== + Hits 49972 49999 +27 + Misses 10018 10004 -14 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.