LCOV - code coverage report
Current view: top level - clusters - OutputCluster.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 20 20 100.0 %
Date: 2025-04-08 21:11:17 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2015-2023 The plumed team
       3             :    (see the PEOPLE file at the root of the distribution for a list of names)
       4             : 
       5             :    See http://www.plumed.org for more information.
       6             : 
       7             :    This file is part of plumed, version 2.
       8             : 
       9             :    plumed is free software: you can redistribute it and/or modify
      10             :    it under the terms of the GNU Lesser General Public License as published by
      11             :    the Free Software Foundation, either version 3 of the License, or
      12             :    (at your option) any later version.
      13             : 
      14             :    plumed 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
      17             :    GNU Lesser General Public License for more details.
      18             : 
      19             :    You should have received a copy of the GNU Lesser General Public License
      20             :    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
      21             : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
      22             : #include "core/ActionShortcut.h"
      23             : #include "core/ActionRegister.h"
      24             : 
      25             : //+PLUMEDOC CONCOMP OUTPUT_CLUSTER
      26             : /*
      27             : Output the indices of the atoms in one of the clusters identified by a clustering object
      28             : 
      29             : This action provides one way of getting output from a [DFSCLUSTERING](DFSCLUSTERING.md) calculation.
      30             : The output in question here is a [gromacs ndx file](https://manual.gromacs.org/archive/5.0.6/online/ndx.html)
      31             : that contains a list of the atom indices
      32             : that form part of one of the clusters that was identified using DFSCLUSTERING
      33             : 
      34             : The input shown below constructs a [CONTACT_MATRIX](CONTACT_MATRIX.md) that describes the connectivity between the atoms.
      35             : The DFS algorithm is then used to find the connected components
      36             : in this matrix.  The indices of the atoms in the largest connected component are then output
      37             : to a ndx file.
      38             : 
      39             : ```plumed
      40             : mat: CONTACT_MATRIX ATOMS=1-1996 SWITCH={CUBIC D_0=0.34 D_MAX=0.38}
      41             : dfs: DFSCLUSTERING ARG=mat
      42             : OUTPUT_CLUSTER ATOMS=1-1996 CLUSTERS=dfs CLUSTER=1 FILE=dfs.ndx
      43             : ```
      44             : 
      45             : */
      46             : //+ENDPLUMEDOC
      47             : 
      48             : namespace PLMD {
      49             : namespace clusters {
      50             : 
      51             : class OutputCluster : public ActionShortcut {
      52             : public:
      53             :   static void registerKeywords( Keywords& keys );
      54             :   explicit OutputCluster(const ActionOptions&);
      55             : };
      56             : 
      57             : PLUMED_REGISTER_ACTION(OutputCluster,"OUTPUT_CLUSTER")
      58             : 
      59           4 : void OutputCluster::registerKeywords( Keywords& keys ) {
      60           4 :   ActionShortcut::registerKeywords( keys );
      61           4 :   keys.add("compulsory","ATOMS","the atoms for which clustering were performed");
      62           4 :   keys.add("compulsory","CLUSTERS","the action that performed the clustering");
      63           4 :   keys.add("compulsory","CLUSTER","1","which cluster would you like to look at 1 is the largest cluster, 2 is the second largest, 3 is the the third largest and so on");
      64           4 :   keys.add("compulsory","STRIDE","1","the frequency with which you would like to output the atoms in the cluster");
      65           4 :   keys.add("compulsory","FILE","the name of the file on which to output the details of the cluster");
      66           4 :   keys.remove("HAS_VALUES");
      67           4 :   keys.needsAction("PRINT_NDX");
      68           4 :   keys.addDOI("https://doi.org/10.1021/acs.jctc.6b01073");
      69           4 : }
      70             : 
      71           2 : OutputCluster::OutputCluster(const ActionOptions& ao):
      72             :   Action(ao),
      73           2 :   ActionShortcut(ao) {
      74             :   std::string id;
      75           4 :   parse("CLUSTER",id);
      76             :   std::string stride;
      77           4 :   parse("STRIDE",stride);
      78             :   std::string clusters;
      79           4 :   parse("CLUSTERS",clusters);
      80             :   std::string filename;
      81           4 :   parse("FILE",filename);
      82             :   std::string atoms;
      83           2 :   parse("ATOMS",atoms);
      84           4 :   readInputLine("PRINT_NDX ATOMS=" + atoms + " ARG=" + clusters + " FILE=" + filename + " STRIDE=" + stride + " LESS_THAN_OR_EQUAL=" + id + " GREATER_THAN_OR_EQUAL=" + id );
      85           2 : }
      86             : 
      87             : }
      88             : }
      89             : 
      90             : 

Generated by: LCOV version 1.16