From 529ee1e5124f4c656e9d13387b32cc50b49d927b Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 09:08:11 -0400 Subject: [PATCH 01/17] Initial incarnation of the graft command. --- src/Command.cpp | 2 ++ src/Exec_Graft.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++++ src/Exec_Graft.h | 12 ++++++++++++ src/cpptrajdepend | 3 ++- src/cpptrajfiles | 1 + 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/Exec_Graft.cpp create mode 100644 src/Exec_Graft.h diff --git a/src/Command.cpp b/src/Command.cpp index 558ad036b7..f6f1786e9d 100644 --- a/src/Command.cpp +++ b/src/Command.cpp @@ -41,6 +41,7 @@ #include "Exec_CrdAction.h" #include "Exec_CrdOut.h" #include "Exec_Emin.h" +#include "Exec_Graft.h" #include "Exec_LoadCrd.h" #include "Exec_LoadTraj.h" #include "Exec_PermuteDihedrals.h" @@ -249,6 +250,7 @@ void Command::Init() { Command::AddCmd( new Exec_CrdAction(), Cmd::EXE, 1, "crdaction" ); Command::AddCmd( new Exec_CrdOut(), Cmd::EXE, 1, "crdout" ); Command::AddCmd( new Exec_Emin(), Cmd::EXE, 1, "emin"); // hidden + Command::AddCmd( new Exec_Graft(), Cmd::EXE, 1, "graft"); Command::AddCmd( new Exec_LoadCrd(), Cmd::EXE, 1, "loadcrd" ); Command::AddCmd( new Exec_LoadTraj(), Cmd::EXE, 1, "loadtraj" ); Command::AddCmd( new Exec_PermuteDihedrals(), Cmd::EXE, 1, "permutedihedrals" ); diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp new file mode 100644 index 0000000000..5954edbe71 --- /dev/null +++ b/src/Exec_Graft.cpp @@ -0,0 +1,47 @@ +#include "Exec_Graft.h" +#include "CpptrajStdio.h" +#include "DataSet_Coords.h" + +// Exec_Graft::Help() +void Exec_Graft::Help() const +{ + mprintf("\tsrc srcmask \n" + "\ttgt \n"); +} + +// Exec_Graft::Execute() +Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) +{ + // Get source coords + std::string kw = argIn.GetStringKey("src"); + if (kw.empty()) { + mprinterr("Error: Source COORDS must be specified with 'src'.\n"); + return CpptrajState::ERR; + } + DataSet_Coords* srcCoords = (DataSet_Coords*)State.DSL().FindSetOfGroup(kw, DataSet::COORDINATES); + if (srcCoords == 0) { + mprinterr("Error: Source COORDS %s not found.\n", kw.c_str()); + return CpptrajState::ERR; + } + // Get target coords + kw = argIn.GetStringKey("tgt"); + if (kw.empty()) { + mprinterr("Error: Target COORDS must be specified with 'tgt'.\n"); + return CpptrajState::ERR; + } + DataSet_Coords* tgtCoords = (DataSet_Coords*)State.DSL().FindSetOfGroup(kw, DataSet::COORDINATES); + if (tgtCoords == 0) { + mprinterr("Error: Target COORDS %s not found.\n", kw.c_str()); + return CpptrajState::ERR; + } + // Get other keywords + AtomMask srcMask; + srcMask.SetMaskString( argIn.GetStringKey("srcmask") ); + + // Info + mprintf("\tSource coords : %s\n", srcCoords->legend()); + mprintf("\tTarget coords : %s\n", tgtCoords->legend()); + mprintf("\tSource mask : %s\n", srcMask.MaskString()); + + return CpptrajState::OK; +} diff --git a/src/Exec_Graft.h b/src/Exec_Graft.h new file mode 100644 index 0000000000..d3f8840626 --- /dev/null +++ b/src/Exec_Graft.h @@ -0,0 +1,12 @@ +#ifndef INC_EXEC_GRAFT_H +#define INC_EXEC_GRAFT_H +#include "Exec.h" +/// Graft part of one COORDS to another COORDS +class Exec_Graft : public Exec { + public: + Exec_Graft() : Exec(COORDS) {} + void Help() const; + DispatchObject* Alloc() const { return (DispatchObject*)new Exec_Graft(); } + RetType Execute(CpptrajState&, ArgList&); +}; +#endif diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 2c2a4481c8..b6b868c7f1 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -159,7 +159,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 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_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 AtomExtra.h AtomMap.h AtomMask.h AtomType.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 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 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 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_Emin.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_PrepareForLeap.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_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 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 ParameterSet.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 TypeNameHolder.h Vec3.h cuda_kernels/GistCudaSetup.cuh 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_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_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 AtomExtra.h AtomMap.h AtomMask.h AtomType.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 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 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 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_Emin.h Exec_GenerateAmberRst.h Exec_Graft.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_PrepareForLeap.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_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 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 ParameterSet.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 TypeNameHolder.h Vec3.h cuda_kernels/GistCudaSetup.cuh molsurf.h ComplexArray.o : ComplexArray.cpp ArrayIterator.h ComplexArray.h Constraints.o : Constraints.cpp ArgList.h Atom.h AtomExtra.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 SymbolExporting.h Topology.h TypeNameHolder.h Vec3.h ControlBlock_For.o : ControlBlock_For.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h ControlBlock.h ControlBlock_For.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.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 ForLoop.h ForLoop_dataSetBlocks.h ForLoop_integer.h ForLoop_list.h ForLoop_mask.h ForLoop_overSets.h Frame.h FramePtrArray.h InputTrajCommon.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 ReplicaInfo.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Vec3.h @@ -258,6 +258,7 @@ Exec_DataFilter.o : Exec_DataFilter.cpp Action.h ActionList.h ActionState.h Acti Exec_DataSetCmd.o : Exec_DataSetCmd.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h AtomType.h BaseIOtype.h Box.h ComplexArray.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixDbl.h DataSet_Mesh.h DataSet_Vector.h DataSet_string.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_DataSetCmd.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Spline.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Vec3.h Exec_Emin.o : Exec_Emin.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h AtomType.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnergyArray.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Emin.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Minimize_SteepestDescent.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h PotentialFunction.h PotentialTerm.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Vec3.h Exec_GenerateAmberRst.o : Exec_GenerateAmberRst.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h DistRoutines.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_GenerateAmberRst.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 ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Vec3.h +Exec_Graft.o : Exec_Graft.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Graft.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 ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Vec3.h Exec_Help.o : Exec_Help.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h AtomType.h BaseIOtype.h Box.h Cmd.h CmdList.h Command.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Help.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 ParameterHolders.h ParameterSet.h ParameterTypes.h ParmFile.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Vec3.h Exec_LoadCrd.o : Exec_LoadCrd.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_LoadCrd.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 ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h Trajin_Single.h TrajoutList.h TypeNameHolder.h Vec3.h Exec_LoadTraj.o : Exec_LoadTraj.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomExtra.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_Coords_TRJ.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_LoadTraj.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 ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajFrameIndex.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Vec3.h diff --git a/src/cpptrajfiles b/src/cpptrajfiles index bfb6216e2f..cb7c051201 100644 --- a/src/cpptrajfiles +++ b/src/cpptrajfiles @@ -258,6 +258,7 @@ COMMON_SOURCES= \ Exec_DataSetCmd.cpp \ Exec_Emin.cpp \ Exec_GenerateAmberRst.cpp \ + Exec_Graft.cpp \ Exec_Help.cpp \ Exec_LoadCrd.cpp \ Exec_LoadTraj.cpp \ From a145e32af8b98ced1c5aeefbeac9b34536af0fdd Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 09:15:37 -0400 Subject: [PATCH 02/17] Start adding a graft test --- test/Test_Graft/RunTest.sh | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 test/Test_Graft/RunTest.sh diff --git a/test/Test_Graft/RunTest.sh b/test/Test_Graft/RunTest.sh new file mode 100755 index 0000000000..d13ce19dea --- /dev/null +++ b/test/Test_Graft/RunTest.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +. ../MasterTest.sh + +CleanFiles cpptraj.in +TESTNAME='Graft test' +Requires notparallel + +INPUT="-i cpptraj.in" +# Combine Tyr FF14SB backbone + CB with PRY fragment +cat > cpptraj.in < Date: Tue, 18 Aug 2020 09:30:06 -0400 Subject: [PATCH 03/17] Add target and source fit masks. --- src/Exec_Graft.cpp | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 5954edbe71..9aa73c6d11 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -34,14 +34,46 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) mprinterr("Error: Target COORDS %s not found.\n", kw.c_str()); return CpptrajState::ERR; } - // Get other keywords + // Get atoms to keep from source. AtomMask srcMask; - srcMask.SetMaskString( argIn.GetStringKey("srcmask") ); + if (srcMask.SetMaskString( argIn.GetStringKey("srcmask") )) + return CpptrajState::ERR; + // Get atoms from source to fit on target, and atoms from target + // for source to fit on. + AtomMask srcFitMask, tgtFitMask; + std::string srcfitstr = argIn.GetStringKey("srcfitmask"); + std::string tgtfitstr = argIn.GetStringKey("tgtfitmask"); + bool doRmsFit = false; + if (!srcfitstr.empty() || !tgtfitstr.empty()) { + doRmsFit = true; + // If either is empty, fill with the other. + if (srcfitstr.empty()) + srcfitstr = tgtfitstr; + else if (tgtfitstr.empty()) + tgtfitstr = srcfitstr; + if (srcFitMask.SetMaskString( srcfitstr )) + return CpptrajState::ERR; + if (tgtFitMask.SetMaskString( tgtfitstr )) + return CpptrajState::ERR; + // Set up the masks. + if (srcCoords->Top().SetupIntegerMask(srcFitMask)) + return CpptrajState::ERR; + if (tgtCoords->Top().SetupIntegerMask(tgtFitMask)) + return CpptrajState::ERR; + } + // Info - mprintf("\tSource coords : %s\n", srcCoords->legend()); - mprintf("\tTarget coords : %s\n", tgtCoords->legend()); - mprintf("\tSource mask : %s\n", srcMask.MaskString()); + mprintf("\tSource coords : %s\n", srcCoords->legend()); + mprintf("\tTarget coords : %s\n", tgtCoords->legend()); + mprintf("\tSource mask : %s\n", srcMask.MaskString()); + if (doRmsFit) { + mprintf( "\tSource fit mask :"); + srcFitMask.BriefMaskInfo(); + mprintf("\n\tTarget fit mask :"); + tgtFitMask.BriefMaskInfo(); + mprintf("\n"); + } return CpptrajState::OK; } From 4fdb9cb2f1cc26dfdc1aa95425bdf9fd6322125e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 09:32:47 -0400 Subject: [PATCH 04/17] Do atom selection for source mask. --- src/Exec_Graft.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 9aa73c6d11..60ac41022c 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -38,6 +38,8 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) AtomMask srcMask; if (srcMask.SetMaskString( argIn.GetStringKey("srcmask") )) return CpptrajState::ERR; + if (srcCoords->Top().SetupIntegerMask(srcMask)) + return CpptrajState::ERR; // Get atoms from source to fit on target, and atoms from target // for source to fit on. AtomMask srcFitMask, tgtFitMask; @@ -66,7 +68,9 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) // Info mprintf("\tSource coords : %s\n", srcCoords->legend()); mprintf("\tTarget coords : %s\n", tgtCoords->legend()); - mprintf("\tSource mask : %s\n", srcMask.MaskString()); + mprintf("\tSource mask :"); + srcMask.BriefMaskInfo(); + mprintf("\n"); if (doRmsFit) { mprintf( "\tSource fit mask :"); srcFitMask.BriefMaskInfo(); From 90de3fef63a3e456fd2739914328da2dceb2530a Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 10:10:22 -0400 Subject: [PATCH 05/17] Add output COORDS, getting frames, and rms fit --- src/Exec_Graft.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 60ac41022c..3bf852c499 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -5,8 +5,9 @@ // Exec_Graft::Help() void Exec_Graft::Help() const { - mprintf("\tsrc srcmask \n" - "\ttgt \n"); + mprintf("\tsrc [srcframe <#>] [srcfitmask ] [srcmask ]\n" + "\ttgt [tgtframe <#>] [tgtfitmask ]\n" + "\tname \n"); } // Exec_Graft::Execute() @@ -23,6 +24,8 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) mprinterr("Error: Source COORDS %s not found.\n", kw.c_str()); return CpptrajState::ERR; } + Frame srcFrame = srcCoords->AllocateFrame(); + srcCoords->GetFrame(argIn.getKeyInt("srcframe", 1)-1, srcFrame); // Get target coords kw = argIn.GetStringKey("tgt"); if (kw.empty()) { @@ -34,6 +37,19 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) mprinterr("Error: Target COORDS %s not found.\n", kw.c_str()); return CpptrajState::ERR; } + Frame tgtFrame = tgtCoords->AllocateFrame(); + tgtCoords->GetFrame(argIn.getKeyInt("tgtframe", 1)-1, tgtFrame); + // Create output coords + kw = argIn.GetStringKey("name"); + if (kw.empty()) { + mprinterr("Error: Output COORDS must be specified with 'name'.\n"); + return CpptrajState::ERR; + } + DataSet_Coords* outCoords = (DataSet_Coords*)State.DSL().AddSet(DataSet::COORDS, MetaData(kw)); + if (outCoords == 0) { + mprinterr("Error: Output COORDS %s could not be created.\n", kw.c_str()); + return CpptrajState::ERR; + } // Get atoms to keep from source. AtomMask srcMask; if (srcMask.SetMaskString( argIn.GetStringKey("srcmask") )) @@ -68,6 +84,7 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) // Info mprintf("\tSource coords : %s\n", srcCoords->legend()); mprintf("\tTarget coords : %s\n", tgtCoords->legend()); + mprintf("\tOutput coords : %s\n", outCoords->legend()); mprintf("\tSource mask :"); srcMask.BriefMaskInfo(); mprintf("\n"); @@ -77,7 +94,24 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) mprintf("\n\tTarget fit mask :"); tgtFitMask.BriefMaskInfo(); mprintf("\n"); + if (srcFitMask.Nselected() != tgtFitMask.Nselected()) { + mprinterr("Error: RMS-fit requires same # of atoms selected in source and target.\n"); + return CpptrajState::ERR; + } + // Source gets RMS fit to target (reference) + Frame srcFitFrame; + srcFitFrame.SetupFrameFromMask(srcFitMask, srcCoords->Top().Atoms()); + srcFitFrame.SetCoordinates(srcFrame, srcFitMask); + Frame tgtFitFrame; + tgtFitFrame.SetupFrameFromMask(tgtFitMask, tgtCoords->Top().Atoms()); + tgtFitFrame.SetCoordinates(tgtFrame, tgtFitMask); + Vec3 refTrans = tgtFitFrame.CenterOnOrigin(false); + Matrix_3x3 Rot; + Vec3 Trans; + srcFitFrame.RMSD_CenteredRef( tgtFitFrame, Rot, Trans, false ); + srcFrame.Trans_Rot_Trans( Trans, Rot, refTrans ); } + return CpptrajState::OK; } From 2883f066835f1b66d798c6c95592561943bc6a6e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 10:27:07 -0400 Subject: [PATCH 06/17] Add initial combination code --- src/Exec_Graft.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 3bf852c499..83dde92db6 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -1,6 +1,7 @@ #include "Exec_Graft.h" #include "CpptrajStdio.h" #include "DataSet_Coords.h" +#include // std::copy // Exec_Graft::Help() void Exec_Graft::Help() const @@ -112,6 +113,25 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) srcFrame.Trans_Rot_Trans( Trans, Rot, refTrans ); } + // Combine topologies. Use target box info. + Topology combinedTop; + combinedTop.SetDebug( State.Debug() ); + combinedTop.SetParmName( outCoords->Meta().Name(), FileName() ); + combinedTop.AppendTop( tgtCoords->Top() ); + // TODO do any tgt mods here? + combinedTop.AppendTop( srcCoords->Top() ); + combinedTop.SetParmBox( tgtFrame.BoxCrd() ); + combinedTop.Brief("Grafted parm:"); + + // Output coords. + // Only coords+box for now. + CoordinateInfo outInfo(tgtFrame.BoxCrd(), false, false, false); + if (outCoords->CoordsSetup(combinedTop, outInfo)) return CpptrajState::ERR; + Frame CombinedFrame = outCoords->AllocateFrame(); + std::copy(tgtFrame.xAddress(), tgtFrame.xAddress()+tgtFrame.size(), CombinedFrame.xAddress()); + std::copy(srcFrame.xAddress(), srcFrame.xAddress()+srcFrame.size(), CombinedFrame.xAddress()+tgtFrame.size()); + CombinedFrame.SetBox( tgtFrame.BoxCrd() ); + outCoords->AddFrame( CombinedFrame ); return CpptrajState::OK; } From 5f0be6c61a20b0e5cd99361c651a145e07ce7475 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 10:40:15 -0400 Subject: [PATCH 07/17] Modify source --- src/Exec_Graft.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 83dde92db6..f970feff5b 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -81,7 +81,6 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) return CpptrajState::ERR; } - // Info mprintf("\tSource coords : %s\n", srcCoords->legend()); mprintf("\tTarget coords : %s\n", tgtCoords->legend()); @@ -113,13 +112,27 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) srcFrame.Trans_Rot_Trans( Trans, Rot, refTrans ); } + // Modify source if needed. + Topology* srcTopPtr = srcCoords->TopPtr(); + Frame* srcFrmPtr = &srcFrame; + if (srcMask.Nselected() != srcCoords->Top().Natom()) { + srcTopPtr = srcCoords->Top().modifyStateByMask( srcMask ); + if (srcTopPtr == 0) { + mprinterr("Error: Could not modify source topology.\n"); + return CpptrajState::ERR; + } + srcFrmPtr = new Frame(); + srcFrmPtr->SetupFrameV(srcTopPtr->Atoms(), srcCoords->CoordsInfo()); + srcFrmPtr->SetFrame(srcFrame, srcMask); + } + // Combine topologies. Use target box info. Topology combinedTop; combinedTop.SetDebug( State.Debug() ); combinedTop.SetParmName( outCoords->Meta().Name(), FileName() ); combinedTop.AppendTop( tgtCoords->Top() ); // TODO do any tgt mods here? - combinedTop.AppendTop( srcCoords->Top() ); + combinedTop.AppendTop( *srcTopPtr ); combinedTop.SetParmBox( tgtFrame.BoxCrd() ); combinedTop.Brief("Grafted parm:"); @@ -129,9 +142,15 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) if (outCoords->CoordsSetup(combinedTop, outInfo)) return CpptrajState::ERR; Frame CombinedFrame = outCoords->AllocateFrame(); std::copy(tgtFrame.xAddress(), tgtFrame.xAddress()+tgtFrame.size(), CombinedFrame.xAddress()); - std::copy(srcFrame.xAddress(), srcFrame.xAddress()+srcFrame.size(), CombinedFrame.xAddress()+tgtFrame.size()); + std::copy(srcFrmPtr->xAddress(), srcFrmPtr->xAddress()+srcFrmPtr->size(), CombinedFrame.xAddress()+tgtFrame.size()); CombinedFrame.SetBox( tgtFrame.BoxCrd() ); outCoords->AddFrame( CombinedFrame ); + // Free memory if needed + if (srcTopPtr != srcCoords->TopPtr()) { + delete srcTopPtr; + delete srcFrmPtr; + } + return CpptrajState::OK; } From 8bcedc5c27ef95315bcc615a8f6b168189b490df Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 10:51:41 -0400 Subject: [PATCH 08/17] Modify target if needed. --- src/Exec_Graft.cpp | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index f970feff5b..297f2e7026 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -57,6 +57,12 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) return CpptrajState::ERR; if (srcCoords->Top().SetupIntegerMask(srcMask)) return CpptrajState::ERR; + // Get atoms to keep from target. + AtomMask tgtMask; + if (tgtMask.SetMaskString( argIn.GetStringKey("tgtmask") )) + return CpptrajState::ERR; + if (tgtCoords->Top().SetupIntegerMask(tgtMask)) + return CpptrajState::ERR; // Get atoms from source to fit on target, and atoms from target // for source to fit on. AtomMask srcFitMask, tgtFitMask; @@ -88,6 +94,9 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) mprintf("\tSource mask :"); srcMask.BriefMaskInfo(); mprintf("\n"); + mprintf("\tTarget mask :"); + tgtMask.BriefMaskInfo(); + mprintf("\n"); if (doRmsFit) { mprintf( "\tSource fit mask :"); srcFitMask.BriefMaskInfo(); @@ -126,24 +135,38 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) srcFrmPtr->SetFrame(srcFrame, srcMask); } + // Modify target if needed. + Topology* tgtTopPtr = tgtCoords->TopPtr(); + Frame* tgtFrmPtr = &tgtFrame; + if (tgtMask.Nselected() != tgtCoords->Top().Natom()) { + tgtTopPtr = tgtCoords->Top().modifyStateByMask( tgtMask ); + if (tgtTopPtr == 0) { + mprinterr("Error: Could not modify target topology.\n"); + return CpptrajState::ERR; + } + tgtFrmPtr = new Frame(); + tgtFrmPtr->SetupFrameV(tgtTopPtr->Atoms(), tgtCoords->CoordsInfo()); + tgtFrmPtr->SetFrame(tgtFrame, tgtMask); + } + // Combine topologies. Use target box info. Topology combinedTop; combinedTop.SetDebug( State.Debug() ); combinedTop.SetParmName( outCoords->Meta().Name(), FileName() ); - combinedTop.AppendTop( tgtCoords->Top() ); + combinedTop.AppendTop( *tgtTopPtr ); // TODO do any tgt mods here? combinedTop.AppendTop( *srcTopPtr ); - combinedTop.SetParmBox( tgtFrame.BoxCrd() ); + combinedTop.SetParmBox( tgtFrmPtr->BoxCrd() ); combinedTop.Brief("Grafted parm:"); // Output coords. // Only coords+box for now. - CoordinateInfo outInfo(tgtFrame.BoxCrd(), false, false, false); + CoordinateInfo outInfo(tgtFrmPtr->BoxCrd(), false, false, false); if (outCoords->CoordsSetup(combinedTop, outInfo)) return CpptrajState::ERR; Frame CombinedFrame = outCoords->AllocateFrame(); - std::copy(tgtFrame.xAddress(), tgtFrame.xAddress()+tgtFrame.size(), CombinedFrame.xAddress()); - std::copy(srcFrmPtr->xAddress(), srcFrmPtr->xAddress()+srcFrmPtr->size(), CombinedFrame.xAddress()+tgtFrame.size()); - CombinedFrame.SetBox( tgtFrame.BoxCrd() ); + std::copy(tgtFrmPtr->xAddress(), tgtFrmPtr->xAddress()+tgtFrmPtr->size(), CombinedFrame.xAddress()); + std::copy(srcFrmPtr->xAddress(), srcFrmPtr->xAddress()+srcFrmPtr->size(), CombinedFrame.xAddress()+tgtFrmPtr->size()); + CombinedFrame.SetBox( tgtFrmPtr->BoxCrd() ); outCoords->AddFrame( CombinedFrame ); // Free memory if needed @@ -151,6 +174,10 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) delete srcTopPtr; delete srcFrmPtr; } + if (tgtTopPtr != tgtCoords->TopPtr()) { + delete tgtTopPtr; + delete tgtFrmPtr; + } return CpptrajState::OK; } From 37a3d514a87628583d32e15a7d10890b18bde3c2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 11:03:43 -0400 Subject: [PATCH 09/17] Start adding ability to create bonds. --- src/Exec_Graft.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 297f2e7026..3f70e6c1aa 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -8,12 +8,13 @@ void Exec_Graft::Help() const { mprintf("\tsrc [srcframe <#>] [srcfitmask ] [srcmask ]\n" "\ttgt [tgtframe <#>] [tgtfitmask ]\n" - "\tname \n"); + "\tname [bond , ...]\n"); } // Exec_Graft::Execute() Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) { + typedef std::vector Iarray; // Get source coords std::string kw = argIn.GetStringKey("src"); if (kw.empty()) { @@ -63,6 +64,35 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) return CpptrajState::ERR; if (tgtCoords->Top().SetupIntegerMask(tgtMask)) return CpptrajState::ERR; + // Get bonds + Iarray tgtBondAtoms, srcBondAtoms; + kw = argIn.GetStringKey("bond"); + while (!kw.empty()) { + ArgList bndarg(kw, ","); + if (bndarg.Nargs() != 2) { + mprinterr("Error: Expected 2 atom masks for 'bond' (target, source).\n"); + return CpptrajState::ERR; + } + AtomMask tb, sb; + if (tb.SetMaskString(bndarg[0])) return CpptrajState::ERR; + if (sb.SetMaskString(bndarg[1])) return CpptrajState::ERR; + if (tgtCoords->Top().SetupIntegerMask(tb)) return CpptrajState::ERR; + if (srcCoords->Top().SetupIntegerMask(sb)) return CpptrajState::ERR; + if (tb.Nselected() != 1) { + mprinterr("Error: 'bond' target mask does not select only 1 atom.\n"); + return CpptrajState::ERR; + } + if (sb.Nselected() != 1) { + mprinterr("Error: 'bond' source mask does not select only 1 atom.\n"); + return CpptrajState::ERR; + } + tgtBondAtoms.push_back( tb[0] ); + srcBondAtoms.push_back( sb[0] ); + mprintf("\tWill bond target %s (%i) to source %s (%i)\n", + tb.MaskString(), tgtBondAtoms.back()+1, + sb.MaskString(), srcBondAtoms.back()+1); + kw = argIn.GetStringKey("bond"); + } // Get atoms from source to fit on target, and atoms from target // for source to fit on. AtomMask srcFitMask, tgtFitMask; From 5f9c7e3d3919a1b4a788b7f9bc182bd7f47d8ff6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 11:12:41 -0400 Subject: [PATCH 10/17] Update bond indices for removed atoms --- src/Exec_Graft.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 3f70e6c1aa..81c1fe87c6 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -11,6 +11,28 @@ void Exec_Graft::Help() const "\tname [bond , ...]\n"); } +static const int UpdateIndices(std::vector& Idxs, AtomMask const& maskIn, int offset) +{ + for (std::vector::iterator it = Idxs.begin(); + it != Idxs.end(); ++it) + { + // Search for index in mask + int newidx = 0; + for (; newidx != maskIn.Nselected(); newidx++) + { + if (*it == maskIn[newidx]) { + *it = newidx + offset; + break; + } + } + if (newidx == maskIn.Nselected()) { + mprinterr("Error: Bonded index is in a removed section.\n"); + return 1; + } + } + return 0; +} + // Exec_Graft::Execute() Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) { @@ -93,6 +115,14 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) sb.MaskString(), srcBondAtoms.back()+1); kw = argIn.GetStringKey("bond"); } + // Update the bond indices for the new topologies + if (UpdateIndices(tgtBondAtoms, tgtMask, 0)) + return CpptrajState::ERR; + if (UpdateIndices(srcBondAtoms, srcMask, tgtMask.Nselected())) + return CpptrajState::ERR; + mprintf("\tUpdate bond indices:\n"); + for (unsigned int ii = 0; ii != tgtBondAtoms.size(); ii++) + mprintf("\t tgt= %i src= %i\n", tgtBondAtoms[ii], srcBondAtoms[ii]); // Get atoms from source to fit on target, and atoms from target // for source to fit on. AtomMask srcFitMask, tgtFitMask; From 611eddc28a60490c672ded6bc450a56ca4cb2989 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 11:15:08 -0400 Subject: [PATCH 11/17] DRR - Actually add the bonds. --- src/Exec_Graft.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 81c1fe87c6..d0ac73b9a6 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -214,8 +214,10 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) combinedTop.SetDebug( State.Debug() ); combinedTop.SetParmName( outCoords->Meta().Name(), FileName() ); combinedTop.AppendTop( *tgtTopPtr ); - // TODO do any tgt mods here? combinedTop.AppendTop( *srcTopPtr ); + // Add any bonds + for (unsigned int ii = 0; ii != tgtBondAtoms.size(); ii++) + combinedTop.AddBond( tgtBondAtoms[ii], srcBondAtoms[ii] ); combinedTop.SetParmBox( tgtFrmPtr->BoxCrd() ); combinedTop.Brief("Grafted parm:"); From 48f2b06b0ae88619d12e02e2f5f4d4ec91d24b00 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 11:15:57 -0400 Subject: [PATCH 12/17] Finish graft test. --- test/Test_Graft/Final.graft.mol2.save | 80 +++++++++++++++++++++++++++ test/Test_Graft/RunTest.sh | 27 +++------ 2 files changed, 89 insertions(+), 18 deletions(-) create mode 100644 test/Test_Graft/Final.graft.mol2.save diff --git a/test/Test_Graft/Final.graft.mol2.save b/test/Test_Graft/Final.graft.mol2.save new file mode 100644 index 0000000000..c972e8bbcd --- /dev/null +++ b/test/Test_Graft/Final.graft.mol2.save @@ -0,0 +1,80 @@ +@MOLECULE +Cpptraj Generated mol2 file. + 34 34 2 0 0 +SMALL +USER_CHARGES + + +@ATOM + 1 N 3.3258 1.5479 -0.0000 N 1 TYR -0.415700 + 2 H 3.9094 0.7236 -0.0000 H 1 TYR 0.271900 + 3 CA 3.9700 2.8458 -0.0000 CX 1 TYR -0.001400 + 4 HA 3.6717 3.4001 -0.8898 H1 1 TYR 0.087600 + 5 CB 3.5770 3.6538 1.2321 CT 1 TYR -0.015200 + 6 HB2 2.4970 3.8011 1.2414 HC 1 TYR 0.029500 + 7 HB3 3.8775 3.1158 2.1312 HC 1 TYR 0.029500 + 8 C 5.4855 2.7052 -0.0000 C 1 TYR 0.597300 + 9 O 6.0088 1.5932 -0.0000 O 1 TYR -0.567900 + 10 C2 4.2639 4.9836 1.1901 CA 2 PRY 0.033204 + 11 C3 4.0801 5.9281 2.2037 CA 2 PRY -0.149016 + 12 H4 3.4319 5.6969 3.0320 HA 2 PRY 0.153372 + 13 C4 4.7078 7.1513 2.1709 CA 2 PRY -0.336291 + 14 H5 4.5618 7.8733 2.9529 HA 2 PRY 0.167425 + 15 C5 5.5528 7.4798 1.1112 CA 2 PRY 0.423974 + 16 O1 6.1232 8.7016 1.1711 OS 2 PRY -0.391815 + 17 C6 5.7502 6.5602 0.0979 CA 2 PRY -0.336291 + 18 H6 6.3940 6.7755 -0.7328 HA 2 PRY 0.167425 + 19 C7 5.1042 5.3267 0.1498 CA 2 PRY -0.149016 + 20 H7 5.2733 4.6265 -0.6499 HA 2 PRY 0.153372 + 21 C8 6.9675 9.1326 0.1315 CT 2 PRY 0.358047 + 22 C9 7.3706 10.5431 0.4430 CM 2 PRY -0.496680 + 23 C10 8.5791 11.0812 0.3832 CM 2 PRY 0.317549 + 24 C11 8.7852 12.5416 0.7074 CT 2 PRY -0.394216 + 25 C12 9.8453 10.3566 -0.0027 CT 2 PRY -0.394216 + 26 H8 6.4217 9.1015 -0.8099 H1 2 PRY 0.001584 + 27 H9 7.8169 8.4673 0.0461 H1 2 PRY 0.001584 + 28 H10 6.5411 11.1677 0.7309 HA 2 PRY 0.192041 + 29 H11 9.2141 13.0690 -0.1411 HC 2 PRY 0.110363 + 30 H12 9.4819 12.6562 1.5350 HC 2 PRY 0.110363 + 31 H13 7.8571 13.0311 0.9758 HC 2 PRY 0.110363 + 32 H14 10.2613 10.7841 -0.9128 HC 2 PRY 0.110363 + 33 H15 9.7076 9.2974 -0.1689 HC 2 PRY 0.110363 + 34 H16 10.5962 10.4769 0.7732 HC 2 PRY 0.110363 +@BOND + 1 1 3 1 + 2 3 5 1 + 3 3 8 1 + 4 8 9 1 + 5 10 11 1 + 6 10 19 1 + 7 11 13 1 + 8 13 15 1 + 9 15 16 1 + 10 15 17 1 + 11 16 21 1 + 12 17 19 1 + 13 21 22 1 + 14 22 23 1 + 15 23 24 1 + 16 23 25 1 + 17 5 10 1 + 18 1 2 1 + 19 3 4 1 + 20 5 6 1 + 21 5 7 1 + 22 11 12 1 + 23 13 14 1 + 24 17 18 1 + 25 19 20 1 + 26 21 26 1 + 27 21 27 1 + 28 22 28 1 + 29 24 29 1 + 30 24 30 1 + 31 24 31 1 + 32 25 32 1 + 33 25 33 1 + 34 25 34 1 +@SUBSTRUCTURE + 1 TYR 1 **** 0 **** **** + 2 PRY 10 **** 0 **** **** diff --git a/test/Test_Graft/RunTest.sh b/test/Test_Graft/RunTest.sh index d13ce19dea..b2d201f68e 100755 --- a/test/Test_Graft/RunTest.sh +++ b/test/Test_Graft/RunTest.sh @@ -2,7 +2,7 @@ . ../MasterTest.sh -CleanFiles cpptraj.in +CleanFiles cpptraj.in Final.graft.mol2 TESTNAME='Graft test' Requires notparallel @@ -22,26 +22,17 @@ loadcrd \$PRYFILE parmindex 1 name PRY graft \ tgt TYR \ src PRY \ - srcmask + name Final \ + srcfitmask @O1,C5,C6,C4,H6,H5,C7,C3,H7,H4,C2 \ + tgtfitmask @OH,CZ,CE1,CE2,HE1,HE2,CD1,CD2,HD1,HD2,CG \ + srcmask !(@1-4) \ + tgtmask @C,O,CA,HA,N,H,CB,HB2,HB3 \ + bond :1@CB,:1@C2 +crdout Final Final.graft.mol2 -quit -# Load the fragment, fit it on top of the existing tyrosine atoms -parm PRY-gauss-fragment.mol2 [pryparm] -loadcrd PRY-gauss-fragment.mol2 parm [pryparm] PRY -crdaction PRY strip @1-4 -#crdaction PRY center @C2 origin -crdaction PRY rms reference @O1,C5,C6,C4,H6,H5,C7,C3,H7,H4,C2 @OH,CZ,CE1,CE2,HE1,HE2,CD1,CD2,HD1,HD2,CG - -loadcrd Tyr.mol2 parm Tyr.mol2 TYR -crdaction TYR strip !@C,O,CA,HA,N,H,CB,HB2,HB3 -#crdaction TYR center @CB origin -#crdaction TYR translate x 1.0 z -1.0 - -combinecrd TYR PRY parmname Final.PRY crdname Final -crdout Final Final.PRY.mol2 EOF RunCpptraj "$TESTNAME" - +DoTest Final.graft.mol2.save Final.graft.mol2 EndTest exit 0 From f480732cd1effe67abff15ae029cf3e3c043fe33 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 11:17:34 -0400 Subject: [PATCH 13/17] Fix offset in output --- src/Exec_Graft.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index d0ac73b9a6..921ee834cd 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -120,9 +120,9 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) return CpptrajState::ERR; if (UpdateIndices(srcBondAtoms, srcMask, tgtMask.Nselected())) return CpptrajState::ERR; - mprintf("\tUpdate bond indices:\n"); + mprintf("\tUpdated bond indices:\n"); for (unsigned int ii = 0; ii != tgtBondAtoms.size(); ii++) - mprintf("\t tgt= %i src= %i\n", tgtBondAtoms[ii], srcBondAtoms[ii]); + mprintf("\t tgt= %i src= %i\n", tgtBondAtoms[ii]+1, srcBondAtoms[ii]+1); // Get atoms from source to fit on target, and atoms from target // for source to fit on. AtomMask srcFitMask, tgtFitMask; From aee8f6ee13e4ff914758049dd357670fac1227c4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 11:42:07 -0400 Subject: [PATCH 14/17] Add graft manual entry. Fix order of createcrd/crdout in manual. Fix help for graft. --- doc/cpptraj.lyx | 191 +++++++++++++++++++++++++++++++++++++++++---- src/Exec_Graft.cpp | 2 +- 2 files changed, 177 insertions(+), 16 deletions(-) diff --git a/doc/cpptraj.lyx b/doc/cpptraj.lyx index 477bb9fb3e..e77948b383 100644 --- a/doc/cpptraj.lyx +++ b/doc/cpptraj.lyx @@ -5701,7 +5701,7 @@ The following COORDS data set commands are available: \begin_layout Standard \align center \begin_inset Tabular - + @@ -5833,6 +5833,26 @@ createcrd \begin_inset Text +\begin_layout Plain Layout +graft +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Graft part of one COORDS set onto another COORDS set. +\end_layout + +\end_inset + + + + +\begin_inset Text + \begin_layout Plain Layout loadcrd \end_layout @@ -6083,6 +6103,36 @@ For example, to calculate RMSD for a previously created COORDS data set crdaction crd1 rmsd first @CA out rmsd-ca.agr crdframes 1,last,10 \end_layout +\begin_layout Subsection +crdout +\end_layout + +\begin_layout LyX-Code +crdout [] [crdframes ,,] +\end_layout + +\begin_layout Standard +Write COORDS data set to trajectory named . + A subset of frames in the COORDS data set can be specified with 'crdframes'. +\end_layout + +\begin_layout Standard +For example, to write frames 1 to 10 from a previously created COORDS data + set named +\begin_inset Quotes eld +\end_inset + +crd1 +\begin_inset Quotes erd +\end_inset + + to separate PDB files: +\end_layout + +\begin_layout LyX-Code +crdout crd1 crd1.pdb multi crdframes 1,10 +\end_layout + \begin_layout Subsection createcrd \end_layout @@ -6100,33 +6150,144 @@ reference "subsec:cpptraj_createcrd" \end_layout \begin_layout Subsection -crdout +graft \end_layout \begin_layout LyX-Code -crdout [] [crdframes ,,] +graft src [srcframe <#>] [srcfitmask ] [srcmask ] \end_layout -\begin_layout Standard -Write COORDS data set to trajectory named . - A subset of frames in the COORDS data set can be specified with 'crdframes'. +\begin_layout LyX-Code + tgt [tgtframe <#>] [tgtfitmask ] [tgtmask ] \end_layout -\begin_layout Standard -For example, to write frames 1 to 10 from a previously created COORDS data - set named -\begin_inset Quotes eld +\begin_layout LyX-Code + name [bond , ...] +\end_layout + +\begin_deeper +\begin_layout Description +src +\begin_inset space ~ \end_inset -crd1 -\begin_inset Quotes erd + Source coordinates. \end_layout -\begin_layout LyX-Code -crdout crd1 crd1.pdb multi crdframes 1,10 +\begin_layout Description +[srcframe +\begin_inset space ~ +\end_inset + +<#>] Frame # from source coordinates to use (default 1). +\end_layout + +\begin_layout Description +[srcfitmask +\begin_inset space ~ +\end_inset + +] Atoms from source to use if RMS-fitting source onto target. +\end_layout + +\begin_layout Description +[srcmask +\begin_inset space ~ +\end_inset + +] Atoms to keep from source (default all). +\end_layout + +\begin_layout Description +tgt +\begin_inset space ~ +\end_inset + + Target coordinates that will be grafted onto. +\end_layout + +\begin_layout Description +[tgtframe +\begin_inset space ~ +\end_inset + +<#> Frame # from target coordinates to use (default 1). +\end_layout + +\begin_layout Description +[tgtfitmask +\begin_inset space ~ +\end_inset + +] Atoms from target to use if RMS-fitting source onto target. +\end_layout + +\begin_layout Description +[tgtmask +\begin_inset space ~ +\end_inset + +] Atoms to keep from target (default all). +\end_layout + +\begin_layout Description +name +\begin_inset space ~ +\end_inset + + Name of output COORDS set containing source grafted onto target. +\end_layout + +\begin_layout Description +[bond +\begin_inset space ~ +\end_inset + +,] Create a bond between target atom selected by and source + atoms selected by in the final structure. + May be specified multiple times. +\end_layout + +\end_deeper +\begin_layout Standard +Graft one COORDS set onto another. + If +\series bold +srcfitmask +\series default + and/or +\series bold +tgtfitmask +\series default + is specified, the source coordinates will be RMS best-fit onto target using + the specified atoms. + Only the atoms specified by +\series bold +srcmask +\series default + and +\series bold +tgtmask +\series default + will be kept. + The +\series bold +bond +\series default + keyword can be used to create bonds between target and source in the final + structure. \end_layout \begin_layout Subsection diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 921ee834cd..e772bbb1e9 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -7,7 +7,7 @@ void Exec_Graft::Help() const { mprintf("\tsrc [srcframe <#>] [srcfitmask ] [srcmask ]\n" - "\ttgt [tgtframe <#>] [tgtfitmask ]\n" + "\ttgt [tgtframe <#>] [tgtfitmask ] [tgtmask ]\n" "\tname [bond , ...]\n"); } From 162b3c6a66a642b76aa2a4131be624b3d05f4d7c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 11:43:07 -0400 Subject: [PATCH 15/17] Revision bump for graft command. --- src/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Version.h b/src/Version.h index 2d86bf0766..db2327fc9b 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.29.1" +#define CPPTRAJ_INTERNAL_VERSION "V4.29.2" /// PYTRAJ relies on this #define CPPTRAJ_VERSION_STRING CPPTRAJ_INTERNAL_VERSION #endif From 6495ca54ab6dca6fcc8bfa9c03a4880f49560bed Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 11:45:14 -0400 Subject: [PATCH 16/17] Enable graft test. --- test/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index 89547aaea6..29a80bfcb6 100644 --- a/test/Makefile +++ b/test/Makefile @@ -471,6 +471,9 @@ test.emin: test.evalplateau: @-cd Test_EvalPlateau && ./RunTest.sh $(OPT) +test.graft: + @-cd Test_Graft && ./RunTest.sh $(OPT) + # Every test target should go here. COMPLETETESTS=test.general \ test.strip \ @@ -621,7 +624,8 @@ COMPLETETESTS=test.general \ test.slope \ test.diagmatrix \ test.emin \ - test.evalplateau + test.evalplateau \ + test.graft test.all: $(MAKE) test.complete summary From b6529fe8823ffdf6a56df2e8b1ee19dd41816cac Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 18 Aug 2020 13:02:24 -0400 Subject: [PATCH 17/17] Remove unneeded 'const'. Update code docs. Add some text to help. --- src/Exec_Graft.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index e772bbb1e9..a1319c7b94 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -8,10 +8,15 @@ void Exec_Graft::Help() const { mprintf("\tsrc [srcframe <#>] [srcfitmask ] [srcmask ]\n" "\ttgt [tgtframe <#>] [tgtfitmask ] [tgtmask ]\n" - "\tname [bond , ...]\n"); + "\tname [bond , ...]\n" + " Graft coordinates from source to coordinates in target.\n"); } -static const int UpdateIndices(std::vector& Idxs, AtomMask const& maskIn, int offset) +/** Update indices in the given array to what the new indices will + * be after processing with the given mask. + * \return 1 if an index is not in the mask, 0 if all indices updated successfully. + */ +static int UpdateIndices(std::vector& Idxs, AtomMask const& maskIn, int offset) { for (std::vector::iterator it = Idxs.begin(); it != Idxs.end(); ++it)