From ebce523a70f635e9ed8f2bc18a56821d1f61ca29 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 16 Mar 2022 16:05:08 -0400 Subject: [PATCH] Add the 'keep' action. Opposite of 'strip'; can also be used to only keep bridging waters from 'hbond' (#957) * Start adding Keep action * Start parsing bridge ID set * Start testing keep * Add modified topology and frame * Start modifying top and frame * Add topwriter * Indices in bridge res ID data start from 1 * Start keep tests * Add test for bridge with keepmask * Allow keepmask to work on its own * Make nobox option a part of ActionTopWriter * Add basic test for keep, use strip test save * Add nobox to other ActionTopWriter actions * Add residue status array. Check that bridging residue specified by data set was also specified as a bridge residue for command. * Start adding bridgeresonly; allow fine tuning of what atoms to keep when keeping bridging waters * Ensure that only the requested number of bridges are retained (fewer or more will invalidate the topology) * Add test keeping only 1 bridging water * Actually set the status * Add keep two bridging waters at specified residues test * Reorganize vars to keep everything set in Init in one place * Fix up help * Test reading in hb bridge data * Add 'keep' entry. Fix actions table to indicate when actions modify state (like strip). * Hide some debug info. Improve warnings * Add nobridgewarn option * Add nobridgewarn to manual * Enable keep test and protect in parallel. Add warning when run in parallel with bridgedata * 6.4.3. Revision bump for addition of keep action. * Add code docs --- doc/cpptraj.lyx | 336 +++++++++++++++++++++++++- src/ActionTopWriter.cpp | 51 +++- src/ActionTopWriter.h | 12 + src/Action_Closest.cpp | 3 + src/Action_FixAtomOrder.cpp | 5 +- src/Action_Keep.cpp | 339 ++++++++++++++++++++++++++ src/Action_Keep.h | 49 ++++ src/Action_Remap.cpp | 3 + src/Action_ReplicateCell.cpp | 1 + src/Action_Strip.cpp | 19 +- src/Action_Strip.h | 2 - src/AtomMask.cpp | 13 + src/AtomMask.h | 2 + src/Command.cpp | 2 + src/Version.h | 2 +- src/cpptrajdepend | 5 +- src/cpptrajfiles | 1 + test/Makefile | 6 +- test/Test_Keep/RunTest.sh | 111 +++++++++ test/Test_Keep/keep.10.11.crd.save | 71 ++++++ test/Test_Keep/keep.crd.save | 341 +++++++++++++++++++++++++++ test/Test_Keep/keep.onlyone.crd.save | 205 ++++++++++++++++ test/Test_Keep/keep.two.crd.save | 208 ++++++++++++++++ 23 files changed, 1747 insertions(+), 40 deletions(-) create mode 100644 src/Action_Keep.cpp create mode 100644 src/Action_Keep.h create mode 100755 test/Test_Keep/RunTest.sh create mode 100644 test/Test_Keep/keep.10.11.crd.save create mode 100644 test/Test_Keep/keep.crd.save create mode 100644 test/Test_Keep/keep.onlyone.crd.save create mode 100644 test/Test_Keep/keep.two.crd.save diff --git a/doc/cpptraj.lyx b/doc/cpptraj.lyx index 77fa1a3eea..fc3babaf77 100644 --- a/doc/cpptraj.lyx +++ b/doc/cpptraj.lyx @@ -17961,7 +17961,7 @@ Mod \begin_layout Standard \align center \begin_inset Tabular - + @@ -19102,6 +19102,35 @@ Calculate J-coupling values from specified dihedral angles. \begin_inset Text +\begin_layout Plain Layout +keep +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Keep specified atoms in system. +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +X +\end_layout + +\end_inset + + + + +\begin_inset Text + \begin_layout Plain Layout lessplit \end_layout @@ -20141,7 +20170,7 @@ Remove specified atoms from the system. \begin_inset Text \begin_layout Plain Layout - +X \end_layout \end_inset @@ -22433,7 +22462,7 @@ closest \end_layout \begin_layout LyX-Code - [outprefix ] [parmout ] + [outprefix ] [nobox] [parmout ] \end_layout \begin_layout LyX-Code @@ -22536,6 +22565,10 @@ oxygen] Calculate distances between all atoms in . \end_layout +\begin_layout Description +[nobox] Remove any box information from the topology. +\end_layout + \begin_layout Description [parmout \begin_inset space ~ @@ -25394,7 +25427,7 @@ fixatomorder \end_layout \begin_layout LyX-Code -fixatomorder [outprefix ] [parmout ] +fixatomorder [outprefix ] [nobox] [parmout ] \end_layout \begin_layout LyX-Code @@ -25414,6 +25447,10 @@ outprefix Write re-ordered topology to . \end_layout +\begin_layout Description +[nobox] Remove any box information from the re-ordered topology. +\end_layout + \begin_layout Description parmout \begin_inset space ~ @@ -28464,6 +28501,23 @@ The number of hydrogen bonds present at each frame will be determined and out \series default . + If desired, the bridge [ID] data can be used in conjunction with the +\series bold +\emph on +keep +\series default +\emph default + command to generate structures that only contain bridging solvent ( +\begin_inset CommandInset ref +LatexCommand vref +reference "subsec:cpptraj-keep" +plural "false" +caps "false" +noprefix "false" + +\end_inset + +). If the \series bold series @@ -29106,6 +29160,256 @@ cpptraj format, only the J-coupling value is written. \end_layout +\begin_layout Subsection +keep +\begin_inset CommandInset label +LatexCommand label +name "subsec:cpptraj-keep" + +\end_inset + + +\end_layout + +\begin_layout LyX-Code +keep [ bridgedata [nbridge <#>] [nobridgewarn] +\end_layout + +\begin_layout LyX-Code + [bridgeresname ] bridgeresonly ] ] +\end_layout + +\begin_layout LyX-Code + [keepmask ] +\end_layout + +\begin_layout LyX-Code + [outprefix ] [nobox] [parmout ] +\end_layout + +\begin_layout LyX-Code + [parmopts ] +\end_layout + +\begin_deeper +\begin_layout Description +bridgedata +\begin_inset space ~ +\end_inset + + Data set containing bridge ID strings from the +\series bold +\emph on +hbond +\series default +\emph default + command ( +\begin_inset CommandInset ref +LatexCommand vref +reference "subsec:cpptraj-hbond" +plural "false" +caps "false" +noprefix "false" + +\end_inset + +). +\end_layout + +\begin_deeper +\begin_layout Description +nbridge +\begin_inset space ~ +\end_inset + +<#> Number of bridging residues to keep (default 1). +\end_layout + +\begin_layout Description +nobridgewarn If specified, suppress warnings for when active # bridges does + not equal requested number. +\end_layout + +\begin_layout Description +bridgeresname +\begin_inset space ~ +\end_inset + + Name of bridging residues (default 'WAT'). +\end_layout + +\begin_layout Description +bridgeresonly +\begin_inset space ~ +\end_inset + + If specified, only keep bridges that bridge residues in the + list. +\end_layout + +\end_deeper +\begin_layout Description +keepmask +\begin_inset space ~ +\end_inset + + Mask of atoms to keep. +\end_layout + +\begin_layout Description +outprefix +\begin_inset space ~ +\end_inset + + Write modified topology to . +\end_layout + +\begin_layout Description +[nobox] Remove any box information from the modified topology. +\end_layout + +\begin_layout Description +parmout +\begin_inset space ~ +\end_inset + + Write modified topology to . +\end_layout + +\begin_layout Description +parmopts +\begin_inset space ~ +\end_inset + + Options for writing topology file. +\end_layout + +\end_deeper +\begin_layout Standard +Keep only specified atoms (opposite of +\series bold +\emph on +strip +\series default +\emph default +). + This can also be used in conjunction with output from the +\series bold +\emph on +hbond +\series default +\emph default + command to retain solute and only bridging residues (e.g. + bridging waters). + For example, the following run generates bridging data with the +\series bold +\emph on +'hbond' +\series default +\emph default + command in a first pass, then uses the bridge ID data to retain only 1 + single bridging water between residues 10 and 11: +\end_layout + +\begin_layout LyX-Code +parm tz2.ortho.parm7 +\end_layout + +\begin_layout LyX-Code +trajin tz2.ortho.nc +\end_layout + +\begin_layout LyX-Code +# First pass, generate bridge time series +\end_layout + +\begin_layout LyX-Code +hbond hb solventacceptor :WAT@O solventdonor :WAT out hb.dat +\end_layout + +\begin_layout LyX-Code +run +\end_layout + +\begin_layout LyX-Code +# Second pass, retain only frames where the bridge is present +\end_layout + +\begin_layout LyX-Code +# for residues 10 and 11. +\end_layout + +\begin_layout LyX-Code +keep bridgedata hb[ID] nbridge 1 bridgeresonly 10,11 parmout keep.parm7 +\end_layout + +\begin_layout LyX-Code +# Write trajectory +\end_layout + +\begin_layout LyX-Code +trajout keep.nc +\end_layout + +\begin_layout LyX-Code +run +\end_layout + +\begin_layout Standard +This run reads in bridge ID data from a previous hbond run and uses it to + keep only residues 10, 11, and a bridging water: +\end_layout + +\begin_layout LyX-Code +parm tz2.ortho.parm7 +\end_layout + +\begin_layout LyX-Code +trajin tz2.ortho.nc +\end_layout + +\begin_layout LyX-Code +readdata hb.dat +\end_layout + +\begin_layout LyX-Code +keep keepmask :10,11 bridgedata hb.dat:5 nbridge 1 bridgesonly 10,11 +\backslash + +\end_layout + +\begin_layout LyX-Code + parmout keep.10.11.parm7 +\end_layout + +\begin_layout LyX-Code +trajout keep.10.11.nc +\end_layout + +\begin_layout LyX-Code +run +\end_layout + \begin_layout Subsection lessplit \end_layout @@ -34557,7 +34861,7 @@ remap data \end_layout \begin_layout LyX-Code - [outprefix ] [parmout ] + [outprefix ] [nobox] [parmout ] \end_layout \begin_layout LyX-Code @@ -34582,6 +34886,10 @@ outprefix Write remapped topology to . \end_layout +\begin_layout Description +[nobox] Remove any box information from the remapped topology. +\end_layout + \begin_layout Description parmout \begin_inset space ~ @@ -34627,7 +34935,7 @@ replicatecell [out ] [name ] \end_layout \begin_layout LyX-Code - [outprefix ] [parmout ] + [outprefix ] [nobox] [parmout ] \end_layout \begin_layout LyX-Code @@ -34686,6 +34994,10 @@ outprefix Write replicated topology to . \end_layout +\begin_layout Description +[nobox] Remove any box information from the replicated topology. +\end_layout + \begin_layout Description parmout \begin_inset space ~ @@ -36883,11 +37195,11 @@ strip \end_inset - [nobox] + \end_layout \begin_layout LyX-Code - [outprefix ] [parmout ] + [outprefix ] [nobox] [parmout ] \end_layout \begin_layout LyX-Code @@ -36903,10 +37215,6 @@ strip Remove atoms specified by mask from the system. \end_layout -\begin_layout Description -[nobox] Remove any box information from the stripped topology. -\end_layout - \begin_layout Description [outprefix \begin_inset space ~ @@ -36916,6 +37224,10 @@ strip Topology Name>'. \end_layout +\begin_layout Description +[nobox] Remove any box information from the stripped topology. +\end_layout + \begin_layout Description [parmout \begin_inset space ~ diff --git a/src/ActionTopWriter.cpp b/src/ActionTopWriter.cpp index 1e14a962d4..fce3ec557a 100644 --- a/src/ActionTopWriter.cpp +++ b/src/ActionTopWriter.cpp @@ -1,27 +1,39 @@ #include "ActionTopWriter.h" +#include "ActionState.h" #include "ArgList.h" +#include "CoordinateInfo.h" #include "CpptrajStdio.h" #include "Topology.h" #include "ParmFile.h" -static const char* keywords_ = "\t[outprefix ] [parmout ]\n" - "\t[parmopts ]\n"; -static const char* options_ = - " outprefix : Write modified topology to .\n" - " parmout : Write modified topology to \n" - " parmopts : Options for writing topology file\n"; +const char* ActionTopWriter::keywords_ = + "\t[outprefix ] [nobox] [parmout ]\n" + "\t[parmopts ]\n"; +const char* ActionTopWriter::options_ = + " outprefix : Write modified topology to .\n" + " nobox : If specified, remove box information from topology\n" + " parmout : Write modified topology to \n" + " parmopts : Options for writing topology file\n"; const char* ActionTopWriter::Keywords() { return keywords_; } const char* ActionTopWriter::Options() { return options_; } /** CONSTRUCTOR */ ActionTopWriter::ActionTopWriter() : - debug_(0) + debug_(0), + removeBoxInfo_(false), + newCinfo_(0) {} +/** DESTRUCTOR */ +ActionTopWriter::~ActionTopWriter() { + if (newCinfo_ != 0) delete newCinfo_; +} + /** Parse arguments. */ int ActionTopWriter::InitTopWriter(ArgList& argIn, const char* typeStrIn, int debugIn) { debug_ = debugIn; + removeBoxInfo_ = argIn.hasKey("nobox"); prefix_ = argIn.GetStringKey("outprefix"); parmoutName_ = argIn.GetStringKey("parmout"); parmOpts_ = argIn.GetStringKey("parmopts"); @@ -35,6 +47,8 @@ int ActionTopWriter::InitTopWriter(ArgList& argIn, const char* typeStrIn, int de /** Print arguments to stdout. */ void ActionTopWriter::PrintOptions() const { + if (removeBoxInfo_) + mprintf("\tAny existing box information will be removed.\n"); if (!prefix_.empty()) mprintf("\tWriting '%s' topology file with prefix '%s'\n", typeStr_.c_str(), prefix_.c_str()); if (!parmoutName_.empty()) @@ -72,3 +86,26 @@ int ActionTopWriter::WriteTops(Topology const& topIn) const { } return err; } + +/** Modify given ActionSetup. */ +int ActionTopWriter::ModifyActionState(ActionSetup& setup, Topology* topIn) +{ + // Remove box information if asked + if (removeBoxInfo_) { + topIn->SetParmBox( Box() ); + newCinfo_ = new CoordinateInfo( setup.CoordInfo() ); + newCinfo_->SetBox( Box() ); + setup.SetCoordInfo( newCinfo_ ); + } + return 0; +} + +/** Modify given Topology only. */ +int ActionTopWriter::ModifyTop(Topology* topIn) +{ + // Remove box information if asked + if (removeBoxInfo_) { + topIn->SetParmBox( Box() ); + } + return 0; +} diff --git a/src/ActionTopWriter.h b/src/ActionTopWriter.h index 3eedd309fc..390ce9bb74 100644 --- a/src/ActionTopWriter.h +++ b/src/ActionTopWriter.h @@ -2,12 +2,15 @@ #define INC_ACTIONTOPWRITER_H #include // Forward declares +class ActionSetup; class ArgList; +class CoordinateInfo; class Topology; /// Class to hold common functionality for actions that will write modified topologies. class ActionTopWriter { public: ActionTopWriter(); + ~ActionTopWriter(); static const char* Keywords(); static const char* Options(); @@ -18,11 +21,20 @@ class ActionTopWriter { void PrintOptions() const; /// Write the Topology to file(s) int WriteTops(Topology const&) const; + /// Remove box information from Topology/CoordinateInfo + int ModifyActionState(ActionSetup&, Topology*); + /// Remove box information from Topology + int ModifyTop(Topology*); private: std::string prefix_; ///< Prefix for writing topology as . std::string parmoutName_; ///< Output topology file name std::string parmOpts_; ///< Topology file write args std::string typeStr_; ///< Label for kind of topology being written. int debug_; ///< Debug level to pass to Topology file writer. + bool removeBoxInfo_; ///< If true, remove box information from Topology/CoordinateInfo + CoordinateInfo* newCinfo_; ///< Hold any modified CoordinateInfo + + static const char* keywords_; + static const char* options_; }; #endif diff --git a/src/Action_Closest.cpp b/src/Action_Closest.cpp index a822a599b8..fa2bc2c9fb 100644 --- a/src/Action_Closest.cpp +++ b/src/Action_Closest.cpp @@ -295,6 +295,9 @@ Action::RetType Action_Closest::Setup(ActionSetup& setup) { return Action::ERR; } setup.SetTopology( newParm_ ); + // Remove box information if asked + if (topWriter_.ModifyActionState(setup, newParm_)) + return Action::ERR; newParm_->Brief("Closest topology:"); // Allocate space for new frame newFrame_.SetupFrameV( setup.Top().Atoms(), setup.CoordInfo() ); diff --git a/src/Action_FixAtomOrder.cpp b/src/Action_FixAtomOrder.cpp index b6a1a3f11f..c48be97faa 100644 --- a/src/Action_FixAtomOrder.cpp +++ b/src/Action_FixAtomOrder.cpp @@ -83,8 +83,11 @@ Action::RetType Action_FixAtomOrder::Setup(ActionSetup& setup) { mprinterr("Error: Could not create re-ordered topology.\n"); return Action::ERR; } - newParm_->Brief("Re-ordered parm:"); setup.SetTopology( newParm_ ); + // Remove box information if asked + if (topWriter_.ModifyActionState(setup, newParm_)) + return Action::ERR; + newParm_->Brief("Re-ordered parm:"); // Allocate space for new frame newFrame_.SetupFrameV( setup.Top().Atoms(), setup.CoordInfo() ); diff --git a/src/Action_Keep.cpp b/src/Action_Keep.cpp new file mode 100644 index 0000000000..f73fe62ae5 --- /dev/null +++ b/src/Action_Keep.cpp @@ -0,0 +1,339 @@ +#include "Action_Keep.h" +#include "CharMask.h" +#include "CpptrajStdio.h" +#include "DataSet_string.h" +#include "Range.h" + +/** CONSTRUCTOR */ +Action_Keep::Action_Keep() : + debug_(0), + currentParm_(0), + keepParm_(0), + bridgeData_(0), + nbridge_(0), + bridgeWarn_(true), + nNonBridgeAtoms_(-1) +{} + +/** DESTRUCTOR */ +Action_Keep::~Action_Keep() { + if (keepParm_ != 0) delete keepParm_; +} + +// Residue status characters +const char Action_Keep::STAT_NONE_ = 'X'; +const char Action_Keep::STAT_BRIDGERES_ = 'B'; +const char Action_Keep::STAT_NONBRIDGERES_ = 'U'; + +// Action_Keep::Help() +void Action_Keep::Help() const { + mprintf("\t[ bridgedata [nbridge <#>] [nobridgewarn]\n" + "\t [bridgeresname ] bridgeresonly ] ]\n" + "\t[keepmask ]\n"); + mprintf("%s", ActionTopWriter::Keywords()); + mprintf(" Keep only specified parts of the system.\n"); + mprintf("%s", ActionTopWriter::Options()); +} + +// Action_Keep::Init() +Action::RetType Action_Keep::Init(ArgList& actionArgs, ActionInit& init, int debugIn) +{ + debug_ = debugIn; + std::string keepmaskstr = actionArgs.GetStringKey("keepmask"); + if (!keepmaskstr.empty()) { + if ( keepMask_.SetMaskString( keepmaskstr )) { + mprinterr("Error: Invalid mask for 'keepmask'\n"); + return Action::ERR; + } + } + + std::string bridgeDataName = actionArgs.GetStringKey("bridgedata"); + if (!bridgeDataName.empty()) { + DataSet* ds = init.DSL().GetDataSet( bridgeDataName ); + if (ds == 0) { + mprinterr("Error: No data set corresponding to '%s'\n", bridgeDataName.c_str()); + return Action::ERR; + } + if (ds->Type() != DataSet::STRING) { + mprinterr("Error: Bridge data set '%s' is not a string data set.\n", ds->legend()); + return Action::ERR; + } + bridgeData_ = static_cast( ds ); + nbridge_ = actionArgs.getKeyInt("nbridge", 1); + if (nbridge_ < 1) { + mprinterr("Error: Number of bridging residues to keep must be >= 1.\n"); + return Action::ERR; + } + bridgeResName_ = actionArgs.GetStringKey("bridgeresname", "WAT"); + std::string bridgeresonlystr = actionArgs.GetStringKey("bridgeresonly"); + if (!bridgeresonlystr.empty()) { + Range brange; + if (brange.SetRange( bridgeresonlystr )) { + mprinterr("Error: Invalid range given for 'bridgeresonly': %s\n", bridgeresonlystr.c_str()); + return Action::ERR; + } + // User residue numbers start from 1 + bridgeResOnly_.clear(); + for (Range::const_iterator it = brange.begin(); it != brange.end(); ++it) + bridgeResOnly_.push_back( *it - 1 ); + } + bridgeWarn_ = !actionArgs.hasKey("nobridgewarn"); + } else if (!keepMask_.MaskStringSet()) { + mprinterr("Error: Nothing specified to keep.\n"); + return Action::ERR; + } + + topWriter_.InitTopWriter(actionArgs, "keep", debugIn); + + mprintf(" KEEP:\n"); + if (keepMask_.MaskStringSet()) { + mprintf("\tKeeping atoms selected by '%s'\n", keepMask_.MaskString()); + } + if (bridgeData_ != 0) { + mprintf("\tKeeping bridging residues from bridge ID data set: %s\n", bridgeData_->legend()); + mprintf("\t# of bridging residues to keep: %i\n", nbridge_); + mprintf("\tBridge residue name: %s\n", bridgeResName_.c_str()); + if (!bridgeResOnly_.empty()) { + mprintf("\tOnly keeping bridge residues when bridging residues:"); + for (Iarray::const_iterator it = bridgeResOnly_.begin(); it != bridgeResOnly_.end(); ++it) + mprintf(" %i", *it + 1); + mprintf("\n"); + } + if (bridgeWarn_) + mprintf("\tWill warn when # active bridges does not match requested.\n"); + else + mprintf("\tHiding warnings for when # active bridges does not match requested.\n"); +# ifdef MPI + if (init.TrajComm().Size() > 1) + mprintf("Warning: Skipping frames with incorrect # of bridges in parallel\n" + "Warning: can cause certain actions (e.g. 'rms') to hang.\n" + "Warning: In addition, trajectories written after skipping frames may have issues.\n"); +# endif + } + topWriter_.PrintOptions(); + return Action::OK; +} + +// Action_Keep::Setup() +Action::RetType Action_Keep::Setup(ActionSetup& setup) +{ + currentParm_ = setup.TopAddress(); + + atomsToKeep_.ClearSelected(); + atomsToKeep_.SetNatoms( setup.Top().Natom() ); + + resStat_.assign( setup.Top().Nres(), STAT_NONE_ ); + + if (keepMask_.MaskStringSet()) { + if (setup.Top().SetupIntegerMask( keepMask_ )) { + mprinterr("Error: Could not set up keep mask '%s'\n", keepMask_.MaskString()); + return Action::ERR; + } + if (keepMask_.None()) { + mprintf("Warning: No atoms selected for keep mask.\n"); + return Action::SKIP; + } + keepMask_.MaskInfo(); + for (AtomMask::const_iterator it = keepMask_.begin(); it != keepMask_.end(); ++it) + atomsToKeep_.AddSelectedAtom(*it); + } + + if (bridgeData_ != 0) { + // Set up to keep bridge residues + AtomMask bmask; + if (bmask.SetMaskString( ":" + bridgeResName_ )) { + mprinterr("Error: Could not set up mask for bridge residues: %s\n", bridgeResName_.c_str()); + return Action::ERR; + } + // Select potential bridge residues + if (setup.Top().SetupIntegerMask( bmask )) { + mprinterr("Error: Setting up bridge residue mask failed.\n"); + return Action::ERR; + } + if (bmask.None()) { + mprintf("Warning: No potential bridge residues selected.\n"); + return Action::SKIP; + } + bmask.MaskInfo(); + // Ensure all bridge residues have same # atoms + std::vector Rnums = setup.Top().ResnumsSelectedBy( bmask ); + int resSize = -1; + for (std::vector::const_iterator rnum = Rnums.begin(); + rnum != Rnums.end(); ++rnum) + { + if (resSize == -1) + resSize = setup.Top().Res(*rnum).NumAtoms(); + else if (setup.Top().Res(*rnum).NumAtoms() != resSize) { + mprinterr("Error: Residue '%s' size (%i) != first residue size (%s)\n", + setup.Top().TruncResNameNum(*rnum).c_str(), + setup.Top().Res(*rnum).NumAtoms(), resSize); + return Action::ERR; + } + resStat_[*rnum] = STAT_BRIDGERES_; + } + mprintf("\tBridge residue size= %i\n", resSize); + // This character mask will be used if keepMask is not set. + CharMask cmask; + if (!keepMask_.MaskStringSet()) { + // Keep all atoms not in the bridge mask + cmask = CharMask( bmask.ConvertToCharMask(), bmask.Nselected() ); + for (int idx = 0; idx != setup.Top().Natom(); idx++) { + if (!cmask.AtomInCharMask(idx)) { + atomsToKeep_.AddSelectedAtom( idx ); + } + } + } + // Set up non-bridge residue status + if (!bridgeResOnly_.empty()) { + for (Iarray::const_iterator it = bridgeResOnly_.begin(); it != bridgeResOnly_.end(); ++it) + { + if (*it < 0 || *it >= setup.Top().Nres()) { + mprinterr("Error: Residue # %i for bridgeresonly out of range.\n", *it+1); + return Action::ERR; + } + resStat_[ *it ] = STAT_NONBRIDGERES_; + } + } else if (keepMask_.MaskStringSet()) { + for (AtomMask::const_iterator at = keepMask_.begin(); at != keepMask_.end(); ++at) + resStat_[ setup.Top()[*at].ResNum() ] = STAT_NONBRIDGERES_; + } else { + for (int idx = 0; idx != setup.Top().Natom(); idx++) { + if (!cmask.AtomInCharMask(idx)) + resStat_[ setup.Top()[idx].ResNum() ] = STAT_NONBRIDGERES_; + } + } + // Will keep only the first nbridge_ residues + if ((unsigned int)nbridge_ > Rnums.size()) { + mprinterr("Error: Number of bridge residues to keep (%i) > number of potential bridge residues (%zu).\n", nbridge_, Rnums.size()); + return Action::ERR; + } + nNonBridgeAtoms_ = atomsToKeep_.Nselected(); + for (int ridx = 0; ridx < nbridge_; ridx++) { + Residue const& res = setup.Top().Res(Rnums[ridx]); + for (int at = res.FirstAtom(); at != res.LastAtom(); at++) { + atomsToKeep_.AddSelectedAtom( at ); + } + } + } // END bridgeData + + // DEBUG: Print res stat + if (debug_ > 1) { + for (int rnum = 0; rnum != setup.Top().Nres(); rnum++) { + mprintf("DEBUG: Res %20s stat %c\n", setup.Top().TruncResNameNum(rnum).c_str(), resStat_[rnum]); + } + } + + // Create topology with only atoms to keep + if (keepParm_ != 0) + delete keepParm_; + if (atomsToKeep_.Nselected() < 1) { + mprintf("Warning: No atoms to keep.\n"); + return Action::SKIP; + } + keepParm_ = setup.Top().modifyStateByMask( atomsToKeep_ ); + if (keepParm_ == 0) { + mprinterr("Error: Could not create topology for kept atoms.\n"); + return Action::ERR; + } + setup.SetTopology( keepParm_ ); + // Modify State if asked + if (topWriter_.ModifyActionState(setup, keepParm_)) + return Action::ERR; + keepParm_->Brief("Topology for kept atoms:"); + keepFrame_.SetupFrameV( setup.Top().Atoms(), setup.CoordInfo() ); + + topWriter_.WriteTops( *keepParm_ ); + + return Action::MODIFY_TOPOLOGY; +} + +// Action_Keep::DoAction() +Action::RetType Action_Keep::DoAction(int frameNum, ActionFrame& frm) +{ + Action::RetType err = Action::OK; + if (bridgeData_ != 0) + err = keepBridge(frameNum, frm); + + if (err == Action::OK) { + keepFrame_.SetFrame(frm.Frm(), atomsToKeep_); + frm.SetFrame( &keepFrame_ ); + } + + return err; +} + +/** Want to keep only residues specified in a bridge ID data set. */ +Action::RetType Action_Keep::keepBridge(int frameNum, ActionFrame& frm) { + atomsToKeep_.ShrinkSelectedTo( nNonBridgeAtoms_ ); + // Ensure we can get data + if ((unsigned int)frameNum >= bridgeData_->Size()) { + mprinterr("Error: Frame # %i is out of range for bridge data '%s' (size is %zu)\n", + frameNum+1, bridgeData_->legend(), bridgeData_->Size()); + return Action::ERR; + } + std::string const& bridgeIDstr = (*bridgeData_)[frameNum]; + if (bridgeIDstr == "None") { + if (bridgeWarn_) + mprintf("Warning: Frame %i has no bridging residues.\n", frameNum+1); + return Action::SUPPRESS_COORD_OUTPUT; + } + ArgList bridgeID( bridgeIDstr, "," ); + if (debug_ > 0) + mprintf("DEBUG: Frame %i has %i bridging residues.\n", frameNum+1, bridgeID.Nargs()); + if (bridgeID.Nargs() < nbridge_) { + if (bridgeWarn_) + mprintf("Warning: Frame %i has fewer total bridges than requested (%i).\n", frameNum+1, bridgeID.Nargs()); + return Action::SUPPRESS_COORD_OUTPUT; + } + int nBridgeInFrame = 0; + for (int nb = 0; nb != bridgeID.Nargs(); nb++) { + // Format: (ures0+ures1+...) + ArgList bridge( bridgeID[nb], "()+" ); + if (bridge.Nargs() < 3) { + mprinterr("Error: Expected at least 3 args for bridge ID '%s', got %i\n", + bridgeID[nb].c_str(), bridge.Nargs()); + return Action::ERR; + } + // bres# indices start from 1 + int bres = bridge.getNextInteger(0) - 1; + if (debug_ > 0) + mprintf("DEBUG: Bridge res %i\n", bres+1); + // Check that bres is actually a bridging residue + if (bres < 0) { + mprinterr("Error: Invalid bridging residue # %i for bridge '%s'\n", bres+1, bridge.ArgLine()); + } else if ( resStat_[bres] != STAT_BRIDGERES_ ) { + mprinterr("Error: Residue %s listed as bridging but was not selected by 'bridgeresname'.\n", + currentParm_->TruncResNameNum(bres).c_str()); + } + // Check that residues being bridged are active + bool bridgeIsActive = true; + int nBres = bridge.getNextInteger(0) - 1; + while (nBres > -1) { + if ( resStat_[nBres] != STAT_NONBRIDGERES_ ) { + bridgeIsActive = false; + break; + } + nBres = bridge.getNextInteger(0) - 1; + } + if (bridgeIsActive) { + nBridgeInFrame++; + if (nBridgeInFrame > nbridge_) { + if (bridgeWarn_) + mprintf("Warning: More active bridges in frame %i (%i) than specified (%i); skipping.\n", + frameNum+1, nBridgeInFrame, nbridge_); + return SUPPRESS_COORD_OUTPUT; + } + Residue const& res = currentParm_->Res(bres); + for (int at = res.FirstAtom(); at != res.LastAtom(); at++) + atomsToKeep_.AddSelectedAtom( at ); + } + } + if (nBridgeInFrame < nbridge_) { + if (bridgeWarn_) + mprintf("Warning: Fewer active bridges in frame %i (%i) than specified (%i); skipping.\n", + frameNum+1, nBridgeInFrame, nbridge_); + return SUPPRESS_COORD_OUTPUT; + } + + return Action::OK; +} diff --git a/src/Action_Keep.h b/src/Action_Keep.h new file mode 100644 index 0000000000..4bcc838ebc --- /dev/null +++ b/src/Action_Keep.h @@ -0,0 +1,49 @@ +#ifndef INC_ACTION_KEEP_H +#define INC_ACTION_KEEP_H +#include "Action.h" +#include "ActionTopWriter.h" +class DataSet_string; +/// Keep only specified parts of the system +class Action_Keep : public Action { + public: + Action_Keep(); + ~Action_Keep(); + DispatchObject* Alloc() const { return (DispatchObject*)new Action_Keep(); } + void Help() const; + private: + Action::RetType Init(ArgList&, ActionInit&, int); + Action::RetType Setup(ActionSetup&); + Action::RetType DoAction(int, ActionFrame&); + void Print() {} + + Action::RetType keepBridge(int, ActionFrame&); + + typedef std::vector StatArray; + typedef std::vector Iarray; + + int debug_; + + Topology* currentParm_; ///< Current topology + Topology* keepParm_; ///< Topology for atoms to keep + Frame keepFrame_; ///< Frame for atoms to keep + + ActionTopWriter topWriter_; + + StatArray resStat_; ///< Hold status of each array + static const char STAT_NONE_; + static const char STAT_BRIDGERES_; + static const char STAT_NONBRIDGERES_; + + // For keeping bridging residues + DataSet_string* bridgeData_; ///< Bridging resdiue ID data set + int nbridge_; ///< Number of bridging residues to keep + std::string bridgeResName_; ///< Bridging residues name + Iarray bridgeResOnly_; ///< If set, only keep bridge when bridging these residues + bool bridgeWarn_; ///< If true, warn when # active bridges doesnt match + int nNonBridgeAtoms_; ///< Number of non-bridge atoms, for resizing atomsToKeep_ + + AtomMask keepMask_; ///< Mask of atoms to keep no matter what. + + AtomMask atomsToKeep_; ///< Mask of all atoms to keep. +}; +#endif diff --git a/src/Action_Remap.cpp b/src/Action_Remap.cpp index 3b35673804..76cffd5e2f 100644 --- a/src/Action_Remap.cpp +++ b/src/Action_Remap.cpp @@ -73,6 +73,9 @@ Action::RetType Action_Remap::Setup(ActionSetup& setup) { return Action::ERR; } setup.SetTopology( newParm_ ); + // Remove box information if asked + if (topWriter_.ModifyActionState(setup, newParm_)) + return Action::ERR; newParm_->Brief("Re-mapped topology:"); // Allocate space for new frame newFrame_.SetupFrameV(setup.Top().Atoms(), setup.CoordInfo()); diff --git a/src/Action_ReplicateCell.cpp b/src/Action_ReplicateCell.cpp index 398e99395f..9ee6d0b0b8 100644 --- a/src/Action_ReplicateCell.cpp +++ b/src/Action_ReplicateCell.cpp @@ -155,6 +155,7 @@ Action::RetType Action_ReplicateCell::Setup(ActionSetup& setup) { combinedTop_.AppendTop( *stripParm ); combinedTop_.Brief("Combined parm:"); delete stripParm; + topWriter_.ModifyTop( &combinedTop_ ); topWriter_.WriteTops( combinedTop_ ); // Only coordinates for now. FIXME combinedFrame_.SetupFrameM(combinedTop_.Atoms()); diff --git a/src/Action_Strip.cpp b/src/Action_Strip.cpp index 625eff3cfd..1752b6b405 100644 --- a/src/Action_Strip.cpp +++ b/src/Action_Strip.cpp @@ -4,20 +4,18 @@ // CONSTRUCTOR Action_Strip::Action_Strip() : - newParm_(0), newCinfo_(0), masterDSL_(0), removeBoxInfo_(false) {} + newParm_(0), masterDSL_(0) {} void Action_Strip::Help() const { - mprintf("\t [nobox]\n"); + mprintf("\t\n"); mprintf("%s", ActionTopWriter::Keywords()); - mprintf(" Strip atoms in from the system. If 'nobox' specified,\n" - " remove any unit cell info.\n"); + mprintf(" Strip atoms in from the system.\n"); mprintf("%s", ActionTopWriter::Options()); } // DESTRUCTOR Action_Strip::~Action_Strip() { if (newParm_!=0) delete newParm_; - if (newCinfo_ != 0) delete newCinfo_; } // Action_Strip::Init() @@ -25,7 +23,6 @@ Action::RetType Action_Strip::Init(ArgList& actionArgs, ActionInit& init, int de { // Get output stripped parm filename topWriter_.InitTopWriter(actionArgs, "stripped", debugIn); - removeBoxInfo_ = actionArgs.hasKey("nobox"); // Get mask of atoms to be stripped std::string mask1 = actionArgs.GetMaskNext(); @@ -42,8 +39,6 @@ Action::RetType Action_Strip::Init(ArgList& actionArgs, ActionInit& init, int de mprintf(" STRIP: Stripping atoms in mask [%s]\n", M1_.MaskString()); topWriter_.PrintOptions(); - if (removeBoxInfo_) - mprintf("\tAny existing box information will be removed.\n"); masterDSL_ = init.DslPtr(); return Action::OK; } @@ -75,12 +70,8 @@ Action::RetType Action_Strip::Setup(ActionSetup& setup) { } setup.SetTopology( newParm_ ); // Remove box information if asked - if (removeBoxInfo_) { - newParm_->SetParmBox( Box() ); - newCinfo_ = new CoordinateInfo( setup.CoordInfo() ); - newCinfo_->SetBox( Box() ); - setup.SetCoordInfo( newCinfo_ ); - } + if (topWriter_.ModifyActionState(setup, newParm_)) + return Action::ERR; newParm_->Brief("Stripped topology:"); // Allocate space for new frame newFrame_.SetupFrameV(setup.Top().Atoms(), setup.CoordInfo()); diff --git a/src/Action_Strip.h b/src/Action_Strip.h index 518046b04e..7530f5bf3b 100644 --- a/src/Action_Strip.h +++ b/src/Action_Strip.h @@ -16,11 +16,9 @@ class Action_Strip: public Action { void Print() {} Topology* newParm_; - CoordinateInfo* newCinfo_; DataSetList* masterDSL_; Frame newFrame_; AtomMask M1_; - bool removeBoxInfo_; ActionTopWriter topWriter_; }; #endif diff --git a/src/AtomMask.cpp b/src/AtomMask.cpp index 480b2fee57..6e6512a359 100644 --- a/src/AtomMask.cpp +++ b/src/AtomMask.cpp @@ -114,6 +114,19 @@ bool AtomMask::IsSelected(int atomIn) const { return false; } +/** Shrink the current selected array to only the first N entries. */ +void AtomMask::ShrinkSelectedTo(int newNselected) { + if (newNselected < 0) { + mprinterr("InternalError: AtomMask::ShrinkSelectedTo called with negative #.\n"); + return; + } + if ((unsigned int)newNselected > Selected_.size()) { + mprinterr("InternalError: AtomMask::ShrinkSelectedTo called with # (%i) > selected atoms (%zu).\n", newNselected, Selected_.size()); + return; + } + Selected_.resize( newNselected ); +} + // AtomMask::AddAtom() /** Attempt to enforce some sorting by looking for the atom in the mask; * as soon as an atom # is found larger than atomIn, insert it at the diff --git a/src/AtomMask.h b/src/AtomMask.h index 76ee8cef55..2d4d8000f1 100644 --- a/src/AtomMask.h +++ b/src/AtomMask.h @@ -54,6 +54,8 @@ class AtomMask : public MaskTokenArray { int NumAtomsInCommon(AtomMask const&) const; /// \return True if the given at is in the selected array. bool IsSelected(int) const; + /// Shrink the current selected array to the first N atoms + void ShrinkSelectedTo(int); /// Add atom to Selected array; assumes atoms will be in order. void AddSelectedAtom(int i) { Selected_.push_back( i ); } /// Add given atom to Selected array diff --git a/src/Command.cpp b/src/Command.cpp index 7996720f01..1d9bc81972 100644 --- a/src/Command.cpp +++ b/src/Command.cpp @@ -153,6 +153,7 @@ #include "Action_Time.h" #include "Action_DihedralRMS.h" #include "Action_MultiPucker.h" +#include "Action_Keep.h" // ----- ANALYSIS -------------------------------------------------------------- #include "Analysis_Hist.h" #include "Analysis_Corr.h" @@ -336,6 +337,7 @@ void Command::Init() { Command::AddCmd( new Action_Image(), Cmd::ACT, 1, "image" ); Command::AddCmd( new Action_InfraredSpectrum(),Cmd::ACT,2,"irspec","infraredspec"); // hidden Command::AddCmd( new Action_Jcoupling(), Cmd::ACT, 1, "jcoupling" ); + Command::AddCmd( new Action_Keep(), Cmd::ACT, 1, "keep" ); Command::AddCmd( new Action_LESsplit(), Cmd::ACT, 1, "lessplit" ); Command::AddCmd( new Action_LIE(), Cmd::ACT, 1, "lie" ); Command::AddCmd( new Action_OrderParameter(),Cmd::ACT, 1, "lipidorder" ); diff --git a/src/Version.h b/src/Version.h index 904a7ea2e7..85d8f565bd 100644 --- a/src/Version.h +++ b/src/Version.h @@ -12,7 +12,7 @@ * Whenever a number that precedes is incremented, all subsequent * numbers should be reset to 0. */ -#define CPPTRAJ_INTERNAL_VERSION "V6.4.2" +#define CPPTRAJ_INTERNAL_VERSION "V6.4.3" /// PYTRAJ relies on this #define CPPTRAJ_VERSION_STRING CPPTRAJ_INTERNAL_VERSION #endif diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 3ca00e7b91..ed63c24da5 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -1,6 +1,6 @@ ActionFrameCounter.o : ActionFrameCounter.cpp ActionFrameCounter.h ArgList.h CpptrajStdio.h ActionList.o : ActionList.cpp Action.h ActionList.h ActionState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h -ActionTopWriter.o : ActionTopWriter.cpp ActionTopWriter.h ArgList.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ParmFile.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h +ActionTopWriter.o : ActionTopWriter.cpp ActionState.h ActionTopWriter.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ParmFile.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Action_Align.o : Action_Align.cpp Action.h ActionState.h Action_Align.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceAction.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Action_Angle.o : Action_Angle.cpp Action.h ActionState.h Action_Angle.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Action_AreaPerMol.o : Action_AreaPerMol.cpp Action.h ActionState.h Action_AreaPerMol.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h @@ -41,6 +41,7 @@ Action_HydrogenBond.o : Action_HydrogenBond.cpp Action.h ActionState.h Action_Hy Action_Image.o : Action_Image.cpp Action.h ActionState.h Action_Image.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h ImageRoutines.h ImageTypes.h Image_List.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Action_InfraredSpectrum.o : Action_InfraredSpectrum.cpp Action.h ActionState.h Action_InfraredSpectrum.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ComplexArray.h Constants.h CoordinateInfo.h Corr.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_Vector.h DataSet_double.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ProgressBar.h PubFFT.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Action_Jcoupling.o : Action_Jcoupling.cpp Action.h ActionState.h Action_Jcoupling.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h +Action_Keep.o : Action_Keep.cpp Action.h ActionState.h ActionTopWriter.h Action_Keep.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_string.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Action_LESsplit.o : Action_LESsplit.cpp Action.h ActionFrameCounter.h ActionState.h Action_LESsplit.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OutputTrajCommon.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajectoryFile.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h Action_LIE.o : Action_LIE.cpp Action.h ActionState.h Action_LIE.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Action_LipidOrder.o : Action_LipidOrder.cpp Action.h ActionState.h Action_LipidOrder.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h @@ -151,7 +152,7 @@ ClusterMap.o : ClusterMap.cpp AssociatedData.h ClusterMap.h Constants.h CpptrajF Cmd.o : Cmd.cpp Cmd.h DispatchObject.h CmdInput.o : CmdInput.cpp CmdInput.h StringRoutines.h CmdList.o : CmdList.cpp Cmd.h CmdList.h DispatchObject.h -Command.o : Command.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h ActionTopWriter.h Action_Align.h Action_Angle.h Action_AreaPerMol.h Action_AtomMap.h Action_AtomicCorr.h Action_AtomicFluct.h Action_AutoImage.h Action_Average.h Action_Bounds.h Action_Box.h Action_Center.h Action_Channel.h Action_CheckChirality.h Action_CheckStructure.h Action_Closest.h Action_ClusterDihedral.h Action_Contacts.h Action_CreateCrd.h Action_CreateReservoir.h Action_DNAionTracker.h Action_DSSP.h Action_Density.h Action_Diffusion.h Action_Dihedral.h Action_DihedralRMS.h Action_Dipole.h Action_DistRmsd.h Action_Distance.h Action_Energy.h Action_Esander.h Action_FilterByData.h Action_FixAtomOrder.h Action_FixImagedBonds.h Action_GIST.h Action_Grid.h Action_GridFreeEnergy.h Action_HydrogenBond.h Action_Image.h Action_InfraredSpectrum.h Action_Jcoupling.h Action_LESsplit.h Action_LIE.h Action_LipidOrder.h Action_MakeStructure.h Action_Mask.h Action_Matrix.h Action_MinImage.h Action_Molsurf.h Action_MultiDihedral.h Action_MultiPucker.h Action_MultiVector.h Action_NAstruct.h Action_NMRrst.h Action_NativeContacts.h Action_OrderParameter.h Action_Outtraj.h Action_PairDist.h Action_Pairwise.h Action_Principal.h Action_Projection.h Action_Pucker.h Action_Radgyr.h Action_Radial.h Action_RandomizeIons.h Action_Remap.h Action_ReplicateCell.h Action_Rmsd.h Action_Rotate.h Action_RunningAvg.h Action_STFC_Diffusion.h Action_Scale.h Action_SetVelocity.h Action_Spam.h Action_Strip.h Action_Surf.h Action_SymmetricRmsd.h Action_Temperature.h Action_Time.h Action_Translate.h Action_Unstrip.h Action_Unwrap.h Action_Vector.h Action_VelocityAutoCorr.h Action_Volmap.h Action_Volume.h Action_Watershell.h Action_XtalSymm.h Analysis.h AnalysisList.h AnalysisState.h Analysis_AmdBias.h Analysis_AutoCorr.h Analysis_Average.h Analysis_Clustering.h Analysis_ConstantPHStats.h Analysis_Corr.h Analysis_CrankShaft.h Analysis_CrdFluct.h Analysis_CrossCorr.h Analysis_CurveFit.h Analysis_Divergence.h Analysis_EvalPlateau.h Analysis_FFT.h Analysis_HausdorffDistance.h Analysis_Hist.h Analysis_IRED.h Analysis_Integrate.h Analysis_KDE.h Analysis_Lifetime.h Analysis_LowestCurve.h Analysis_Matrix.h Analysis_MeltCurve.h Analysis_Modes.h Analysis_MultiHist.h Analysis_Multicurve.h Analysis_Overlap.h Analysis_PhiPsi.h Analysis_Regression.h Analysis_RemLog.h Analysis_Rms2d.h Analysis_RmsAvgCorr.h Analysis_Rotdif.h Analysis_RunningAvg.h Analysis_Slope.h Analysis_Spline.h Analysis_State.h Analysis_Statistics.h Analysis_TI.h Analysis_Timecorr.h Analysis_VectorMath.h Analysis_Wavelet.h ArgList.h Array1D.h ArrayIterator.h AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h AxisType.h BaseIOtype.h Box.h BoxArgs.h BufferedLine.h CharMask.h Cluster/Algorithm.h Cluster/BestReps.h Cluster/CentroidArray.h Cluster/Cframes.h Cluster/Control.h Cluster/DrawGraph.h Cluster/List.h Cluster/Metric.h Cluster/MetricArray.h Cluster/Node.h Cluster/Sieve.h Cluster/Silhouette.h ClusterMap.h Cmd.h CmdInput.h CmdList.h Command.h CompactFrameArray.h ComplexArray.h Constants.h Constraints.h ControlBlock.h ControlBlock_For.h CoordinateInfo.h Corr.h Cph.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_REF.h DataSet_GridFlt.h DataSet_Mat3x3.h DataSet_MatrixDbl.h DataSet_MatrixFlt.h DataSet_Mesh.h DataSet_Modes.h DataSet_RemLog.h DataSet_Vector.h DataSet_double.h DataSet_float.h DataSet_integer.h DataSet_integer_mem.h DataSet_pH.h DataSet_string.h Deprecated.h DihedralSearch.h Dimension.h DispatchObject.h Energy.h Energy_Sander.h EnsembleIn.h EnsembleOutList.h Ewald.h EwaldOptions.h Ewald_ParticleMesh.h ExclusionArray.h Exec.h Exec_AddMissingRes.h Exec_Analyze.h Exec_Calc.h Exec_CatCrd.h Exec_Change.h Exec_ClusterMap.h Exec_CombineCoords.h Exec_Commands.h Exec_CompareClusters.h Exec_CompareTop.h Exec_CrdAction.h Exec_CrdOut.h Exec_CreateSet.h Exec_DataFile.h Exec_DataFilter.h Exec_DataSetCmd.h Exec_Emin.h Exec_Flatten.h Exec_GenerateAmberRst.h Exec_Graft.h Exec_Help.h Exec_HmassRepartition.h Exec_LoadCrd.h Exec_LoadTraj.h Exec_ParallelAnalysis.h Exec_ParmBox.h Exec_ParmSolvent.h Exec_ParmStrip.h Exec_ParmWrite.h Exec_PermuteDihedrals.h Exec_Precision.h Exec_PrepareForLeap.h Exec_PrintData.h Exec_Random.h Exec_ReadData.h Exec_ReadEnsembleData.h Exec_ReadInput.h Exec_RotateDihedral.h Exec_RunAnalysis.h Exec_ScaleDihedralK.h Exec_SequenceAlign.h Exec_Set.h Exec_Show.h Exec_SortEnsembleData.h Exec_SplitCoords.h Exec_System.h Exec_Top.h Exec_Traj.h Exec_UpdateParameters.h Exec_ViewRst.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h GIST_PME.h Grid.h GridAction.h GridBin.h HistBin.h Hungarian.h ImageOption.h ImageTypes.h InputTrajCommon.h MapAtom.h MaskArray.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h NetcdfFile.h OnlineVarT.h OutputTrajCommon.h PDBfile.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h PubFFT.h Pucker.h Pucker_PuckerMask.h Pucker_PuckerSearch.h Pucker_PuckerToken.h RPNcalc.h Random.h Range.h ReferenceAction.h ReferenceFrame.h RemdReservoirNC.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h Spline.h SplineFxnTable.h StructureCheck.h SymbolExporting.h SymmetricRmsdCalc.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h cuda_kernels/GistCudaSetup.cuh helpme_standalone.h molsurf.h +Command.o : Command.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h ActionTopWriter.h Action_Align.h Action_Angle.h Action_AreaPerMol.h Action_AtomMap.h Action_AtomicCorr.h Action_AtomicFluct.h Action_AutoImage.h Action_Average.h Action_Bounds.h Action_Box.h Action_Center.h Action_Channel.h Action_CheckChirality.h Action_CheckStructure.h Action_Closest.h Action_ClusterDihedral.h Action_Contacts.h Action_CreateCrd.h Action_CreateReservoir.h Action_DNAionTracker.h Action_DSSP.h Action_Density.h Action_Diffusion.h Action_Dihedral.h Action_DihedralRMS.h Action_Dipole.h Action_DistRmsd.h Action_Distance.h Action_Energy.h Action_Esander.h Action_FilterByData.h Action_FixAtomOrder.h Action_FixImagedBonds.h Action_GIST.h Action_Grid.h Action_GridFreeEnergy.h Action_HydrogenBond.h Action_Image.h Action_InfraredSpectrum.h Action_Jcoupling.h Action_Keep.h Action_LESsplit.h Action_LIE.h Action_LipidOrder.h Action_MakeStructure.h Action_Mask.h Action_Matrix.h Action_MinImage.h Action_Molsurf.h Action_MultiDihedral.h Action_MultiPucker.h Action_MultiVector.h Action_NAstruct.h Action_NMRrst.h Action_NativeContacts.h Action_OrderParameter.h Action_Outtraj.h Action_PairDist.h Action_Pairwise.h Action_Principal.h Action_Projection.h Action_Pucker.h Action_Radgyr.h Action_Radial.h Action_RandomizeIons.h Action_Remap.h Action_ReplicateCell.h Action_Rmsd.h Action_Rotate.h Action_RunningAvg.h Action_STFC_Diffusion.h Action_Scale.h Action_SetVelocity.h Action_Spam.h Action_Strip.h Action_Surf.h Action_SymmetricRmsd.h Action_Temperature.h Action_Time.h Action_Translate.h Action_Unstrip.h Action_Unwrap.h Action_Vector.h Action_VelocityAutoCorr.h Action_Volmap.h Action_Volume.h Action_Watershell.h Action_XtalSymm.h Analysis.h AnalysisList.h AnalysisState.h Analysis_AmdBias.h Analysis_AutoCorr.h Analysis_Average.h Analysis_Clustering.h Analysis_ConstantPHStats.h Analysis_Corr.h Analysis_CrankShaft.h Analysis_CrdFluct.h Analysis_CrossCorr.h Analysis_CurveFit.h Analysis_Divergence.h Analysis_EvalPlateau.h Analysis_FFT.h Analysis_HausdorffDistance.h Analysis_Hist.h Analysis_IRED.h Analysis_Integrate.h Analysis_KDE.h Analysis_Lifetime.h Analysis_LowestCurve.h Analysis_Matrix.h Analysis_MeltCurve.h Analysis_Modes.h Analysis_MultiHist.h Analysis_Multicurve.h Analysis_Overlap.h Analysis_PhiPsi.h Analysis_Regression.h Analysis_RemLog.h Analysis_Rms2d.h Analysis_RmsAvgCorr.h Analysis_Rotdif.h Analysis_RunningAvg.h Analysis_Slope.h Analysis_Spline.h Analysis_State.h Analysis_Statistics.h Analysis_TI.h Analysis_Timecorr.h Analysis_VectorMath.h Analysis_Wavelet.h ArgList.h Array1D.h ArrayIterator.h AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h AxisType.h BaseIOtype.h Box.h BoxArgs.h BufferedLine.h CharMask.h Cluster/Algorithm.h Cluster/BestReps.h Cluster/CentroidArray.h Cluster/Cframes.h Cluster/Control.h Cluster/DrawGraph.h Cluster/List.h Cluster/Metric.h Cluster/MetricArray.h Cluster/Node.h Cluster/Sieve.h Cluster/Silhouette.h ClusterMap.h Cmd.h CmdInput.h CmdList.h Command.h CompactFrameArray.h ComplexArray.h Constants.h Constraints.h ControlBlock.h ControlBlock_For.h CoordinateInfo.h Corr.h Cph.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_REF.h DataSet_GridFlt.h DataSet_Mat3x3.h DataSet_MatrixDbl.h DataSet_MatrixFlt.h DataSet_Mesh.h DataSet_Modes.h DataSet_RemLog.h DataSet_Vector.h DataSet_double.h DataSet_float.h DataSet_integer.h DataSet_integer_mem.h DataSet_pH.h DataSet_string.h Deprecated.h DihedralSearch.h Dimension.h DispatchObject.h Energy.h Energy_Sander.h EnsembleIn.h EnsembleOutList.h Ewald.h EwaldOptions.h Ewald_ParticleMesh.h ExclusionArray.h Exec.h Exec_AddMissingRes.h Exec_Analyze.h Exec_Calc.h Exec_CatCrd.h Exec_Change.h Exec_ClusterMap.h Exec_CombineCoords.h Exec_Commands.h Exec_CompareClusters.h Exec_CompareTop.h Exec_CrdAction.h Exec_CrdOut.h Exec_CreateSet.h Exec_DataFile.h Exec_DataFilter.h Exec_DataSetCmd.h Exec_Emin.h Exec_Flatten.h Exec_GenerateAmberRst.h Exec_Graft.h Exec_Help.h Exec_HmassRepartition.h Exec_LoadCrd.h Exec_LoadTraj.h Exec_ParallelAnalysis.h Exec_ParmBox.h Exec_ParmSolvent.h Exec_ParmStrip.h Exec_ParmWrite.h Exec_PermuteDihedrals.h Exec_Precision.h Exec_PrepareForLeap.h Exec_PrintData.h Exec_Random.h Exec_ReadData.h Exec_ReadEnsembleData.h Exec_ReadInput.h Exec_RotateDihedral.h Exec_RunAnalysis.h Exec_ScaleDihedralK.h Exec_SequenceAlign.h Exec_Set.h Exec_Show.h Exec_SortEnsembleData.h Exec_SplitCoords.h Exec_System.h Exec_Top.h Exec_Traj.h Exec_UpdateParameters.h Exec_ViewRst.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h GIST_PME.h Grid.h GridAction.h GridBin.h HistBin.h Hungarian.h ImageOption.h ImageTypes.h InputTrajCommon.h MapAtom.h MaskArray.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h NetcdfFile.h OnlineVarT.h OutputTrajCommon.h PDBfile.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h PubFFT.h Pucker.h Pucker_PuckerMask.h Pucker_PuckerSearch.h Pucker_PuckerToken.h RPNcalc.h Random.h Range.h ReferenceAction.h ReferenceFrame.h RemdReservoirNC.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h Spline.h SplineFxnTable.h StructureCheck.h SymbolExporting.h SymmetricRmsdCalc.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h cuda_kernels/GistCudaSetup.cuh helpme_standalone.h molsurf.h CompactFrameArray.o : CompactFrameArray.cpp Box.h CompactFrameArray.h CoordinateInfo.h CpptrajStdio.h Matrix_3x3.h Parallel.h ReplicaDimArray.h Vec3.h ComplexArray.o : ComplexArray.cpp ArrayIterator.h ComplexArray.h Constraints.o : Constraints.cpp ArgList.h Atom.h AtomMask.h AtomType.h Box.h CharMask.h Constants.h Constraints.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h diff --git a/src/cpptrajfiles b/src/cpptrajfiles index aedb7000db..8927674c65 100644 --- a/src/cpptrajfiles +++ b/src/cpptrajfiles @@ -44,6 +44,7 @@ COMMON_SOURCES= \ Action_Image.cpp \ Action_InfraredSpectrum.cpp \ Action_Jcoupling.cpp \ + Action_Keep.cpp \ Action_LESsplit.cpp \ Action_LIE.cpp \ Action_LipidOrder.cpp \ diff --git a/test/Makefile b/test/Makefile index ae4f17e355..d536122176 100644 --- a/test/Makefile +++ b/test/Makefile @@ -498,6 +498,9 @@ test.hmassrepartition: test.prepareforleap: @-cd Test_PrepareForLeap && ./RunTest.sh $(OPT) +test.keep: + @-cd Test_Keep && ./RunTest.sh $(OPT) + # Every test target should go here. COMPLETETESTS=test.general \ test.strip \ @@ -655,7 +658,8 @@ COMPLETETESTS=test.general \ test.multipucker \ test.ljc \ test.hmassrepartition \ - test.prepareforleap + test.prepareforleap \ + test.keep test.all: $(MAKE) test.complete summary diff --git a/test/Test_Keep/RunTest.sh b/test/Test_Keep/RunTest.sh new file mode 100755 index 0000000000..00ae1db257 --- /dev/null +++ b/test/Test_Keep/RunTest.sh @@ -0,0 +1,111 @@ +#!/bin/bash + +. ../MasterTest.sh + +CleanFiles keep.in solvavg.dat uvseries.dat hb.dat b.dat \ + keep.parm7 keep.dcd keep.crd \ + keep.10.11.parm7 keep.10.11.crd \ + res1.tz2.crd \ + hb.2.dat keep.onlyone.crd \ + keep.two.crd + +INPUT='keep.in' + +TESTNAME='Keep command tests.' + +UNITNAME='Keep bridging water test' +CheckFor netcdf maxthreads 1 +if [ $? -eq 0 ] ; then + cat > keep.in < keep.in < keep.in < keep.in < keep.in <