From af332c7f33aa6fbc350f7e8263821c6e75b72a1c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 14 Jun 2019 14:31:09 -0400 Subject: [PATCH 01/26] DRR - Cpptraj: Use forward declares. Add routine for using dihtype. --- src/DihedralSearch.cpp | 26 ++++++++++++++++++++++++++ src/DihedralSearch.h | 14 ++++++++++---- src/cpptrajdepend | 2 +- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/DihedralSearch.cpp b/src/DihedralSearch.cpp index 2b17e6ea7d..d47038b701 100644 --- a/src/DihedralSearch.cpp +++ b/src/DihedralSearch.cpp @@ -1,5 +1,8 @@ #include "DihedralSearch.h" #include "CpptrajStdio.h" +#include "StringRoutines.h" // convertToInteger +#include "ArgList.h" +#include "Topology.h" const DihedralSearch::DihedralType DihedralSearch::D_FIRST = MetaData::ALPHA; const DihedralSearch::DihedralType DihedralSearch::D_END = MetaData::PUCKER; @@ -204,6 +207,29 @@ void DihedralSearch::SearchForArgs(ArgList& argIn) { } } +const char* DihedralSearch::newTypeArgsHelp_ = "dihtype ::::[:] ..."; + +/** Get custom dihedral arguments: + * 'dihtype ::::[:]' + * where determines which residue / are in. + */ +int DihedralSearch::SearchForNewTypeArgs(ArgList& argIn) { + std::string dihtype_arg = argIn.GetStringKey("dihtype"); + while (!dihtype_arg.empty()) { + ArgList dihtype(dihtype_arg, ":"); + if (dihtype.Nargs() < 5) { + mprinterr("Error: Malformed dihtype arg.\n"); + return 1; + } + int offset = 0; + if (dihtype.Nargs() == 6) offset = convertToInteger(dihtype[5]); + // NOTE: Not checking return status here because worse that happens is a Warning + SearchForNewType(offset,dihtype[1],dihtype[2],dihtype[3],dihtype[4], dihtype[0]); + dihtype_arg = argIn.GetStringKey("dihtype"); + } + return 0; +} + // DihedralSearch::SearchForNewType() /** Add new type to search for. */ int DihedralSearch::SearchForNewType(int off, std::string const& an0, std::string const& an1, diff --git a/src/DihedralSearch.h b/src/DihedralSearch.h index 1f76467131..23384b7602 100644 --- a/src/DihedralSearch.h +++ b/src/DihedralSearch.h @@ -1,9 +1,11 @@ #ifndef INC_DIHEDRALSEARCH_H #define INC_DIHEDRALSEARCH_H -#include "Topology.h" -#include "DataSet.h" -#include "Range.h" -#include "ArgList.h" +#include "MetaData.h" +#include "AtomMask.h" +// Forward declarations +class ArgList; +class Range; +class Topology; /// Class that can be used to search for dihedral angles in a range. // Thanks to C. Bergonzo for the NA angle definitions. class DihedralSearch { @@ -28,6 +30,10 @@ class DihedralSearch { int SearchFor(DihedralType); /// Search for known dihedral type keywords. void SearchForArgs(ArgList&); + /// Contains keywords for SearchNewTypeArgs() + static const char* newTypeArgsHelp_; + /// Search for new type via args + int SearchForNewTypeArgs(ArgList&); /// Add a new dihedral type to be searched for. int SearchForNewType(int, std::string const&, std::string const&, std::string const&, std::string const&, std::string const&); diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 766bda7614..cbc47210e6 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -221,7 +221,7 @@ DataSet_integer_mem.o : DataSet_integer_mem.cpp ArgList.h AssociatedData.h Cpptr DataSet_pH.o : DataSet_pH.cpp ArgList.h AssociatedData.h Cph.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_1D.h DataSet_pH.h Dimension.h FileIO.h FileName.h MetaData.h NameType.h Parallel.h Range.h TextFormat.h DataSet_string.o : DataSet_string.cpp ArgList.h AssociatedData.h CpptrajFile.h DataSet.h DataSet_string.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h TextFormat.h Deprecated.o : Deprecated.cpp CpptrajStdio.h Deprecated.h DispatchObject.h -DihedralSearch.o : DihedralSearch.cpp ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DihedralSearch.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Topology.h Vec3.h +DihedralSearch.o : DihedralSearch.cpp ArgList.h Atom.h AtomExtra.h AtomMask.h Box.h CharMask.h CoordinateInfo.h CpptrajStdio.h DihedralSearch.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h StringRoutines.h SymbolExporting.h Topology.h Vec3.h DistRoutines.o : DistRoutines.cpp Box.h DistRoutines.h Matrix_3x3.h Parallel.h Vec3.h Energy.o : Energy.cpp Atom.h AtomExtra.h AtomMask.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h Energy.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h SymbolExporting.h Topology.h TorsionRoutines.h Vec3.h Energy_Sander.o : Energy_Sander.cpp ArgList.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h BondSearch.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h Energy_Sander.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterTypes.h ParmFile.h ParmIO.h Range.h ReplicaDimArray.h Residue.h SymbolExporting.h Topology.h Vec3.h From 4249341cc3856f40e67826e414cae34eef944b04 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 14 Jun 2019 14:32:18 -0400 Subject: [PATCH 02/26] DRR - Cpptraj: Use the new SearchForNewTypeArgs routine --- src/Action_MultiDihedral.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/Action_MultiDihedral.cpp b/src/Action_MultiDihedral.cpp index 90de0b1c40..412d31bf59 100644 --- a/src/Action_MultiDihedral.cpp +++ b/src/Action_MultiDihedral.cpp @@ -37,18 +37,7 @@ Action::RetType Action_MultiDihedral::Init(ArgList& actionArgs, ActionInit& init // Search for known dihedral keywords dihSearch_.SearchForArgs(actionArgs); // Get custom dihedral arguments: dihtype ::::[:] - std::string dihtype_arg = actionArgs.GetStringKey("dihtype"); - while (!dihtype_arg.empty()) { - ArgList dihtype(dihtype_arg, ":"); - if (dihtype.Nargs() < 5) { - mprinterr("Error: Malformed dihtype arg.\n"); - return Action::ERR; - } - int offset = 0; - if (dihtype.Nargs() == 6) offset = convertToInteger(dihtype[5]); - dihSearch_.SearchForNewType(offset,dihtype[1],dihtype[2],dihtype[3],dihtype[4], dihtype[0]); - dihtype_arg = actionArgs.GetStringKey("dihtype"); - } + if (dihSearch_.SearchForNewTypeArgs(actionArgs)) return Action::ERR; // If no dihedral types yet selected, this will select all. dihSearch_.SearchForAll(); From 66c5d98c0d5c85f12d25be4c622c6525d7bacdc6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 14 Jun 2019 14:52:38 -0400 Subject: [PATCH 03/26] DRR - Cpptraj: Enable command. Add reference keywords. --- src/Command.cpp | 2 ++ src/cpptrajdepend | 3 ++- src/cpptrajfiles | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Command.cpp b/src/Command.cpp index 8771e8f7ea..8214c31d09 100644 --- a/src/Command.cpp +++ b/src/Command.cpp @@ -140,6 +140,7 @@ #include "Action_InfraredSpectrum.h" #include "Action_XtalSymm.h" #include "Action_Time.h" +#include "Action_DihedralRMS.h" // ----- ANALYSIS -------------------------------------------------------------- #include "Analysis_Hist.h" #include "Analysis_Corr.h" @@ -297,6 +298,7 @@ void Command::Init() { Command::AddCmd( new Action_Density(), Cmd::ACT, 1, "density" ); Command::AddCmd( new Action_Diffusion(), Cmd::ACT, 1, "diffusion" ); Command::AddCmd( new Action_Dihedral(), Cmd::ACT, 1, "dihedral" ); + Command::AddCmd( new Action_DihedralRMS(), Cmd::ACT, 1, "dihrms" ); Command::AddCmd( new Action_Dipole(), Cmd::ACT, 1, "dipole" ); Command::AddCmd( new Action_Distance(), Cmd::ACT, 1, "distance" ); Command::AddCmd( new Action_DNAionTracker(), Cmd::ACT, 1, "dnaiontracker" ); // HIDDEN diff --git a/src/cpptrajdepend b/src/cpptrajdepend index cbc47210e6..94d90ca82c 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -25,6 +25,7 @@ Action_DSSP.o : Action_DSSP.cpp Action.h ActionState.h Action_DSSP.h ArgList.h A Action_Density.o : Action_Density.cpp Action.h ActionState.h Action_Density.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImagedAction.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h Action_Diffusion.o : Action_Diffusion.cpp Action.h ActionState.h Action_Diffusion.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImagedAction.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h Action_Dihedral.o : Action_Dihedral.cpp Action.h ActionState.h Action_Dihedral.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.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 ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h Vec3.h +Action_DihedralRMS.o : Action_DihedralRMS.cpp Action.h ActionState.h Action_DihedralRMS.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DihedralSearch.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 ParameterTypes.h Range.h ReferenceAction.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h Action_Dipole.o : Action_Dipole.cpp Action.h ActionState.h Action_Dipole.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridFlt.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h Grid.h GridAction.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h Action_DistRmsd.o : Action_DistRmsd.cpp Action.h ActionState.h Action_DistRmsd.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.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 ParameterTypes.h Range.h ReferenceAction.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h Action_Distance.o : Action_Distance.cpp Action.h ActionState.h Action_Distance.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.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 ImagedAction.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h @@ -156,7 +157,7 @@ Cluster_ReadInfo.o : Cluster_ReadInfo.cpp ArgList.h ArrayIterator.h AssociatedDa 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 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_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_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_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_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 AtomExtra.h AtomMap.h AtomMask.h AxisType.h BaseIOtype.h Box.h BufferedLine.h CharMask.h ClusterDist.h ClusterList.h ClusterMap.h ClusterNode.h ClusterSieve.h Cmd.h CmdInput.h CmdList.h Command.h ComplexArray.h Constraints.h Control.h CoordinateInfo.h Corr.h Cph.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Cmatrix.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 DistRoutines.h Energy.h Energy_Sander.h EnsembleIn.h EnsembleOutList.h Ewald.h Exec.h Exec_Analyze.h Exec_Calc.h Exec_CatCrd.h Exec_Change.h Exec_ClusterMap.h Exec_CombineCoords.h Exec_Commands.h Exec_CompareTop.h Exec_CrdAction.h Exec_CrdOut.h Exec_CreateSet.h Exec_DataFile.h Exec_DataFilter.h Exec_DataSetCmd.h Exec_GenerateAmberRst.h Exec_Help.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_PrintData.h Exec_ReadData.h Exec_ReadEnsembleData.h Exec_ReadInput.h Exec_RotateDihedral.h Exec_RunAnalysis.h Exec_ScaleDihedralK.h Exec_SequenceAlign.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 Grid.h GridAction.h GridBin.h HistBin.h Hungarian.h ImageTypes.h ImagedAction.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 ParameterTypes.h PubFFT.h RPNcalc.h Random.h Range.h ReferenceAction.h ReferenceFrame.h RemdReservoirNC.h ReplicaDimArray.h ReplicaInfo.h Residue.h Spline.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 VariableArray.h Vec3.h molsurf.h +Command.o : Command.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.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_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_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_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 AtomExtra.h AtomMap.h AtomMask.h AxisType.h BaseIOtype.h Box.h BufferedLine.h CharMask.h ClusterDist.h ClusterList.h ClusterMap.h ClusterNode.h ClusterSieve.h Cmd.h CmdInput.h CmdList.h Command.h ComplexArray.h Constraints.h Control.h CoordinateInfo.h Corr.h Cph.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Cmatrix.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 DistRoutines.h Energy.h Energy_Sander.h EnsembleIn.h EnsembleOutList.h Ewald.h Exec.h Exec_Analyze.h Exec_Calc.h Exec_CatCrd.h Exec_Change.h Exec_ClusterMap.h Exec_CombineCoords.h Exec_Commands.h Exec_CompareTop.h Exec_CrdAction.h Exec_CrdOut.h Exec_CreateSet.h Exec_DataFile.h Exec_DataFilter.h Exec_DataSetCmd.h Exec_GenerateAmberRst.h Exec_Help.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_PrintData.h Exec_ReadData.h Exec_ReadEnsembleData.h Exec_ReadInput.h Exec_RotateDihedral.h Exec_RunAnalysis.h Exec_ScaleDihedralK.h Exec_SequenceAlign.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 Grid.h GridAction.h GridBin.h HistBin.h Hungarian.h ImageTypes.h ImagedAction.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 ParameterTypes.h PubFFT.h RPNcalc.h Random.h Range.h ReferenceAction.h ReferenceFrame.h RemdReservoirNC.h ReplicaDimArray.h ReplicaInfo.h Residue.h Spline.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 VariableArray.h Vec3.h molsurf.h ComplexArray.o : ComplexArray.cpp ArrayIterator.h ComplexArray.h Constraints.o : Constraints.cpp ArgList.h Atom.h AtomExtra.h AtomMask.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 ParameterTypes.h Range.h ReplicaDimArray.h Residue.h SymbolExporting.h Topology.h Vec3.h Control.o : Control.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h Control.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h VariableArray.h Vec3.h diff --git a/src/cpptrajfiles b/src/cpptrajfiles index b51ae76dca..c02caaa64e 100644 --- a/src/cpptrajfiles +++ b/src/cpptrajfiles @@ -29,6 +29,7 @@ COMMON_SOURCES= \ Action_Density.cpp \ Action_Diffusion.cpp \ Action_Dihedral.cpp \ + Action_DihedralRMS.cpp \ Action_Dipole.cpp \ Action_Distance.cpp \ Action_DistRmsd.cpp \ From 354f48fe485d9a3e65b59419ee6d1c98a4760936 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 14 Jun 2019 15:43:52 -0400 Subject: [PATCH 04/26] DRR - Cpptraj: Add the Action_DihedralRMS class --- src/Action_DihedralRMS.cpp | 109 +++++++++++++++++++++++++++++++++++++ src/Action_DihedralRMS.h | 31 +++++++++++ 2 files changed, 140 insertions(+) create mode 100644 src/Action_DihedralRMS.cpp create mode 100644 src/Action_DihedralRMS.h diff --git a/src/Action_DihedralRMS.cpp b/src/Action_DihedralRMS.cpp new file mode 100644 index 0000000000..960e695e5d --- /dev/null +++ b/src/Action_DihedralRMS.cpp @@ -0,0 +1,109 @@ +#include "Action_DihedralRMS.h" +#include "CpptrajStdio.h" +#include "TorsionRoutines.h" + +// Action_DihedralRMS::Help() +void Action_DihedralRMS::Help() const { + mprintf("\t[] [out ]\n" + "%s" + "\t[%s]\n", ReferenceAction::Help(), DihedralSearch::newTypeArgsHelp_); +} + +// Action_DihedralRMS::Init() +Action::RetType Action_DihedralRMS::Init(ArgList& actionArgs, ActionInit& init, int debugIn) +{ + // Get keywords + DataFile* outfile = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs); + std::string tgtArg = actionArgs.GetStringKey("tgtrange"); + std::string refArg = actionArgs.GetStringKey("refrange"); + if (!tgtArg.empty()) { + if (tgtRange_.SetRange( tgtArg )) return Action::ERR; + } + if (!refArg.empty()) { + if (refRange_.SetRange( refArg )) return Action::ERR; + } else if (!tgtArg.empty()) { + if (refRange_.SetRange( tgtArg )) return Action::ERR; + } + // Reference keywords. false= no fit, false= no use mass + if (REF_.InitRef(actionArgs, init.DSL(), false, false)) return Action::ERR; + // Search for known dihedral keywords + dihSearch_.SearchForArgs(actionArgs); + // Get custom dihedral arguments: dihtype ::::[:] + if (dihSearch_.SearchForNewTypeArgs(actionArgs)) return Action::ERR; + // If no dihedral types yet selected, this will select all. + dihSearch_.SearchForAll(); + // Setup DataSet(s) name + std::string dsetname = actionArgs.GetStringNext(); + // Setup output data set + dataOut_ = init.DSL().AddSet(DataSet::DOUBLE, dsetname, "DIHRMS"); + if (dataOut_ == 0) return Action::ERR; + if (outfile != 0) outfile->AddDataSet( dataOut_ ); +# ifdef MPI + if (REF_.SetTrajComm( init.TrajComm() )) return Action::ERR; +# endif + + mprintf(" DIHEDRAL RMSD: Calculating dihedral RMS for dihedrals:"); + dihSearch_.PrintTypes(); + mprintf("\n"); + if (!tgtRange_.Empty()) + mprintf("\tTarget residue range: %s\n", tgtRange_.RangeArg()); + if (!refRange_.Empty()) + mprintf("\tReference residue range: %s\n", refRange_.RangeArg()); + mprintf("\tReference is %s\n", REF_.RefModeString().c_str()); + return Action::OK; +} + +int Action_DihedralRMS::GetRefDihedrals(Topology const& top, Frame const& frm) { + Range actualRange = GetActualRange(top, refRange_); + if (actualRange.Empty()) { + mprinterr("Error: No residues in reference topology %s\n", top.c_str()); + return 1; + } + // Search for specified dihedrals in each residue in the range + if (dihSearch_.FindDihedrals(top, actualRange)) { + mprinterr("Error: No dihedrals found in reference topology %s\n", top.c_str()); + return 1; + } + // Calculate dihedrals + refVals_.clear(); + refVals_.reserve( dihSearch_.Ndihedrals() ); + for (DihedralSearch::mask_it dih = dihSearch_.begin(); + dih != dihSearch_.end(); ++dih) + { + double torsion = Torsion( frm.XYZ(dih->A0()), + frm.XYZ(dih->A1()), + frm.XYZ(dih->A2()), + frm.XYZ(dih->A3()) ); + refVals_.push_back( torsion ); + } + return 0; +} + +Range Action_DihedralRMS::GetActualRange(Topology const& top, Range const& resRange) const { + Range actualRange; + // If range is empty (i.e. no resrange arg given) look through all + // solute residues. + if (resRange.Empty()) + actualRange = top.SoluteResidues(); + else { + // If user range specified, create new range shifted by -1 since internal + // resnums start from 0. + actualRange = resRange; + actualRange.ShiftBy(-1); + } + return actualRange; +} + +// Action_DihedralRMS::Setup() +Action::RetType Action_DihedralRMS::Setup(ActionSetup& setup) +{ + + return Action::ERR; +} + +// Action_DihedralRMS::DoAction() +Action::RetType Action_DihedralRMS::DoAction(int frameNum, ActionFrame& frm) +{ + + return Action::ERR; +} diff --git a/src/Action_DihedralRMS.h b/src/Action_DihedralRMS.h new file mode 100644 index 0000000000..05d47a880b --- /dev/null +++ b/src/Action_DihedralRMS.h @@ -0,0 +1,31 @@ +#ifndef INC_ACTION_DIHEDRALRMS_H +#define INC_ACTION_DIHEDRALRMS_H +#include "Action.h" +#include "DihedralSearch.h" +#include "ReferenceAction.h" +/// Calculate dihedral RMSD to reference +class Action_DihedralRMS : public Action { + public: + Action_DihedralRMS() {} + DispatchObject* Alloc() const { return (DispatchObject*)new Action_DihedralRMS(); } + void Help() const; + private: + Action::RetType Init(ArgList&, ActionInit&, int); + Action::RetType Setup(ActionSetup&); + Action::RetType DoAction(int, ActionFrame&); + void Print() {} + + typedef std::vector Darray; + + Range GetActualRange(Topology const&, Range const&) const; + int GetRefDihedrals(Topology const&, Frame const&); + + DihedralSearch dihSearch_; ///< Used to select specified dihedrals + ReferenceAction REF_; ///< Hold reference structure + Darray refVals_; ///< Reference dihedral values in radians + Range tgtRange_; + Range refRange_; + DataSet* dataOut_; ///< Output data set + +}; +#endif From d1f9b3650ffd3192d761a7f32fe95d51e3b4ce08 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sat, 15 Jun 2019 13:57:23 -0400 Subject: [PATCH 05/26] DRR - Cpptraj: First incarnation of dihedral rms test. --- test/Test_DihedralRMS/RunTest.sh | 65 ++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 test/Test_DihedralRMS/RunTest.sh diff --git a/test/Test_DihedralRMS/RunTest.sh b/test/Test_DihedralRMS/RunTest.sh new file mode 100755 index 0000000000..0349980a69 --- /dev/null +++ b/test/Test_DihedralRMS/RunTest.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +. ../MasterTest.sh + +CleanFiles dih.in + +TESTNAME='Dihedral RMSD tests' +Requires maxthreads 10 + +INPUT="-i dih.in" +UNITNAME='Dihedral RMSD test' +CheckFor netcdf +if [ $? -eq 0 ] ; then + cat > dih.in < dih.in < dih.in < dih.in < Date: Sat, 15 Jun 2019 14:15:50 -0400 Subject: [PATCH 06/26] DRR - Cpptraj: Make use of forward delcares. Make RefModeType public --- src/ReferenceAction.cpp | 1 + src/ReferenceAction.h | 15 ++++++++++++--- src/cpptrajdepend | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/ReferenceAction.cpp b/src/ReferenceAction.cpp index 451ada1179..e546952ef3 100644 --- a/src/ReferenceAction.cpp +++ b/src/ReferenceAction.cpp @@ -1,4 +1,5 @@ #include "ReferenceAction.h" +#include "DataSetList.h" #include "CpptrajStdio.h" #include "DataSet_Coords_TRJ.h" #include "ReferenceFrame.h" diff --git a/src/ReferenceAction.h b/src/ReferenceAction.h index 6b0c8d4622..90e3290dd1 100644 --- a/src/ReferenceAction.h +++ b/src/ReferenceAction.h @@ -1,12 +1,21 @@ #ifndef INC_REFERENCEACTION_H #define INC_REFERENCEACTION_H -#include "DataSetList.h" +#include +#include "Frame.h" #include "DataSet_Coords.h" +// Forward declarations +class DataSetList; +class ArgList; +class Topology; /// Class that can be used by Actions to hold a COORDS DataSet to use as reference. class ReferenceAction { public: ReferenceAction(); ~ReferenceAction(); + + /// Modes: FIRST=first frame, FRAME=given frame, TRAJ=reference traj + enum RefModeType { FIRST = 0, FRAME, TRAJ }; + /// Process all reference-related arguments, figure out reference mode. int InitRef(ArgList&, DataSetList const&, bool, bool); # ifdef MPI @@ -29,6 +38,8 @@ class ReferenceAction { Frame const& SelectedRef() const { return selectedRef_; } /// \return Translation vector from origin to original ref center. Vec3 const& RefTrans() const { return refTrans_; } + /// \return Current reference mode + RefModeType RefMode() const { return refMode_; } /// \return Help text static const char* Help() { return help_.c_str(); } /// \return Pointer to reference COORDS topology if possible. @@ -41,8 +52,6 @@ class ReferenceAction { void SelectRefAtoms(Frame const&); /// Set up ref mask for given topology. Allocate space for selected ref atoms. int SetupRefMask(Topology const&); - /// Modes: FIRST=first frame, FRAME=given frame, TRAJ=reference traj - enum RefModeType { FIRST = 0, FRAME, TRAJ }; RefModeType refMode_; ///< Reference mode. DataSet_Coords* refCrd_; ///< Reference COORDS DataSet. diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 94d90ca82c..4134609640 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -25,7 +25,7 @@ Action_DSSP.o : Action_DSSP.cpp Action.h ActionState.h Action_DSSP.h ArgList.h A Action_Density.o : Action_Density.cpp Action.h ActionState.h Action_Density.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImagedAction.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h Action_Diffusion.o : Action_Diffusion.cpp Action.h ActionState.h Action_Diffusion.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImagedAction.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h Action_Dihedral.o : Action_Dihedral.cpp Action.h ActionState.h Action_Dihedral.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.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 ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h Vec3.h -Action_DihedralRMS.o : Action_DihedralRMS.cpp Action.h ActionState.h Action_DihedralRMS.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DihedralSearch.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 ParameterTypes.h Range.h ReferenceAction.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h +Action_DihedralRMS.o : Action_DihedralRMS.cpp Action.h ActionState.h Action_DihedralRMS.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DihedralSearch.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 ParameterTypes.h Range.h ReferenceAction.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h Vec3.h Action_Dipole.o : Action_Dipole.cpp Action.h ActionState.h Action_Dipole.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridFlt.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h Grid.h GridAction.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h Action_DistRmsd.o : Action_DistRmsd.cpp Action.h ActionState.h Action_DistRmsd.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.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 ParameterTypes.h Range.h ReferenceAction.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h Action_Distance.o : Action_Distance.cpp Action.h ActionState.h Action_Distance.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.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 ImagedAction.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h From aa4941e0df5a59c3e16d1e242124442a514e1f10 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sat, 15 Jun 2019 14:37:16 -0400 Subject: [PATCH 07/26] DRR - Cpptraj: Add some reference setup --- src/Action_DihedralRMS.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Action_DihedralRMS.cpp b/src/Action_DihedralRMS.cpp index 960e695e5d..ec5d0e3caf 100644 --- a/src/Action_DihedralRMS.cpp +++ b/src/Action_DihedralRMS.cpp @@ -53,6 +53,7 @@ Action::RetType Action_DihedralRMS::Init(ArgList& actionArgs, ActionInit& init, return Action::OK; } +/** Fill the refVals_ array with reference dihedral values. */ int Action_DihedralRMS::GetRefDihedrals(Topology const& top, Frame const& frm) { Range actualRange = GetActualRange(top, refRange_); if (actualRange.Empty()) { @@ -64,6 +65,7 @@ int Action_DihedralRMS::GetRefDihedrals(Topology const& top, Frame const& frm) { mprinterr("Error: No dihedrals found in reference topology %s\n", top.c_str()); return 1; } + mprintf("DEBUG: %i reference dihedrals\n", dihSearch_.Ndihedrals()); // Calculate dihedrals refVals_.clear(); refVals_.reserve( dihSearch_.Ndihedrals() ); @@ -79,6 +81,9 @@ int Action_DihedralRMS::GetRefDihedrals(Topology const& top, Frame const& frm) { return 0; } +/** \return Range with actual residues to search for dihedrals in. If the + * given range is not set, will use all solute residues. + */ Range Action_DihedralRMS::GetActualRange(Topology const& top, Range const& resRange) const { Range actualRange; // If range is empty (i.e. no resrange arg given) look through all @@ -97,8 +102,34 @@ Range Action_DihedralRMS::GetActualRange(Topology const& top, Range const& resRa // Action_DihedralRMS::Setup() Action::RetType Action_DihedralRMS::Setup(ActionSetup& setup) { + // Fill the reference values if needed + if (refVals_.empty() && REF_.RefMode() == ReferenceAction::FRAME) { + // Sanity check + Topology* refTop = REF_.RefCrdTopPtr(); + if (refTop == 0) { + mprinterr("Internal Error: Reference topology is null.\n"); + return Action::ERR; + } + if (GetRefDihedrals( *refTop, REF_.CurrentReference() )) return Action::ERR; + // DEBUG + mprintf("DEBUG: Reference dihedral values (radians):\n"); + for (Darray::const_iterator it = refVals_.begin(); it != refVals_.end(); ++it) + mprintf("\t%8li %12.4f\n", it-refVals_.begin(), *it); + } + // Get the target range + Range actualRange = GetActualRange(setup.Top(), tgtRange_); + if (actualRange.Empty()) { + mprinterr("Error: No residues in topology %s\n", setup.Top().c_str()); + return Action::ERR; + } + // Search for specified dihedrals in each residue in the range + if (dihSearch_.FindDihedrals(setup.Top(), actualRange)) { + mprinterr("Error: No dihedrals found in topology %s\n", setup.Top().c_str()); + return Action::ERR; + } + mprintf("DEBUG: %i dihedrals\n", dihSearch_.Ndihedrals()); - return Action::ERR; + return Action::OK; } // Action_DihedralRMS::DoAction() From 2bcadf102d91f30040acad9e555c838662fd0b26 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 17 Jun 2019 08:04:45 -0400 Subject: [PATCH 08/26] DRR - Cpptraj: Do not print mask expression if no mask string is set. --- src/ReferenceAction.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ReferenceAction.cpp b/src/ReferenceAction.cpp index e546952ef3..24df40abf3 100644 --- a/src/ReferenceAction.cpp +++ b/src/ReferenceAction.cpp @@ -27,7 +27,8 @@ std::string ReferenceAction::RefModeString() const { modeString = "trajectory " + refCrd_->Meta().Legend(); else // FRAME modeString = "\"" + refCrd_->Meta().Legend() + "\""; - modeString += " (" + refMask_.MaskExpression() + ")"; + if (refMask_.MaskStringSet()) + modeString += " (" + refMask_.MaskExpression() + ")"; return modeString; } From 345bc87bb304e923ca763e41190e7bd175b75284 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 17 Jun 2019 08:19:42 -0400 Subject: [PATCH 09/26] DRR - Cpptraj: Add reference setup when no mask string set. Make -1 passed into SetupRef() mean do not check number selected atoms. --- src/Action_DihedralRMS.cpp | 7 ++++++- src/ReferenceAction.cpp | 16 +++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Action_DihedralRMS.cpp b/src/Action_DihedralRMS.cpp index ec5d0e3caf..47ef3d0fd0 100644 --- a/src/Action_DihedralRMS.cpp +++ b/src/Action_DihedralRMS.cpp @@ -102,6 +102,11 @@ Range Action_DihedralRMS::GetActualRange(Topology const& top, Range const& resRa // Action_DihedralRMS::Setup() Action::RetType Action_DihedralRMS::Setup(ActionSetup& setup) { + // Perform any reference setup. -1 means do not check number of selected + // atoms, which is not necessary because we are looking for dihedrals, + // not atoms. + if (REF_.SetupRef(setup.Top(), -1)) + return Action::SKIP; // Fill the reference values if needed if (refVals_.empty() && REF_.RefMode() == ReferenceAction::FRAME) { // Sanity check @@ -127,7 +132,7 @@ Action::RetType Action_DihedralRMS::Setup(ActionSetup& setup) mprinterr("Error: No dihedrals found in topology %s\n", setup.Top().c_str()); return Action::ERR; } - mprintf("DEBUG: %i dihedrals\n", dihSearch_.Ndihedrals()); + mprintf("\tSelected %i dihedrals\n", dihSearch_.Ndihedrals()); return Action::OK; } diff --git a/src/ReferenceAction.cpp b/src/ReferenceAction.cpp index 24df40abf3..e2b44b0e4f 100644 --- a/src/ReferenceAction.cpp +++ b/src/ReferenceAction.cpp @@ -126,10 +126,16 @@ int ReferenceAction::InitRef(ArgList& argIn, DataSetList const& DSLin, // ReferenceAction::SetupRefMask() int ReferenceAction::SetupRefMask(Topology const& topIn) { - if (topIn.SetupIntegerMask( refMask_ )) return 1; - mprintf("\tReference mask:"); - refMask_.BriefMaskInfo(); - mprintf("\n"); + if (refMask_.MaskStringSet()) { + if (topIn.SetupIntegerMask( refMask_ )) return 1; + mprintf("\tReference mask:"); + refMask_.BriefMaskInfo(); + mprintf("\n"); + } else { + refMask_.ResetMask(); + refMask_.SetNatoms( topIn.Natom() ); + refMask_.AddAtomRange(0, topIn.Natom() ); + } if (refMask_.None()) { mprinterr("Error: No reference atoms selected for parm %s, [%s]\n", topIn.c_str(), refMask_.MaskString()); @@ -170,7 +176,7 @@ int ReferenceAction::SetupRef(Topology const& topIn, int Ntgt) { needsSetup_ = false; } // Check that num atoms in target mask from this parm match ref parm mask - if ( refMask_.Nselected() != Ntgt ) { + if ( Ntgt != -1 && refMask_.Nselected() != Ntgt ) { mprintf("Warning: Number of atoms in target mask (%i) does not equal\n" "Warning: number of atoms in reference mask (%i).\n", Ntgt, refMask_.Nselected()); From cd76b8b028b4f799e508fa434340dd3dd3978139 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 17 Jun 2019 08:30:59 -0400 Subject: [PATCH 10/26] DRR - Cpptraj: Add rms previous test --- test/Test_RMSD/Previous.dat.save | 102 +++++++++++++++++++++++++++++++ test/Test_RMSD/RunTest.sh | 17 +++++- 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 test/Test_RMSD/Previous.dat.save diff --git a/test/Test_RMSD/Previous.dat.save b/test/Test_RMSD/Previous.dat.save new file mode 100644 index 0000000000..23bae5bc87 --- /dev/null +++ b/test/Test_RMSD/Previous.dat.save @@ -0,0 +1,102 @@ +#Frame ToPrevious + 1 0.0000 + 2 2.1102 + 3 2.6657 + 4 2.8798 + 5 2.2748 + 6 2.1173 + 7 1.4090 + 8 1.7446 + 9 1.1094 + 10 1.8847 + 11 1.4097 + 12 1.7047 + 13 1.5082 + 14 1.3011 + 15 2.0984 + 16 1.0750 + 17 1.0545 + 18 1.4590 + 19 1.5297 + 20 2.1662 + 21 1.5121 + 22 1.1485 + 23 0.9683 + 24 1.3260 + 25 1.3356 + 26 1.2075 + 27 1.2002 + 28 1.2428 + 29 1.1899 + 30 0.7560 + 31 0.7470 + 32 0.8129 + 33 0.7247 + 34 0.9262 + 35 0.9481 + 36 1.8451 + 37 1.3816 + 38 1.3536 + 39 1.0506 + 40 1.2662 + 41 1.0735 + 42 0.9529 + 43 1.2059 + 44 1.0675 + 45 0.6325 + 46 1.2733 + 47 1.2536 + 48 0.9471 + 49 1.3816 + 50 1.2726 + 51 1.3706 + 52 1.3910 + 53 1.1945 + 54 1.1893 + 55 0.8935 + 56 0.8008 + 57 1.0033 + 58 1.2264 + 59 1.0521 + 60 1.6308 + 61 1.4625 + 62 1.7002 + 63 2.0505 + 64 2.2386 + 65 1.1838 + 66 2.4704 + 67 1.6381 + 68 2.0139 + 69 1.3298 + 70 1.1375 + 71 2.0602 + 72 1.2243 + 73 1.5397 + 74 1.3060 + 75 0.8654 + 76 1.0908 + 77 1.4419 + 78 1.6556 + 79 1.4579 + 80 1.1345 + 81 1.4208 + 82 0.9251 + 83 1.0891 + 84 1.4585 + 85 1.5224 + 86 1.7205 + 87 0.7044 + 88 1.1861 + 89 1.2520 + 90 0.9204 + 91 1.3051 + 92 1.0254 + 93 1.3494 + 94 1.0139 + 95 1.2253 + 96 0.7153 + 97 1.4620 + 98 1.1131 + 99 1.2667 + 100 1.4925 + 101 1.2152 diff --git a/test/Test_RMSD/RunTest.sh b/test/Test_RMSD/RunTest.sh index fedde56ce7..13c4a5f948 100755 --- a/test/Test_RMSD/RunTest.sh +++ b/test/Test_RMSD/RunTest.sh @@ -6,7 +6,7 @@ CleanFiles rms.in rmsd.dat rms.mass.in rmsd.mass.dat rms.reftraj.in \ rmsd.reftraj.dat tz2.norotate.crd tz2.rotate.crd rmatrices.dat \ rmsd.refcoords.dat rms.dat NoMod.dat NoMod.crd.save NoMod.crd \ - vecs.dat + vecs.dat Previous.dat TESTNAME='RMSD tests' Requires netcdf @@ -75,6 +75,21 @@ RunCpptraj "RMS fit with no coordinates modification test." DoTest NoMod.dat.save NoMod.dat DoTest NoMod.crd.save NoMod.crd +# Test RMS 'previous' +UNITNAME='RMS fit to previous test' +CheckFor notparallel +if [ $? -eq 0 ] ; then + TOP='' + INPUT='-i rms.in' + cat > rms.in < Date: Mon, 17 Jun 2019 09:33:12 -0400 Subject: [PATCH 11/26] DRR - Cpptraj: Test rms first with changing topology --- test/Test_General/RunTest.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Test_General/RunTest.sh b/test/Test_General/RunTest.sh index e44d516446..1c31b5d003 100755 --- a/test/Test_General/RunTest.sh +++ b/test/Test_General/RunTest.sh @@ -5,7 +5,7 @@ # Clean CleanFiles general.in distance.dat rmsd.dat rmsda.dat phi2.dat PhiPsi.dat \ test.crd a1.dat Restart/* Restart test.nc r4.dat a2.dat.gz \ - a3.dat.bz2 r2.dat r3-nofit.dat + a3.dat.bz2 r2.dat r3-nofit.dat r5.dat TESTNAME='General tests' # Required environment @@ -30,7 +30,6 @@ reference ../tz2.rst7 angle a1 :2@CA :3@CA :4@CA out a1.dat angle a2 :2@CA :3@CA :4@CA out a2.dat.gz angle a3 :2@CA :3@CA :4@CA out a3.dat.bz2 -#rmsd r4 first out r4.dat :2-10 nofit rmsd r1 ref tz2.rst7 out rmsd.dat rmsd r1a refindex 0 out rmsda.dat rmsd r2 :1-4@C,CA,N ref tz2.rst7 :1-4@C,CA,N out r2.dat @@ -54,6 +53,7 @@ trajin ../tz2.crd \ 3 \ 2 +rmsd r5 first out r5.dat :2-5@N,CA,C nomod EOF INPUT="general.in" @@ -81,6 +81,7 @@ fi DoTest a3.dat.bz2.save a3.dat.bz2 DoTest r2.dat.save r2.dat DoTest r3-nofit.dat.save r3-nofit.dat +DoTest r5.dat.save r5.dat EndTest From a5a7a6de6506789431abde2649103652e0be6e5e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 17 Jun 2019 11:43:27 -0400 Subject: [PATCH 12/26] DRR - Cpptraj: Get rid of previous as a bool, add as a mode. Do not change modes during actions; this way classes using ReferenceAction always know how reference was selected. --- src/ReferenceAction.cpp | 34 +++++++++++++++++++--------------- src/ReferenceAction.h | 13 ++++++------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/ReferenceAction.cpp b/src/ReferenceAction.cpp index e2b44b0e4f..9edd9a8ed5 100644 --- a/src/ReferenceAction.cpp +++ b/src/ReferenceAction.cpp @@ -8,7 +8,6 @@ ReferenceAction::ReferenceAction() : refMode_( FIRST ), refCrd_( 0 ), traj_( 0 ), - previous_( false ), needsSetup_( false), fitRef_( false ), useMass_( false ) @@ -19,7 +18,7 @@ ReferenceAction::~ReferenceAction() { if (traj_ != 0) delete traj_; } // ReferenceAction::RefModeString() std::string ReferenceAction::RefModeString() const { std::string modeString; - if (previous_) + if (refMode_ == PREVIOUS) modeString = "previous frame"; else if (refMode_ == FIRST) modeString = "first frame"; @@ -40,7 +39,7 @@ std::string ReferenceAction::help_ = /** Should be called after InitRef(). */ int ReferenceAction::SetTrajComm( Parallel::Comm const& commIn ) { // Does not work for previous - if (previous_ && commIn.Size() > 1) { + if (refMode_ == PREVIOUS && commIn.Size() > 1) { mprinterr("Error: 'previous' reference does not work in parallel.\n"); return 1; } @@ -74,10 +73,11 @@ int ReferenceAction::InitRef(ArgList& argIn, DataSetList const& DSLin, { fitRef_ = fitRefIn; useMass_ = useMassIn; - previous_ = argIn.hasKey("previous"); // Attempt to determine reference mode. refMode_ = FIRST; // Default - if (!argIn.hasKey("first")) { + if (argIn.hasKey("previous")) { + refMode_ = PREVIOUS; + } else if (!argIn.hasKey("first")) { // Attempt to set refMode_ and refCrd_ if (argIn.Contains("reftraj")) { // Reference trajectory. First try to find COORDS or TRAJ. @@ -118,9 +118,9 @@ int ReferenceAction::InitRef(ArgList& argIn, DataSetList const& DSLin, /// Allocate space for reading Frame from COORDS if necessary if (refCrd_ != 0) { refFrame_ = refCrd_->AllocateFrame(); - needsSetup_ = true; } } + needsSetup_ = true; return 0; } @@ -164,16 +164,20 @@ void ReferenceAction::SelectRefAtoms(Frame const& frameIn) { // ReferenceAction::SetupRef() int ReferenceAction::SetupRef(Topology const& topIn, int Ntgt) { - if (refMode_ == FIRST) { - if ( SetupRefMask( topIn ) ) return 1; - } else if (previous_) { - mprintf("Warning: 'previous' may not work properly for changing topologies.\n"); - if ( SetupRefMask( topIn ) ) return 1; - } else if (needsSetup_) { // FRAME, TRAJ; only set up once. - if ( SetupRefMask( refCrd_->Top() ) ) return 1; - if (refMode_ == FRAME) - SelectRefAtoms( ((DataSet_Coords_REF*)refCrd_)->RefFrame() ); + if (needsSetup_) { + if (refMode_ == FIRST || refMode_ == PREVIOUS) { + // First frame or previous frame. Topology will be topIn. + if ( SetupRefMask( topIn ) ) return 1; + } else { + // Specified frame or trajectory. Accessed via refCrd_. + if ( SetupRefMask( refCrd_->Top() ) ) return 1; + if (refMode_ == FRAME) + SelectRefAtoms( ((DataSet_Coords_REF*)refCrd_)->RefFrame() ); + } needsSetup_ = false; + } else { + if (refMode_ == PREVIOUS) + mprintf("Warning: 'previous' may not work properly for changing topologies.\n"); } // Check that num atoms in target mask from this parm match ref parm mask if ( Ntgt != -1 && refMask_.Nselected() != Ntgt ) { diff --git a/src/ReferenceAction.h b/src/ReferenceAction.h index 90e3290dd1..b305da1a63 100644 --- a/src/ReferenceAction.h +++ b/src/ReferenceAction.h @@ -14,7 +14,7 @@ class ReferenceAction { ~ReferenceAction(); /// Modes: FIRST=first frame, FRAME=given frame, TRAJ=reference traj - enum RefModeType { FIRST = 0, FRAME, TRAJ }; + enum RefModeType { FIRST = 0, FRAME, TRAJ, PREVIOUS }; /// Process all reference-related arguments, figure out reference mode. int InitRef(ArgList&, DataSetList const&, bool, bool); @@ -61,7 +61,6 @@ class ReferenceAction { Frame selectedRef_; ///< Atoms from reference frame selected by refMask_. Vec3 refTrans_; ///< If fitting, translation from origin to original ref center. static std::string help_;///< Help text. - bool previous_; ///< True if current reference is previous frame (only RMSD now) bool needsSetup_; ///< True if ref from COORDS needs to be set up during SetupRef() bool fitRef_; ///< If true, move reference to origin for RMS fitting bool useMass_; ///< (If fitRef_) If true, move COM, otherwise geometric center. @@ -73,18 +72,18 @@ class ReferenceAction { // ReferenceAction::ActionRef() void ReferenceAction::ActionRef(int frameNum, Frame const& frameIn) { - if (refMode_ == FIRST) { - SelectRefAtoms( frameIn ); - refMode_ = FRAME; - } else if (refMode_ == TRAJ) { + if (refMode_ == TRAJ) { refCrd_->GetFrame( frameNum, refFrame_ ); selectedRef_.SetCoordinates(refFrame_, refMask_); if (fitRef_) refTrans_ = selectedRef_.CenterOnOrigin(useMass_); + } else if (refFrame_.empty()) { + // FIRST or first PREVIOUS + SelectRefAtoms( frameIn ); } } void ReferenceAction::PreviousRef(Frame const& frameIn) { - if (previous_) SelectRefAtoms( frameIn ); + if (refMode_ == PREVIOUS) SelectRefAtoms( frameIn ); } #endif From 4e6346df2c8cbbe4172d6884744211726dde6f43 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 17 Jun 2019 12:48:04 -0400 Subject: [PATCH 13/26] DRR - Cpptraj: Use separate DihedralSearch for selecting reference dihedrals. Finish up dihedral rms calculation. --- src/Action_DihedralRMS.cpp | 129 ++++++++++++++++++++++++++----------- src/Action_DihedralRMS.h | 6 +- src/cpptrajdepend | 2 +- 3 files changed, 97 insertions(+), 40 deletions(-) diff --git a/src/Action_DihedralRMS.cpp b/src/Action_DihedralRMS.cpp index 47ef3d0fd0..51143a676d 100644 --- a/src/Action_DihedralRMS.cpp +++ b/src/Action_DihedralRMS.cpp @@ -1,6 +1,8 @@ +#include // fabs, sqrt #include "Action_DihedralRMS.h" #include "CpptrajStdio.h" #include "TorsionRoutines.h" +#include "Constants.h" // Action_DihedralRMS::Help() void Action_DihedralRMS::Help() const { @@ -32,6 +34,8 @@ Action::RetType Action_DihedralRMS::Init(ArgList& actionArgs, ActionInit& init, if (dihSearch_.SearchForNewTypeArgs(actionArgs)) return Action::ERR; // If no dihedral types yet selected, this will select all. dihSearch_.SearchForAll(); + // Reference will try to select same types as target + refSearch_ = dihSearch_; // Setup DataSet(s) name std::string dsetname = actionArgs.GetStringNext(); // Setup output data set @@ -44,6 +48,7 @@ Action::RetType Action_DihedralRMS::Init(ArgList& actionArgs, ActionInit& init, mprintf(" DIHEDRAL RMSD: Calculating dihedral RMS for dihedrals:"); dihSearch_.PrintTypes(); + refSearch_.PrintTypes(); // DEBUG mprintf("\n"); if (!tgtRange_.Empty()) mprintf("\tTarget residue range: %s\n", tgtRange_.RangeArg()); @@ -53,24 +58,47 @@ Action::RetType Action_DihedralRMS::Init(ArgList& actionArgs, ActionInit& init, return Action::OK; } -/** Fill the refVals_ array with reference dihedral values. */ -int Action_DihedralRMS::GetRefDihedrals(Topology const& top, Frame const& frm) { +/** \return Range with actual residues to search for dihedrals in. If the + * given range is not set, will use all solute residues. + */ +Range Action_DihedralRMS::GetActualRange(Topology const& top, Range const& resRange) const { + Range actualRange; + // If range is empty (i.e. no resrange arg given) look through all + // solute residues. + if (resRange.Empty()) + actualRange = top.SoluteResidues(); + else { + // If user range specified, create new range shifted by -1 since internal + // resnums start from 0. + actualRange = resRange; + actualRange.ShiftBy(-1); + } + return actualRange; +} + +/** Find dihedrals in the reference structure.*/ +int Action_DihedralRMS::SetupRefDihedrals(Topology const& top) { Range actualRange = GetActualRange(top, refRange_); if (actualRange.Empty()) { mprinterr("Error: No residues in reference topology %s\n", top.c_str()); return 1; } // Search for specified dihedrals in each residue in the range - if (dihSearch_.FindDihedrals(top, actualRange)) { + if (refSearch_.FindDihedrals(top, actualRange)) { mprinterr("Error: No dihedrals found in reference topology %s\n", top.c_str()); return 1; } - mprintf("DEBUG: %i reference dihedrals\n", dihSearch_.Ndihedrals()); + mprintf("\tSelected %i reference dihedrals\n", refSearch_.Ndihedrals()); + return 0; +} + +/**Fill the refVals_ array with reference dihedral values. */ +int Action_DihedralRMS::CalcRefDihedrals(Frame const& frm) { // Calculate dihedrals refVals_.clear(); - refVals_.reserve( dihSearch_.Ndihedrals() ); - for (DihedralSearch::mask_it dih = dihSearch_.begin(); - dih != dihSearch_.end(); ++dih) + refVals_.reserve( refSearch_.Ndihedrals() ); + for (DihedralSearch::mask_it dih = refSearch_.begin(); + dih != refSearch_.end(); ++dih) { double torsion = Torsion( frm.XYZ(dih->A0()), frm.XYZ(dih->A1()), @@ -81,24 +109,6 @@ int Action_DihedralRMS::GetRefDihedrals(Topology const& top, Frame const& frm) { return 0; } -/** \return Range with actual residues to search for dihedrals in. If the - * given range is not set, will use all solute residues. - */ -Range Action_DihedralRMS::GetActualRange(Topology const& top, Range const& resRange) const { - Range actualRange; - // If range is empty (i.e. no resrange arg given) look through all - // solute residues. - if (resRange.Empty()) - actualRange = top.SoluteResidues(); - else { - // If user range specified, create new range shifted by -1 since internal - // resnums start from 0. - actualRange = resRange; - actualRange.ShiftBy(-1); - } - return actualRange; -} - // Action_DihedralRMS::Setup() Action::RetType Action_DihedralRMS::Setup(ActionSetup& setup) { @@ -107,20 +117,30 @@ Action::RetType Action_DihedralRMS::Setup(ActionSetup& setup) // not atoms. if (REF_.SetupRef(setup.Top(), -1)) return Action::SKIP; + // Perform any dihedral-specific setup for reference. // Fill the reference values if needed - if (refVals_.empty() && REF_.RefMode() == ReferenceAction::FRAME) { - // Sanity check - Topology* refTop = REF_.RefCrdTopPtr(); - if (refTop == 0) { - mprinterr("Internal Error: Reference topology is null.\n"); - return Action::ERR; + if (refVals_.empty()) { + if (REF_.RefMode() == ReferenceAction::FRAME || + REF_.RefMode() == ReferenceAction::TRAJ) + { + // Sanity check + Topology* refTop = REF_.RefCrdTopPtr(); + if (refTop == 0) { + mprinterr("Internal Error: Reference topology is null.\n"); + return Action::ERR; + } + if (SetupRefDihedrals( *refTop )) return Action::ERR; + if (CalcRefDihedrals( REF_.CurrentReference() )) return Action::ERR; + // DEBUG + mprintf("DEBUG: Reference dihedral values (radians):\n"); + for (Darray::const_iterator it = refVals_.begin(); it != refVals_.end(); ++it) + mprintf("\t%8li %12.4f\n", it-refVals_.begin(), *it); + } else { + // FIRST, PREVIOUS + if (SetupRefDihedrals( setup.Top() )) return Action::ERR; } - if (GetRefDihedrals( *refTop, REF_.CurrentReference() )) return Action::ERR; - // DEBUG - mprintf("DEBUG: Reference dihedral values (radians):\n"); - for (Darray::const_iterator it = refVals_.begin(); it != refVals_.end(); ++it) - mprintf("\t%8li %12.4f\n", it-refVals_.begin(), *it); } + // Get the target range Range actualRange = GetActualRange(setup.Top(), tgtRange_); if (actualRange.Empty()) { @@ -134,12 +154,47 @@ Action::RetType Action_DihedralRMS::Setup(ActionSetup& setup) } mprintf("\tSelected %i dihedrals\n", dihSearch_.Ndihedrals()); + if (dihSearch_.Ndihedrals() != refSearch_.Ndihedrals()) { + mprintf("Warning: # target dihedrals %i != # reference dihedrals %i. Skipping.\n", + dihSearch_.Ndihedrals(), refSearch_.Ndihedrals()); + return Action::SKIP; + } return Action::OK; } // Action_DihedralRMS::DoAction() Action::RetType Action_DihedralRMS::DoAction(int frameNum, ActionFrame& frm) { + // Perform any needed reference actions + REF_.ActionRef( frm.TrajoutNum(), frm.Frm() ); + if (REF_.RefMode() == ReferenceAction::TRAJ || refVals_.empty()) + CalcRefDihedrals( REF_.CurrentReference() ); + // Calculate dihedral rmsd + mprintf("DEBUG: Frame %i\n", frameNum); + double rms = 0.0; + double total_mass = (double)refVals_.size(); + Darray::const_iterator refv = refVals_.begin(); + for (DihedralSearch::mask_it dih = dihSearch_.begin(); + dih != dihSearch_.end(); ++dih, ++refv) + { + double torsion = Torsion( frm.Frm().XYZ(dih->A0()), + frm.Frm().XYZ(dih->A1()), + frm.Frm().XYZ(dih->A2()), + frm.Frm().XYZ(dih->A3()) ); + double diff = fabs(torsion - *refv); + mprintf("DEBUG:\t\tTgt = %12.4f Ref = %12.4f Diff = %12.4f", + torsion*Constants::RADDEG, + (*refv)*Constants::RADDEG, + diff*Constants::RADDEG); + if (diff > Constants::PI) + diff = Constants::TWOPI - diff; // TODO what if diff is > TWOPI? Can that happen? + mprintf(" AdjDiff = %12.4f\n", diff * Constants::RADDEG); + rms += (diff*diff); + } + rms = sqrt(rms / total_mass); + + rms = rms * Constants::RADDEG; - return Action::ERR; + dataOut_->Add(frameNum, &rms); + return Action::OK; } diff --git a/src/Action_DihedralRMS.h b/src/Action_DihedralRMS.h index 05d47a880b..dfcc8ade9b 100644 --- a/src/Action_DihedralRMS.h +++ b/src/Action_DihedralRMS.h @@ -18,9 +18,11 @@ class Action_DihedralRMS : public Action { typedef std::vector Darray; Range GetActualRange(Topology const&, Range const&) const; - int GetRefDihedrals(Topology const&, Frame const&); + int SetupRefDihedrals(Topology const&); + int CalcRefDihedrals(Frame const&); - DihedralSearch dihSearch_; ///< Used to select specified dihedrals + DihedralSearch dihSearch_; ///< Used to select specified dihedrals in target + DihedralSearch refSearch_; ///< Used to select specified dihedrals in reference ReferenceAction REF_; ///< Hold reference structure Darray refVals_; ///< Reference dihedral values in radians Range tgtRange_; diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 4134609640..94b9602c77 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -25,7 +25,7 @@ Action_DSSP.o : Action_DSSP.cpp Action.h ActionState.h Action_DSSP.h ArgList.h A Action_Density.o : Action_Density.cpp Action.h ActionState.h Action_Density.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImagedAction.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h Action_Diffusion.o : Action_Diffusion.cpp Action.h ActionState.h Action_Diffusion.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImagedAction.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h Action_Dihedral.o : Action_Dihedral.cpp Action.h ActionState.h Action_Dihedral.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.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 ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h Vec3.h -Action_DihedralRMS.o : Action_DihedralRMS.cpp Action.h ActionState.h Action_DihedralRMS.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DihedralSearch.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 ParameterTypes.h Range.h ReferenceAction.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h Vec3.h +Action_DihedralRMS.o : Action_DihedralRMS.cpp Action.h ActionState.h Action_DihedralRMS.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DihedralSearch.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 ParameterTypes.h Range.h ReferenceAction.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h Vec3.h Action_Dipole.o : Action_Dipole.cpp Action.h ActionState.h Action_Dipole.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridFlt.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h Grid.h GridAction.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h Action_DistRmsd.o : Action_DistRmsd.cpp Action.h ActionState.h Action_DistRmsd.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.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 ParameterTypes.h Range.h ReferenceAction.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h Action_Distance.o : Action_Distance.cpp Action.h ActionState.h Action_Distance.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h BaseIOtype.h Box.h CharMask.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataIO.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 ImagedAction.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h Vec3.h From 64054d6040402bc293a4b0806a19e172c0182598 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 17 Jun 2019 12:54:20 -0400 Subject: [PATCH 14/26] DRR - Cpptraj: Add to first and to reference tests. --- test/Test_DihedralRMS/RunTest.sh | 10 ++++++---- test/Test_DihedralRMS/dihrms.dat.save | 10 ++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 test/Test_DihedralRMS/dihrms.dat.save diff --git a/test/Test_DihedralRMS/RunTest.sh b/test/Test_DihedralRMS/RunTest.sh index 0349980a69..f81e1ce332 100755 --- a/test/Test_DihedralRMS/RunTest.sh +++ b/test/Test_DihedralRMS/RunTest.sh @@ -2,7 +2,7 @@ . ../MasterTest.sh -CleanFiles dih.in +CleanFiles dih.in dihrms.dat toref.dat TESTNAME='Dihedral RMSD tests' Requires maxthreads 10 @@ -14,11 +14,13 @@ if [ $? -eq 0 ] ; then cat > dih.in < Date: Mon, 17 Jun 2019 13:02:07 -0400 Subject: [PATCH 15/26] DRR - Cpptraj: Fix calc to previous ref --- src/Action_DihedralRMS.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Action_DihedralRMS.cpp b/src/Action_DihedralRMS.cpp index 51143a676d..8c6abd1c94 100644 --- a/src/Action_DihedralRMS.cpp +++ b/src/Action_DihedralRMS.cpp @@ -167,7 +167,9 @@ Action::RetType Action_DihedralRMS::DoAction(int frameNum, ActionFrame& frm) { // Perform any needed reference actions REF_.ActionRef( frm.TrajoutNum(), frm.Frm() ); - if (REF_.RefMode() == ReferenceAction::TRAJ || refVals_.empty()) + if (REF_.RefMode() == ReferenceAction::TRAJ || + REF_.RefMode() == ReferenceAction::PREVIOUS || + refVals_.empty()) CalcRefDihedrals( REF_.CurrentReference() ); // Calculate dihedral rmsd mprintf("DEBUG: Frame %i\n", frameNum); @@ -196,5 +198,7 @@ Action::RetType Action_DihedralRMS::DoAction(int frameNum, ActionFrame& frm) rms = rms * Constants::RADDEG; dataOut_->Add(frameNum, &rms); + + REF_.PreviousRef( frm.Frm() ); return Action::OK; } From cbf99ee2cd4bb6e24ddc2dbba044aff30154fb0b Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 17 Jun 2019 13:02:55 -0400 Subject: [PATCH 16/26] DRR - Cpptraj: Add to previous test --- test/Test_DihedralRMS/RunTest.sh | 6 ++++-- test/Test_DihedralRMS/previous.dat.save | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 test/Test_DihedralRMS/previous.dat.save diff --git a/test/Test_DihedralRMS/RunTest.sh b/test/Test_DihedralRMS/RunTest.sh index f81e1ce332..0ff803f8d1 100755 --- a/test/Test_DihedralRMS/RunTest.sh +++ b/test/Test_DihedralRMS/RunTest.sh @@ -2,7 +2,7 @@ . ../MasterTest.sh -CleanFiles dih.in dihrms.dat toref.dat +CleanFiles dih.in dihrms.dat toref.dat previous.dat TESTNAME='Dihedral RMSD tests' Requires maxthreads 10 @@ -17,10 +17,12 @@ trajin ../tz2.nc 1 10 reference ../tz2.nc 1 [MyRef] dihrms ToFirst out dihrms.dat noheader phi psi dihrms ToRef ref [MyRef] out toref.dat noheader phi psi +dihrms ToPrev previous out previous.dat phi psi EOF RunCpptraj "$UNITNAME" DoTest dihrms.dat.save dihrms.dat - DoTest dihrms.dat.save toref.dat + DoTest dihrms.dat.save toref.dat + DoTest previous.dat.save previous.dat fi Disable() { diff --git a/test/Test_DihedralRMS/previous.dat.save b/test/Test_DihedralRMS/previous.dat.save new file mode 100644 index 0000000000..c78f101699 --- /dev/null +++ b/test/Test_DihedralRMS/previous.dat.save @@ -0,0 +1,11 @@ +#Frame ToPrev + 1 0.0000 + 2 39.0806 + 3 34.0183 + 4 24.9326 + 5 30.9825 + 6 28.6087 + 7 24.0206 + 8 30.4697 + 9 29.4682 + 10 20.8620 From ff4d0c4a76e888cdd86b09307369a367cc52f782 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 17 Jun 2019 13:05:56 -0400 Subject: [PATCH 17/26] DRR - Cpptraj: Only calculate reference values during setup if mode is FRAME --- src/Action_DihedralRMS.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Action_DihedralRMS.cpp b/src/Action_DihedralRMS.cpp index 8c6abd1c94..6a83899ff6 100644 --- a/src/Action_DihedralRMS.cpp +++ b/src/Action_DihedralRMS.cpp @@ -130,11 +130,13 @@ Action::RetType Action_DihedralRMS::Setup(ActionSetup& setup) return Action::ERR; } if (SetupRefDihedrals( *refTop )) return Action::ERR; - if (CalcRefDihedrals( REF_.CurrentReference() )) return Action::ERR; - // DEBUG - mprintf("DEBUG: Reference dihedral values (radians):\n"); - for (Darray::const_iterator it = refVals_.begin(); it != refVals_.end(); ++it) - mprintf("\t%8li %12.4f\n", it-refVals_.begin(), *it); + if (REF_.RefMode() == ReferenceAction::FRAME) { + if (CalcRefDihedrals( REF_.CurrentReference() )) return Action::ERR; + // DEBUG + mprintf("DEBUG: Reference dihedral values (radians):\n"); + for (Darray::const_iterator it = refVals_.begin(); it != refVals_.end(); ++it) + mprintf("\t%8li %12.4f\n", it-refVals_.begin(), *it); + } } else { // FIRST, PREVIOUS if (SetupRefDihedrals( setup.Top() )) return Action::ERR; From 5050ea889e4f8a9d8075c4ba6665ae678a2a18cd Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 17 Jun 2019 13:07:18 -0400 Subject: [PATCH 18/26] DRR - Cpptraj: Add to reference traj test --- test/Test_DihedralRMS/RunTest.sh | 5 ++++- test/Test_DihedralRMS/totraj.dat.save | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/Test_DihedralRMS/totraj.dat.save diff --git a/test/Test_DihedralRMS/RunTest.sh b/test/Test_DihedralRMS/RunTest.sh index 0ff803f8d1..2513a1a9f9 100755 --- a/test/Test_DihedralRMS/RunTest.sh +++ b/test/Test_DihedralRMS/RunTest.sh @@ -2,7 +2,7 @@ . ../MasterTest.sh -CleanFiles dih.in dihrms.dat toref.dat previous.dat +CleanFiles dih.in dihrms.dat toref.dat previous.dat totraj.dat TESTNAME='Dihedral RMSD tests' Requires maxthreads 10 @@ -18,11 +18,14 @@ reference ../tz2.nc 1 [MyRef] dihrms ToFirst out dihrms.dat noheader phi psi dihrms ToRef ref [MyRef] out toref.dat noheader phi psi dihrms ToPrev previous out previous.dat phi psi +# NOTE: All calculated values for same traj should be 0.0 +dihrms ToTraj reftraj ../tz2.nc out totraj.dat phi psi EOF RunCpptraj "$UNITNAME" DoTest dihrms.dat.save dihrms.dat DoTest dihrms.dat.save toref.dat DoTest previous.dat.save previous.dat + DoTest totraj.dat.save totraj.dat fi Disable() { diff --git a/test/Test_DihedralRMS/totraj.dat.save b/test/Test_DihedralRMS/totraj.dat.save new file mode 100644 index 0000000000..0c29dd6b9d --- /dev/null +++ b/test/Test_DihedralRMS/totraj.dat.save @@ -0,0 +1,11 @@ +#Frame ToTraj + 1 0.0000 + 2 0.0000 + 3 0.0000 + 4 0.0000 + 5 0.0000 + 6 0.0000 + 7 0.0000 + 8 0.0000 + 9 0.0000 + 10 0.0000 From 46fc7e2ce33d7589a29191d050d464f164549465 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 17 Jun 2019 13:17:02 -0400 Subject: [PATCH 19/26] DRR - Cpptraj: Hide some debug info --- src/Action_DihedralRMS.cpp | 33 +++++++++++++++++++++++---------- src/Action_DihedralRMS.h | 4 ++-- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/Action_DihedralRMS.cpp b/src/Action_DihedralRMS.cpp index 6a83899ff6..2d6c265d7f 100644 --- a/src/Action_DihedralRMS.cpp +++ b/src/Action_DihedralRMS.cpp @@ -4,6 +4,12 @@ #include "TorsionRoutines.h" #include "Constants.h" +/// CONSTRUCTOR +Action_DihedralRMS::Action_DihedralRMS() : + dataOut_(0), + debug_(0) +{} + // Action_DihedralRMS::Help() void Action_DihedralRMS::Help() const { mprintf("\t[] [out ]\n" @@ -14,6 +20,7 @@ void Action_DihedralRMS::Help() const { // Action_DihedralRMS::Init() Action::RetType Action_DihedralRMS::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { + debug_ = debugIn; // Get keywords DataFile* outfile = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs); std::string tgtArg = actionArgs.GetStringKey("tgtrange"); @@ -48,8 +55,12 @@ Action::RetType Action_DihedralRMS::Init(ArgList& actionArgs, ActionInit& init, mprintf(" DIHEDRAL RMSD: Calculating dihedral RMS for dihedrals:"); dihSearch_.PrintTypes(); - refSearch_.PrintTypes(); // DEBUG mprintf("\n"); + if (debug_ > 0) { + mprintf("\tReference dihedrals:"); + refSearch_.PrintTypes(); // DEBUG + mprintf("\n"); + } if (!tgtRange_.Empty()) mprintf("\tTarget residue range: %s\n", tgtRange_.RangeArg()); if (!refRange_.Empty()) @@ -133,9 +144,11 @@ Action::RetType Action_DihedralRMS::Setup(ActionSetup& setup) if (REF_.RefMode() == ReferenceAction::FRAME) { if (CalcRefDihedrals( REF_.CurrentReference() )) return Action::ERR; // DEBUG - mprintf("DEBUG: Reference dihedral values (radians):\n"); - for (Darray::const_iterator it = refVals_.begin(); it != refVals_.end(); ++it) - mprintf("\t%8li %12.4f\n", it-refVals_.begin(), *it); + if (debug_ > 0) { + mprintf("DEBUG: Reference dihedral values (radians):\n"); + for (Darray::const_iterator it = refVals_.begin(); it != refVals_.end(); ++it) + mprintf("\t%8li %12.4f\n", it-refVals_.begin(), *it); + } } } else { // FIRST, PREVIOUS @@ -174,7 +187,7 @@ Action::RetType Action_DihedralRMS::DoAction(int frameNum, ActionFrame& frm) refVals_.empty()) CalcRefDihedrals( REF_.CurrentReference() ); // Calculate dihedral rmsd - mprintf("DEBUG: Frame %i\n", frameNum); + //mprintf("DEBUG: Frame %i\n", frameNum); double rms = 0.0; double total_mass = (double)refVals_.size(); Darray::const_iterator refv = refVals_.begin(); @@ -186,13 +199,13 @@ Action::RetType Action_DihedralRMS::DoAction(int frameNum, ActionFrame& frm) frm.Frm().XYZ(dih->A2()), frm.Frm().XYZ(dih->A3()) ); double diff = fabs(torsion - *refv); - mprintf("DEBUG:\t\tTgt = %12.4f Ref = %12.4f Diff = %12.4f", - torsion*Constants::RADDEG, - (*refv)*Constants::RADDEG, - diff*Constants::RADDEG); + //mprintf("DEBUG:\t\tTgt = %12.4f Ref = %12.4f Diff = %12.4f", + // torsion*Constants::RADDEG, + // (*refv)*Constants::RADDEG, + // diff*Constants::RADDEG); if (diff > Constants::PI) diff = Constants::TWOPI - diff; // TODO what if diff is > TWOPI? Can that happen? - mprintf(" AdjDiff = %12.4f\n", diff * Constants::RADDEG); + //mprintf(" AdjDiff = %12.4f\n", diff * Constants::RADDEG); rms += (diff*diff); } rms = sqrt(rms / total_mass); diff --git a/src/Action_DihedralRMS.h b/src/Action_DihedralRMS.h index dfcc8ade9b..779dd8113a 100644 --- a/src/Action_DihedralRMS.h +++ b/src/Action_DihedralRMS.h @@ -6,7 +6,7 @@ /// Calculate dihedral RMSD to reference class Action_DihedralRMS : public Action { public: - Action_DihedralRMS() {} + Action_DihedralRMS(); DispatchObject* Alloc() const { return (DispatchObject*)new Action_DihedralRMS(); } void Help() const; private: @@ -28,6 +28,6 @@ class Action_DihedralRMS : public Action { Range tgtRange_; Range refRange_; DataSet* dataOut_; ///< Output data set - + int debug_; }; #endif From 3f28c32196b61e95f7e50526d25ae0c350518897 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 17 Jun 2019 13:17:26 -0400 Subject: [PATCH 20/26] DRR - Cpptraj: Remove obsolete test stuff, split into parallel/not parallel tests --- test/Test_DihedralRMS/RunTest.sh | 44 ++++++-------------------------- 1 file changed, 8 insertions(+), 36 deletions(-) diff --git a/test/Test_DihedralRMS/RunTest.sh b/test/Test_DihedralRMS/RunTest.sh index 2513a1a9f9..7fcd4cf837 100755 --- a/test/Test_DihedralRMS/RunTest.sh +++ b/test/Test_DihedralRMS/RunTest.sh @@ -8,7 +8,8 @@ TESTNAME='Dihedral RMSD tests' Requires maxthreads 10 INPUT="-i dih.in" -UNITNAME='Dihedral RMSD test' + +UNITNAME='Dihedral RMSD tests (first, reference, reference traj.)' CheckFor netcdf if [ $? -eq 0 ] ; then cat > dih.in < dih.in < dih.in < dih.in < Date: Thu, 20 Jun 2019 08:42:58 -0400 Subject: [PATCH 21/26] DRR - Cpptraj: Add dihedral fluctuation (multidihedral plus avg) test --- test/Test_DihedralRMS/RunTest.sh | 28 ++++++++++++++-------- test/Test_DihedralRMS/phipsifluct.dat.save | 24 +++++++++++++++++++ 2 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 test/Test_DihedralRMS/phipsifluct.dat.save diff --git a/test/Test_DihedralRMS/RunTest.sh b/test/Test_DihedralRMS/RunTest.sh index 7fcd4cf837..8e025a8024 100755 --- a/test/Test_DihedralRMS/RunTest.sh +++ b/test/Test_DihedralRMS/RunTest.sh @@ -2,17 +2,15 @@ . ../MasterTest.sh -CleanFiles dih.in dihrms.dat toref.dat previous.dat totraj.dat +CleanFiles dih.in dihrms.dat toref.dat previous.dat totraj.dat phipsifluct.dat TESTNAME='Dihedral RMSD tests' -Requires maxthreads 10 +Requires netcdf maxthreads 10 INPUT="-i dih.in" UNITNAME='Dihedral RMSD tests (first, reference, reference traj.)' -CheckFor netcdf -if [ $? -eq 0 ] ; then - cat > dih.in < dih.in < dih.in < Date: Thu, 20 Jun 2019 08:43:56 -0400 Subject: [PATCH 22/26] DRR - Cpptraj: Revision bump for new dihrms command --- src/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Version.h b/src/Version.h index e324438b53..f3b2c9afaa 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 "V4.14.11" +#define CPPTRAJ_INTERNAL_VERSION "V4.14.12" /// PYTRAJ relies on this #define CPPTRAJ_VERSION_STRING CPPTRAJ_INTERNAL_VERSION #endif From 6ec9bdbd37746fc248b632e3e5c04988d01dca20 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 20 Jun 2019 12:44:28 -0400 Subject: [PATCH 23/26] DRR - Cpptraj: Take max of format specifier and actual data width when writing strings using Write --- src/DataSet_string.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DataSet_string.cpp b/src/DataSet_string.cpp index 9269d22a05..e533b8d86c 100644 --- a/src/DataSet_string.cpp +++ b/src/DataSet_string.cpp @@ -38,7 +38,8 @@ void DataSet_string::WriteBuffer(CpptrajFile &cbuffer, SizeArray const& pIn) con cbuffer.Printf(format_.fmt(), "NoData"); else { // Protect against CpptrajFile buffer overflow. - if (format_.Width() >= (int)CpptrajFile::BUF_SIZE) { + size_t maxWidth = std::max( (size_t)format_.Width(), Data_[pIn[0]].size() ); + if (maxWidth >= CpptrajFile::BUF_SIZE) { // FIXME: Data sets should not have to worry about spaces in format strings. if (format_.fmt()[0] == ' ') cbuffer.Printf(" "); cbuffer.Write(Data_[pIn[0]].c_str(), Data_[pIn[0]].size()); From be9e017c6cd2f7ed1032451a07dcc2994b7c6875 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 21 Jun 2019 11:02:52 -0400 Subject: [PATCH 24/26] DRR - Cpptraj: Add missing test save --- test/Test_General/r5.dat.save | 214 ++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 test/Test_General/r5.dat.save diff --git a/test/Test_General/r5.dat.save b/test/Test_General/r5.dat.save new file mode 100644 index 0000000000..ce2ef7cca6 --- /dev/null +++ b/test/Test_General/r5.dat.save @@ -0,0 +1,214 @@ +#Frame r5 + 1 0.0000 + 2 0.0000 + 3 1.1850 + 4 1.1708 + 5 1.2850 + 6 0.6151 + 7 0.9045 + 8 1.4247 + 9 0.9079 + 10 1.0859 + 11 1.3162 + 12 1.0245 + 13 0.9281 + 14 1.0085 + 15 0.8288 + 16 0.6763 + 17 0.4964 + 18 0.2562 + 19 0.5528 + 20 0.7463 + 21 0.8516 + 22 1.0801 + 23 0.8957 + 24 1.1432 + 25 0.3892 + 26 0.5452 + 27 0.7580 + 28 0.9466 + 29 0.8491 + 30 0.8016 + 31 0.7551 + 32 0.9414 + 33 0.7840 + 34 0.9734 + 35 0.9687 + 36 0.8601 + 37 0.6812 + 38 0.8393 + 39 0.7072 + 40 0.5148 + 41 0.8146 + 42 0.7216 + 43 0.8551 + 44 1.2741 + 45 0.8022 + 46 0.7130 + 47 1.2127 + 48 0.8550 + 49 0.7239 + 50 1.1310 + 51 0.5478 + 52 0.7971 + 53 0.6610 + 54 0.2956 + 55 1.1954 + 56 0.6131 + 57 0.6670 + 58 0.5715 + 59 1.0767 + 60 0.9006 + 61 0.5013 + 62 0.8088 + 63 0.6717 + 64 0.5124 + 65 0.6333 + 66 0.8486 + 67 0.9073 + 68 1.0784 + 69 0.6032 + 70 0.7067 + 71 0.7052 + 72 0.8756 + 73 0.9430 + 74 0.6022 + 75 1.0604 + 76 0.8103 + 77 0.6350 + 78 0.3590 + 79 0.3990 + 80 0.5811 + 81 0.4910 + 82 0.4671 + 83 0.7361 + 84 0.5911 + 85 0.7511 + 86 0.7276 + 87 0.6857 + 88 0.6339 + 89 0.8087 + 90 0.7831 + 91 0.7446 + 92 0.5410 + 93 0.4242 + 94 0.6532 + 95 0.6892 + 96 0.6801 + 97 0.6897 + 98 0.8750 + 99 0.4879 + 100 0.7086 + 101 0.6738 + 102 0.5204 + 103 1.0942 + 104 1.1031 + 105 1.0644 + 106 1.0894 + 107 1.1340 + 108 1.0581 + 109 1.1180 + 110 1.1553 + 111 1.1427 + 112 1.1073 + 113 1.0816 + 114 1.1616 + 115 1.2315 + 116 1.2892 + 117 1.1689 + 118 1.2546 + 119 1.1697 + 120 1.1758 + 121 1.2674 + 122 1.2345 + 123 1.2366 + 124 1.2577 + 125 1.2687 + 126 1.2344 + 127 1.1958 + 128 1.1945 + 129 1.2551 + 130 1.2822 + 131 1.1314 + 132 1.2044 + 133 1.1615 + 134 1.2156 + 135 1.1172 + 136 1.1073 + 137 1.1246 + 138 1.0797 + 139 1.0996 + 140 1.2875 + 141 1.1638 + 142 1.1800 + 143 1.1269 + 144 1.1905 + 145 1.0948 + 146 1.1647 + 147 1.2504 + 148 1.1497 + 149 1.1545 + 150 1.1550 + 151 1.0885 + 152 1.1089 + 153 1.2451 + 154 1.2341 + 155 1.1796 + 156 1.1658 + 157 1.1737 + 158 1.0988 + 159 1.0619 + 160 1.0786 + 161 1.2579 + 162 1.2307 + 163 1.2206 + 164 1.0860 + 165 1.1353 + 166 1.0305 + 167 1.0594 + 168 1.1583 + 169 1.2574 + 170 1.1668 + 171 1.1389 + 172 1.1283 + 173 1.0780 + 174 1.1931 + 175 1.1012 + 176 1.1307 + 177 1.1870 + 178 1.2431 + 179 1.0467 + 180 1.1883 + 181 1.0451 + 182 1.2454 + 183 1.1814 + 184 1.2291 + 185 1.0367 + 186 1.1531 + 187 1.1620 + 188 1.0861 + 189 1.2717 + 190 1.1612 + 191 1.0674 + 192 1.1354 + 193 1.0611 + 194 1.0979 + 195 0.9436 + 196 1.0598 + 197 1.2721 + 198 1.2309 + 199 1.1786 + 200 1.3078 + 201 1.2338 + 202 1.1076 + 203 1.0823 + 204 1.1058 + 205 1.2004 + 206 1.1657 + 207 1.2070 + 208 1.1077 + 209 1.1680 + 210 1.1233 + 211 1.1923 + 212 1.1791 + 213 1.1850 From 4e27f8257ec752e658b8574fafe0995f6c721c9d Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 21 Jun 2019 13:26:15 -0400 Subject: [PATCH 25/26] DRR - Cpptraj: Enabled dihedral rms test. --- test/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index 86eb7e97bf..15062eae2d 100644 --- a/test/Makefile +++ b/test/Makefile @@ -453,6 +453,9 @@ test.time: test.splitcoords: @-cd Test_SplitCoords && ./RunTest.sh $(OPT) +test.dihedralrms: + @-cd Test_DihedralRMS && ./RunTest.sh $(OPT) + # Every test target should go here. COMPLETETESTS=test.general \ test.strip \ @@ -598,7 +601,8 @@ COMPLETETESTS=test.general \ test.catcrd \ test.xtalsymm \ test.time \ - test.splitcoords + test.splitcoords \ + test.dihedralrms test.all: $(MAKE) test.complete summary From 6e8581b7df1b23c921d4518057b591b3b1e148a2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 21 Jun 2019 14:15:30 -0400 Subject: [PATCH 26/26] DRR - Cpptraj: Add missing include --- src/DataSet_string.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DataSet_string.cpp b/src/DataSet_string.cpp index e533b8d86c..3db69d5218 100644 --- a/src/DataSet_string.cpp +++ b/src/DataSet_string.cpp @@ -1,3 +1,4 @@ +#include // std::max #include "DataSet_string.h" size_t DataSet_string::MemUsageInBytes() const {