From d887aae5575a01e082f21e767f787eb4b73c69c6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 4 Mar 2022 14:05:33 -0500 Subject: [PATCH 001/245] Start InternalCoords class --- src/Structure/InternalCoords.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Structure/InternalCoords.h diff --git a/src/Structure/InternalCoords.h b/src/Structure/InternalCoords.h new file mode 100644 index 0000000000..65e585433b --- /dev/null +++ b/src/Structure/InternalCoords.h @@ -0,0 +1,27 @@ +#ifndef INC_STRUCTURE_INTERNALCOORDS_H +#define INC_STRUCTURE_INTERNALCOORDS_H +namespace Cpptraj { +namespace Structure { +/// Hold internal coordinates for an atom +/** Given that this is atom i connected to atoms j, k, and l: + * k - j + * / \ + * l i + * hold the following: + * distance j - i + * angle k - j - i + * torsion l - k - j - i + */ +class InternalCoords { + public: + /// CONSTRUCTOR + InternalCoords(); + + enum IdxType { DISTANCE = 0, ANGLE, TORSION }; + private: + int idx_[3]; ///< Atom index for distance, angle, torsion + double val_[3]; ///< Value for distance, angle, torsion +}; +} +} +#endif From 0b22ac55816d50b2756c0a5c1b73863ef283ea0a Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 4 Mar 2022 15:31:17 -0500 Subject: [PATCH 002/245] Add NO_ATOM --- src/Structure/InternalCoords.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Structure/InternalCoords.h b/src/Structure/InternalCoords.h index 65e585433b..d8c9fcb9ca 100644 --- a/src/Structure/InternalCoords.h +++ b/src/Structure/InternalCoords.h @@ -18,6 +18,8 @@ class InternalCoords { InternalCoords(); enum IdxType { DISTANCE = 0, ANGLE, TORSION }; + + static const int NO_ATOM; private: int idx_[3]; ///< Atom index for distance, angle, torsion double val_[3]; ///< Value for distance, angle, torsion From c1256f48444e73d987e65474ea7b59269e56679b Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 4 Mar 2022 15:37:14 -0500 Subject: [PATCH 003/245] Start Zmatrix --- src/Structure/Zmatrix.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/Structure/Zmatrix.h diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h new file mode 100644 index 0000000000..26ec731776 --- /dev/null +++ b/src/Structure/Zmatrix.h @@ -0,0 +1,22 @@ +#ifndef INC_STRUCTURE_ZMATRIX_H +#define INC_STRUCTURE_ZMATRIX_H +class Frame; +class Topology; +namespace Cpptraj { +namespace Structure { +class InternalCoords; +/// Hold internal coordinates for a system. +class Zmatrix { + public: + /// CONSTRUCTOR + Zmatrix(); + /// Convert Frame/Topology to internal coordinates array + SetFromFrame(Frame const&, Topology const&); + private: + typedef std::vector ICarray; + + ICarray IC_; ///< Hold internal coordinates for all atoms +}; +} +} +#endif From b370997cb295deba49a9408c1e046933a0c7c40f Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 4 Mar 2022 15:39:32 -0500 Subject: [PATCH 004/245] InternalCoords implementation --- src/Structure/InternalCoords.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/Structure/InternalCoords.cpp diff --git a/src/Structure/InternalCoords.cpp b/src/Structure/InternalCoords.cpp new file mode 100644 index 0000000000..31c22ce0f5 --- /dev/null +++ b/src/Structure/InternalCoords.cpp @@ -0,0 +1,12 @@ +#include +#include "InternalCoords.h" + +using namespace Cpptraj::Structure; + +const int InternalCoords::NO_ATOM = -1; + +/** CONSTRUCTOR */ +InternalCoords::InternalCoords() { + std::fill(idx_, idx_+3, NO_ATOM); + std::fill(val_, val_+3, 0); +} From eeba7242b4ddb83d0e47d04093e22837a7482de2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 4 Mar 2022 15:42:24 -0500 Subject: [PATCH 005/245] Start Zmatrix implementation --- src/Structure/Zmatrix.cpp | 8 ++++++++ src/Structure/Zmatrix.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/Structure/Zmatrix.cpp diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp new file mode 100644 index 0000000000..4f4e6879bd --- /dev/null +++ b/src/Structure/Zmatrix.cpp @@ -0,0 +1,8 @@ +#include +#include "Zmatrix.h" +#include "InternalCoords.h" + +using namespace Cpptraj::Structure; + +/** CONSTRUCTOR */ +Zmatrix::Zmatrix() {} diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 26ec731776..055a5933dc 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -11,7 +11,7 @@ class Zmatrix { /// CONSTRUCTOR Zmatrix(); /// Convert Frame/Topology to internal coordinates array - SetFromFrame(Frame const&, Topology const&); + int SetFromFrame(Frame const&, Topology const&); private: typedef std::vector ICarray; From ce57aa5d550f4804ae59dcb81695726a9b74e863 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 4 Mar 2022 15:51:24 -0500 Subject: [PATCH 006/245] First seed atom --- src/Structure/InternalCoords.cpp | 6 ++++++ src/Structure/InternalCoords.h | 2 ++ src/Structure/Zmatrix.cpp | 18 +++++++++++++++++- src/Structure/Zmatrix.h | 3 +++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Structure/InternalCoords.cpp b/src/Structure/InternalCoords.cpp index 31c22ce0f5..2f6434b4b5 100644 --- a/src/Structure/InternalCoords.cpp +++ b/src/Structure/InternalCoords.cpp @@ -10,3 +10,9 @@ InternalCoords::InternalCoords() { std::fill(idx_, idx_+3, NO_ATOM); std::fill(val_, val_+3, 0); } + +/** CONSTRUCTOR - pointer to XYZ coords, for first seed atom */ +InternalCoords::InternalCoords(const double* xyz) { + std::fill(idx_, idx_+3, NO_ATOM); + std::copy( xyz, xyz+3, val_ ); +} diff --git a/src/Structure/InternalCoords.h b/src/Structure/InternalCoords.h index d8c9fcb9ca..f01966f235 100644 --- a/src/Structure/InternalCoords.h +++ b/src/Structure/InternalCoords.h @@ -16,6 +16,8 @@ class InternalCoords { public: /// CONSTRUCTOR InternalCoords(); + /// CONSTRUCTOR - Take pointer to XYZ coords (for first seed atom) + InternalCoords(const double*); enum IdxType { DISTANCE = 0, ANGLE, TORSION }; diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 4f4e6879bd..e0165cba45 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -1,8 +1,24 @@ #include #include "Zmatrix.h" #include "InternalCoords.h" +#include "../Frame.h" using namespace Cpptraj::Structure; /** CONSTRUCTOR */ -Zmatrix::Zmatrix() {} +Zmatrix::Zmatrix() : + seed0_(InternalCoords::NO_ATOM), + seed1_(InternalCoords::NO_ATOM), + seed2_(InternalCoords::NO_ATOM) +{} + +/** Setup Zmatrix from coordinates/topology. */ +int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) +{ + IC_.clear(); + // First seed is first atom. Store XYZ. + IC_.push_back( InternalCoords( frameIn.XYZ(0) ) ); + seed0_ = 0; + + return 0; +} diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 055a5933dc..4b5a7fff4b 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -16,6 +16,9 @@ class Zmatrix { typedef std::vector ICarray; ICarray IC_; ///< Hold internal coordinates for all atoms + int seed0_; ///< Index of first seed atom + int seed1_; ///< Index of second seed atom + int seed2_; ///< Index of third seed atom }; } } From ddea7e31203306609b00490685b8356c4d159909 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 4 Mar 2022 15:53:31 -0500 Subject: [PATCH 007/245] Add comments --- src/Structure/Zmatrix.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index e0165cba45..21096841d6 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -20,5 +20,7 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) IC_.push_back( InternalCoords( frameIn.XYZ(0) ) ); seed0_ = 0; + // Choose second seed as bonded atom with lowest index. Prefer heavy atoms + return 0; } From 2af6f54ab336c598c4e37a10c071cfe2c080237c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 7 Mar 2022 18:33:25 -0500 Subject: [PATCH 008/245] Skip building libcpptraj_cluster, not really needed. --- src/Makefile | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Makefile b/src/Makefile index 8f3e72ab6d..02ed489544 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,11 +3,15 @@ include ../config.h include cpptrajfiles +include Cluster/clusterfiles + DEL_FILE = /bin/rm -f OBJECTS=$(SOURCES:.cpp=.o) $(CSOURCES:.c=.o) -CLUSTER_TARGET=Cluster/libcpptraj_cluster.a +#CLUSTER_TARGET=ClusterBuild + +CLUSTER_OBJECTS=$(CLUSTER_SOURCES:%.cpp=Cluster/%.o) # Default target: cpptraj only all: cpptraj$(SFX)$(EXE) @@ -19,8 +23,8 @@ install: $(INSTALL_TARGETS) install_cpptraj: cpptraj$(SFX)$(EXE) mv cpptraj$(SFX)$(EXE) $(CPPTRAJBIN) -cpptraj$(SFX)$(EXE): $(OBJECTS) $(FFT_TARGET) $(READLINE_TARGET) $(CUDA_TARGET) $(CLUSTER_TARGET) $(XDRFILE_TARGET) $(ARPACK_TARGET) $(TNGFILE_TARGET) - $(CXX) -o cpptraj$(SFX)$(EXE) $(OBJECTS) $(CUDA_TARGET) $(CLUSTER_TARGET) $(FFT_TARGET) $(READLINE_LIB) $(CPPTRAJ_LIB) $(LDFLAGS) +cpptraj$(SFX)$(EXE): $(OBJECTS) $(FFT_TARGET) $(READLINE_TARGET) $(CUDA_TARGET) $(CLUSTER_OBJECTS) $(XDRFILE_TARGET) $(ARPACK_TARGET) $(TNGFILE_TARGET) + $(CXX) -o cpptraj$(SFX)$(EXE) $(OBJECTS) $(CUDA_TARGET) $(CLUSTER_OBJECTS) $(FFT_TARGET) $(READLINE_LIB) $(CPPTRAJ_LIB) $(LDFLAGS) # libcpptraj --------------------------- # Rule to make libcpptraj-specific objects @@ -29,8 +33,8 @@ cpptraj$(SFX)$(EXE): $(OBJECTS) $(FFT_TARGET) $(READLINE_TARGET) $(CUDA_TARGET) libcpptraj: $(LIBCPPTRAJ_TARGET) -$(CPPTRAJLIB)/libcpptraj$(SHARED_SUFFIX): $(LIBCPPTRAJ_OBJECTS) $(FFT_TARGET) $(CUDA_TARGET) $(CLUSTER_TARGET) $(XDRFILE_TARGET) $(ARPACK_TARGET) $(TNGFILE_TARGET) - $(CXX) -shared -o $(CPPTRAJLIB)/libcpptraj$(SHARED_SUFFIX) $(LIBCPPTRAJ_OBJECTS) $(FFT_TARGET) $(CUDA_TARGET) $(CLUSTER_TARGET) $(CPPTRAJ_LIB) $(LDFLAGS) +$(CPPTRAJLIB)/libcpptraj$(SHARED_SUFFIX): $(LIBCPPTRAJ_OBJECTS) $(FFT_TARGET) $(CUDA_TARGET) $(CLUSTER_OBJECTS) $(XDRFILE_TARGET) $(ARPACK_TARGET) $(TNGFILE_TARGET) + $(CXX) -shared -o $(CPPTRAJLIB)/libcpptraj$(SHARED_SUFFIX) $(LIBCPPTRAJ_OBJECTS) $(FFT_TARGET) $(CUDA_TARGET) $(CLUSTER_OBJECTS) $(CPPTRAJ_LIB) $(LDFLAGS) # Data directory ----------------------- install_dat: @@ -105,8 +109,8 @@ noarpack: cuda_kernels/libcpptraj_cuda.a: ../external.config.h cd cuda_kernels && $(MAKE) all -$(CLUSTER_TARGET):: - cd Cluster && $(MAKE) all +#$(CLUSTER_TARGET):: +# cd Cluster && $(MAKE) all # Dependency targets findDepend: FindDepend.cpp FindDepend.o From ccd0c7b7bf284e501b11a8b89f21e478e51015e6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 25 Sep 2023 11:09:27 -0400 Subject: [PATCH 009/245] Add assignment and copy constructor --- src/Structure/InternalCoords.cpp | 25 +++++++++++++++++++++++-- src/Structure/InternalCoords.h | 6 ++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Structure/InternalCoords.cpp b/src/Structure/InternalCoords.cpp index 2f6434b4b5..3a68255166 100644 --- a/src/Structure/InternalCoords.cpp +++ b/src/Structure/InternalCoords.cpp @@ -6,13 +6,34 @@ using namespace Cpptraj::Structure; const int InternalCoords::NO_ATOM = -1; /** CONSTRUCTOR */ -InternalCoords::InternalCoords() { +InternalCoords::InternalCoords() : isSet_(false) { std::fill(idx_, idx_+3, NO_ATOM); std::fill(val_, val_+3, 0); + std::fill(xyz_, xyz_+3, 0); } /** CONSTRUCTOR - pointer to XYZ coords, for first seed atom */ InternalCoords::InternalCoords(const double* xyz) { std::fill(idx_, idx_+3, NO_ATOM); - std::copy( xyz, xyz+3, val_ ); + std::fill(val_, val_+3, 0); + std::copy( xyz, xyz+3, xyz_ ); + isSet_ = true; +} + +/** COPY CONSTRUCTOR */ +InternalCoords::InternalCoords(InternalCoords const& rhs) : isSet_(rhs.isSet_) { + std::copy( rhs.idx_, rhs.idx_+3, idx_ ); + std::copy( rhs.val_, rhs.val_+3, val_ ); + std::copy( rhs.xyz_, rhs.xyz_+3, xyz_ ); } + +/** ASSIGNMENT */ +InternalCoords& InternalCoords::operator=(InternalCoords const& rhs) { + if (&rhs == this) return *this; + std::copy( rhs.idx_, rhs.idx_+3, idx_ ); + std::copy( rhs.val_, rhs.val_+3, val_ ); + std::copy( rhs.xyz_, rhs.xyz_+3, xyz_ ); + isSet_ = rhs.isSet_; + return *this; +} + diff --git a/src/Structure/InternalCoords.h b/src/Structure/InternalCoords.h index f01966f235..054a12f0b8 100644 --- a/src/Structure/InternalCoords.h +++ b/src/Structure/InternalCoords.h @@ -18,6 +18,10 @@ class InternalCoords { InternalCoords(); /// CONSTRUCTOR - Take pointer to XYZ coords (for first seed atom) InternalCoords(const double*); + /// COPY CONSTRUCTOR + InternalCoords(InternalCoords const&); + /// ASSIGNMENT + InternalCoords& operator=(InternalCoords const&); enum IdxType { DISTANCE = 0, ANGLE, TORSION }; @@ -25,6 +29,8 @@ class InternalCoords { private: int idx_[3]; ///< Atom index for distance, angle, torsion double val_[3]; ///< Value for distance, angle, torsion + double xyz_[3]; ///< XYZ coordinates + bool isSet_; ///< True if xyz coords are set }; } } From b50cac6950f0538566584755f8574c22e9a7e4c3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 25 Sep 2023 11:39:13 -0400 Subject: [PATCH 010/245] Start adding internal to cartesian routine --- src/Structure/InternalCoords.cpp | 16 ++++++++++ src/Structure/InternalCoords.h | 23 ++++++++++++++- src/Structure/Zmatrix.cpp | 50 +++++++++++++++++++++++++++++++- src/Structure/Zmatrix.h | 2 ++ 4 files changed, 89 insertions(+), 2 deletions(-) diff --git a/src/Structure/InternalCoords.cpp b/src/Structure/InternalCoords.cpp index 3a68255166..b44d047330 100644 --- a/src/Structure/InternalCoords.cpp +++ b/src/Structure/InternalCoords.cpp @@ -1,5 +1,6 @@ #include #include "InternalCoords.h" +#include "../Vec3.h" using namespace Cpptraj::Structure; @@ -37,3 +38,18 @@ InternalCoords& InternalCoords::operator=(InternalCoords const& rhs) { return *this; } +/** Zero out the XYZ coordinates. */ +void InternalCoords::ZeroXYZ() { + std::fill(idx_, idx_+3, NO_ATOM); + std::fill(val_, val_+3, 0); + std::fill(xyz_, xyz_+3, 0); + isSet_ = true; +} + +/** Set xyz coords */ +void InternalCoords::SetXYZ(Vec3 const& xyz) { + xyz_[0] = xyz[0]; + xyz_[1] = xyz[1]; + xyz_[2] = xyz[2]; + isSet_ = true; +} diff --git a/src/Structure/InternalCoords.h b/src/Structure/InternalCoords.h index 054a12f0b8..4802ba3685 100644 --- a/src/Structure/InternalCoords.h +++ b/src/Structure/InternalCoords.h @@ -1,5 +1,6 @@ #ifndef INC_STRUCTURE_INTERNALCOORDS_H #define INC_STRUCTURE_INTERNALCOORDS_H +class Vec3; namespace Cpptraj { namespace Structure { /// Hold internal coordinates for an atom @@ -23,9 +24,29 @@ class InternalCoords { /// ASSIGNMENT InternalCoords& operator=(InternalCoords const&); - enum IdxType { DISTANCE = 0, ANGLE, TORSION }; + //enum ValType { DISTANCE = 0, ANGLE, TORSION }; + //enum AtType { AT_J = 0, AT_K, AT_L }; static const int NO_ATOM; + + /// Zero XYZ coords (seed atom 0) + void ZeroXYZ(); + /// Set XYZ coords + void SetXYZ( Vec3 const&); + /// \return Specifed value + //double Val(ValType v) const { return val_[(int)v]; } + /// \return Specified atom index + //int Idx(AtType a) const { return idx_[(int)a]; } + double Dist() const { return val_[0]; } + double Theta() const { return val_[1]; } + double Phi() const { return val_[2]; } + + int AtJ() const { return idx_[0]; } + int AtK() const { return idx_[1]; } + int AtL() const { return idx_[2]; } + + /// Set index of atom + //void SetIdx(AtType a) { idx_[(int)a] = idx; } private: int idx_[3]; ///< Atom index for distance, angle, torsion double val_[3]; ///< Value for distance, angle, torsion diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 21096841d6..4e11512905 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -2,6 +2,9 @@ #include "Zmatrix.h" #include "InternalCoords.h" #include "../Frame.h" +#include "../CpptrajStdio.h" +#include "../Constants.h" +#include // cos using namespace Cpptraj::Structure; @@ -12,7 +15,7 @@ Zmatrix::Zmatrix() : seed2_(InternalCoords::NO_ATOM) {} -/** Setup Zmatrix from coordinates/topology. */ +/** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) { IC_.clear(); @@ -24,3 +27,48 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) return 0; } + +/** Set Cartesian coordinates in Frame from internal coordinates. */ +int Zmatrix::SetToFrame(Frame& frameOut) const { + if ((unsigned int)frameOut.Natom() != IC_.size()) { + mprinterr("Internal Error: Output frame size (%i) != # internal coords (%zu)\n", + frameOut.Natom(), IC_.size()); + return 1; + } + // Set position of the first atom. + if (seed0_ != InternalCoords::NO_ATOM) { + //IC_[seed0_].ZeroXYZ(); + frameOut.SetXYZ(seed0_, Vec3(0.0)); + // Set position of the second atom. + if (seed1_ != InternalCoords::NO_ATOM) { + if (IC_[seed1_].AtJ() != seed0_) { + mprinterr("Internal Error: Atom j of seed 1 is not seed 0.\n"); + return 1; + } + double r1 = IC_[seed1_].Dist(); + //IC_[seed1_].SetXYZ( Vec3(r1, 0, 0) ); + frameOut.SetXYZ(seed1_, Vec3(r1, 0, 0)); + // Set position of the third atom + if (seed2_ != InternalCoords::NO_ATOM) { + if (IC_[seed2_].AtJ() != seed1_) { + mprinterr("Internal Error: Atom j of seed 2 is not seed 1.\n"); + return 1; + } + if (IC_[seed2_].AtK() != seed0_) { + mprinterr("Internal Error: Atom k of seed 2 is not seed 0.\n"); + return 1; + } + double r2 = IC_[seed2_].Dist(); + double theta = IC_[seed2_].Theta(); + + double x = r2 * cos(180.0 - theta) * Constants::DEGRAD; + double y = r2 * cos(180.0 - theta) * Constants::DEGRAD; + + //IC_[seed2].SetXYZ( Vec3(r1 + x, y, 0) ); + frameOut.SetXYZ( seed2_, Vec3(r1 + x, y, 0) ); + } // END seed atom 2 + } // END seed atom 1 + } // END seed atom 0 + + return 0; +} diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 4b5a7fff4b..39d70d7c02 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -12,6 +12,8 @@ class Zmatrix { Zmatrix(); /// Convert Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&); + /// Set Frame from internal coords + int SetToFrame(Frame&) const; private: typedef std::vector ICarray; From b4d9f2dc1510eefb5b52b5dcfe8d0122fa3247c6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 25 Sep 2023 11:40:15 -0400 Subject: [PATCH 011/245] Add files to the build --- src/Structure/CMakeLists.txt | 2 ++ src/Structure/structuredepend | 2 ++ src/Structure/structurefiles | 4 +++- src/cpptrajdepend | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Structure/CMakeLists.txt b/src/Structure/CMakeLists.txt index b030fd7346..de4fbb2379 100644 --- a/src/Structure/CMakeLists.txt +++ b/src/Structure/CMakeLists.txt @@ -4,9 +4,11 @@ target_sources(cpptraj_common_obj PRIVATE ${CMAKE_CURRENT_LIST_DIR}/FunctionalGroup.cpp ${CMAKE_CURRENT_LIST_DIR}/FxnGroupBuilder.cpp ${CMAKE_CURRENT_LIST_DIR}/HisProt.cpp + ${CMAKE_CURRENT_LIST_DIR}/InternalCoords.cpp ${CMAKE_CURRENT_LIST_DIR}/StructureRoutines.cpp ${CMAKE_CURRENT_LIST_DIR}/SugarBuilder.cpp ${CMAKE_CURRENT_LIST_DIR}/Sugar.cpp ${CMAKE_CURRENT_LIST_DIR}/SugarLinkAtoms.cpp ${CMAKE_CURRENT_LIST_DIR}/SugarToken.cpp + ${CMAKE_CURRENT_LIST_DIR}/Zmatrix.cpp ) diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index 2cbff1ef9f..117a6061cd 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -2,8 +2,10 @@ Disulfide.o : Disulfide.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Co FunctionalGroup.o : FunctionalGroup.cpp ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.o : FxnGroupBuilder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h StructureRoutines.h Sugar.h SugarToken.h HisProt.o : HisProt.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h HisProt.h StructureRoutines.h +InternalCoords.o : InternalCoords.cpp ../Vec3.h InternalCoords.h StructureRoutines.o : StructureRoutines.cpp ../Atom.h ../CpptrajStdio.h ../NameType.h ../Residue.h ../SymbolExporting.h StructureRoutines.h Sugar.o : Sugar.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Sugar.h SugarToken.h SugarBuilder.o : SugarBuilder.cpp ../ArgList.h ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../CharMask.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajFile.h ../CpptrajStdio.h ../DistRoutines.h ../FileIO.h ../FileName.h ../Frame.h ../ImageOption.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h LinkAtom.h ResStatArray.h StructureRoutines.h Sugar.h SugarBuilder.h SugarLinkAtoms.h SugarToken.h SugarLinkAtoms.o : SugarLinkAtoms.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../StringRoutines.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h LinkAtom.h SugarLinkAtoms.h SugarToken.o : SugarToken.cpp ../ArgList.h ../CpptrajStdio.h SugarToken.h +Zmatrix.o : Zmatrix.cpp ../Atom.h ../AtomMask.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Unit.h ../Vec3.h InternalCoords.h Zmatrix.h diff --git a/src/Structure/structurefiles b/src/Structure/structurefiles index b517cbaf51..ea6bded7d2 100644 --- a/src/Structure/structurefiles +++ b/src/Structure/structurefiles @@ -4,8 +4,10 @@ STRUCTURE_SOURCES= \ FunctionalGroup.cpp \ FxnGroupBuilder.cpp \ HisProt.cpp \ + InternalCoords.cpp \ StructureRoutines.cpp \ SugarBuilder.cpp \ Sugar.cpp \ SugarLinkAtoms.cpp \ - SugarToken.cpp + SugarToken.cpp \ + Zmatrix.cpp diff --git a/src/cpptrajdepend b/src/cpptrajdepend index e2c8c578a7..d41cf35834 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -432,11 +432,13 @@ Structure/Disulfide.o : Structure/Disulfide.cpp Atom.h AtomMask.h AtomType.h Box Structure/FunctionalGroup.o : Structure/FunctionalGroup.cpp Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/FxnGroupBuilder.o : Structure/FxnGroupBuilder.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/HisProt.o : Structure/HisProt.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/HisProt.h Structure/StructureRoutines.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h +Structure/InternalCoords.o : Structure/InternalCoords.cpp Structure/InternalCoords.h Vec3.h Structure/StructureRoutines.o : Structure/StructureRoutines.cpp Atom.h CpptrajStdio.h NameType.h Residue.h Structure/StructureRoutines.h SymbolExporting.h Structure/Sugar.o : Structure/Sugar.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarBuilder.o : Structure/SugarBuilder.cpp ArgList.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h CharMask.h Chirality.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DistRoutines.h FileIO.h FileName.h Frame.h ImageOption.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/LinkAtom.h Structure/ResStatArray.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarBuilder.h Structure/SugarLinkAtoms.h Structure/SugarToken.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarLinkAtoms.o : Structure/SugarLinkAtoms.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/LinkAtom.h Structure/SugarLinkAtoms.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarToken.o : Structure/SugarToken.cpp ArgList.h CpptrajStdio.h Structure/SugarToken.h +Structure/Zmatrix.o : Structure/Zmatrix.cpp Atom.h AtomMask.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ReplicaDimArray.h Residue.h Segment.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h Unit.h Vec3.h StructureCheck.o : StructureCheck.cpp Atom.h AtomMask.h AtomType.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h ExclusionArray.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StructureCheck.h SymbolExporting.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h StructureMapper.o : StructureMapper.cpp AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StructureMapper.h SymbolExporting.h TextFormat.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h SymmetricRmsdCalc.o : SymmetricRmsdCalc.cpp ArrayIterator.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h Hungarian.h ImageOption.h MapAtom.h MaskToken.h Matrix.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h SymmetricRmsdCalc.h Topology.h TypeNameHolder.h Unit.h Vec3.h From 40baa92568ba51503f804cd03f9af7ede221a39b Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 25 Sep 2023 11:51:54 -0400 Subject: [PATCH 012/245] Remove xyz coords from InternalCoords --- src/Structure/InternalCoords.cpp | 30 +++++++++++++++--------------- src/Structure/InternalCoords.h | 12 ++++++------ src/Structure/Zmatrix.cpp | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Structure/InternalCoords.cpp b/src/Structure/InternalCoords.cpp index b44d047330..61686e08f8 100644 --- a/src/Structure/InternalCoords.cpp +++ b/src/Structure/InternalCoords.cpp @@ -1,31 +1,31 @@ #include #include "InternalCoords.h" -#include "../Vec3.h" +//#incl ude "../Vec3.h" using namespace Cpptraj::Structure; const int InternalCoords::NO_ATOM = -1; /** CONSTRUCTOR */ -InternalCoords::InternalCoords() : isSet_(false) { +InternalCoords::InternalCoords() { std::fill(idx_, idx_+3, NO_ATOM); std::fill(val_, val_+3, 0); - std::fill(xyz_, xyz_+3, 0); +// std::fill(xyz_, xyz_+3, 0); } /** CONSTRUCTOR - pointer to XYZ coords, for first seed atom */ -InternalCoords::InternalCoords(const double* xyz) { +/*InternalCoords::InternalCoords(const double* xyz) { std::fill(idx_, idx_+3, NO_ATOM); std::fill(val_, val_+3, 0); - std::copy( xyz, xyz+3, xyz_ ); - isSet_ = true; -} +// std::copy( xyz, xyz+3, xyz_ ); +// isSet_ = true; +}*/ /** COPY CONSTRUCTOR */ -InternalCoords::InternalCoords(InternalCoords const& rhs) : isSet_(rhs.isSet_) { +InternalCoords::InternalCoords(InternalCoords const& rhs) { std::copy( rhs.idx_, rhs.idx_+3, idx_ ); std::copy( rhs.val_, rhs.val_+3, val_ ); - std::copy( rhs.xyz_, rhs.xyz_+3, xyz_ ); +// std::copy( rhs.xyz_, rhs.xyz_+3, xyz_ ); } /** ASSIGNMENT */ @@ -33,23 +33,23 @@ InternalCoords& InternalCoords::operator=(InternalCoords const& rhs) { if (&rhs == this) return *this; std::copy( rhs.idx_, rhs.idx_+3, idx_ ); std::copy( rhs.val_, rhs.val_+3, val_ ); - std::copy( rhs.xyz_, rhs.xyz_+3, xyz_ ); - isSet_ = rhs.isSet_; + //std::copy( rhs.xyz_, rhs.xyz_+3, xyz_ ); + //isSet_ = rhs.isSet_; return *this; } /** Zero out the XYZ coordinates. */ -void InternalCoords::ZeroXYZ() { +/*void InternalCoords::ZeroXYZ() { std::fill(idx_, idx_+3, NO_ATOM); std::fill(val_, val_+3, 0); std::fill(xyz_, xyz_+3, 0); isSet_ = true; -} +}*/ /** Set xyz coords */ -void InternalCoords::SetXYZ(Vec3 const& xyz) { +/*void InternalCoords::SetXYZ(Vec3 const& xyz) { xyz_[0] = xyz[0]; xyz_[1] = xyz[1]; xyz_[2] = xyz[2]; isSet_ = true; -} +}*/ diff --git a/src/Structure/InternalCoords.h b/src/Structure/InternalCoords.h index 4802ba3685..c9c6155fea 100644 --- a/src/Structure/InternalCoords.h +++ b/src/Structure/InternalCoords.h @@ -1,6 +1,6 @@ #ifndef INC_STRUCTURE_INTERNALCOORDS_H #define INC_STRUCTURE_INTERNALCOORDS_H -class Vec3; +//class Vec3; namespace Cpptraj { namespace Structure { /// Hold internal coordinates for an atom @@ -18,7 +18,7 @@ class InternalCoords { /// CONSTRUCTOR InternalCoords(); /// CONSTRUCTOR - Take pointer to XYZ coords (for first seed atom) - InternalCoords(const double*); + //InternalCoords(const double*); /// COPY CONSTRUCTOR InternalCoords(InternalCoords const&); /// ASSIGNMENT @@ -30,9 +30,9 @@ class InternalCoords { static const int NO_ATOM; /// Zero XYZ coords (seed atom 0) - void ZeroXYZ(); + //void ZeroXYZ(); /// Set XYZ coords - void SetXYZ( Vec3 const&); + //void SetXYZ( Vec3 const&); /// \return Specifed value //double Val(ValType v) const { return val_[(int)v]; } /// \return Specified atom index @@ -50,8 +50,8 @@ class InternalCoords { private: int idx_[3]; ///< Atom index for distance, angle, torsion double val_[3]; ///< Value for distance, angle, torsion - double xyz_[3]; ///< XYZ coordinates - bool isSet_; ///< True if xyz coords are set + //double xyz_[3]; ///< XYZ coordinates + //bool isSet_; ///< True if xyz coords are set }; } } diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 4e11512905..c881bc77f8 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -19,8 +19,8 @@ Zmatrix::Zmatrix() : int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) { IC_.clear(); - // First seed is first atom. Store XYZ. - IC_.push_back( InternalCoords( frameIn.XYZ(0) ) ); + // First seed is first atom. No bonds, angles, or torsions. + IC_.push_back( InternalCoords() ); seed0_ = 0; // Choose second seed as bonded atom with lowest index. Prefer heavy atoms From 8e0c099d3b99bad2386fe986564d77125f5a7850 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 25 Sep 2023 11:52:24 -0400 Subject: [PATCH 013/245] Update depends --- src/Structure/structuredepend | 2 +- src/cpptrajdepend | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index 117a6061cd..6daaa795c5 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -2,7 +2,7 @@ Disulfide.o : Disulfide.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Co FunctionalGroup.o : FunctionalGroup.cpp ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.o : FxnGroupBuilder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h StructureRoutines.h Sugar.h SugarToken.h HisProt.o : HisProt.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h HisProt.h StructureRoutines.h -InternalCoords.o : InternalCoords.cpp ../Vec3.h InternalCoords.h +InternalCoords.o : InternalCoords.cpp InternalCoords.h StructureRoutines.o : StructureRoutines.cpp ../Atom.h ../CpptrajStdio.h ../NameType.h ../Residue.h ../SymbolExporting.h StructureRoutines.h Sugar.o : Sugar.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Sugar.h SugarToken.h SugarBuilder.o : SugarBuilder.cpp ../ArgList.h ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../CharMask.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajFile.h ../CpptrajStdio.h ../DistRoutines.h ../FileIO.h ../FileName.h ../Frame.h ../ImageOption.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h LinkAtom.h ResStatArray.h StructureRoutines.h Sugar.h SugarBuilder.h SugarLinkAtoms.h SugarToken.h diff --git a/src/cpptrajdepend b/src/cpptrajdepend index d41cf35834..550262e553 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -432,7 +432,7 @@ Structure/Disulfide.o : Structure/Disulfide.cpp Atom.h AtomMask.h AtomType.h Box Structure/FunctionalGroup.o : Structure/FunctionalGroup.cpp Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/FxnGroupBuilder.o : Structure/FxnGroupBuilder.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/HisProt.o : Structure/HisProt.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/HisProt.h Structure/StructureRoutines.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h -Structure/InternalCoords.o : Structure/InternalCoords.cpp Structure/InternalCoords.h Vec3.h +Structure/InternalCoords.o : Structure/InternalCoords.cpp Structure/InternalCoords.h Structure/StructureRoutines.o : Structure/StructureRoutines.cpp Atom.h CpptrajStdio.h NameType.h Residue.h Structure/StructureRoutines.h SymbolExporting.h Structure/Sugar.o : Structure/Sugar.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarBuilder.o : Structure/SugarBuilder.cpp ArgList.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h CharMask.h Chirality.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DistRoutines.h FileIO.h FileName.h Frame.h ImageOption.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/LinkAtom.h Structure/ResStatArray.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarBuilder.h Structure/SugarLinkAtoms.h Structure/SugarToken.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h From 8fcf1dcd0228dc599aa259cf94eefdccd72aee44 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 25 Sep 2023 13:04:12 -0400 Subject: [PATCH 014/245] Start reading amber prep files --- src/DataFile.cpp | 3 ++ src/DataFile.h | 2 +- src/DataIO_AmberPrep.cpp | 85 ++++++++++++++++++++++++++++++++++++++++ src/DataIO_AmberPrep.h | 17 ++++++++ src/cpptrajdepend | 3 +- src/cpptrajfiles | 1 + 6 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 src/DataIO_AmberPrep.cpp create mode 100644 src/DataIO_AmberPrep.h diff --git a/src/DataFile.cpp b/src/DataFile.cpp index 32c6c44ee2..060eeb4f54 100644 --- a/src/DataFile.cpp +++ b/src/DataFile.cpp @@ -32,6 +32,7 @@ #include "DataIO_NetCDF.h" #include "DataIO_AmberEne.h" #include "DataIO_Numpy.h" +#include "DataIO_AmberPrep.h" // CONSTRUCTOR DataFile::DataFile() : @@ -85,6 +86,7 @@ const FileTypes::AllocToken DataFile::DF_AllocArray[] = { # endif { "Amber Energy File", 0, 0, DataIO_AmberEne::Alloc}, { "Numpy array", 0, 0, DataIO_Numpy::Alloc}, + { "Amber Prep File", 0, 0, DataIO_AmberPrep::Alloc}, { "Unknown Data file", 0, 0, 0 } }; @@ -111,6 +113,7 @@ const FileTypes::KeyToken DataFile::DF_KeyArray[] = { { PEAKS, "peaks", ".peaks" }, { AMBERENE, "amberene", ".ene" }, { NUMPY, "numpy", ".npy" }, + { AMBERPREP, "prepin", ".prepin" }, { UNKNOWN_DATA, 0, 0 } }; diff --git a/src/DataFile.h b/src/DataFile.h index 4571381644..378cf552ff 100644 --- a/src/DataFile.h +++ b/src/DataFile.h @@ -18,7 +18,7 @@ class DataFile { DATAFILE=0, XMGRACE, GNUPLOT, XPLOR, OPENDX, REMLOG, MDOUT, EVECS, VECTRAJ, XVG, CCP4, CHARMMREPD, CHARMMFASTREP, CHARMMOUT, CPOUT, CHARMMRTFPRM, CMATRIX_BINARY, CMATRIX_NETCDF, PEAKS, - NETCDFDATA, AMBERENE, NUMPY, + NETCDFDATA, AMBERENE, NUMPY, AMBERPREP, UNKNOWN_DATA }; DataFile(); diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp new file mode 100644 index 0000000000..fa3a88b0ce --- /dev/null +++ b/src/DataIO_AmberPrep.cpp @@ -0,0 +1,85 @@ +#include "DataIO_AmberPrep.h" +#include "CpptrajStdio.h" +#include "BufferedLine.h" + +/// CONSTRUCTOR +DataIO_AmberPrep::DataIO_AmberPrep() +{ + +} + +// DataIO_AmberPrep::ID_DataFormat() +bool DataIO_AmberPrep::ID_DataFormat(CpptrajFile& infile) +{ + + return false; +} + +// DataIO_AmberPrep::ReadHelp() +void DataIO_AmberPrep::ReadHelp() +{ + +} + +// DataIO_AmberPrep::processReadArgs() +int DataIO_AmberPrep::processReadArgs(ArgList& argIn) +{ + + return 0; +} + +static inline int CheckLine(const char* line) { + if (line==0) { + mprinterr("Error: Unexpected end of prep file.\n"); + return 1; + } + return 0; +} + +// DataIO_AmberPrep::ReadData() +int DataIO_AmberPrep::ReadData(FileName const& fname, DataSetList& dsl, std::string const& dsname) +{ + BufferedLine infile; + + if (infile.OpenFileRead(fname)) { + mprinterr("Error: Could not open '%s'\n", fname.full()); + return 1; + } + // 1 - Control for data base generation + // IDBGEN, IREST, ITYPF + // Format (3I) + const char* line = infile.Line(); + if (CheckLine(line)) return 1; + // 2 - Name of the data base file. Blank if not data base gen. + // NAMDBF + // Format (A80) + line = infile.Line(); + if (CheckLine(line)) return 1; + // 3 - Title + // Descriptive header for the residue + line = infile.Line(); + if (CheckLine(line)) return 1; + mprintf("DEBUG: Prep title: '%s'\n", line); + + return 0; +} + +// DataIO_AmberPrep::WriteHelp() +void DataIO_AmberPrep::WriteHelp() +{ + +} + +// DataIO_AmberPrep::processWriteArgs() +int DataIO_AmberPrep::processWriteArgs(ArgList& argIn) +{ + + return 0; +} + +// DataIO_AmberPrep::WriteData() +int DataIO_AmberPrep::WriteData(FileName const& fname, DataSetList const& dsl) +{ + + return 1; +} diff --git a/src/DataIO_AmberPrep.h b/src/DataIO_AmberPrep.h new file mode 100644 index 0000000000..01a08326d3 --- /dev/null +++ b/src/DataIO_AmberPrep.h @@ -0,0 +1,17 @@ +#ifndef INC_DATAIO_AMBERPREP_H +#define INC_DATAIO_AMBERPREP_H +#include "DataIO.h" +/// Read in the Amber prep file format +class DataIO_AmberPrep : public DataIO { + public: + DataIO_AmberPrep(); + static void ReadHelp(); + static void WriteHelp(); + static BaseIOtype* Alloc() { return (BaseIOtype*)new DataIO_AmberPrep(); } + int processReadArgs(ArgList&); + int ReadData(FileName const&, DataSetList&, std::string const&); + int processWriteArgs(ArgList&); + int WriteData(FileName const&, DataSetList const&); + bool ID_DataFormat(CpptrajFile&); +}; +#endif diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 550262e553..2bd39b7e02 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -199,11 +199,12 @@ CpptrajFile.o : CpptrajFile.cpp CpptrajFile.h CpptrajStdio.h FileIO.h FileIO_Bzi CpptrajState.o : CpptrajState.cpp Action.h ActionList.h ActionState.h Action_CreateCrd.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h CompactFrameArray.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_REF.h DataSet_Coords_TRJ.h DataSet_Topology.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleNavigator.h EnsembleOutList.h FileIO.h FileName.h FileTypes.h Frame.h FrameArray.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ProgressBar.h Random.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajFrameIndex.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h CpptrajStdio.o : CpptrajStdio.cpp Parallel.h CurveFit.o : CurveFit.cpp CurveFit.h -DataFile.o : DataFile.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Cluster/Cframes.h Cluster/Cmatrix_NC.h Constants.h CoordinateInfo.h Cph.h CpptrajFile.h CpptrajStdio.h DataFile.h DataIO.h DataIO_AmberEne.h DataIO_CCP4.h DataIO_CharmmFastRep.h DataIO_CharmmOutput.h DataIO_CharmmRepLog.h DataIO_CharmmRtfPrm.h DataIO_Cmatrix_Binary.h DataIO_Cmatrix_NC.h DataIO_Cpout.h DataIO_Evecs.h DataIO_Gnuplot.h DataIO_Grace.h DataIO_Mdout.h DataIO_NetCDF.h DataIO_Numpy.h DataIO_OpenDx.h DataIO_Peaks.h DataIO_RemLog.h DataIO_Std.h DataIO_VecTraj.h DataIO_XVG.h DataIO_Xplor.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_PairwiseCache.h DataSet_PairwiseCache_MEM.h DataSet_RemLog.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.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 Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajectoryFile.h TypeNameHolder.h Unit.h Vec3.h +DataFile.o : DataFile.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Cluster/Cframes.h Cluster/Cmatrix_NC.h Constants.h CoordinateInfo.h Cph.h CpptrajFile.h CpptrajStdio.h DataFile.h DataIO.h DataIO_AmberEne.h DataIO_AmberPrep.h DataIO_CCP4.h DataIO_CharmmFastRep.h DataIO_CharmmOutput.h DataIO_CharmmRepLog.h DataIO_CharmmRtfPrm.h DataIO_Cmatrix_Binary.h DataIO_Cmatrix_NC.h DataIO_Cpout.h DataIO_Evecs.h DataIO_Gnuplot.h DataIO_Grace.h DataIO_Mdout.h DataIO_NetCDF.h DataIO_Numpy.h DataIO_OpenDx.h DataIO_Peaks.h DataIO_RemLog.h DataIO_Std.h DataIO_VecTraj.h DataIO_XVG.h DataIO_Xplor.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_PairwiseCache.h DataSet_PairwiseCache_MEM.h DataSet_RemLog.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.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 Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajectoryFile.h TypeNameHolder.h Unit.h Vec3.h DataFileList.o : DataFileList.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h PDBfile.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataFilter.o : DataFilter.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_integer.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO.o : DataIO.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataSet.h DataSetList.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixDbl.h Dimension.h FileIO.h FileName.h Frame.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 Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_AmberEne.o : DataIO_AmberEne.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberEne.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h +DataIO_AmberPrep.o : DataIO_AmberPrep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberPrep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CCP4.o : DataIO_CCP4.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ByteRoutines.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CCP4.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridFlt.h Dimension.h FileIO.h FileName.h Frame.h Grid.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmFastRep.o : DataIO_CharmmFastRep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmFastRep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_RemLog.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmOutput.o : DataIO_CharmmOutput.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmOutput.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_double.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h diff --git a/src/cpptrajfiles b/src/cpptrajfiles index 224bdaae47..03bf21c28a 100644 --- a/src/cpptrajfiles +++ b/src/cpptrajfiles @@ -175,6 +175,7 @@ COMMON_SOURCES= \ DataFilter.cpp \ DataIO.cpp \ DataIO_AmberEne.cpp \ + DataIO_AmberPrep.cpp \ DataIO_CCP4.cpp \ DataIO_CharmmFastRep.cpp \ DataIO_CharmmOutput.cpp \ From dc77a30b42e89683287429cbedc6ec50f667fa7c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 25 Sep 2023 13:56:19 -0400 Subject: [PATCH 015/245] Start setting up topology and z matrix --- src/DataIO_AmberPrep.cpp | 128 +++++++++++++++++++++++++++++++ src/DataSet_Topology.h | 1 + src/Structure/InternalCoords.cpp | 20 +++++ src/Structure/InternalCoords.h | 2 + src/Structure/Zmatrix.cpp | 14 ++++ src/Structure/Zmatrix.h | 4 + src/cpptrajdepend | 2 +- 7 files changed, 170 insertions(+), 1 deletion(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index fa3a88b0ce..2249cd64a3 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -1,6 +1,10 @@ #include "DataIO_AmberPrep.h" #include "CpptrajStdio.h" #include "BufferedLine.h" +#include "DataSet_Topology.h" +#include "StringRoutines.h" +#include "Structure/Zmatrix.h" +#include "Structure/InternalCoords.h" /// CONSTRUCTOR DataIO_AmberPrep::DataIO_AmberPrep() @@ -60,6 +64,130 @@ int DataIO_AmberPrep::ReadData(FileName const& fname, DataSetList& dsl, std::str line = infile.Line(); if (CheckLine(line)) return 1; mprintf("DEBUG: Prep title: '%s'\n", line); + // 4 - Name of output file if an individual res file is being generated + // NAMF + // Format (A80) + line = infile.Line(); + if (CheckLine(line)) return 1; + // 5 - NAMRES, INTX, KFORM + // NAMERES - a unique name for the residue + // INTX - Flag for the type of coords to be saved for LINK module. INT - internal, XYZ - cart. + // KFORM - Format of output for individual residue files 0 - formatted, 1 - binary + // FORMAT (2A, I) + line = infile.Line(); + if (CheckLine(line)) return 1; + ArgList args( line ); + if (args.Nargs() != 3) { + mprinterr("Error: Expected NAMRES, INTX, KFORM: %s\n", line); + return 1; + } + std::string resName = args.GetStringNext(); + std::string coordFlag = args.GetStringNext(); + int kform = args.getNextInteger(-1); + mprintf("DEBUG: %s %s %i\n", resName.c_str(), coordFlag.c_str(), kform); + // 6 - IFIXC , IOMIT , ISYMDU , IPOS + // FORMAT (4A) + // IFIXC Flag for the type of input geometry of the residue(s) + // 'CORRECT' The geometry is input as internal coordinates with + // correct order according to the tree structure. + // NOTE: the tree structure types ('M', 'S', etc) and order + // must be defined correctly: NA(I), NB(I), and NC(I) on card + // 8 are always ignored. + // 'CHANGE' It is input as cartesian coordinates or part cartesian + // and part internal. Cartesians should precede internals + // to ensure that the resulting coordinates are correct. + // Coordinates need not be in correct order, since each + // is labeled with its atom number. NOTE: NA(I), NB(I), and + // NC(I) on card 8 must be omitted for cartesian coordinates + // with this option. + // + // IOMIT Flag for the omission of dummy atoms + // 'OMIT' dummy atoms will be deleted after generating all the + // information (this is used for all but the first residue + // in the system) + // 'NOMIT' they will not be deleted (dummy atoms are retained for + // the first residue of the system. others are omitted) + // + // ISYMDU Symbol for the dummy atoms. The symbol must be + // be unique. It is preferable to use 'DU' for it. + // + // IPOS Flag for the position of dummy atoms to be deleted + // 'ALL' all the dummy atoms will be deleted + // 'BEG' only the beginning dummy atoms will be deleted + line = infile.Line(); + if (CheckLine(line)) return 1; + args.SetList( line, " \t" ); + if (args.Nargs() != 4) { + mprinterr("Error: Expected IFIXC, IOMIT, ISYMDU, IPOS: %s\n", line); + return 1; + } + std::string IFIXC = args.GetStringNext(); + std::string IOMIT = args.GetStringNext(); + std::string ISYMDU = args.GetStringNext(); + std::string IPOS = args.GetStringNext(); + mprintf("DEBUG: %s %s %s %s\n", IFIXC.c_str(), IOMIT.c_str(), ISYMDU.c_str(), IPOS.c_str()); + if (IFIXC != "CORRECT") { + mprinterr("Error: IFIXC is not 'CORRECT' (%s=)\n", IFIXC.c_str()); + return 1; + } + // 7 - CUT + // The cutoff distance for loop closing bonds which + // cannot be defined by the tree structure. Any pair of + // atoms within this distance is assumed to be bonded. + line = infile.Line(); + if (CheckLine(line)) return 1; + // 0 1 2 3 4 5 6 7 8 9 10 + // 8 - I IGRAPH(I) ISYMBL(I) ITREE(I) NA(I) NB(I) NC(I) R(I) THETA(I) PHI(I) CHG(I) [I = 1, NATOM] + // FORMAT(I,3A,3I,4F) + // Terminated by a blank line + using namespace Cpptraj::Structure; + Zmatrix zmatrix; + // Topology + DataSet* ds = dsl.AddSet( DataSet::TOPOLOGY, MetaData(dsname, "top") ); + if (ds == 0) { + mprinterr("Error: Could not create topology for prep.\n"); + return 1; + } + Topology& top = ((DataSet_Topology*)ds)->ModifyTop(); + // Residue + Residue res(resName, 1, ' ', ' '); + // Loop over entries + line = infile.Line(); + if (CheckLine(line)) return 1; + while (line[0] != '\0') { + mprintf("DEBUG: '%s'\n", line); + args.SetList( line, " \t" ); + if (args.Nargs() != 11) { + mprinterr("Error: Expected 11 columns in prep line, got %i\n", args.Nargs()); + return 1; + } + double charge = convertToDouble(args[10]); + // Add top atom + if (args[2] == "EP") { + // Special case for extra points + Atom atm(args[1], "XP"); + atm.SetTypeName(args[2]); + atm.SetCharge(charge); + top.AddTopAtom(atm, res); + } else + top.AddTopAtom( Atom(args[1], args[2], charge), res ); + // Add zmatrix entry. In prep file, indices start from 1. + int atJ = convertToInteger(args[4]) - 1; + int atK = convertToInteger(args[5]) - 1; + int atL = convertToInteger(args[6]) - 1; + double dist = convertToDouble(args[7]); + double theta = convertToDouble(args[8]); + double phi = convertToDouble(args[9]); + zmatrix.AddIC( InternalCoords(atJ, atK, atL, dist, theta, phi) ); + line = infile.Line(); + if (line == 0) break; + } + // Ignore everything else for now + infile.CloseFile(); + // Set up topology + top.CommonSetup(true, false); + top.Summary(); + zmatrix.print(); return 0; } diff --git a/src/DataSet_Topology.h b/src/DataSet_Topology.h index fcdbef4e55..331c25233c 100644 --- a/src/DataSet_Topology.h +++ b/src/DataSet_Topology.h @@ -22,6 +22,7 @@ class DataSet_Topology : public DataSet { int LoadTopFromFile(ArgList const&, int); int StripTop( std::string const& ); void SetTop(Topology const& t) { top_ = t; } + Topology& ModifyTop() { return top_; } void SetPindex(int p) { top_.SetPindex( p ); } Topology* TopPtr() { return &top_; } // NOTE: pytraj currently relies on this Topology const& Top() const { return top_; } diff --git a/src/Structure/InternalCoords.cpp b/src/Structure/InternalCoords.cpp index 61686e08f8..9cae170d4d 100644 --- a/src/Structure/InternalCoords.cpp +++ b/src/Structure/InternalCoords.cpp @@ -13,6 +13,26 @@ InternalCoords::InternalCoords() { // std::fill(xyz_, xyz_+3, 0); } +/** CONSTRUCTOR - Take indices and values */ +InternalCoords::InternalCoords(int atJ, int atK, int atL, double dist, double theta, double phi) { + if (atJ < 0) + idx_[0] = NO_ATOM; + else + idx_[0] = atJ; + if (atK < 0) + idx_[1] = NO_ATOM; + else + idx_[1] = atK; + if (atL < 0) + idx_[2] = NO_ATOM; + else + idx_[2] = atL; + + val_[0] = dist; + val_[1] = theta; + val_[2] = phi; +} + /** CONSTRUCTOR - pointer to XYZ coords, for first seed atom */ /*InternalCoords::InternalCoords(const double* xyz) { std::fill(idx_, idx_+3, NO_ATOM); diff --git a/src/Structure/InternalCoords.h b/src/Structure/InternalCoords.h index c9c6155fea..161042a978 100644 --- a/src/Structure/InternalCoords.h +++ b/src/Structure/InternalCoords.h @@ -17,6 +17,8 @@ class InternalCoords { public: /// CONSTRUCTOR InternalCoords(); + /// CONSTRUCTOR - Take atoms j, k, l and values dist, theta, phi + InternalCoords(int, int, int, double, double, double); /// CONSTRUCTOR - Take pointer to XYZ coords (for first seed atom) //InternalCoords(const double*); /// COPY CONSTRUCTOR diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index c881bc77f8..70b49de2ea 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -15,6 +15,20 @@ Zmatrix::Zmatrix() : seed2_(InternalCoords::NO_ATOM) {} +/** Add internal coords */ +void Zmatrix::AddIC(InternalCoords const& ic) { + IC_.push_back( ic ); +} + +/** Print to stdout */ +void Zmatrix::print() const { + mprintf("%zu internal coords.\n", IC_.size()); + for (ICarray::const_iterator it = IC_.begin(); it != IC_.end(); ++it) + mprintf("\t%8li %8i %8i %8i %12.4f %12.4f %12.4f\n", it - IC_.begin() + 1, + it->AtJ()+1, it->AtK()+1, it->AtL()+1, + it->Dist(), it->Theta(), it->Phi()); +} + /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) { diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 39d70d7c02..abfedb4a0f 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -10,10 +10,14 @@ class Zmatrix { public: /// CONSTRUCTOR Zmatrix(); + /// Add internal coordinate + void AddIC(InternalCoords const&); /// Convert Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&); /// Set Frame from internal coords int SetToFrame(Frame&) const; + /// Print to stdout + void print() const; private: typedef std::vector ICarray; diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 2bd39b7e02..c72b35a8f2 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -204,7 +204,7 @@ DataFileList.o : DataFileList.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h A DataFilter.o : DataFilter.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_integer.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO.o : DataIO.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataSet.h DataSetList.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixDbl.h Dimension.h FileIO.h FileName.h Frame.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 Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_AmberEne.o : DataIO_AmberEne.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberEne.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h -DataIO_AmberPrep.o : DataIO_AmberPrep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberPrep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h +DataIO_AmberPrep.o : DataIO_AmberPrep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberPrep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_Topology.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CCP4.o : DataIO_CCP4.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ByteRoutines.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CCP4.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridFlt.h Dimension.h FileIO.h FileName.h Frame.h Grid.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmFastRep.o : DataIO_CharmmFastRep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmFastRep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_RemLog.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmOutput.o : DataIO_CharmmOutput.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmOutput.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_double.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h From a8df0a1b857d3f7cbd7c4ed11410f9bf29a986be Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 25 Sep 2023 14:03:42 -0400 Subject: [PATCH 016/245] Add bonds to top --- src/DataIO_AmberPrep.cpp | 12 +++++++++++- src/Structure/Zmatrix.cpp | 1 - src/Structure/Zmatrix.h | 8 ++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 2249cd64a3..70d4f7584e 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -4,7 +4,6 @@ #include "DataSet_Topology.h" #include "StringRoutines.h" #include "Structure/Zmatrix.h" -#include "Structure/InternalCoords.h" /// CONSTRUCTOR DataIO_AmberPrep::DataIO_AmberPrep() @@ -154,6 +153,7 @@ int DataIO_AmberPrep::ReadData(FileName const& fname, DataSetList& dsl, std::str // Loop over entries line = infile.Line(); if (CheckLine(line)) return 1; + int atIdx = 0; while (line[0] != '\0') { mprintf("DEBUG: '%s'\n", line); args.SetList( line, " \t" ); @@ -172,18 +172,28 @@ int DataIO_AmberPrep::ReadData(FileName const& fname, DataSetList& dsl, std::str } else top.AddTopAtom( Atom(args[1], args[2], charge), res ); // Add zmatrix entry. In prep file, indices start from 1. + int atI = convertToInteger(args[0]) - 1; + if (atI != atIdx) { + mprinterr("Error: Expected index %i, got %i\n", atIdx + 1, atI + 1); + return 1; + } int atJ = convertToInteger(args[4]) - 1; int atK = convertToInteger(args[5]) - 1; int atL = convertToInteger(args[6]) - 1; double dist = convertToDouble(args[7]); double theta = convertToDouble(args[8]); double phi = convertToDouble(args[9]); + atIdx++; zmatrix.AddIC( InternalCoords(atJ, atK, atL, dist, theta, phi) ); line = infile.Line(); if (line == 0) break; } // Ignore everything else for now infile.CloseFile(); + // Add bonds to topology + for (Zmatrix::const_iterator it = zmatrix.begin(); it != zmatrix.end(); ++it) + if (it->AtJ() != InternalCoords::NO_ATOM) + top.AddBond( it - zmatrix.begin(), it->AtJ() ); // Set up topology top.CommonSetup(true, false); top.Summary(); diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 70b49de2ea..132105e784 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -1,6 +1,5 @@ #include #include "Zmatrix.h" -#include "InternalCoords.h" #include "../Frame.h" #include "../CpptrajStdio.h" #include "../Constants.h" diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index abfedb4a0f..a3c254e93d 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -1,12 +1,13 @@ #ifndef INC_STRUCTURE_ZMATRIX_H #define INC_STRUCTURE_ZMATRIX_H +#include "InternalCoords.h" class Frame; class Topology; namespace Cpptraj { namespace Structure { -class InternalCoords; /// Hold internal coordinates for a system. class Zmatrix { + typedef std::vector ICarray; public: /// CONSTRUCTOR Zmatrix(); @@ -18,8 +19,11 @@ class Zmatrix { int SetToFrame(Frame&) const; /// Print to stdout void print() const; + + typedef ICarray::const_iterator const_iterator; + const_iterator begin() const { return IC_.begin(); } + const_iterator end() const { return IC_.end(); } private: - typedef std::vector ICarray; ICarray IC_; ///< Hold internal coordinates for all atoms int seed0_; ///< Index of first seed atom From a802f2e2ba708c24b4ac4290f8f98653a08f891b Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 25 Sep 2023 14:10:18 -0400 Subject: [PATCH 017/245] Add ability to add atoms as a seed --- src/DataIO_AmberPrep.cpp | 6 +++++- src/Structure/Zmatrix.cpp | 17 +++++++++++++++++ src/Structure/Zmatrix.h | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 70d4f7584e..dad87f7931 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -184,7 +184,11 @@ int DataIO_AmberPrep::ReadData(FileName const& fname, DataSetList& dsl, std::str double theta = convertToDouble(args[8]); double phi = convertToDouble(args[9]); atIdx++; - zmatrix.AddIC( InternalCoords(atJ, atK, atL, dist, theta, phi) ); + if (args[2] == ISYMDU) { + if (zmatrix.AddICseed( InternalCoords(atJ, atK, atL, dist, theta, phi) )) + return 1; + } else + zmatrix.AddIC( InternalCoords(atJ, atK, atL, dist, theta, phi) ); line = infile.Line(); if (line == 0) break; } diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 132105e784..48ab1cb793 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -19,9 +19,26 @@ void Zmatrix::AddIC(InternalCoords const& ic) { IC_.push_back( ic ); } +/** Add internal coords as a seed. */ +int Zmatrix::AddICseed(InternalCoords const& ic) { + if (seed0_ == InternalCoords::NO_ATOM) + seed0_ = IC_.size(); + else if (seed1_ == InternalCoords::NO_ATOM) + seed1_ = IC_.size(); + else if (seed2_ == InternalCoords::NO_ATOM) + seed2_ = IC_.size(); + else { + mprinterr("Error: Too many seed atoms.\n"); + return 1; + } + IC_.push_back( ic ); + return 0; +} + /** Print to stdout */ void Zmatrix::print() const { mprintf("%zu internal coords.\n", IC_.size()); + mprintf("Seed atoms: %i %i %i\n", seed0_+1, seed1_+1, seed2_+1); for (ICarray::const_iterator it = IC_.begin(); it != IC_.end(); ++it) mprintf("\t%8li %8i %8i %8i %12.4f %12.4f %12.4f\n", it - IC_.begin() + 1, it->AtJ()+1, it->AtK()+1, it->AtL()+1, diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index a3c254e93d..9a4453e02a 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -13,6 +13,8 @@ class Zmatrix { Zmatrix(); /// Add internal coordinate void AddIC(InternalCoords const&); + /// Add internal coordinate as next available seed + int AddICseed(InternalCoords const&); /// Convert Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&); /// Set Frame from internal coords From 35eb86df9a67657b9fb67c3b9539a111c35a9502 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 25 Sep 2023 14:19:39 -0400 Subject: [PATCH 018/245] Do frame setup --- src/DataIO_AmberPrep.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index dad87f7931..e318f4274c 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -2,6 +2,7 @@ #include "CpptrajStdio.h" #include "BufferedLine.h" #include "DataSet_Topology.h" +#include "DataSet_Coords.h" #include "StringRoutines.h" #include "Structure/Zmatrix.h" @@ -202,6 +203,27 @@ int DataIO_AmberPrep::ReadData(FileName const& fname, DataSetList& dsl, std::str top.CommonSetup(true, false); top.Summary(); zmatrix.print(); + // Frame set + ds = dsl.AddSet( DataSet::REF_FRAME, MetaData(dsname, "crd") ); + if (ds == 0) { + mprinterr("Error: Could not create coordinates for prep.\n"); + return 1; + } + DataSet_Coords* CRD = static_cast( ds ); + // Frame + Frame frm( top.Natom() ); + // Internal coords to cart + if (zmatrix.SetToFrame( frm )) { + mprinterr("Error: IC to Cartesian coords failed.\n"); + return 1; + } + // TODO delete dummy atoms + // Output Set up frame set + if (CRD->CoordsSetup(top, CoordinateInfo())) { + mprinterr("Error: Could not set up COORDS set for prep.\n"); + return 1; + } + CRD->SetCRD(0, frm); return 0; } From 5074294e210093289b151cdf6154f7bc03db91dd Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 25 Sep 2023 14:35:01 -0400 Subject: [PATCH 019/245] Find next atom to set --- src/Structure/Zmatrix.cpp | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 48ab1cb793..e76e581bf4 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -58,6 +58,13 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) return 0; } +static inline void atomIsSet(int i, std::vector& isSet, unsigned int& Nset) { + if (!isSet[i]) { + isSet[i] = true; + Nset++; + } +} + /** Set Cartesian coordinates in Frame from internal coordinates. */ int Zmatrix::SetToFrame(Frame& frameOut) const { if ((unsigned int)frameOut.Natom() != IC_.size()) { @@ -65,10 +72,14 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { frameOut.Natom(), IC_.size()); return 1; } + + std::vector isSet( IC_.size(), false ); + unsigned int Nset = 0; // Set position of the first atom. if (seed0_ != InternalCoords::NO_ATOM) { //IC_[seed0_].ZeroXYZ(); frameOut.SetXYZ(seed0_, Vec3(0.0)); + atomIsSet(seed0_, isSet, Nset); // Set position of the second atom. if (seed1_ != InternalCoords::NO_ATOM) { if (IC_[seed1_].AtJ() != seed0_) { @@ -78,6 +89,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { double r1 = IC_[seed1_].Dist(); //IC_[seed1_].SetXYZ( Vec3(r1, 0, 0) ); frameOut.SetXYZ(seed1_, Vec3(r1, 0, 0)); + atomIsSet(seed1_, isSet, Nset); // Set position of the third atom if (seed2_ != InternalCoords::NO_ATOM) { if (IC_[seed2_].AtJ() != seed1_) { @@ -96,9 +108,41 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { //IC_[seed2].SetXYZ( Vec3(r1 + x, y, 0) ); frameOut.SetXYZ( seed2_, Vec3(r1 + x, y, 0) ); + atomIsSet(seed2_, isSet, Nset); } // END seed atom 2 } // END seed atom 1 } // END seed atom 0 + // Find the lowest unset atom + unsigned int lowestUnsetAtom = 0; + for (; lowestUnsetAtom < IC_.size(); ++lowestUnsetAtom) + if (!isSet[lowestUnsetAtom]) break; + mprintf("Lowest unset atom: %u\n", lowestUnsetAtom+1); + + // Loop over remaining atoms + while (Nset < IC_.size()) { + // Find the next atom that is not yet set. + unsigned int idx = lowestUnsetAtom; + bool findNextAtom = true; + while (findNextAtom) { + while (idx < IC_.size() && isSet[idx]) idx++; + if (idx >= IC_.size()) { + mprinterr("Error: Could not find next atom to set.\n"); + return 1; + } + // All 3 of the connecting atoms must be set + if (isSet[ IC_[idx].AtJ() ] && + isSet[ IC_[idx].AtK() ] && + isSet[ IC_[idx].AtL() ]) + { + findNextAtom = false; + } + } // END loop finding next atom to set + mprintf("DEBUG: Next atom to set is %u\n", idx+1); + break; // DEBUG + } // END loop over internal coordinates + + + return 0; } From 1c34304a624e88f25c9d3d9b19283d39a83487b1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 25 Sep 2023 15:24:05 -0400 Subject: [PATCH 020/245] Build the rest of the coordinates --- src/Structure/Zmatrix.cpp | 43 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index e76e581bf4..98fd153297 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -139,7 +139,48 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { } } // END loop finding next atom to set mprintf("DEBUG: Next atom to set is %u\n", idx+1); - break; // DEBUG + + InternalCoords const& ic = IC_[idx]; + double rdist = ic.Dist(); + double theta = ic.Theta(); + double phi = ic.Phi(); + + double sinTheta = sin(theta * Constants::DEGRAD); + double cosTheta = cos(theta * Constants::DEGRAD); + double sinPhi = sin(phi * Constants::DEGRAD); + double cosPhi = cos(phi * Constants::DEGRAD); + + // NOTE: Want -x + Vec3 xyz( -(rdist * cosTheta), + rdist * cosPhi * sinTheta, + rdist * sinPhi * sinTheta ); + + Vec3 a = Vec3( frameOut.XYZ( ic.AtL()) ); + Vec3 b = Vec3( frameOut.XYZ( ic.AtK()) ); + Vec3 c = Vec3( frameOut.XYZ( ic.AtJ()) ); + + Vec3 ab = b - a; + Vec3 bc = c - b; + bc.Normalize(); + Vec3 n = ab.Cross(bc); + n.Normalize(); + Vec3 ncbc = n.Cross(bc); + + Matrix_3x3 M( bc[0], ncbc[0], n[0], + bc[1], ncbc[1], n[1], + bc[2], ncbc[2], n[2] ); + + Vec3 d = (M * xyz) + c; + + frameOut.SetXYZ( idx, d ); + atomIsSet(idx, isSet, Nset); + + // Next lowest unset atom + for (; lowestUnsetAtom < IC_.size(); ++lowestUnsetAtom) + if (!isSet[lowestUnsetAtom]) break; + + + //break; // DEBUG } // END loop over internal coordinates From ba3e4ea020f8cb08718eb1b7f27f0f98769ac523 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 08:33:58 -0400 Subject: [PATCH 021/245] Do not create separate topology data set. Remove dummy atoms. --- src/DataFile.cpp | 2 +- src/DataIO_AmberPrep.cpp | 60 +++++++++++++++++++++++++++++----------- src/DataIO_AmberPrep.h | 2 ++ src/cpptrajdepend | 2 +- 4 files changed, 48 insertions(+), 18 deletions(-) diff --git a/src/DataFile.cpp b/src/DataFile.cpp index 060eeb4f54..5fd034d5f9 100644 --- a/src/DataFile.cpp +++ b/src/DataFile.cpp @@ -86,7 +86,7 @@ const FileTypes::AllocToken DataFile::DF_AllocArray[] = { # endif { "Amber Energy File", 0, 0, DataIO_AmberEne::Alloc}, { "Numpy array", 0, 0, DataIO_Numpy::Alloc}, - { "Amber Prep File", 0, 0, DataIO_AmberPrep::Alloc}, + { "Amber Prep File", DataIO_AmberPrep::ReadHelp, 0, DataIO_AmberPrep::Alloc}, { "Unknown Data file", 0, 0, 0 } }; diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index e318f4274c..43afe0ff8e 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -1,16 +1,14 @@ #include "DataIO_AmberPrep.h" #include "CpptrajStdio.h" #include "BufferedLine.h" -#include "DataSet_Topology.h" #include "DataSet_Coords.h" #include "StringRoutines.h" #include "Structure/Zmatrix.h" /// CONSTRUCTOR -DataIO_AmberPrep::DataIO_AmberPrep() -{ - -} +DataIO_AmberPrep::DataIO_AmberPrep() : + removeDummyAtoms_(true) +{ } // DataIO_AmberPrep::ID_DataFormat() bool DataIO_AmberPrep::ID_DataFormat(CpptrajFile& infile) @@ -22,16 +20,17 @@ bool DataIO_AmberPrep::ID_DataFormat(CpptrajFile& infile) // DataIO_AmberPrep::ReadHelp() void DataIO_AmberPrep::ReadHelp() { - + mprintf("\tkeepdummyatoms : Keep dummy atoms instead of removing them.\n"); } // DataIO_AmberPrep::processReadArgs() int DataIO_AmberPrep::processReadArgs(ArgList& argIn) { - + removeDummyAtoms_ = !argIn.hasKey("keepdummyatoms"); return 0; } +/// Used to check for premature EOF static inline int CheckLine(const char* line) { if (line==0) { mprinterr("Error: Unexpected end of prep file.\n"); @@ -143,12 +142,13 @@ int DataIO_AmberPrep::ReadData(FileName const& fname, DataSetList& dsl, std::str using namespace Cpptraj::Structure; Zmatrix zmatrix; // Topology - DataSet* ds = dsl.AddSet( DataSet::TOPOLOGY, MetaData(dsname, "top") ); - if (ds == 0) { - mprinterr("Error: Could not create topology for prep.\n"); - return 1; - } - Topology& top = ((DataSet_Topology*)ds)->ModifyTop(); + //DataSet* ds = dsl.AddSet( DataSet::TOPOLOGY, MetaData(dsname, "top") ); + //if (ds == 0) { + // mprinterr("Error: Could not create topology for prep.\n"); + // return 1; + //} + //Topology& top = ((DataSet_Topology*)ds)->ModifyTop(); + Topology top; // Residue Residue res(resName, 1, ' ', ' '); // Loop over entries @@ -201,10 +201,12 @@ int DataIO_AmberPrep::ReadData(FileName const& fname, DataSetList& dsl, std::str top.AddBond( it - zmatrix.begin(), it->AtJ() ); // Set up topology top.CommonSetup(true, false); + top.SetParmName( resName, fname ); top.Summary(); zmatrix.print(); - // Frame set - ds = dsl.AddSet( DataSet::REF_FRAME, MetaData(dsname, "crd") ); + // Create COORDS set + //ds = dsl.AddSet( DataSet::REF_FRAME, MetaData(dsname, "crd") ); + DataSet* ds = dsl.AddSet( DataSet::REF_FRAME, MetaData(dsname) ); if (ds == 0) { mprinterr("Error: Could not create coordinates for prep.\n"); return 1; @@ -217,7 +219,33 @@ int DataIO_AmberPrep::ReadData(FileName const& fname, DataSetList& dsl, std::str mprinterr("Error: IC to Cartesian coords failed.\n"); return 1; } - // TODO delete dummy atoms + // Delete dummy atoms if needed + if (removeDummyAtoms_) { + AtomMask keepAtoms; + if (keepAtoms.SetMaskString( "!@%" + ISYMDU )) { + mprinterr("Error: Could not set up mask string to remove dummy atoms.\n"); + return 1; + } + if (top.SetupIntegerMask( keepAtoms )) { + mprinterr("Error: Could not set up mask '%s' to remove dummy atoms.\n", keepAtoms.MaskString()); + return 1; + } + keepAtoms.MaskInfo(); + if (keepAtoms.Nselected() == top.Natom()) { + mprintf("\tNo dummy atoms to remove.\n"); + } else { + Topology* newTop = top.modifyStateByMask( keepAtoms ); + if (newTop == 0) { + mprinterr("Error: Could not remove dummy atoms.\n"); + return 1; + } + Frame newFrame( frm, keepAtoms ); + top = *newTop; + delete newTop; + frm = newFrame; + top.Summary(); + } + } // Output Set up frame set if (CRD->CoordsSetup(top, CoordinateInfo())) { mprinterr("Error: Could not set up COORDS set for prep.\n"); diff --git a/src/DataIO_AmberPrep.h b/src/DataIO_AmberPrep.h index 01a08326d3..1753cf1de9 100644 --- a/src/DataIO_AmberPrep.h +++ b/src/DataIO_AmberPrep.h @@ -13,5 +13,7 @@ class DataIO_AmberPrep : public DataIO { int processWriteArgs(ArgList&); int WriteData(FileName const&, DataSetList const&); bool ID_DataFormat(CpptrajFile&); + private: + bool removeDummyAtoms_; ///< Remove dummy atoms if true }; #endif diff --git a/src/cpptrajdepend b/src/cpptrajdepend index c72b35a8f2..06569a71ed 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -204,7 +204,7 @@ DataFileList.o : DataFileList.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h A DataFilter.o : DataFilter.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_integer.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO.o : DataIO.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataSet.h DataSetList.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixDbl.h Dimension.h FileIO.h FileName.h Frame.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 Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_AmberEne.o : DataIO_AmberEne.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberEne.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h -DataIO_AmberPrep.o : DataIO_AmberPrep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberPrep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_Topology.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h +DataIO_AmberPrep.o : DataIO_AmberPrep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberPrep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CCP4.o : DataIO_CCP4.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ByteRoutines.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CCP4.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridFlt.h Dimension.h FileIO.h FileName.h Frame.h Grid.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmFastRep.o : DataIO_CharmmFastRep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmFastRep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_RemLog.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmOutput.o : DataIO_CharmmOutput.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmOutput.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_double.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h From e991c33b69e2260572eda8bcd6cd5fa6c48aece5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 09:26:34 -0400 Subject: [PATCH 022/245] Put prep residue read in separate function, read past section 9 --- src/DataIO_AmberPrep.cpp | 88 +++++++++++++++++++++++++++++----------- src/DataIO_AmberPrep.h | 3 ++ 2 files changed, 68 insertions(+), 23 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 43afe0ff8e..dbffc51df8 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -39,28 +39,15 @@ static inline int CheckLine(const char* line) { return 0; } -// DataIO_AmberPrep::ReadData() -int DataIO_AmberPrep::ReadData(FileName const& fname, DataSetList& dsl, std::string const& dsname) +/** Read 1 or more PREP residue sections (cards 3-10). + * \return 1 if error, -1 if STOP/EOF, 0 if more residues to be read. + */ +int DataIO_AmberPrep::readAmberPrep(BufferedLine& infile, DataSetList& dsl, std::string const& dsname) +const { - BufferedLine infile; - - if (infile.OpenFileRead(fname)) { - mprinterr("Error: Could not open '%s'\n", fname.full()); - return 1; - } - // 1 - Control for data base generation - // IDBGEN, IREST, ITYPF - // Format (3I) - const char* line = infile.Line(); - if (CheckLine(line)) return 1; - // 2 - Name of the data base file. Blank if not data base gen. - // NAMDBF - // Format (A80) - line = infile.Line(); - if (CheckLine(line)) return 1; // 3 - Title // Descriptive header for the residue - line = infile.Line(); + const char* line = infile.Line(); if (CheckLine(line)) return 1; mprintf("DEBUG: Prep title: '%s'\n", line); // 4 - Name of output file if an individual res file is being generated @@ -193,20 +180,39 @@ int DataIO_AmberPrep::ReadData(FileName const& fname, DataSetList& dsl, std::str line = infile.Line(); if (line == 0) break; } - // Ignore everything else for now - infile.CloseFile(); + // 9 - Read additional information about the residue. + // CHARGE - Read additional partial atomic charges. FORMAT (5f) + // LOOP - Read explicit loop closing bonds + int errStat = 0; + while (line != 0) { + if (line[0] != '\0') { + std::string lineStr(line); + if (lineStr == "DONE") { + // Check for STOP + line = infile.Line(); + if (line == 0) + errStat = -1; + else if (std::string(line) == "STOP") + errStat = -1; + break; + } // TODO CHARGE, LOOP + } + line = infile.Line(); + } + // ----------------------------------- // Add bonds to topology for (Zmatrix::const_iterator it = zmatrix.begin(); it != zmatrix.end(); ++it) if (it->AtJ() != InternalCoords::NO_ATOM) top.AddBond( it - zmatrix.begin(), it->AtJ() ); + // TODO bond search? // Set up topology top.CommonSetup(true, false); - top.SetParmName( resName, fname ); + top.SetParmName( resName, infile.Filename() ); top.Summary(); zmatrix.print(); // Create COORDS set //ds = dsl.AddSet( DataSet::REF_FRAME, MetaData(dsname, "crd") ); - DataSet* ds = dsl.AddSet( DataSet::REF_FRAME, MetaData(dsname) ); + DataSet* ds = dsl.AddSet( DataSet::REF_FRAME, MetaData(dsname, resName) ); if (ds == 0) { mprinterr("Error: Could not create coordinates for prep.\n"); return 1; @@ -253,6 +259,42 @@ int DataIO_AmberPrep::ReadData(FileName const& fname, DataSetList& dsl, std::str } CRD->SetCRD(0, frm); + return errStat; +} + +// DataIO_AmberPrep::ReadData() +int DataIO_AmberPrep::ReadData(FileName const& fname, DataSetList& dsl, std::string const& dsname) +{ + BufferedLine infile; + + if (infile.OpenFileRead(fname)) { + mprinterr("Error: Could not open '%s'\n", fname.full()); + return 1; + } + // 1 - Control for data base generation + // IDBGEN, IREST, ITYPF + // Format (3I) + const char* line = infile.Line(); + if (CheckLine(line)) return 1; + // 2 - Name of the data base file. Blank if not data base gen. + // NAMDBF + // Format (A80) + line = infile.Line(); + if (CheckLine(line)) return 1; + + bool readPrep = true; + while (readPrep) { + int errStat = readAmberPrep(infile, dsl, dsname); + if (errStat == 1) { + mprinterr("Error: Could not read residue(s) from prep file.\n"); + return 1; + } else if (errStat == -1) { + readPrep = false; + } + } + + infile.CloseFile(); + return 0; } diff --git a/src/DataIO_AmberPrep.h b/src/DataIO_AmberPrep.h index 1753cf1de9..31009de737 100644 --- a/src/DataIO_AmberPrep.h +++ b/src/DataIO_AmberPrep.h @@ -1,6 +1,7 @@ #ifndef INC_DATAIO_AMBERPREP_H #define INC_DATAIO_AMBERPREP_H #include "DataIO.h" +class BufferedLine; /// Read in the Amber prep file format class DataIO_AmberPrep : public DataIO { public: @@ -14,6 +15,8 @@ class DataIO_AmberPrep : public DataIO { int WriteData(FileName const&, DataSetList const&); bool ID_DataFormat(CpptrajFile&); private: + int readAmberPrep(BufferedLine&, DataSetList&, std::string const&) const; + bool removeDummyAtoms_; ///< Remove dummy atoms if true }; #endif From 7acec660d7bdf3c7ea9a88fdd24adef47626e66e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 09:51:46 -0400 Subject: [PATCH 023/245] Separate routines for reading sections. Add bonds from LOOP sections --- src/DataIO_AmberPrep.cpp | 62 +++++++++++++++++++++++++++++++++++++++- src/DataIO_AmberPrep.h | 8 ++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index dbffc51df8..de3bf2c3b0 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -39,6 +39,42 @@ static inline int CheckLine(const char* line) { return 0; } +/** Read CHARGE section. */ +int DataIO_AmberPrep::readCHARGE(BufferedLine& infile) const { + const char* line = infile.Line(); + while (line != 0 && line[0] != '\0') { + mprintf("DEBUG: CHARGE: %s\n", line); + line = infile.Line(); + } + return 0; +} + +/** Read LOOP section. */ +int DataIO_AmberPrep::readLOOP(BufferedLine& infile, AtPairArray& BondPairs) const { + const char* line = infile.Line(); + while (line != 0 && line[0] != '\0') { + mprintf("DEBUG: LOOP: %s\n", line); + ArgList atpair(line, " \t"); + if (atpair.Nargs() != 2) { + mprinterr("Error: Expected 2 atom names, got %i: %s\n", atpair.Nargs(), line); + return 1; + } + BondPairs.push_back(AtPairType(atpair[0], atpair[1])); + line = infile.Line(); + } + return 0; +} + +/** Read IMPROPER section. */ +int DataIO_AmberPrep::readIMPROPER(BufferedLine& infile) const { + const char* line = infile.Line(); + while (line != 0 && line[0] != '\0') { + mprintf("DEBUG: IMPROPER: %s\n", line); + line = infile.Line(); + } + return 0; +} + /** Read 1 or more PREP residue sections (cards 3-10). * \return 1 if error, -1 if STOP/EOF, 0 if more residues to be read. */ @@ -183,6 +219,8 @@ const // 9 - Read additional information about the residue. // CHARGE - Read additional partial atomic charges. FORMAT (5f) // LOOP - Read explicit loop closing bonds + // IMPROPER - Read improper torsion angles. + AtPairArray BondPairs; int errStat = 0; while (line != 0) { if (line[0] != '\0') { @@ -195,7 +233,16 @@ const else if (std::string(line) == "STOP") errStat = -1; break; - } // TODO CHARGE, LOOP + } else if (lineStr == "CHARGE") { + readCHARGE(infile); + } else if (lineStr == "LOOP") { + if (readLOOP(infile, BondPairs)) { + mprinterr("Error: Reading LOOP section.\n"); + return 1; + } + } else if (lineStr == "IMPROPER") { + readIMPROPER(infile); + } } line = infile.Line(); } @@ -204,6 +251,19 @@ const for (Zmatrix::const_iterator it = zmatrix.begin(); it != zmatrix.end(); ++it) if (it->AtJ() != InternalCoords::NO_ATOM) top.AddBond( it - zmatrix.begin(), it->AtJ() ); + for (AtPairArray::const_iterator it = BondPairs.begin(); it != BondPairs.end(); ++it) { + int idx1 = top.FindAtomInResidue(0, it->first); + if (idx1 < 0) { + mprinterr("Error: Could not find LOOP atom '%s'\n", it->first.c_str()); + return 1; + } + int idx2 = top.FindAtomInResidue(0, it->second); + if (idx2 < 0) { + mprinterr("Error: Could not find LOOP atom '%s'\n", it->second.c_str()); + return 1; + } + top.AddBond( idx1, idx2 ); + } // TODO bond search? // Set up topology top.CommonSetup(true, false); diff --git a/src/DataIO_AmberPrep.h b/src/DataIO_AmberPrep.h index 31009de737..2f86f4adab 100644 --- a/src/DataIO_AmberPrep.h +++ b/src/DataIO_AmberPrep.h @@ -1,5 +1,7 @@ #ifndef INC_DATAIO_AMBERPREP_H #define INC_DATAIO_AMBERPREP_H +#include +#include #include "DataIO.h" class BufferedLine; /// Read in the Amber prep file format @@ -15,6 +17,12 @@ class DataIO_AmberPrep : public DataIO { int WriteData(FileName const&, DataSetList const&); bool ID_DataFormat(CpptrajFile&); private: + typedef std::pair AtPairType; + typedef std::vector AtPairArray; + + int readCHARGE(BufferedLine&) const; + int readLOOP(BufferedLine&, AtPairArray&) const; + int readIMPROPER(BufferedLine&) const; int readAmberPrep(BufferedLine&, DataSetList&, std::string const&) const; bool removeDummyAtoms_; ///< Remove dummy atoms if true From 0b3d096004d297393a0f41950d03f26c9cf0b282 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 10:02:17 -0400 Subject: [PATCH 024/245] Add Test --- test/Test_ReadPrep/RunTest.sh | 18 ++++++++++++++++++ test/Test_ReadPrep/epACE.prepin | 26 ++++++++++++++++++++++++++ test/Test_ReadPrep/test1.mol2.save | 24 ++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 test/Test_ReadPrep/RunTest.sh create mode 100644 test/Test_ReadPrep/epACE.prepin create mode 100644 test/Test_ReadPrep/test1.mol2.save diff --git a/test/Test_ReadPrep/RunTest.sh b/test/Test_ReadPrep/RunTest.sh new file mode 100644 index 0000000000..7fda6c2511 --- /dev/null +++ b/test/Test_ReadPrep/RunTest.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +. ../MasterTest.sh + +CleanFiles cpptraj.in test1.mol2 + +INPUT='-i cpptraj.in' + +TESTNAME='Test Prep File Read and Zmatrix Functionality' + +cat > cpptraj.in <MOLECULE +Cpptraj Generated mol2 file. + 7 6 1 0 0 +SMALL +USER_CHARGES + + +@ATOM + 1 C 2.8833 -0.5961 -0.0000 C 1 ACE 0.622165 + 2 CH3 1.6792 0.3097 0.0990 CT 1 ACE -0.184601 + 3 HH31 0.7746 -0.2946 0.1110 HC 1 ACE 0.065183 + 4 HH32 1.7446 0.9090 1.0047 HC 1 ACE 0.065183 + 5 HH33 1.6621 0.9675 -0.7700 HC 1 ACE 0.065183 + 6 O 3.5821 -0.5797 -1.0036 OD 1 ACE -0.633114 + 7 EP1 4.5687 -0.5565 -2.4208 EP 1 ACE 0.000000 +@BOND + 1 2 1 1 + 2 6 1 1 + 3 7 6 1 + 4 2 3 1 + 5 2 4 1 + 6 2 5 1 +@SUBSTRUCTURE + 1 ACE 1 **** 0 **** **** From 43b4346ceb76a8b1df1a98387612d8b89ee60d52 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 10:02:49 -0400 Subject: [PATCH 025/245] Make exe --- test/Test_ReadPrep/RunTest.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/Test_ReadPrep/RunTest.sh diff --git a/test/Test_ReadPrep/RunTest.sh b/test/Test_ReadPrep/RunTest.sh old mode 100644 new mode 100755 From 9c81033027c2ff9df65fa7e92401032bd4aead1f Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 10:02:58 -0400 Subject: [PATCH 026/245] Improve check for STOP --- src/DataIO_AmberPrep.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index de3bf2c3b0..140413ba83 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -84,8 +84,16 @@ const // 3 - Title // Descriptive header for the residue const char* line = infile.Line(); - if (CheckLine(line)) return 1; + // If EOF here, assume missing STOP + if (line == 0) { + mprintf("Warning: Prep file '%s' missing STOP.\n", infile.Filename().base()); + return -1; + } + // Check for STOP + if (std::string(line) == "STOP") + return -1; mprintf("DEBUG: Prep title: '%s'\n", line); + // 4 - Name of output file if an individual res file is being generated // NAMF // Format (A80) @@ -226,12 +234,7 @@ const if (line[0] != '\0') { std::string lineStr(line); if (lineStr == "DONE") { - // Check for STOP - line = infile.Line(); - if (line == 0) - errStat = -1; - else if (std::string(line) == "STOP") - errStat = -1; + break; } else if (lineStr == "CHARGE") { readCHARGE(infile); From 364f086dced93fa5c99b4fae35d1a2ed8e492b76 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 10:13:24 -0400 Subject: [PATCH 027/245] Hide some debug info. Warn about non-zero bond cutoff --- src/DataIO_AmberPrep.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 140413ba83..d63896b1f4 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -92,7 +92,8 @@ const // Check for STOP if (std::string(line) == "STOP") return -1; - mprintf("DEBUG: Prep title: '%s'\n", line); + if (debug_ > 0) + mprintf("DEBUG: Prep title: '%s'\n", line); // 4 - Name of output file if an individual res file is being generated // NAMF @@ -114,7 +115,8 @@ const std::string resName = args.GetStringNext(); std::string coordFlag = args.GetStringNext(); int kform = args.getNextInteger(-1); - mprintf("DEBUG: %s %s %i\n", resName.c_str(), coordFlag.c_str(), kform); + if (debug_ > 0) + mprintf("DEBUG: %s %s %i\n", resName.c_str(), coordFlag.c_str(), kform); // 6 - IFIXC , IOMIT , ISYMDU , IPOS // FORMAT (4A) // IFIXC Flag for the type of input geometry of the residue(s) @@ -155,9 +157,11 @@ const std::string IOMIT = args.GetStringNext(); std::string ISYMDU = args.GetStringNext(); std::string IPOS = args.GetStringNext(); - mprintf("DEBUG: %s %s %s %s\n", IFIXC.c_str(), IOMIT.c_str(), ISYMDU.c_str(), IPOS.c_str()); + if (debug_ > 0) + mprintf("DEBUG: %s %s %s %s\n", IFIXC.c_str(), IOMIT.c_str(), ISYMDU.c_str(), IPOS.c_str()); if (IFIXC != "CORRECT") { - mprinterr("Error: IFIXC is not 'CORRECT' (%s=)\n", IFIXC.c_str()); + mprinterr("Error: IFIXC is not 'CORRECT' (%s=); only internal coordinates currently supported.\n", + IFIXC.c_str()); return 1; } // 7 - CUT @@ -166,6 +170,11 @@ const // atoms within this distance is assumed to be bonded. line = infile.Line(); if (CheckLine(line)) return 1; + double bondCutoff = 0; + if (line[0] != '\0') + bondCutoff = convertToDouble( std::string(line) ); + if (bondCutoff > 0.0) + mprintf("Warning: Non-zero cutoff in prep file (%g); currently ignored.\n", bondCutoff); // 0 1 2 3 4 5 6 7 8 9 10 // 8 - I IGRAPH(I) ISYMBL(I) ITREE(I) NA(I) NB(I) NC(I) R(I) THETA(I) PHI(I) CHG(I) [I = 1, NATOM] // FORMAT(I,3A,3I,4F) From e7cd25fc83f69388168ef3973cf07e44ceb359a2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 10:19:01 -0400 Subject: [PATCH 028/245] Add debug level to Zmatrix --- src/DataIO_AmberPrep.cpp | 12 ++++++++---- src/Structure/Zmatrix.cpp | 5 +++-- src/Structure/Zmatrix.h | 4 +++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index d63896b1f4..11c8564917 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -181,6 +181,7 @@ const // Terminated by a blank line using namespace Cpptraj::Structure; Zmatrix zmatrix; + zmatrix.SetDebug( debug_ ); // Topology //DataSet* ds = dsl.AddSet( DataSet::TOPOLOGY, MetaData(dsname, "top") ); //if (ds == 0) { @@ -196,7 +197,8 @@ const if (CheckLine(line)) return 1; int atIdx = 0; while (line[0] != '\0') { - mprintf("DEBUG: '%s'\n", line); + if (debug_ > 1) + mprintf("DEBUG: '%s'\n", line); args.SetList( line, " \t" ); if (args.Nargs() != 11) { mprinterr("Error: Expected 11 columns in prep line, got %i\n", args.Nargs()); @@ -280,8 +282,10 @@ const // Set up topology top.CommonSetup(true, false); top.SetParmName( resName, infile.Filename() ); - top.Summary(); - zmatrix.print(); + if (debug_ > 0) + top.Summary(); + if (debug_ > 1) + zmatrix.print(); // Create COORDS set //ds = dsl.AddSet( DataSet::REF_FRAME, MetaData(dsname, "crd") ); DataSet* ds = dsl.AddSet( DataSet::REF_FRAME, MetaData(dsname, resName) ); @@ -321,7 +325,7 @@ const top = *newTop; delete newTop; frm = newFrame; - top.Summary(); + if (debug_ > 0) top.Summary(); } } // Output Set up frame set diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 98fd153297..2aa6804ded 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -9,6 +9,7 @@ using namespace Cpptraj::Structure; /** CONSTRUCTOR */ Zmatrix::Zmatrix() : + debug_(0), seed0_(InternalCoords::NO_ATOM), seed1_(InternalCoords::NO_ATOM), seed2_(InternalCoords::NO_ATOM) @@ -117,7 +118,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { unsigned int lowestUnsetAtom = 0; for (; lowestUnsetAtom < IC_.size(); ++lowestUnsetAtom) if (!isSet[lowestUnsetAtom]) break; - mprintf("Lowest unset atom: %u\n", lowestUnsetAtom+1); + if (debug_ > 0) mprintf("DEBUG: Lowest unset atom: %u\n", lowestUnsetAtom+1); // Loop over remaining atoms while (Nset < IC_.size()) { @@ -138,7 +139,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { findNextAtom = false; } } // END loop finding next atom to set - mprintf("DEBUG: Next atom to set is %u\n", idx+1); + if (debug_ > 0) mprintf("DEBUG: Next atom to set is %u\n", idx+1); InternalCoords const& ic = IC_[idx]; double rdist = ic.Dist(); diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 9a4453e02a..69eaf4aab7 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -11,6 +11,8 @@ class Zmatrix { public: /// CONSTRUCTOR Zmatrix(); + /// Set debug level + void SetDebug(int d) { debug_ = d; } /// Add internal coordinate void AddIC(InternalCoords const&); /// Add internal coordinate as next available seed @@ -26,7 +28,7 @@ class Zmatrix { const_iterator begin() const { return IC_.begin(); } const_iterator end() const { return IC_.end(); } private: - + int debug_; ///< Print debug info ICarray IC_; ///< Hold internal coordinates for all atoms int seed0_; ///< Index of first seed atom int seed1_; ///< Index of second seed atom From 8b5376eb99e058c46df723a7ab5eca9f422c21f3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 10:24:42 -0400 Subject: [PATCH 029/245] Fix when warning is printed --- src/DataSet_Coords_REF.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/DataSet_Coords_REF.cpp b/src/DataSet_Coords_REF.cpp index 1fcdce3cce..10abce711f 100644 --- a/src/DataSet_Coords_REF.cpp +++ b/src/DataSet_Coords_REF.cpp @@ -33,8 +33,7 @@ void DataSet_Coords_REF::AddFrame(Frame const& fIn) { /** Set REF from incoming frame. */ void DataSet_Coords_REF::SetCRD(int idx, Frame const& fIn) { - // TODO warn if idx not zero? - if (idx == 0) + if (idx != 0) mprintf("Warning: In reference set '%s', attempting to set index which is not 1 (%i)\n", legend(), idx+1); if (frame_.empty()) frame_.SetupFrame( fIn ); From b329d14928336465b9721eea90a107ef457cfb88 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 10:24:52 -0400 Subject: [PATCH 030/245] Enable read prep test --- test/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index efc11e1fd6..313bdfda04 100644 --- a/test/Makefile +++ b/test/Makefile @@ -524,6 +524,9 @@ test.calcdiffusion: test.parsetiming: @-cd Test_ParseTiming && ./RunTest.sh $(OPT) +test.readprep: + @-cd Test_ReadPrep && ./RunTest.sh $(OPT) + # Every test target should go here. COMPLETETESTS=test.general \ test.strip \ @@ -689,7 +692,8 @@ COMPLETETESTS=test.general \ test.avgbox \ test.tordiff \ test.calcdiffusion \ - test.parsetiming + test.parsetiming \ + test.readprep test.all: $(MAKE) test.complete summary From 0049ba64c55ee212da2116666ef806376de2e359 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 10:25:04 -0400 Subject: [PATCH 031/245] Hide debug info --- src/DataIO_AmberPrep.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 11c8564917..7ecaa8a163 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -312,7 +312,7 @@ const mprinterr("Error: Could not set up mask '%s' to remove dummy atoms.\n", keepAtoms.MaskString()); return 1; } - keepAtoms.MaskInfo(); + if (debug_ > 0) keepAtoms.MaskInfo(); if (keepAtoms.Nselected() == top.Natom()) { mprintf("\tNo dummy atoms to remove.\n"); } else { From 5517a02ce113baeaa944bc853fb29036812d5a89 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 10:30:55 -0400 Subject: [PATCH 032/245] Hide more debug info. Set parm name right after it is instantiated. --- src/DataIO_AmberPrep.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 7ecaa8a163..e83569e9e5 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -43,7 +43,7 @@ static inline int CheckLine(const char* line) { int DataIO_AmberPrep::readCHARGE(BufferedLine& infile) const { const char* line = infile.Line(); while (line != 0 && line[0] != '\0') { - mprintf("DEBUG: CHARGE: %s\n", line); + if (debug_ > 0) mprintf("DEBUG: CHARGE: %s\n", line); line = infile.Line(); } return 0; @@ -53,7 +53,7 @@ int DataIO_AmberPrep::readCHARGE(BufferedLine& infile) const { int DataIO_AmberPrep::readLOOP(BufferedLine& infile, AtPairArray& BondPairs) const { const char* line = infile.Line(); while (line != 0 && line[0] != '\0') { - mprintf("DEBUG: LOOP: %s\n", line); + if (debug_ > 0) mprintf("DEBUG: LOOP: %s\n", line); ArgList atpair(line, " \t"); if (atpair.Nargs() != 2) { mprinterr("Error: Expected 2 atom names, got %i: %s\n", atpair.Nargs(), line); @@ -69,7 +69,7 @@ int DataIO_AmberPrep::readLOOP(BufferedLine& infile, AtPairArray& BondPairs) con int DataIO_AmberPrep::readIMPROPER(BufferedLine& infile) const { const char* line = infile.Line(); while (line != 0 && line[0] != '\0') { - mprintf("DEBUG: IMPROPER: %s\n", line); + if (debug_ > 0) mprintf("DEBUG: IMPROPER: %s\n", line); line = infile.Line(); } return 0; @@ -168,6 +168,7 @@ const // The cutoff distance for loop closing bonds which // cannot be defined by the tree structure. Any pair of // atoms within this distance is assumed to be bonded. + // TODO implement bond search line = infile.Line(); if (CheckLine(line)) return 1; double bondCutoff = 0; @@ -190,6 +191,7 @@ const //} //Topology& top = ((DataSet_Topology*)ds)->ModifyTop(); Topology top; + top.SetParmName( resName, infile.Filename() ); // Residue Residue res(resName, 1, ' ', ' '); // Loop over entries @@ -281,7 +283,6 @@ const // TODO bond search? // Set up topology top.CommonSetup(true, false); - top.SetParmName( resName, infile.Filename() ); if (debug_ > 0) top.Summary(); if (debug_ > 1) From 83490abe27f2a01b59686fe474c9351207f7fa6c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 10:32:22 -0400 Subject: [PATCH 033/245] errStat not needed in this function --- src/DataIO_AmberPrep.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index e83569e9e5..7ee58d85e4 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -242,7 +242,6 @@ const // LOOP - Read explicit loop closing bonds // IMPROPER - Read improper torsion angles. AtPairArray BondPairs; - int errStat = 0; while (line != 0) { if (line[0] != '\0') { std::string lineStr(line); @@ -336,7 +335,7 @@ const } CRD->SetCRD(0, frm); - return errStat; + return 0; } // DataIO_AmberPrep::ReadData() From 7dbaabab5277f5c0db81cb30341480bf1712ec71 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 10:42:35 -0400 Subject: [PATCH 034/245] Add bond search when cutoff greater than 0 --- src/DataIO_AmberPrep.cpp | 25 ++++++++++++++++--------- src/cpptrajdepend | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 7ee58d85e4..a329e627e6 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -1,5 +1,6 @@ #include "DataIO_AmberPrep.h" #include "CpptrajStdio.h" +#include "BondSearch.h" #include "BufferedLine.h" #include "DataSet_Coords.h" #include "StringRoutines.h" @@ -175,7 +176,8 @@ const if (line[0] != '\0') bondCutoff = convertToDouble( std::string(line) ); if (bondCutoff > 0.0) - mprintf("Warning: Non-zero cutoff in prep file (%g); currently ignored.\n", bondCutoff); + mprintf("Warning: Non-zero cutoff in prep file (%g); will search for additional\n" + "Warning: bonds based on distances.\n", bondCutoff); // 0 1 2 3 4 5 6 7 8 9 10 // 8 - I IGRAPH(I) ISYMBL(I) ITREE(I) NA(I) NB(I) NC(I) R(I) THETA(I) PHI(I) CHG(I) [I = 1, NATOM] // FORMAT(I,3A,3I,4F) @@ -279,7 +281,18 @@ const } top.AddBond( idx1, idx2 ); } - // TODO bond search? + // Frame + Frame frm( top.Natom() ); + // Internal coords to cart + if (zmatrix.SetToFrame( frm )) { + mprinterr("Error: IC to Cartesian coords failed.\n"); + return 1; + } + // Bond search + if (bondCutoff > 0) { + BondSearch bondSearch; + bondSearch.FindBonds( top, BondSearch::SEARCH_REGULAR, frm, 0.2, debug_ ); + } // Set up topology top.CommonSetup(true, false); if (debug_ > 0) @@ -294,13 +307,7 @@ const return 1; } DataSet_Coords* CRD = static_cast( ds ); - // Frame - Frame frm( top.Natom() ); - // Internal coords to cart - if (zmatrix.SetToFrame( frm )) { - mprinterr("Error: IC to Cartesian coords failed.\n"); - return 1; - } + // Delete dummy atoms if needed if (removeDummyAtoms_) { AtomMask keepAtoms; diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 06569a71ed..d190f7177f 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -204,7 +204,7 @@ DataFileList.o : DataFileList.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h A DataFilter.o : DataFilter.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_integer.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO.o : DataIO.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataSet.h DataSetList.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixDbl.h Dimension.h FileIO.h FileName.h Frame.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 Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_AmberEne.o : DataIO_AmberEne.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberEne.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h -DataIO_AmberPrep.o : DataIO_AmberPrep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberPrep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h +DataIO_AmberPrep.o : DataIO_AmberPrep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h BondSearch.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberPrep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CCP4.o : DataIO_CCP4.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ByteRoutines.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CCP4.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridFlt.h Dimension.h FileIO.h FileName.h Frame.h Grid.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmFastRep.o : DataIO_CharmmFastRep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmFastRep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_RemLog.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmOutput.o : DataIO_CharmmOutput.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmOutput.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_double.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h From f3fe99765d8e62fde0e838226a70d6301a95916b Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 11:33:20 -0400 Subject: [PATCH 035/245] More descriptive variable names --- src/Structure/Zmatrix.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 2aa6804ded..5b8ec7fe7c 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -156,24 +156,24 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { rdist * cosPhi * sinTheta, rdist * sinPhi * sinTheta ); - Vec3 a = Vec3( frameOut.XYZ( ic.AtL()) ); - Vec3 b = Vec3( frameOut.XYZ( ic.AtK()) ); - Vec3 c = Vec3( frameOut.XYZ( ic.AtJ()) ); + Vec3 posL = Vec3( frameOut.XYZ( ic.AtL()) ); + Vec3 posK = Vec3( frameOut.XYZ( ic.AtK()) ); + Vec3 posJ = Vec3( frameOut.XYZ( ic.AtJ()) ); - Vec3 ab = b - a; - Vec3 bc = c - b; - bc.Normalize(); - Vec3 n = ab.Cross(bc); - n.Normalize(); - Vec3 ncbc = n.Cross(bc); + Vec3 LK = posK - posL; + Vec3 KJ = posJ - posK; + KJ.Normalize(); + Vec3 Norm = LK.Cross(KJ); + Norm.Normalize(); + Vec3 NxKJ = Norm.Cross(KJ); - Matrix_3x3 M( bc[0], ncbc[0], n[0], - bc[1], ncbc[1], n[1], - bc[2], ncbc[2], n[2] ); + Matrix_3x3 Rot( KJ[0], NxKJ[0], Norm[0], + KJ[1], NxKJ[1], Norm[1], + KJ[2], NxKJ[2], Norm[2] ); - Vec3 d = (M * xyz) + c; + Vec3 posI = (Rot * xyz) + posJ; - frameOut.SetXYZ( idx, d ); + frameOut.SetXYZ( idx, posI ); atomIsSet(idx, isSet, Nset); // Next lowest unset atom From fbc5eb0128c7b2576611ee67fd190caec256be6e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 11:37:06 -0400 Subject: [PATCH 036/245] Add reference to natural reference frame paper --- src/Structure/Zmatrix.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 5b8ec7fe7c..edcb28f569 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -66,7 +66,12 @@ static inline void atomIsSet(int i, std::vector& isSet, unsigned int& Nset } } -/** Set Cartesian coordinates in Frame from internal coordinates. */ +/** Set Cartesian coordinates in Frame from internal coordinates. + * The procedure used here is from: + * Parsons et al., "Practical Conversion from Torsion Space to + * Cartesian Space for In Silico Protein Synthesis", + * J Comput Chem 26: 1063–1068, 2005. + */ int Zmatrix::SetToFrame(Frame& frameOut) const { if ((unsigned int)frameOut.Natom() != IC_.size()) { mprinterr("Internal Error: Output frame size (%i) != # internal coords (%zu)\n", @@ -78,7 +83,6 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { unsigned int Nset = 0; // Set position of the first atom. if (seed0_ != InternalCoords::NO_ATOM) { - //IC_[seed0_].ZeroXYZ(); frameOut.SetXYZ(seed0_, Vec3(0.0)); atomIsSet(seed0_, isSet, Nset); // Set position of the second atom. @@ -88,7 +92,6 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { return 1; } double r1 = IC_[seed1_].Dist(); - //IC_[seed1_].SetXYZ( Vec3(r1, 0, 0) ); frameOut.SetXYZ(seed1_, Vec3(r1, 0, 0)); atomIsSet(seed1_, isSet, Nset); // Set position of the third atom @@ -107,7 +110,6 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { double x = r2 * cos(180.0 - theta) * Constants::DEGRAD; double y = r2 * cos(180.0 - theta) * Constants::DEGRAD; - //IC_[seed2].SetXYZ( Vec3(r1 + x, y, 0) ); frameOut.SetXYZ( seed2_, Vec3(r1 + x, y, 0) ); atomIsSet(seed2_, isSet, Nset); } // END seed atom 2 @@ -153,8 +155,8 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { // NOTE: Want -x Vec3 xyz( -(rdist * cosTheta), - rdist * cosPhi * sinTheta, - rdist * sinPhi * sinTheta ); + rdist * cosPhi * sinTheta, + rdist * sinPhi * sinTheta ); Vec3 posL = Vec3( frameOut.XYZ( ic.AtL()) ); Vec3 posK = Vec3( frameOut.XYZ( ic.AtK()) ); From 5e6f1a0ba8a5d934f59fb75ee1b1d667b76d9967 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 26 Sep 2023 15:03:37 -0400 Subject: [PATCH 037/245] Start calculating Zmatrix from frame/top --- src/DataIO_AmberPrep.cpp | 4 ++ src/Structure/Zmatrix.cpp | 99 ++++++++++++++++++++++++++++++++++++++- src/cpptrajdepend | 2 +- 3 files changed, 103 insertions(+), 2 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index a329e627e6..3ac1127c17 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -335,6 +335,10 @@ const if (debug_ > 0) top.Summary(); } } + // DEBUG - back convert + Zmatrix tempZ; + tempZ.SetFromFrame( frm, top ); + tempZ.print(); // Output Set up frame set if (CRD->CoordsSetup(top, CoordinateInfo())) { mprinterr("Error: Could not set up COORDS set for prep.\n"); diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index edcb28f569..e2fac744a1 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -1,8 +1,12 @@ #include +#include #include "Zmatrix.h" #include "../Frame.h" #include "../CpptrajStdio.h" #include "../Constants.h" +#include "../DistRoutines.h" +#include "../Topology.h" +#include "../TorsionRoutines.h" #include // cos using namespace Cpptraj::Structure; @@ -46,15 +50,108 @@ void Zmatrix::print() const { it->Dist(), it->Theta(), it->Phi()); } +/// For bonded atoms, hold atom index, atom number, and # bonds. +class AtnumNbonds { + public: + /// CONSTRUCTOR + AtnumNbonds(int idx, Atom const& atm) : + idx_(idx), priority_(mainChainPriority(atm)), nbonds_(atm.Nbonds()) {} + /// Sort by priority, # bonds, atom index + bool operator<(const AtnumNbonds& rhs) const { + if (priority_ == rhs.priority_) { + if (nbonds_ == rhs.nbonds_) { + return (idx_ < rhs.idx_); + } else { + return (nbonds_ < rhs.nbonds_); + } + } else { + return (priority_ < rhs.priority_); + } + } + int Idx() const { return idx_; } + int Priority() const { return priority_; } + int Nbonds() const { return nbonds_; } + private: + /// Set priority based on how likely this is to be a main chain atom. + static int mainChainPriority(Atom const& atm) { + switch(atm.Element()) { + case Atom::CARBON : return 0; // highest priority + case Atom::NITROGEN : + case Atom::BORON : + case Atom::PHOSPHORUS : return 1; + case Atom::OXYGEN : + case Atom::SULFUR : return 2; + // These atoms form only 1 bond and have lowest priority + case Atom::HYDROGEN : + case Atom::FLUORINE : + case Atom::CHLORINE : + case Atom::BROMINE : + case Atom::LITHIUM : return 4; + default : return 3; // 1 bond priority - 1 + } + return 5; // should never get here + } + + int idx_; ///< Atom index + int priority_; ///< Likelyhood of begin a main chain atom (0 most likely) + int nbonds_; ///< Number of bonded atoms +}; + +/// Get bonded atom priorities +static std::set getBondedAtomPriorities(int seed0, Topology const& topIn, int ignoreIdx) { + std::set bondedAtoms; + for (Atom::bond_iterator bat = topIn[seed0].bondbegin(); + bat != topIn[seed0].bondend(); ++bat) + { + if (*bat != ignoreIdx) + bondedAtoms.insert( AtnumNbonds(*bat, topIn[*bat]) ); + } + for (std::set::const_iterator it = bondedAtoms.begin(); it != bondedAtoms.end(); ++it) + mprintf("DEBUG: Atom %s bonded atom %s idx=%i priority= %i nbonds=%i\n", + topIn.AtomMaskName(seed0).c_str(), + topIn.AtomMaskName(it->Idx()).c_str(), + it->Idx(), it->Priority(), it->Nbonds()); + return bondedAtoms; +} + +static inline int FrontIdx(std::set const& in) { + std::set::const_iterator it = in.begin(); + return it->Idx(); +} + /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) { + // TODO add ability to set up dummy atoms + seed0_ = InternalCoords::NO_ATOM; + seed1_ = InternalCoords::NO_ATOM; + seed2_ = InternalCoords::NO_ATOM; IC_.clear(); - // First seed is first atom. No bonds, angles, or torsions. + // First seed is first atom. No bonds, angles, or torsions. TODO should be lowest heavy atom? IC_.push_back( InternalCoords() ); seed0_ = 0; // Choose second seed as bonded atom with lowest index. Prefer heavy atoms + // and atoms with more than 1 bond. + std::set bondedAtoms = getBondedAtomPriorities(seed0_, topIn, -1); + if (!bondedAtoms.empty()) { + seed1_ = FrontIdx(bondedAtoms); + IC_.push_back( InternalCoords(seed0_, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, + sqrt(DIST2_NoImage( frameIn.XYZ(seed1_), frameIn.XYZ(seed0_) )), + 0, 0) ); + // Choose third seed, ignoring first seed. + bondedAtoms = getBondedAtomPriorities(seed1_, topIn, seed0_); + if (!bondedAtoms.empty()) { + seed2_ = FrontIdx(bondedAtoms); + IC_.push_back( InternalCoords(seed1_, seed0_, InternalCoords::NO_ATOM, + sqrt(DIST2_NoImage( frameIn.XYZ(seed2_), frameIn.XYZ(seed1_) )), + CalcAngle( frameIn.XYZ(seed2_), + frameIn.XYZ(seed1_), + frameIn.XYZ(seed0_) ) * Constants::RADDEG, + 0) ); + } + } + return 0; } diff --git a/src/cpptrajdepend b/src/cpptrajdepend index d190f7177f..34f65e0dd5 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -439,7 +439,7 @@ Structure/Sugar.o : Structure/Sugar.cpp Atom.h AtomMask.h AtomType.h Box.h Const Structure/SugarBuilder.o : Structure/SugarBuilder.cpp ArgList.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h CharMask.h Chirality.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DistRoutines.h FileIO.h FileName.h Frame.h ImageOption.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/LinkAtom.h Structure/ResStatArray.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarBuilder.h Structure/SugarLinkAtoms.h Structure/SugarToken.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarLinkAtoms.o : Structure/SugarLinkAtoms.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/LinkAtom.h Structure/SugarLinkAtoms.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarToken.o : Structure/SugarToken.cpp ArgList.h CpptrajStdio.h Structure/SugarToken.h -Structure/Zmatrix.o : Structure/Zmatrix.cpp Atom.h AtomMask.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ReplicaDimArray.h Residue.h Segment.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h Unit.h Vec3.h +Structure/Zmatrix.o : Structure/Zmatrix.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h StructureCheck.o : StructureCheck.cpp Atom.h AtomMask.h AtomType.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h ExclusionArray.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StructureCheck.h SymbolExporting.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h StructureMapper.o : StructureMapper.cpp AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StructureMapper.h SymbolExporting.h TextFormat.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h SymmetricRmsdCalc.o : SymmetricRmsdCalc.cpp ArrayIterator.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h Hungarian.h ImageOption.h MapAtom.h MaskToken.h Matrix.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h SymmetricRmsdCalc.h Topology.h TypeNameHolder.h Unit.h Vec3.h From 0609056828588f0f817204f63680ea49d36fb914 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 27 Sep 2023 09:10:42 -0400 Subject: [PATCH 038/245] Start with the idea of a topology index --- src/DataIO_AmberPrep.cpp | 12 +-- src/Structure/Zmatrix.cpp | 153 ++++++++++++++++++++++++++++++++++---- src/Structure/Zmatrix.h | 24 ++++-- 3 files changed, 162 insertions(+), 27 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 3ac1127c17..a41df472b2 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -230,12 +230,12 @@ const double dist = convertToDouble(args[7]); double theta = convertToDouble(args[8]); double phi = convertToDouble(args[9]); - atIdx++; if (args[2] == ISYMDU) { - if (zmatrix.AddICseed( InternalCoords(atJ, atK, atL, dist, theta, phi) )) + if (zmatrix.AddICseed( InternalCoords(atJ, atK, atL, dist, theta, phi), atIdx )) return 1; } else - zmatrix.AddIC( InternalCoords(atJ, atK, atL, dist, theta, phi) ); + zmatrix.AddIC( InternalCoords(atJ, atK, atL, dist, theta, phi), atIdx ); + atIdx++; line = infile.Line(); if (line == 0) break; } @@ -336,9 +336,9 @@ const } } // DEBUG - back convert - Zmatrix tempZ; - tempZ.SetFromFrame( frm, top ); - tempZ.print(); + //Zmatrix tempZ; + //tempZ.SetFromFrame( frm, top ); + //tempZ.print(); // Output Set up frame set if (CRD->CoordsSetup(top, CoordinateInfo())) { mprinterr("Error: Could not set up COORDS set for prep.\n"); diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index e2fac744a1..a3f5ffef67 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -20,12 +20,13 @@ Zmatrix::Zmatrix() : {} /** Add internal coords */ -void Zmatrix::AddIC(InternalCoords const& ic) { +void Zmatrix::AddIC(InternalCoords const& ic, int topIdx) { IC_.push_back( ic ); + topIndices_.push_back( topIdx ); } /** Add internal coords as a seed. */ -int Zmatrix::AddICseed(InternalCoords const& ic) { +int Zmatrix::AddICseed(InternalCoords const& ic, int topIdx) { if (seed0_ == InternalCoords::NO_ATOM) seed0_ = IC_.size(); else if (seed1_ == InternalCoords::NO_ATOM) @@ -37,13 +38,14 @@ int Zmatrix::AddICseed(InternalCoords const& ic) { return 1; } IC_.push_back( ic ); + topIndices_.push_back( topIdx ); return 0; } /** Print to stdout */ void Zmatrix::print() const { mprintf("%zu internal coords.\n", IC_.size()); - mprintf("Seed atoms: %i %i %i\n", seed0_+1, seed1_+1, seed2_+1); + mprintf("Seed indices: %i %i %i\n", seed0_+1, seed1_+1, seed2_+1); for (ICarray::const_iterator it = IC_.begin(); it != IC_.end(); ++it) mprintf("\t%8li %8i %8i %8i %12.4f %12.4f %12.4f\n", it - IC_.begin() + 1, it->AtJ()+1, it->AtK()+1, it->AtL()+1, @@ -114,19 +116,92 @@ static std::set getBondedAtomPriorities(int seed0, Topology const& return bondedAtoms; } +/// \return Index of atom at front of set static inline int FrontIdx(std::set const& in) { std::set::const_iterator it = in.begin(); return it->Idx(); } +/// \return Index of first set atom, or atom at front of set +static inline int FirstOrFrontIdx(std::set const& in, std::vector const& isSet) +{ + if (in.empty()) return -1; + int firstIdx = FrontIdx( in ); + int firstSetIdx = -1; + if (in.size() == 1) + firstSetIdx = firstIdx; + else { + for (std::set::const_iterator it = in.begin(); + it != in.end(); ++it) + { + if (isSet[it->Idx()]) { + firstSetIdx = it->Idx(); + break; + } + } + } + mprintf("DEBUG: First idx= %i First set idx= %i\n", firstIdx, firstSetIdx); + if (firstSetIdx > -1) + return firstSetIdx; + return firstIdx; +} + +/// Set j k and l indices for given atom i +static inline int SetJKL(int ai, Topology const& topIn, std::vector const& isSet) +{ + int aj, ak, al; + + std::set bondedAtoms = getBondedAtomPriorities(ai, topIn, -1); + if (bondedAtoms.empty()) return 1; + int firstIdx = FirstOrFrontIdx( bondedAtoms, isSet ); + + return 0; +} + +/** \return True if no seeds are set. */ +bool Zmatrix::NoSeeds() const { + return (seed0_ == InternalCoords::NO_ATOM || + seed1_ == InternalCoords::NO_ATOM || + seed2_ == InternalCoords::NO_ATOM ); +} + /** Setup Zmatrix from Cartesian coordinates/topology. */ -int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) +int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnum) { - // TODO add ability to set up dummy atoms - seed0_ = InternalCoords::NO_ATOM; - seed1_ = InternalCoords::NO_ATOM; - seed2_ = InternalCoords::NO_ATOM; IC_.clear(); + topIndices_.clear(); + // See if we need to assign seed atoms + if (NoSeeds()) { + mprinterr("Internal Error: Automatic seed generation not yet implemented.\n"); +/* mprintf("DEBUG: Generating dummy seed atoms.\n"); + seed0_ = InternalCoords::NO_ATOM; + seed1_ = InternalCoords::NO_ATOM; + seed2_ = InternalCoords::NO_ATOM; + // Seed 0 is at the origin + IC_.push_back( InternalCoords() ); + seed0_ = 0; + topIndices_.push_back( -1 ); + seed0Pos_ = Vec3(0.0); + // Seed 1 is at X=1 + IC_.push_back( InternalCoords(0, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, + 1.0, 0, 0) ); + seed1_ = 1; + topIndices_.push_back( -1 ); + seed1Pos_ = Vec3(1.0, 0.0, 0.0); + // Seed 2 is at X=Y=1 + IC_.push_back( InternalCoords(1, 0, InternalCoords::NO_ATOM, + 1.0, 90.0, 0) ); + seed2_ = 2; + topIndices_.push_back( -1 ); + seed2Pos_ = Vec3(1.0, 1.0, 0.0);*/ + } else { + mprintf("DEBUG: Seed atoms: %s %s %s\n", + topIn.AtomMaskName(topIndices_[seed0_]).c_str(), + topIn.AtomMaskName(topIndices_[seed1_]).c_str(), + topIn.AtomMaskName(topIndices_[seed2_]).c_str()); + } + +/* // First seed is first atom. No bonds, angles, or torsions. TODO should be lowest heavy atom? IC_.push_back( InternalCoords() ); seed0_ = 0; @@ -151,7 +226,59 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) 0) ); } } - + // If less than 4 atoms, all done. + if (topIn.Natom() < 4) return 0; + + if (seed0_ == InternalCoords::NO_ATOM || + seed1_ == InternalCoords::NO_ATOM || + seed2_ == InternalCoords::NO_ATOM) + { + mprinterr("Internal Error: Zmatrix::SetFromFrame(): Not enough seeds.\n"); + return 1; + }*/ + + + // Do the remaining atoms + unsigned int maxAtom = (unsigned int)topIn.Natom(); + std::vector isSet( maxAtom, false ); + isSet[seed0_] = true; + isSet[seed1_] = true; + isSet[seed2_] = true; + unsigned int Nset = 3; + + // Find the lowest unset atom + unsigned int lowestUnsetAtom = 0; + for (; lowestUnsetAtom < maxAtom; ++lowestUnsetAtom) + if (!isSet[lowestUnsetAtom]) break; + //if (debug_ > 0) + mprintf("DEBUG: Lowest unset atom: %u\n", lowestUnsetAtom+1); + + // Loop over remaining atoms + while (Nset < maxAtom) { + // Find the next atom that is not yet set. + unsigned int idx = lowestUnsetAtom; + bool findNextAtom = true; + while (findNextAtom) { + while (idx < maxAtom && isSet[idx]) idx++; + if (idx >= maxAtom) { + mprinterr("Error: Could not find next atom to set.\n"); + return 1; + } + SetJKL(idx, topIn, isSet); + break; // DEBUG + // All 3 of the connecting atoms must be set + //if (isSet[ IC_[idx].AtJ() ] && + // isSet[ IC_[idx].AtK() ] && + // isSet[ IC_[idx].AtL() ]) + //{ + // findNextAtom = false; + //} + } // END loop finding next atom to set + //if (debug_ > 0) + mprintf("DEBUG: Next atom to set is %u\n", idx+1); + break; //DEBUG + } // END loop over remaining atoms + return 0; } @@ -180,7 +307,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { unsigned int Nset = 0; // Set position of the first atom. if (seed0_ != InternalCoords::NO_ATOM) { - frameOut.SetXYZ(seed0_, Vec3(0.0)); + frameOut.SetXYZ(topIndices_[seed0_], Vec3(0.0)); atomIsSet(seed0_, isSet, Nset); // Set position of the second atom. if (seed1_ != InternalCoords::NO_ATOM) { @@ -189,7 +316,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { return 1; } double r1 = IC_[seed1_].Dist(); - frameOut.SetXYZ(seed1_, Vec3(r1, 0, 0)); + frameOut.SetXYZ(topIndices_[seed1_], Vec3(r1, 0, 0)); atomIsSet(seed1_, isSet, Nset); // Set position of the third atom if (seed2_ != InternalCoords::NO_ATOM) { @@ -207,7 +334,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { double x = r2 * cos(180.0 - theta) * Constants::DEGRAD; double y = r2 * cos(180.0 - theta) * Constants::DEGRAD; - frameOut.SetXYZ( seed2_, Vec3(r1 + x, y, 0) ); + frameOut.SetXYZ( topIndices_[seed2_], Vec3(r1 + x, y, 0) ); atomIsSet(seed2_, isSet, Nset); } // END seed atom 2 } // END seed atom 1 @@ -272,7 +399,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { Vec3 posI = (Rot * xyz) + posJ; - frameOut.SetXYZ( idx, posI ); + frameOut.SetXYZ( topIndices_[idx], posI ); atomIsSet(idx, isSet, Nset); // Next lowest unset atom diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 69eaf4aab7..ef3dd6a519 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -8,17 +8,21 @@ namespace Structure { /// Hold internal coordinates for a system. class Zmatrix { typedef std::vector ICarray; + typedef std::vector Iarray; public: /// CONSTRUCTOR Zmatrix(); /// Set debug level void SetDebug(int d) { debug_ = d; } - /// Add internal coordinate - void AddIC(InternalCoords const&); - /// Add internal coordinate as next available seed - int AddICseed(InternalCoords const&); + /// Add internal coordinate and topology index + void AddIC(InternalCoords const&, int); + /// Add internal coordinate and topology index as next available seed + int AddICseed(InternalCoords const&, int); /// Convert Frame/Topology to internal coordinates array - int SetFromFrame(Frame const&, Topology const&); + int SetFromFrame(Frame const&, Topology const&, int); + + /// \return True if any of the seeds are not set + bool NoSeeds() const; /// Set Frame from internal coords int SetToFrame(Frame&) const; /// Print to stdout @@ -30,9 +34,13 @@ class Zmatrix { private: int debug_; ///< Print debug info ICarray IC_; ///< Hold internal coordinates for all atoms - int seed0_; ///< Index of first seed atom - int seed1_; ///< Index of second seed atom - int seed2_; ///< Index of third seed atom + Iarray topIndices_; ///< For each IC, corresponding atom index in topology + int seed0_; ///< Index into IC_ of first seed atom + int seed1_; ///< Index into IC_ of second seed atom + int seed2_; ///< Index into IC_ of third seed atom + //Vec3 seed0Pos_; ///< Seed 0 xyz + //Vec3 seed1Pos_; ///< Seed 1 xyz + //Vec3 seed2Pos_; ///< Seed 2 xyz }; } } From f99a2f3cd698814eb47fe23d995388c6f8a54c19 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 27 Sep 2023 09:22:39 -0400 Subject: [PATCH 039/245] Allow ability to set positions --- src/Structure/Zmatrix.cpp | 31 ++++++++++++++++++++++--------- src/Structure/Zmatrix.h | 20 ++++++++++++-------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index a3f5ffef67..487252fddb 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -16,7 +16,10 @@ Zmatrix::Zmatrix() : debug_(0), seed0_(InternalCoords::NO_ATOM), seed1_(InternalCoords::NO_ATOM), - seed2_(InternalCoords::NO_ATOM) + seed2_(InternalCoords::NO_ATOM), + hasSeed0Pos_(false), + hasSeed1Pos_(false), + hasSeed2Pos_(false) {} /** Add internal coords */ @@ -47,7 +50,7 @@ void Zmatrix::print() const { mprintf("%zu internal coords.\n", IC_.size()); mprintf("Seed indices: %i %i %i\n", seed0_+1, seed1_+1, seed2_+1); for (ICarray::const_iterator it = IC_.begin(); it != IC_.end(); ++it) - mprintf("\t%8li %8i %8i %8i %12.4f %12.4f %12.4f\n", it - IC_.begin() + 1, + mprintf("\t%8i %8i %8i %8i %12.4f %12.4f %12.4f\n", topIndices_[it - IC_.begin()]+1, it->AtJ()+1, it->AtK()+1, it->AtL()+1, it->Dist(), it->Theta(), it->Phi()); } @@ -307,7 +310,10 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { unsigned int Nset = 0; // Set position of the first atom. if (seed0_ != InternalCoords::NO_ATOM) { - frameOut.SetXYZ(topIndices_[seed0_], Vec3(0.0)); + if (hasSeed0Pos_) + frameOut.SetXYZ(topIndices_[seed0_], seed0Pos_); + else + frameOut.SetXYZ(topIndices_[seed0_], Vec3(0.0)); atomIsSet(seed0_, isSet, Nset); // Set position of the second atom. if (seed1_ != InternalCoords::NO_ATOM) { @@ -316,7 +322,10 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { return 1; } double r1 = IC_[seed1_].Dist(); - frameOut.SetXYZ(topIndices_[seed1_], Vec3(r1, 0, 0)); + if (hasSeed1Pos_) + frameOut.SetXYZ(topIndices_[seed1_], seed1Pos_); + else + frameOut.SetXYZ(topIndices_[seed1_], Vec3(r1, 0, 0)); atomIsSet(seed1_, isSet, Nset); // Set position of the third atom if (seed2_ != InternalCoords::NO_ATOM) { @@ -328,13 +337,17 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { mprinterr("Internal Error: Atom k of seed 2 is not seed 0.\n"); return 1; } - double r2 = IC_[seed2_].Dist(); - double theta = IC_[seed2_].Theta(); + if (hasSeed2Pos_) + frameOut.SetXYZ(topIndices_[seed2_], seed2Pos_); + else { + double r2 = IC_[seed2_].Dist(); + double theta = IC_[seed2_].Theta(); - double x = r2 * cos(180.0 - theta) * Constants::DEGRAD; - double y = r2 * cos(180.0 - theta) * Constants::DEGRAD; + double x = r2 * cos(180.0 - theta) * Constants::DEGRAD; + double y = r2 * cos(180.0 - theta) * Constants::DEGRAD; - frameOut.SetXYZ( topIndices_[seed2_], Vec3(r1 + x, y, 0) ); + frameOut.SetXYZ( topIndices_[seed2_], Vec3(r1 + x, y, 0) ); + } atomIsSet(seed2_, isSet, Nset); } // END seed atom 2 } // END seed atom 1 diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index ef3dd6a519..b4a51b14a7 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -1,6 +1,7 @@ #ifndef INC_STRUCTURE_ZMATRIX_H #define INC_STRUCTURE_ZMATRIX_H #include "InternalCoords.h" +#include "../Vec3.h" class Frame; class Topology; namespace Cpptraj { @@ -32,15 +33,18 @@ class Zmatrix { const_iterator begin() const { return IC_.begin(); } const_iterator end() const { return IC_.end(); } private: - int debug_; ///< Print debug info - ICarray IC_; ///< Hold internal coordinates for all atoms + int debug_; ///< Print debug info + ICarray IC_; ///< Hold internal coordinates for all atoms Iarray topIndices_; ///< For each IC, corresponding atom index in topology - int seed0_; ///< Index into IC_ of first seed atom - int seed1_; ///< Index into IC_ of second seed atom - int seed2_; ///< Index into IC_ of third seed atom - //Vec3 seed0Pos_; ///< Seed 0 xyz - //Vec3 seed1Pos_; ///< Seed 1 xyz - //Vec3 seed2Pos_; ///< Seed 2 xyz + int seed0_; ///< Index into IC_ of first seed atom + int seed1_; ///< Index into IC_ of second seed atom + int seed2_; ///< Index into IC_ of third seed atom + Vec3 seed0Pos_; ///< Seed 0 xyz + Vec3 seed1Pos_; ///< Seed 1 xyz + Vec3 seed2Pos_; ///< Seed 2 xyz + bool hasSeed0Pos_; ///< True if seed0Pos_ is set + bool hasSeed1Pos_; ///< True if seed1Pos_ is set + bool hasSeed2Pos_; ///< True if seed2Pos_ is set }; } } From 1f816361083090f8946ba7eed181df6518e961bf Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 27 Sep 2023 09:22:54 -0400 Subject: [PATCH 040/245] Update depends --- src/Structure/structuredepend | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index 6daaa795c5..f9b00b1003 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -8,4 +8,4 @@ Sugar.o : Sugar.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants. SugarBuilder.o : SugarBuilder.cpp ../ArgList.h ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../CharMask.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajFile.h ../CpptrajStdio.h ../DistRoutines.h ../FileIO.h ../FileName.h ../Frame.h ../ImageOption.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h LinkAtom.h ResStatArray.h StructureRoutines.h Sugar.h SugarBuilder.h SugarLinkAtoms.h SugarToken.h SugarLinkAtoms.o : SugarLinkAtoms.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../StringRoutines.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h LinkAtom.h SugarLinkAtoms.h SugarToken.o : SugarToken.cpp ../ArgList.h ../CpptrajStdio.h SugarToken.h -Zmatrix.o : Zmatrix.cpp ../Atom.h ../AtomMask.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Unit.h ../Vec3.h InternalCoords.h Zmatrix.h +Zmatrix.o : Zmatrix.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h InternalCoords.h Zmatrix.h From fd80344884dd89f1b6ac69393690bc2b5eb92478 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 27 Sep 2023 09:55:42 -0400 Subject: [PATCH 041/245] Set seeds from specified atoms --- src/Structure/Zmatrix.cpp | 42 +++++++++++++++++++++++++++++++++------ src/Structure/Zmatrix.h | 8 +++++--- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 487252fddb..c254d54662 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -17,9 +17,9 @@ Zmatrix::Zmatrix() : seed0_(InternalCoords::NO_ATOM), seed1_(InternalCoords::NO_ATOM), seed2_(InternalCoords::NO_ATOM), - hasSeed0Pos_(false), - hasSeed1Pos_(false), - hasSeed2Pos_(false) + seed0TopIdx_(InternalCoords::NO_ATOM), + seed1TopIdx_(InternalCoords::NO_ATOM), + seed2TopIdx_(InternalCoords::NO_ATOM) {} /** Add internal coords */ @@ -168,6 +168,36 @@ bool Zmatrix::NoSeeds() const { seed2_ == InternalCoords::NO_ATOM ); } +/** Set seeds from specified atoms. */ +int Zmatrix::SetSeeds(Frame const& frameIn, Topology const& topIn, int a1, int a2, int a3) +{ + // a1 must be bonded to a2 + if (!topIn[a1].IsBondedTo(a2)) { + mprinterr("Error: In topology '%s', seed 0 atom '%s' is not bonded to seed 1 atom '%s'\n", + topIn.c_str(), topIn.AtomMaskName(a1).c_str(), topIn.AtomMaskName(a2).c_str()); + return 1; + } + // a2 must be bonded to a3 + if (!topIn[a2].IsBondedTo(a3)) { + mprinterr("Error: In topology '%s', seed 1 atom '%s' is not bonded to seed 2 atom '%s'\n", + topIn.c_str(), topIn.AtomMaskName(a2).c_str(), topIn.AtomMaskName(a3).c_str()); + return 1; + } + // Store seed positions + seed0TopIdx_ = a1; + seed0Pos_ = Vec3(frameIn.XYZ(a1)); + seed1TopIdx_ = a2; + seed1Pos_ = Vec3(frameIn.XYZ(a2)); + seed2TopIdx_ = a3; + seed2Pos_ = Vec3(frameIn.XYZ(a3)); + mprintf("DEBUG: Seed atoms: %s - %s - %s\n", + topIn.AtomMaskName(a1).c_str(), + topIn.AtomMaskName(a2).c_str(), + topIn.AtomMaskName(a3).c_str()); + + return 0; +} + /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnum) { @@ -310,7 +340,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { unsigned int Nset = 0; // Set position of the first atom. if (seed0_ != InternalCoords::NO_ATOM) { - if (hasSeed0Pos_) + if (seed0TopIdx_ != InternalCoords::NO_ATOM) frameOut.SetXYZ(topIndices_[seed0_], seed0Pos_); else frameOut.SetXYZ(topIndices_[seed0_], Vec3(0.0)); @@ -322,7 +352,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { return 1; } double r1 = IC_[seed1_].Dist(); - if (hasSeed1Pos_) + if (seed1TopIdx_ != InternalCoords::NO_ATOM) frameOut.SetXYZ(topIndices_[seed1_], seed1Pos_); else frameOut.SetXYZ(topIndices_[seed1_], Vec3(r1, 0, 0)); @@ -337,7 +367,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { mprinterr("Internal Error: Atom k of seed 2 is not seed 0.\n"); return 1; } - if (hasSeed2Pos_) + if (seed2TopIdx_ != InternalCoords::NO_ATOM) frameOut.SetXYZ(topIndices_[seed2_], seed2Pos_); else { double r2 = IC_[seed2_].Dist(); diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index b4a51b14a7..7615bc2701 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -19,6 +19,8 @@ class Zmatrix { void AddIC(InternalCoords const&, int); /// Add internal coordinate and topology index as next available seed int AddICseed(InternalCoords const&, int); + /// Set seed atoms from frame/top + int SetSeeds(Frame const&, Topology const&, int, int, int); /// Convert Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&, int); @@ -42,9 +44,9 @@ class Zmatrix { Vec3 seed0Pos_; ///< Seed 0 xyz Vec3 seed1Pos_; ///< Seed 1 xyz Vec3 seed2Pos_; ///< Seed 2 xyz - bool hasSeed0Pos_; ///< True if seed0Pos_ is set - bool hasSeed1Pos_; ///< True if seed1Pos_ is set - bool hasSeed2Pos_; ///< True if seed2Pos_ is set + int seed0TopIdx_; ///< Seed 0 topology index if seed0Pos_ is set + int seed1TopIdx_; ///< Seed 1 topology index if seed1Pos_ is set + int seed2TopIdx_; ///< Seed 2 topology index if seed2Pos_ is set }; } } From f70a401eb360d731181e16190ba2bef26016dbce Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 27 Sep 2023 10:40:41 -0400 Subject: [PATCH 042/245] Number of ICs should not have to match up with number of atoms. Store atom I in internal coordinates --- src/DataIO_AmberPrep.cpp | 7 +- src/Structure/InternalCoords.cpp | 44 +++---- src/Structure/InternalCoords.h | 27 +---- src/Structure/Zmatrix.cpp | 194 +++++++++++++++---------------- src/Structure/Zmatrix.h | 24 ++-- 5 files changed, 127 insertions(+), 169 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index a41df472b2..7f24e25f43 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -231,10 +231,10 @@ const double theta = convertToDouble(args[8]); double phi = convertToDouble(args[9]); if (args[2] == ISYMDU) { - if (zmatrix.AddICseed( InternalCoords(atJ, atK, atL, dist, theta, phi), atIdx )) + if (zmatrix.AddICseed( InternalCoords(atIdx, atJ, atK, atL, dist, theta, phi) )) return 1; } else - zmatrix.AddIC( InternalCoords(atJ, atK, atL, dist, theta, phi), atIdx ); + zmatrix.AddIC( InternalCoords(atIdx, atJ, atK, atL, dist, theta, phi) ); atIdx++; line = infile.Line(); if (line == 0) break; @@ -336,7 +336,8 @@ const } } // DEBUG - back convert - //Zmatrix tempZ; + Zmatrix tempZ; + //tempZ.SetSeeds(frm, top, 5, 0, 1); //tempZ.SetFromFrame( frm, top ); //tempZ.print(); // Output Set up frame set diff --git a/src/Structure/InternalCoords.cpp b/src/Structure/InternalCoords.cpp index 9cae170d4d..df8eb5ec05 100644 --- a/src/Structure/InternalCoords.cpp +++ b/src/Structure/InternalCoords.cpp @@ -7,14 +7,20 @@ using namespace Cpptraj::Structure; const int InternalCoords::NO_ATOM = -1; /** CONSTRUCTOR */ -InternalCoords::InternalCoords() { +InternalCoords::InternalCoords() : + ati_(NO_ATOM) +{ std::fill(idx_, idx_+3, NO_ATOM); std::fill(val_, val_+3, 0); -// std::fill(xyz_, xyz_+3, 0); } /** CONSTRUCTOR - Take indices and values */ -InternalCoords::InternalCoords(int atJ, int atK, int atL, double dist, double theta, double phi) { +InternalCoords::InternalCoords(int atI, int atJ, int atK, int atL, + double dist, double theta, double phi) : + ati_(atI) +{ + if (ati_ < 0) + ati_ = NO_ATOM; if (atJ < 0) idx_[0] = NO_ATOM; else @@ -33,43 +39,19 @@ InternalCoords::InternalCoords(int atJ, int atK, int atL, double dist, double th val_[2] = phi; } -/** CONSTRUCTOR - pointer to XYZ coords, for first seed atom */ -/*InternalCoords::InternalCoords(const double* xyz) { - std::fill(idx_, idx_+3, NO_ATOM); - std::fill(val_, val_+3, 0); -// std::copy( xyz, xyz+3, xyz_ ); -// isSet_ = true; -}*/ - /** COPY CONSTRUCTOR */ -InternalCoords::InternalCoords(InternalCoords const& rhs) { +InternalCoords::InternalCoords(InternalCoords const& rhs) : + ati_(rhs.ati_) +{ std::copy( rhs.idx_, rhs.idx_+3, idx_ ); std::copy( rhs.val_, rhs.val_+3, val_ ); -// std::copy( rhs.xyz_, rhs.xyz_+3, xyz_ ); } /** ASSIGNMENT */ InternalCoords& InternalCoords::operator=(InternalCoords const& rhs) { if (&rhs == this) return *this; + ati_ = rhs.ati_; std::copy( rhs.idx_, rhs.idx_+3, idx_ ); std::copy( rhs.val_, rhs.val_+3, val_ ); - //std::copy( rhs.xyz_, rhs.xyz_+3, xyz_ ); - //isSet_ = rhs.isSet_; return *this; } - -/** Zero out the XYZ coordinates. */ -/*void InternalCoords::ZeroXYZ() { - std::fill(idx_, idx_+3, NO_ATOM); - std::fill(val_, val_+3, 0); - std::fill(xyz_, xyz_+3, 0); - isSet_ = true; -}*/ - -/** Set xyz coords */ -/*void InternalCoords::SetXYZ(Vec3 const& xyz) { - xyz_[0] = xyz[0]; - xyz_[1] = xyz[1]; - xyz_[2] = xyz[2]; - isSet_ = true; -}*/ diff --git a/src/Structure/InternalCoords.h b/src/Structure/InternalCoords.h index 161042a978..76d1505f3f 100644 --- a/src/Structure/InternalCoords.h +++ b/src/Structure/InternalCoords.h @@ -17,43 +17,28 @@ class InternalCoords { public: /// CONSTRUCTOR InternalCoords(); - /// CONSTRUCTOR - Take atoms j, k, l and values dist, theta, phi - InternalCoords(int, int, int, double, double, double); - /// CONSTRUCTOR - Take pointer to XYZ coords (for first seed atom) - //InternalCoords(const double*); + /// CONSTRUCTOR - Take atoms i, j, k, l and values dist, theta, phi + InternalCoords(int, int, int, int, double, double, double); /// COPY CONSTRUCTOR InternalCoords(InternalCoords const&); /// ASSIGNMENT InternalCoords& operator=(InternalCoords const&); - //enum ValType { DISTANCE = 0, ANGLE, TORSION }; - //enum AtType { AT_J = 0, AT_K, AT_L }; - static const int NO_ATOM; - /// Zero XYZ coords (seed atom 0) - //void ZeroXYZ(); - /// Set XYZ coords - //void SetXYZ( Vec3 const&); - /// \return Specifed value - //double Val(ValType v) const { return val_[(int)v]; } - /// \return Specified atom index - //int Idx(AtType a) const { return idx_[(int)a]; } double Dist() const { return val_[0]; } double Theta() const { return val_[1]; } double Phi() const { return val_[2]; } + int AtI() const { return ati_; } int AtJ() const { return idx_[0]; } int AtK() const { return idx_[1]; } int AtL() const { return idx_[2]; } - /// Set index of atom - //void SetIdx(AtType a) { idx_[(int)a] = idx; } private: - int idx_[3]; ///< Atom index for distance, angle, torsion - double val_[3]; ///< Value for distance, angle, torsion - //double xyz_[3]; ///< XYZ coordinates - //bool isSet_; ///< True if xyz coords are set + int ati_; ///< Atom I index + int idx_[3]; ///< Atom indices for distance, angle, torsion + double val_[3]; ///< Values for distance, angle, torsion }; } } diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index c254d54662..2f48caad23 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -14,44 +14,44 @@ using namespace Cpptraj::Structure; /** CONSTRUCTOR */ Zmatrix::Zmatrix() : debug_(0), - seed0_(InternalCoords::NO_ATOM), - seed1_(InternalCoords::NO_ATOM), - seed2_(InternalCoords::NO_ATOM), + icseed0_(InternalCoords::NO_ATOM), + icseed1_(InternalCoords::NO_ATOM), + icseed2_(InternalCoords::NO_ATOM)/*, seed0TopIdx_(InternalCoords::NO_ATOM), seed1TopIdx_(InternalCoords::NO_ATOM), - seed2TopIdx_(InternalCoords::NO_ATOM) + seed2TopIdx_(InternalCoords::NO_ATOM)*/ {} /** Add internal coords */ -void Zmatrix::AddIC(InternalCoords const& ic, int topIdx) { +void Zmatrix::AddIC(InternalCoords const& ic) { IC_.push_back( ic ); - topIndices_.push_back( topIdx ); } /** Add internal coords as a seed. */ -int Zmatrix::AddICseed(InternalCoords const& ic, int topIdx) { - if (seed0_ == InternalCoords::NO_ATOM) - seed0_ = IC_.size(); - else if (seed1_ == InternalCoords::NO_ATOM) - seed1_ = IC_.size(); - else if (seed2_ == InternalCoords::NO_ATOM) - seed2_ = IC_.size(); +int Zmatrix::AddICseed(InternalCoords const& ic) { + if (icseed0_ == InternalCoords::NO_ATOM) + icseed0_ = IC_.size(); + else if (icseed1_ == InternalCoords::NO_ATOM) + icseed1_ = IC_.size(); + else if (icseed2_ == InternalCoords::NO_ATOM) + icseed2_ = IC_.size(); else { - mprinterr("Error: Too many seed atoms.\n"); + mprinterr("Error: Too many seed ICs.\n"); return 1; } IC_.push_back( ic ); - topIndices_.push_back( topIdx ); return 0; } /** Print to stdout */ void Zmatrix::print() const { mprintf("%zu internal coords.\n", IC_.size()); - mprintf("Seed indices: %i %i %i\n", seed0_+1, seed1_+1, seed2_+1); + mprintf("Seed IC indices: %i %i %i\n", icseed0_+1, icseed1_+1, icseed2_+1); + mprintf("%-8s %8s %8s %8s %8s %12s %12s %12s\n", + "#Idx", "AtI", "AtJ", "AtK", "AtL", "Dist", "Theta", "Phi"); for (ICarray::const_iterator it = IC_.begin(); it != IC_.end(); ++it) - mprintf("\t%8i %8i %8i %8i %12.4f %12.4f %12.4f\n", topIndices_[it - IC_.begin()]+1, - it->AtJ()+1, it->AtK()+1, it->AtL()+1, + mprintf("%-8li %8i %8i %8i %8i %12.4f %12.4f %12.4f\n", it - IC_.begin()+1, + it->AtI()+1, it->AtJ()+1, it->AtK()+1, it->AtL()+1, it->Dist(), it->Theta(), it->Phi()); } @@ -162,14 +162,14 @@ static inline int SetJKL(int ai, Topology const& topIn, std::vector const& } /** \return True if no seeds are set. */ -bool Zmatrix::NoSeeds() const { +/*bool Zmatrix::NoSeeds() const { return (seed0_ == InternalCoords::NO_ATOM || seed1_ == InternalCoords::NO_ATOM || seed2_ == InternalCoords::NO_ATOM ); -} +}*/ /** Set seeds from specified atoms. */ -int Zmatrix::SetSeeds(Frame const& frameIn, Topology const& topIn, int a1, int a2, int a3) +/*int Zmatrix::SetSeeds(Frame const& frameIn, Topology const& topIn, int a1, int a2, int a3) { // a1 must be bonded to a2 if (!topIn[a1].IsBondedTo(a2)) { @@ -196,16 +196,15 @@ int Zmatrix::SetSeeds(Frame const& frameIn, Topology const& topIn, int a1, int a topIn.AtomMaskName(a3).c_str()); return 0; -} +}*/ /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnum) { IC_.clear(); - topIndices_.clear(); - // See if we need to assign seed atoms - if (NoSeeds()) { - mprinterr("Internal Error: Automatic seed generation not yet implemented.\n"); +// // See if we need to assign seed atoms +// if (NoSeeds()) { +// mprinterr("Internal Error: Automatic seed generation not yet implemented.\n"); /* mprintf("DEBUG: Generating dummy seed atoms.\n"); seed0_ = InternalCoords::NO_ATOM; seed1_ = InternalCoords::NO_ATOM; @@ -227,12 +226,12 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu seed2_ = 2; topIndices_.push_back( -1 ); seed2Pos_ = Vec3(1.0, 1.0, 0.0);*/ - } else { - mprintf("DEBUG: Seed atoms: %s %s %s\n", - topIn.AtomMaskName(topIndices_[seed0_]).c_str(), - topIn.AtomMaskName(topIndices_[seed1_]).c_str(), - topIn.AtomMaskName(topIndices_[seed2_]).c_str()); - } +/* } else { + mprintf("DEBUG: Seed indices: %s %s %s\n", + topIn.AtomMaskName(seed0_).c_str(), + topIn.AtomMaskName(seed1_).c_str(), + topIn.AtomMaskName(seed2_).c_str()); + }*/ /* // First seed is first atom. No bonds, angles, or torsions. TODO should be lowest heavy atom? @@ -270,7 +269,7 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu return 1; }*/ - +/* // Do the remaining atoms unsigned int maxAtom = (unsigned int)topIn.Natom(); std::vector isSet( maxAtom, false ); @@ -311,15 +310,16 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu mprintf("DEBUG: Next atom to set is %u\n", idx+1); break; //DEBUG } // END loop over remaining atoms - + */ return 0; } -static inline void atomIsSet(int i, std::vector& isSet, unsigned int& Nset) { - if (!isSet[i]) { - isSet[i] = true; - Nset++; +/// Mark an IC as used, update used count +static inline void ICIsUsed(int i, std::vector& isUsed, unsigned int& Nused) { + if (!isUsed[i]) { + isUsed[i] = true; + Nused++; } } @@ -330,85 +330,76 @@ static inline void atomIsSet(int i, std::vector& isSet, unsigned int& Nset * J Comput Chem 26: 1063–1068, 2005. */ int Zmatrix::SetToFrame(Frame& frameOut) const { - if ((unsigned int)frameOut.Natom() != IC_.size()) { - mprinterr("Internal Error: Output frame size (%i) != # internal coords (%zu)\n", - frameOut.Natom(), IC_.size()); - return 1; - } - - std::vector isSet( IC_.size(), false ); - unsigned int Nset = 0; - // Set position of the first atom. - if (seed0_ != InternalCoords::NO_ATOM) { - if (seed0TopIdx_ != InternalCoords::NO_ATOM) - frameOut.SetXYZ(topIndices_[seed0_], seed0Pos_); - else - frameOut.SetXYZ(topIndices_[seed0_], Vec3(0.0)); - atomIsSet(seed0_, isSet, Nset); + // Track which atoms have Cartesian coords set + std::vector hasPosition( frameOut.Natom(), false ); + // Track which ICs are used + std::vector isUsed( IC_.size(), false ); + unsigned int Nused = 0; + // Set positions of atoms from internal coordinate seeds. + if (icseed0_ != InternalCoords::NO_ATOM) { + // First seed IC atom + frameOut.SetXYZ(IC_[icseed0_].AtI(), Vec3(0.0)); + hasPosition[IC_[icseed0_].AtI()] = true; + ICIsUsed(icseed0_, isUsed, Nused); // Set position of the second atom. - if (seed1_ != InternalCoords::NO_ATOM) { - if (IC_[seed1_].AtJ() != seed0_) { - mprinterr("Internal Error: Atom j of seed 1 is not seed 0.\n"); + if (icseed1_ != InternalCoords::NO_ATOM) { + if (IC_[icseed1_].AtJ() != IC_[icseed0_].AtI()) { + mprinterr("Internal Error: Atom j of seed 1 is not Atom i of seed 0.\n"); return 1; } - double r1 = IC_[seed1_].Dist(); - if (seed1TopIdx_ != InternalCoords::NO_ATOM) - frameOut.SetXYZ(topIndices_[seed1_], seed1Pos_); - else - frameOut.SetXYZ(topIndices_[seed1_], Vec3(r1, 0, 0)); - atomIsSet(seed1_, isSet, Nset); + double r1 = IC_[icseed1_].Dist(); + frameOut.SetXYZ(IC_[icseed1_].AtI(), Vec3(r1, 0, 0)); + hasPosition[IC_[icseed1_].AtI()] = true; + ICIsUsed(icseed1_, isUsed, Nused); // Set position of the third atom - if (seed2_ != InternalCoords::NO_ATOM) { - if (IC_[seed2_].AtJ() != seed1_) { - mprinterr("Internal Error: Atom j of seed 2 is not seed 1.\n"); + if (icseed2_ != InternalCoords::NO_ATOM) { + if (IC_[icseed2_].AtJ() != IC_[icseed1_].AtI()) { + mprinterr("Internal Error: Atom j of seed 2 is not Atom i of seed 1.\n"); return 1; } - if (IC_[seed2_].AtK() != seed0_) { - mprinterr("Internal Error: Atom k of seed 2 is not seed 0.\n"); + if (IC_[icseed2_].AtK() != IC_[icseed0_].AtI()) { + mprinterr("Internal Error: Atom k of seed 2 is not Atom i of seed 0.\n"); return 1; } - if (seed2TopIdx_ != InternalCoords::NO_ATOM) - frameOut.SetXYZ(topIndices_[seed2_], seed2Pos_); - else { - double r2 = IC_[seed2_].Dist(); - double theta = IC_[seed2_].Theta(); + double r2 = IC_[icseed2_].Dist(); + double theta = IC_[icseed2_].Theta(); - double x = r2 * cos(180.0 - theta) * Constants::DEGRAD; - double y = r2 * cos(180.0 - theta) * Constants::DEGRAD; + double x = r2 * cos(180.0 - theta) * Constants::DEGRAD; + double y = r2 * cos(180.0 - theta) * Constants::DEGRAD; - frameOut.SetXYZ( topIndices_[seed2_], Vec3(r1 + x, y, 0) ); - } - atomIsSet(seed2_, isSet, Nset); + frameOut.SetXYZ( IC_[icseed2_].AtI(), Vec3(r1 + x, y, 0) ); + hasPosition[IC_[icseed2_].AtI()] = true; + ICIsUsed(icseed2_, isUsed, Nused); } // END seed atom 2 } // END seed atom 1 } // END seed atom 0 - // Find the lowest unset atom - unsigned int lowestUnsetAtom = 0; - for (; lowestUnsetAtom < IC_.size(); ++lowestUnsetAtom) - if (!isSet[lowestUnsetAtom]) break; - if (debug_ > 0) mprintf("DEBUG: Lowest unset atom: %u\n", lowestUnsetAtom+1); - - // Loop over remaining atoms - while (Nset < IC_.size()) { - // Find the next atom that is not yet set. - unsigned int idx = lowestUnsetAtom; - bool findNextAtom = true; - while (findNextAtom) { - while (idx < IC_.size() && isSet[idx]) idx++; + // Find the lowest unused IC + unsigned int lowestUnusedIC = 0; + for (; lowestUnusedIC < IC_.size(); ++lowestUnusedIC) + if (!isUsed[lowestUnusedIC]) break; + if (debug_ > 0) mprintf("DEBUG: Lowest unused IC: %u\n", lowestUnusedIC+1); + + // Loop over remaining ICs + while (Nused < IC_.size()) { + // Find the next IC that is not yet used. + unsigned int idx = lowestUnusedIC; + bool findNextIC = true; + while (findNextIC) { + while (idx < IC_.size() && isUsed[idx]) idx++; if (idx >= IC_.size()) { - mprinterr("Error: Could not find next atom to set.\n"); + mprinterr("Error: Could not find next IC to use.\n"); return 1; } // All 3 of the connecting atoms must be set - if (isSet[ IC_[idx].AtJ() ] && - isSet[ IC_[idx].AtK() ] && - isSet[ IC_[idx].AtL() ]) + if (hasPosition[ IC_[idx].AtJ() ] && + hasPosition[ IC_[idx].AtK() ] && + hasPosition[ IC_[idx].AtL() ]) { - findNextAtom = false; + findNextIC = false; } } // END loop finding next atom to set - if (debug_ > 0) mprintf("DEBUG: Next atom to set is %u\n", idx+1); + if (debug_ > 0) mprintf("DEBUG: Next IC to use is %u\n", idx+1); InternalCoords const& ic = IC_[idx]; double rdist = ic.Dist(); @@ -442,12 +433,13 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { Vec3 posI = (Rot * xyz) + posJ; - frameOut.SetXYZ( topIndices_[idx], posI ); - atomIsSet(idx, isSet, Nset); + frameOut.SetXYZ( ic.AtI(), posI ); + hasPosition[ ic.AtI() ] = true; + ICIsUsed(idx, isUsed, Nused); - // Next lowest unset atom - for (; lowestUnsetAtom < IC_.size(); ++lowestUnsetAtom) - if (!isSet[lowestUnsetAtom]) break; + // Next lowest unused IC + for (; lowestUnusedIC < IC_.size(); ++lowestUnusedIC) + if (!isUsed[lowestUnusedIC]) break; //break; // DEBUG diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 7615bc2701..b36789a832 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -15,17 +15,15 @@ class Zmatrix { Zmatrix(); /// Set debug level void SetDebug(int d) { debug_ = d; } - /// Add internal coordinate and topology index - void AddIC(InternalCoords const&, int); - /// Add internal coordinate and topology index as next available seed - int AddICseed(InternalCoords const&, int); + /// Add internal coordinate + void AddIC(InternalCoords const&); + /// Add internal coordinate as next available IC seed + int AddICseed(InternalCoords const&); /// Set seed atoms from frame/top - int SetSeeds(Frame const&, Topology const&, int, int, int); + //int SetSeeds(Frame const&, Topology const&, int, int, int); /// Convert Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&, int); - /// \return True if any of the seeds are not set - bool NoSeeds() const; /// Set Frame from internal coords int SetToFrame(Frame&) const; /// Print to stdout @@ -35,18 +33,18 @@ class Zmatrix { const_iterator begin() const { return IC_.begin(); } const_iterator end() const { return IC_.end(); } private: + int debug_; ///< Print debug info ICarray IC_; ///< Hold internal coordinates for all atoms - Iarray topIndices_; ///< For each IC, corresponding atom index in topology - int seed0_; ///< Index into IC_ of first seed atom - int seed1_; ///< Index into IC_ of second seed atom - int seed2_; ///< Index into IC_ of third seed atom - Vec3 seed0Pos_; ///< Seed 0 xyz + int icseed0_; ///< Index into IC_ of first seed + int icseed1_; ///< Index into IC_ of second seed + int icseed2_; ///< Index into IC_ of third seed +/* Vec3 seed0Pos_; ///< Seed 0 xyz Vec3 seed1Pos_; ///< Seed 1 xyz Vec3 seed2Pos_; ///< Seed 2 xyz int seed0TopIdx_; ///< Seed 0 topology index if seed0Pos_ is set int seed1TopIdx_; ///< Seed 1 topology index if seed1Pos_ is set - int seed2TopIdx_; ///< Seed 2 topology index if seed2Pos_ is set + int seed2TopIdx_; ///< Seed 2 topology index if seed2Pos_ is set*/ }; } } From 1c9f81fe6776326746415d39fdc168935ca4b22c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 27 Sep 2023 10:47:26 -0400 Subject: [PATCH 043/245] Reenable seed positions --- src/Structure/Zmatrix.cpp | 23 ++++++++++++++++++----- src/Structure/Zmatrix.h | 22 +++++++++++----------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 2f48caad23..4518e1d96c 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -16,10 +16,10 @@ Zmatrix::Zmatrix() : debug_(0), icseed0_(InternalCoords::NO_ATOM), icseed1_(InternalCoords::NO_ATOM), - icseed2_(InternalCoords::NO_ATOM)/*, - seed0TopIdx_(InternalCoords::NO_ATOM), - seed1TopIdx_(InternalCoords::NO_ATOM), - seed2TopIdx_(InternalCoords::NO_ATOM)*/ + icseed2_(InternalCoords::NO_ATOM), + seedAt0_(InternalCoords::NO_ATOM), + seedAt1_(InternalCoords::NO_ATOM), + seedAt2_(InternalCoords::NO_ATOM) {} /** Add internal coords */ @@ -332,10 +332,23 @@ static inline void ICIsUsed(int i, std::vector& isUsed, unsigned int& Nuse int Zmatrix::SetToFrame(Frame& frameOut) const { // Track which atoms have Cartesian coords set std::vector hasPosition( frameOut.Natom(), false ); + // If any seed positions are defined, set them now + if (seedAt0_ != InternalCoords::NO_ATOM) { + frameOut.SetXYZ( seedAt0_, seed0Pos_ ); + hasPosition[ seedAt0_ ] = true; + } + if (seedAt1_ != InternalCoords::NO_ATOM) { + frameOut.SetXYZ( seedAt1_, seed1Pos_ ); + hasPosition[ seedAt1_ ] = true; + } + if (seedAt2_ != InternalCoords::NO_ATOM) { + frameOut.SetXYZ( seedAt2_, seed2Pos_ ); + hasPosition[ seedAt2_ ] = true; + } // Track which ICs are used std::vector isUsed( IC_.size(), false ); unsigned int Nused = 0; - // Set positions of atoms from internal coordinate seeds. + // Set positions of atoms from internal coordinate seeds. TODO check for clashes with seedAtX? if (icseed0_ != InternalCoords::NO_ATOM) { // First seed IC atom frameOut.SetXYZ(IC_[icseed0_].AtI(), Vec3(0.0)); diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index b36789a832..ecc64ba3c1 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -34,17 +34,17 @@ class Zmatrix { const_iterator end() const { return IC_.end(); } private: - int debug_; ///< Print debug info - ICarray IC_; ///< Hold internal coordinates for all atoms - int icseed0_; ///< Index into IC_ of first seed - int icseed1_; ///< Index into IC_ of second seed - int icseed2_; ///< Index into IC_ of third seed -/* Vec3 seed0Pos_; ///< Seed 0 xyz - Vec3 seed1Pos_; ///< Seed 1 xyz - Vec3 seed2Pos_; ///< Seed 2 xyz - int seed0TopIdx_; ///< Seed 0 topology index if seed0Pos_ is set - int seed1TopIdx_; ///< Seed 1 topology index if seed1Pos_ is set - int seed2TopIdx_; ///< Seed 2 topology index if seed2Pos_ is set*/ + int debug_; ///< Print debug info + ICarray IC_; ///< Hold internal coordinates for all atoms + int icseed0_; ///< Index into IC_ of first seed + int icseed1_; ///< Index into IC_ of second seed + int icseed2_; ///< Index into IC_ of third seed + Vec3 seed0Pos_; ///< Seed 0 xyz + Vec3 seed1Pos_; ///< Seed 1 xyz + Vec3 seed2Pos_; ///< Seed 2 xyz + int seedAt0_; ///< Seed 0 topology index if seed0Pos_ is set + int seedAt1_; ///< Seed 1 topology index if seed1Pos_ is set + int seedAt2_; ///< Seed 2 topology index if seed2Pos_ is set }; } } From 34abb9dbdb4b7cc4fb2783ad1e3cb0bcd3c7c239 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 27 Sep 2023 10:56:11 -0400 Subject: [PATCH 044/245] Enable set seed positions --- src/DataIO_AmberPrep.cpp | 2 +- src/Structure/Zmatrix.cpp | 10 +++++----- src/Structure/Zmatrix.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 7f24e25f43..24fa0d887c 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -337,7 +337,7 @@ const } // DEBUG - back convert Zmatrix tempZ; - //tempZ.SetSeeds(frm, top, 5, 0, 1); + //tempZ.SetSeedPositions(frm, top, 5, 0, 1); //tempZ.SetFromFrame( frm, top ); //tempZ.print(); // Output Set up frame set diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 4518e1d96c..d8bafb8a8a 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -169,7 +169,7 @@ static inline int SetJKL(int ai, Topology const& topIn, std::vector const& }*/ /** Set seeds from specified atoms. */ -/*int Zmatrix::SetSeeds(Frame const& frameIn, Topology const& topIn, int a1, int a2, int a3) +int Zmatrix::SetSeedPositions(Frame const& frameIn, Topology const& topIn, int a1, int a2, int a3) { // a1 must be bonded to a2 if (!topIn[a1].IsBondedTo(a2)) { @@ -184,11 +184,11 @@ static inline int SetJKL(int ai, Topology const& topIn, std::vector const& return 1; } // Store seed positions - seed0TopIdx_ = a1; + seedAt0_ = a1; seed0Pos_ = Vec3(frameIn.XYZ(a1)); - seed1TopIdx_ = a2; + seedAt1_ = a2; seed1Pos_ = Vec3(frameIn.XYZ(a2)); - seed2TopIdx_ = a3; + seedAt2_ = a3; seed2Pos_ = Vec3(frameIn.XYZ(a3)); mprintf("DEBUG: Seed atoms: %s - %s - %s\n", topIn.AtomMaskName(a1).c_str(), @@ -196,7 +196,7 @@ static inline int SetJKL(int ai, Topology const& topIn, std::vector const& topIn.AtomMaskName(a3).c_str()); return 0; -}*/ +} /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnum) diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index ecc64ba3c1..3d9d763803 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -20,7 +20,7 @@ class Zmatrix { /// Add internal coordinate as next available IC seed int AddICseed(InternalCoords const&); /// Set seed atoms from frame/top - //int SetSeeds(Frame const&, Topology const&, int, int, int); + int SetSeedPositions(Frame const&, Topology const&, int, int, int); /// Convert Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&, int); From 5f5fe35399d9066c8a4b2fe51e978fe159ba57c5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 27 Sep 2023 13:43:14 -0400 Subject: [PATCH 045/245] Try using fake dummy atoms --- src/DataIO_AmberPrep.cpp | 4 +- src/Structure/InternalCoords.cpp | 22 +++---- src/Structure/Zmatrix.cpp | 99 ++++++++++++++++++++++++-------- src/Structure/Zmatrix.h | 7 +++ 4 files changed, 96 insertions(+), 36 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 24fa0d887c..44d56e8c11 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -338,8 +338,8 @@ const // DEBUG - back convert Zmatrix tempZ; //tempZ.SetSeedPositions(frm, top, 5, 0, 1); - //tempZ.SetFromFrame( frm, top ); - //tempZ.print(); + tempZ.SetFromFrame( frm, top, 0 ); + tempZ.print(); // Output Set up frame set if (CRD->CoordsSetup(top, CoordinateInfo())) { mprinterr("Error: Could not set up COORDS set for prep.\n"); diff --git a/src/Structure/InternalCoords.cpp b/src/Structure/InternalCoords.cpp index df8eb5ec05..cc748d5525 100644 --- a/src/Structure/InternalCoords.cpp +++ b/src/Structure/InternalCoords.cpp @@ -19,19 +19,19 @@ InternalCoords::InternalCoords(int atI, int atJ, int atK, int atL, double dist, double theta, double phi) : ati_(atI) { - if (ati_ < 0) - ati_ = NO_ATOM; - if (atJ < 0) - idx_[0] = NO_ATOM; - else + //if (ati_ < 0) + // ati_ = NO_ATOM; + //if (atJ < 0) + // idx_[0] = NO_ATOM; + //else idx_[0] = atJ; - if (atK < 0) - idx_[1] = NO_ATOM; - else + //if (atK < 0) + // idx_[1] = NO_ATOM; + //else idx_[1] = atK; - if (atL < 0) - idx_[2] = NO_ATOM; - else + //if (atL < 0) + // idx_[2] = NO_ATOM; + //else idx_[2] = atL; val_[0] = dist; diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index d8bafb8a8a..843862c2b0 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -46,7 +46,11 @@ int Zmatrix::AddICseed(InternalCoords const& ic) { /** Print to stdout */ void Zmatrix::print() const { mprintf("%zu internal coords.\n", IC_.size()); - mprintf("Seed IC indices: %i %i %i\n", icseed0_+1, icseed1_+1, icseed2_+1); + mprintf("Seed IC indices : %i %i %i\n", icseed0_+1, icseed1_+1, icseed2_+1); + mprintf("Seed Cart. indices : %i %i %i\n", seedAt0_+1, seedAt1_+1, seedAt2_+1); + seed0Pos_.Print("Seed0"); + seed1Pos_.Print("Seed1"); + seed2Pos_.Print("Seed2"); mprintf("%-8s %8s %8s %8s %8s %12s %12s %12s\n", "#Idx", "AtI", "AtJ", "AtK", "AtL", "Dist", "Theta", "Phi"); for (ICarray::const_iterator it = IC_.begin(); it != IC_.end(); ++it) @@ -161,12 +165,21 @@ static inline int SetJKL(int ai, Topology const& topIn, std::vector const& return 0; } -/** \return True if no seeds are set. */ -/*bool Zmatrix::NoSeeds() const { - return (seed0_ == InternalCoords::NO_ATOM || - seed1_ == InternalCoords::NO_ATOM || - seed2_ == InternalCoords::NO_ATOM ); -}*/ +/** \return True if all IC seeds are set. */ +bool Zmatrix::HasICSeeds() const { + bool has_ic_seed = (icseed0_ != InternalCoords::NO_ATOM && + icseed1_ != InternalCoords::NO_ATOM && + icseed2_ != InternalCoords::NO_ATOM ); + return has_ic_seed; +} + +/** \return True if all Cartesian seeds are set. */ +bool Zmatrix::HasCartSeeds() const { + bool has_cart_seed = (seedAt0_ != InternalCoords::NO_ATOM && + seedAt1_ != InternalCoords::NO_ATOM && + seedAt2_ != InternalCoords::NO_ATOM); + return has_cart_seed; +} /** Set seeds from specified atoms. */ int Zmatrix::SetSeedPositions(Frame const& frameIn, Topology const& topIn, int a1, int a2, int a3) @@ -198,12 +211,31 @@ int Zmatrix::SetSeedPositions(Frame const& frameIn, Topology const& topIn, int a return 0; } +const int Zmatrix::DUMMY0 = -2; +const int Zmatrix::DUMMY1 = -3; +const int Zmatrix::DUMMY2 = -4; + /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnum) { IC_.clear(); // // See if we need to assign seed atoms -// if (NoSeeds()) { + if (!HasCartSeeds()) { + // Generate dummy positions and a "fake" IC for atom 0 + // At0 - DUMMY2 - DUMMY1 - DUMMY0 + // Dummy seed 0 is at the origin + seedAt0_ = DUMMY0; + seed0Pos_ = Vec3(0.0); + seedAt1_ = DUMMY1; + seed1Pos_ = Vec3(1.0, 0.0, 0.0); + seedAt2_ = DUMMY2; + seed2Pos_ = Vec3(1.0, 1.0, 1.0); + const double* xyz = frameIn.XYZ(0); + IC_.push_back( InternalCoords(0, DUMMY2, DUMMY1, DUMMY0, + sqrt(DIST2_NoImage(xyz, seed2Pos_.Dptr())), + CalcAngle(xyz, seed2Pos_.Dptr(), seed1Pos_.Dptr()) * Constants::RADDEG, + Torsion(xyz, seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()) * Constants::RADDEG) ); + // mprinterr("Internal Error: Automatic seed generation not yet implemented.\n"); /* mprintf("DEBUG: Generating dummy seed atoms.\n"); seed0_ = InternalCoords::NO_ATOM; @@ -226,12 +258,12 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu seed2_ = 2; topIndices_.push_back( -1 ); seed2Pos_ = Vec3(1.0, 1.0, 0.0);*/ -/* } else { - mprintf("DEBUG: Seed indices: %s %s %s\n", - topIn.AtomMaskName(seed0_).c_str(), - topIn.AtomMaskName(seed1_).c_str(), - topIn.AtomMaskName(seed2_).c_str()); - }*/ + } else { + mprintf("DEBUG: Cartesian Seed indices: %s %s %s\n", + topIn.AtomMaskName(seedAt0_).c_str(), + topIn.AtomMaskName(seedAt1_).c_str(), + topIn.AtomMaskName(seedAt2_).c_str()); + } /* // First seed is first atom. No bonds, angles, or torsions. TODO should be lowest heavy atom? @@ -333,15 +365,15 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { // Track which atoms have Cartesian coords set std::vector hasPosition( frameOut.Natom(), false ); // If any seed positions are defined, set them now - if (seedAt0_ != InternalCoords::NO_ATOM) { + if (seedAt0_ > InternalCoords::NO_ATOM) { frameOut.SetXYZ( seedAt0_, seed0Pos_ ); hasPosition[ seedAt0_ ] = true; } - if (seedAt1_ != InternalCoords::NO_ATOM) { + if (seedAt1_ > InternalCoords::NO_ATOM) { frameOut.SetXYZ( seedAt1_, seed1Pos_ ); hasPosition[ seedAt1_ ] = true; } - if (seedAt2_ != InternalCoords::NO_ATOM) { + if (seedAt2_ > InternalCoords::NO_ATOM) { frameOut.SetXYZ( seedAt2_, seed2Pos_ ); hasPosition[ seedAt2_ ] = true; } @@ -387,6 +419,16 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { } // END seed atom 1 } // END seed atom 0 + // Check if there is a DUMMY IC + int dummyIcIdx = -1; + for (const_iterator it = IC_.begin(); it != IC_.end(); ++it) { + if (it->AtJ() == DUMMY2) { + dummyIcIdx = (int)(it - IC_.begin()); + mprintf("DEBUG: IC %i is DUMMY IC\n", dummyIcIdx); + break; + } + } + // Find the lowest unused IC unsigned int lowestUnusedIC = 0; for (; lowestUnusedIC < IC_.size(); ++lowestUnusedIC) @@ -398,16 +440,20 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { // Find the next IC that is not yet used. unsigned int idx = lowestUnusedIC; bool findNextIC = true; + bool isDummyIc = false; while (findNextIC) { while (idx < IC_.size() && isUsed[idx]) idx++; if (idx >= IC_.size()) { mprinterr("Error: Could not find next IC to use.\n"); return 1; } + if ((int)idx == dummyIcIdx) { + isDummyIc = true; + findNextIC = false; // All 3 of the connecting atoms must be set - if (hasPosition[ IC_[idx].AtJ() ] && - hasPosition[ IC_[idx].AtK() ] && - hasPosition[ IC_[idx].AtL() ]) + } else if (hasPosition[ IC_[idx].AtJ() ] && + hasPosition[ IC_[idx].AtK() ] && + hasPosition[ IC_[idx].AtL() ]) { findNextIC = false; } @@ -429,9 +475,16 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { rdist * cosPhi * sinTheta, rdist * sinPhi * sinTheta ); - Vec3 posL = Vec3( frameOut.XYZ( ic.AtL()) ); - Vec3 posK = Vec3( frameOut.XYZ( ic.AtK()) ); - Vec3 posJ = Vec3( frameOut.XYZ( ic.AtJ()) ); + Vec3 posL, posK, posJ; + if (isDummyIc) { + posL = seed0Pos_; + posK = seed1Pos_; + posJ = seed2Pos_; + } else { + posL = Vec3( frameOut.XYZ( ic.AtL()) ); + posK = Vec3( frameOut.XYZ( ic.AtK()) ); + posJ = Vec3( frameOut.XYZ( ic.AtJ()) ); + } Vec3 LK = posK - posL; Vec3 KJ = posJ - posK; diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 3d9d763803..8947eb9ac5 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -28,11 +28,18 @@ class Zmatrix { int SetToFrame(Frame&) const; /// Print to stdout void print() const; + /// \return True if IC seeds are set + bool HasICSeeds() const; + /// \return True if Cartesian seeds are set + bool HasCartSeeds() const; typedef ICarray::const_iterator const_iterator; const_iterator begin() const { return IC_.begin(); } const_iterator end() const { return IC_.end(); } private: + static const int DUMMY0; ///< Used to denote a dummy atom 0 + static const int DUMMY1; ///< Used to denote a dummy atom 1 + static const int DUMMY2; ///< Used to denote a dummy atom 2 int debug_; ///< Print debug info ICarray IC_; ///< Hold internal coordinates for all atoms From 1eb3382e10653e782b0f50743f8a770683020d53 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 27 Sep 2023 16:03:15 -0400 Subject: [PATCH 046/245] Try to choose the best 3 atoms as seeds --- src/Structure/Zmatrix.cpp | 108 +++++++++++++++++++++++++++++++------- src/Structure/Zmatrix.h | 2 + 2 files changed, 92 insertions(+), 18 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 843862c2b0..7d8bf699c0 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -62,11 +62,14 @@ void Zmatrix::print() const { /// For bonded atoms, hold atom index, atom number, and # bonds. class AtnumNbonds { public: + /// CONSTRUCTOR + AtnumNbonds() : idx_(-1), priority_(-1), nbonds_(-1) {} /// CONSTRUCTOR AtnumNbonds(int idx, Atom const& atm) : idx_(idx), priority_(mainChainPriority(atm)), nbonds_(atm.Nbonds()) {} /// Sort by priority, # bonds, atom index bool operator<(const AtnumNbonds& rhs) const { + if (idx_ < 0) return false; if (priority_ == rhs.priority_) { if (nbonds_ == rhs.nbonds_) { return (idx_ < rhs.idx_); @@ -215,11 +218,33 @@ const int Zmatrix::DUMMY0 = -2; const int Zmatrix::DUMMY1 = -3; const int Zmatrix::DUMMY2 = -4; +/// Mark an IC as used, update used count +static inline void MARK(int i, std::vector& isUsed, unsigned int& Nused) { + if (!isUsed[i]) { + isUsed[i] = true; + Nused++; + } +} + +void Zmatrix::addIc(int at0, int at1, int at2, int at3, + const double* xyz0, const double* xyz1, + const double* xyz2, const double* xyz3) +{ + IC_.push_back( InternalCoords(at0, at1, at2, at3, + sqrt(DIST2_NoImage(xyz0, xyz1)), + CalcAngle(xyz0, xyz1, xyz2) * Constants::RADDEG, + Torsion(xyz0, xyz1, xyz2, xyz3) * Constants::RADDEG) ); +} + /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnum) { IC_.clear(); -// // See if we need to assign seed atoms + int maxnatom = topIn.Natom(); + + std::vector hasIC( maxnatom, false ); + unsigned int nHasIC = 0; + // See if we need to assign seed atoms if (!HasCartSeeds()) { // Generate dummy positions and a "fake" IC for atom 0 // At0 - DUMMY2 - DUMMY1 - DUMMY0 @@ -230,11 +255,66 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu seed1Pos_ = Vec3(1.0, 0.0, 0.0); seedAt2_ = DUMMY2; seed2Pos_ = Vec3(1.0, 1.0, 1.0); - const double* xyz = frameIn.XYZ(0); - IC_.push_back( InternalCoords(0, DUMMY2, DUMMY1, DUMMY0, - sqrt(DIST2_NoImage(xyz, seed2Pos_.Dptr())), - CalcAngle(xyz, seed2Pos_.Dptr(), seed1Pos_.Dptr()) * Constants::RADDEG, - Torsion(xyz, seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()) * Constants::RADDEG) ); + int at0 = 0; + if (topIn.Natom() < 2) { + const double* xyz0 = frameIn.XYZ(at0); + IC_.push_back( InternalCoords(at0, DUMMY2, DUMMY1, DUMMY0, + sqrt(DIST2_NoImage(xyz0, seed2Pos_.Dptr())), + CalcAngle(xyz0, seed2Pos_.Dptr(), seed1Pos_.Dptr()) * Constants::RADDEG, + Torsion(xyz0, seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()) * Constants::RADDEG) ); + //Mark(at0, hasIC, nHasIC); + return 0; + } + // Choose second seed as bonded atom with lowest index. Prefer heavy atoms + // and atoms with more than 1 bond. + std::set bondedTo0 = getBondedAtomPriorities(at0, topIn, -1); + if (bondedTo0.empty()) { + mprinterr("Internal Error: Zmatrix::SetFromFrame(): could not get second seed atom.\n"); + return 1; + } + int at1 = FrontIdx( bondedTo0 ); + if (topIn.Natom() < 3) { + const double* xyz0 = frameIn.XYZ(at0); + const double* xyz1 = frameIn.XYZ(at1); + IC_.push_back( InternalCoords(at1, at0, DUMMY2, DUMMY1, + sqrt(DIST2_NoImage(xyz1, xyz0)), + CalcAngle(xyz1, xyz0, seed2Pos_.Dptr()) * Constants::RADDEG, + Torsion(xyz1, xyz0, seed2Pos_.Dptr(), seed1Pos_.Dptr()) * Constants::RADDEG) ); + //Mark(at1, hasIC, nHasIC); + return 0; + } + // The third atom will either be bonded to seed 0 or seed 1. + int at2; + AtnumNbonds potential2From0, potential2From1; + std::set bondedTo1 = getBondedAtomPriorities(at1, topIn, at0); + if (!bondedTo1.empty()) { + std::set::const_iterator it = bondedTo1.begin(); + potential2From1 = *it; + } + if (bondedTo0.size() >= 2) { + std::set::const_iterator it = bondedTo0.begin(); + ++it; + potential2From0 = *it; + } + if (potential2From0 < potential2From1) { + at2 = potential2From0.Idx(); + mprintf("DEBUG: 2 - 0 - 1\n"); + // D0 D1 D2 A2 + addIc(at2, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); + // D1 D2 A2 A0 + // D2 A2 A0 A1 + } else { + at2 = potential2From1.Idx(); + mprintf("DEBUG: 0 - 1 - 2\n"); + // D0 D1 D2 A0 + // D1 D2 A0 A1 + // D2 A0 A1 A2 + } + mprintf("DEBUG: Seed atoms: %s %s %s\n", + topIn.AtomMaskName(at0).c_str(), + topIn.AtomMaskName(at1).c_str(), + topIn.AtomMaskName(at2).c_str()); + // mprinterr("Internal Error: Automatic seed generation not yet implemented.\n"); /* mprintf("DEBUG: Generating dummy seed atoms.\n"); @@ -347,14 +427,6 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu return 0; } -/// Mark an IC as used, update used count -static inline void ICIsUsed(int i, std::vector& isUsed, unsigned int& Nused) { - if (!isUsed[i]) { - isUsed[i] = true; - Nused++; - } -} - /** Set Cartesian coordinates in Frame from internal coordinates. * The procedure used here is from: * Parsons et al., "Practical Conversion from Torsion Space to @@ -385,7 +457,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { // First seed IC atom frameOut.SetXYZ(IC_[icseed0_].AtI(), Vec3(0.0)); hasPosition[IC_[icseed0_].AtI()] = true; - ICIsUsed(icseed0_, isUsed, Nused); + MARK(icseed0_, isUsed, Nused); // Set position of the second atom. if (icseed1_ != InternalCoords::NO_ATOM) { if (IC_[icseed1_].AtJ() != IC_[icseed0_].AtI()) { @@ -395,7 +467,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { double r1 = IC_[icseed1_].Dist(); frameOut.SetXYZ(IC_[icseed1_].AtI(), Vec3(r1, 0, 0)); hasPosition[IC_[icseed1_].AtI()] = true; - ICIsUsed(icseed1_, isUsed, Nused); + MARK(icseed1_, isUsed, Nused); // Set position of the third atom if (icseed2_ != InternalCoords::NO_ATOM) { if (IC_[icseed2_].AtJ() != IC_[icseed1_].AtI()) { @@ -414,7 +486,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { frameOut.SetXYZ( IC_[icseed2_].AtI(), Vec3(r1 + x, y, 0) ); hasPosition[IC_[icseed2_].AtI()] = true; - ICIsUsed(icseed2_, isUsed, Nused); + MARK(icseed2_, isUsed, Nused); } // END seed atom 2 } // END seed atom 1 } // END seed atom 0 @@ -501,7 +573,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { frameOut.SetXYZ( ic.AtI(), posI ); hasPosition[ ic.AtI() ] = true; - ICIsUsed(idx, isUsed, Nused); + MARK(idx, isUsed, Nused); // Next lowest unused IC for (; lowestUnusedIC < IC_.size(); ++lowestUnusedIC) diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 8947eb9ac5..c51459cfbe 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -41,6 +41,8 @@ class Zmatrix { static const int DUMMY1; ///< Used to denote a dummy atom 1 static const int DUMMY2; ///< Used to denote a dummy atom 2 + void addIc(int,int,int,int,const double*,const double*,const double*,const double*); + int debug_; ///< Print debug info ICarray IC_; ///< Hold internal coordinates for all atoms int icseed0_; ///< Index into IC_ of first seed From 64ae64c9308fe881fcadf5b4e1c471f9d8243ed3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 27 Sep 2023 16:45:50 -0400 Subject: [PATCH 047/245] Finish initial seeds --- src/Structure/Zmatrix.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 7d8bf699c0..40a099030b 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -302,13 +302,18 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu // D0 D1 D2 A2 addIc(at2, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); // D1 D2 A2 A0 + addIc(at0, at2, DUMMY2, DUMMY1, frameIn.XYZ(at0), frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr()); // D2 A2 A0 A1 + addIc(at1, at0, at2, DUMMY2, frameIn.XYZ(at1), frameIn.XYZ(at0), frameIn.XYZ(at2), seed2Pos_.Dptr()); } else { at2 = potential2From1.Idx(); mprintf("DEBUG: 0 - 1 - 2\n"); // D0 D1 D2 A0 + addIc(at0, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); // D1 D2 A0 A1 + addIc(at1, at0, DUMMY2, DUMMY1, frameIn.XYZ(at1), frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr()); // D2 A0 A1 A2 + addIc(at2, at1, at0, DUMMY2, frameIn.XYZ(at2), frameIn.XYZ(at1), frameIn.XYZ(at0), seed2Pos_.Dptr()); } mprintf("DEBUG: Seed atoms: %s %s %s\n", topIn.AtomMaskName(at0).c_str(), From c26bad288435f32634b35e48ec19ebdeac9f9c3d Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 27 Sep 2023 16:48:02 -0400 Subject: [PATCH 048/245] Print seed atoms in the correct order --- src/Structure/Zmatrix.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 40a099030b..daa169941e 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -299,6 +299,10 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu if (potential2From0 < potential2From1) { at2 = potential2From0.Idx(); mprintf("DEBUG: 2 - 0 - 1\n"); + mprintf("DEBUG: Seed atoms: %s - %s - %s\n", + topIn.AtomMaskName(at2).c_str(), + topIn.AtomMaskName(at0).c_str(), + topIn.AtomMaskName(at1).c_str()); // D0 D1 D2 A2 addIc(at2, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); // D1 D2 A2 A0 @@ -308,6 +312,10 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu } else { at2 = potential2From1.Idx(); mprintf("DEBUG: 0 - 1 - 2\n"); + mprintf("DEBUG: Seed atoms: %s - %s - %s\n", + topIn.AtomMaskName(at0).c_str(), + topIn.AtomMaskName(at1).c_str(), + topIn.AtomMaskName(at2).c_str()); // D0 D1 D2 A0 addIc(at0, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); // D1 D2 A0 A1 @@ -315,10 +323,6 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu // D2 A0 A1 A2 addIc(at2, at1, at0, DUMMY2, frameIn.XYZ(at2), frameIn.XYZ(at1), frameIn.XYZ(at0), seed2Pos_.Dptr()); } - mprintf("DEBUG: Seed atoms: %s %s %s\n", - topIn.AtomMaskName(at0).c_str(), - topIn.AtomMaskName(at1).c_str(), - topIn.AtomMaskName(at2).c_str()); // mprinterr("Internal Error: Automatic seed generation not yet implemented.\n"); From b9f12b41757462c8985d08509b36788c642b1889 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 28 Sep 2023 08:57:37 -0400 Subject: [PATCH 049/245] No need for dummy atoms and fake ICs. Just store the positions of the seeds. Key is to get the seeds in the proper order. --- src/Structure/InternalCoords.cpp | 22 +++--- src/Structure/Zmatrix.cpp | 118 +++++++++++++++---------------- src/Structure/Zmatrix.h | 6 +- 3 files changed, 70 insertions(+), 76 deletions(-) diff --git a/src/Structure/InternalCoords.cpp b/src/Structure/InternalCoords.cpp index cc748d5525..df8eb5ec05 100644 --- a/src/Structure/InternalCoords.cpp +++ b/src/Structure/InternalCoords.cpp @@ -19,19 +19,19 @@ InternalCoords::InternalCoords(int atI, int atJ, int atK, int atL, double dist, double theta, double phi) : ati_(atI) { - //if (ati_ < 0) - // ati_ = NO_ATOM; - //if (atJ < 0) - // idx_[0] = NO_ATOM; - //else + if (ati_ < 0) + ati_ = NO_ATOM; + if (atJ < 0) + idx_[0] = NO_ATOM; + else idx_[0] = atJ; - //if (atK < 0) - // idx_[1] = NO_ATOM; - //else + if (atK < 0) + idx_[1] = NO_ATOM; + else idx_[1] = atK; - //if (atL < 0) - // idx_[2] = NO_ATOM; - //else + if (atL < 0) + idx_[2] = NO_ATOM; + else idx_[2] = atL; val_[0] = dist; diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index daa169941e..5e4da3dcb5 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -157,7 +157,7 @@ static inline int FirstOrFrontIdx(std::set const& in, std::vector const& isSet) +/*static inline int SetJKL(int ai, Topology const& topIn, std::vector const& isSet) { int aj, ak, al; @@ -166,7 +166,7 @@ static inline int SetJKL(int ai, Topology const& topIn, std::vector const& int firstIdx = FirstOrFrontIdx( bondedAtoms, isSet ); return 0; -} +}*/ /** \return True if all IC seeds are set. */ bool Zmatrix::HasICSeeds() const { @@ -214,9 +214,9 @@ int Zmatrix::SetSeedPositions(Frame const& frameIn, Topology const& topIn, int a return 0; } -const int Zmatrix::DUMMY0 = -2; -const int Zmatrix::DUMMY1 = -3; -const int Zmatrix::DUMMY2 = -4; +//const int Zmatrix::DUMMY0 = -2; +//const int Zmatrix::DUMMY1 = -3; +//const int Zmatrix::DUMMY2 = -4; /// Mark an IC as used, update used count static inline void MARK(int i, std::vector& isUsed, unsigned int& Nused) { @@ -246,6 +246,9 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu unsigned int nHasIC = 0; // See if we need to assign seed atoms if (!HasCartSeeds()) { + // First seed will be first atom TODO lowest index heavy atom? + int at0 = 0; +/* // Generate dummy positions and a "fake" IC for atom 0 // At0 - DUMMY2 - DUMMY1 - DUMMY0 // Dummy seed 0 is at the origin @@ -255,14 +258,16 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu seed1Pos_ = Vec3(1.0, 0.0, 0.0); seedAt2_ = DUMMY2; seed2Pos_ = Vec3(1.0, 1.0, 1.0); - int at0 = 0; - if (topIn.Natom() < 2) { - const double* xyz0 = frameIn.XYZ(at0); + int at0 = 0;*/ + if (maxnatom < 2) { + seedAt0_ = at0; + seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); + /*const double* xyz0 = frameIn.XYZ(at0); IC_.push_back( InternalCoords(at0, DUMMY2, DUMMY1, DUMMY0, sqrt(DIST2_NoImage(xyz0, seed2Pos_.Dptr())), CalcAngle(xyz0, seed2Pos_.Dptr(), seed1Pos_.Dptr()) * Constants::RADDEG, Torsion(xyz0, seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()) * Constants::RADDEG) ); - //Mark(at0, hasIC, nHasIC); + //Mark(at0, hasIC, nHasIC);*/ return 0; } // Choose second seed as bonded atom with lowest index. Prefer heavy atoms @@ -273,18 +278,22 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu return 1; } int at1 = FrontIdx( bondedTo0 ); - if (topIn.Natom() < 3) { - const double* xyz0 = frameIn.XYZ(at0); +/* + int at1 = FrontIdx( bondedTo0 );*/ + if (maxnatom < 3) { + seedAt1_ = at1; + seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); + /*const double* xyz0 = frameIn.XYZ(at0); const double* xyz1 = frameIn.XYZ(at1); IC_.push_back( InternalCoords(at1, at0, DUMMY2, DUMMY1, sqrt(DIST2_NoImage(xyz1, xyz0)), CalcAngle(xyz1, xyz0, seed2Pos_.Dptr()) * Constants::RADDEG, Torsion(xyz1, xyz0, seed2Pos_.Dptr(), seed1Pos_.Dptr()) * Constants::RADDEG) ); - //Mark(at1, hasIC, nHasIC); + //Mark(at1, hasIC, nHasIC);*/ return 0; } // The third atom will either be bonded to seed 0 or seed 1. - int at2; + //int at2; AtnumNbonds potential2From0, potential2From1; std::set bondedTo1 = getBondedAtomPriorities(at1, topIn, at0); if (!bondedTo1.empty()) { @@ -297,33 +306,41 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu potential2From0 = *it; } if (potential2From0 < potential2From1) { - at2 = potential2From0.Idx(); + //seedAt2_ = potential2From0.Idx(); mprintf("DEBUG: 2 - 0 - 1\n"); - mprintf("DEBUG: Seed atoms: %s - %s - %s\n", - topIn.AtomMaskName(at2).c_str(), - topIn.AtomMaskName(at0).c_str(), - topIn.AtomMaskName(at1).c_str()); + seedAt0_ = potential2From0.Idx(); + seedAt1_ = at0; + seedAt2_ = at1; // D0 D1 D2 A2 - addIc(at2, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); + //addIc(at2, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); // D1 D2 A2 A0 - addIc(at0, at2, DUMMY2, DUMMY1, frameIn.XYZ(at0), frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr()); + //addIc(at0, at2, DUMMY2, DUMMY1, frameIn.XYZ(at0), frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr()); // D2 A2 A0 A1 - addIc(at1, at0, at2, DUMMY2, frameIn.XYZ(at1), frameIn.XYZ(at0), frameIn.XYZ(at2), seed2Pos_.Dptr()); + //addIc(at1, at0, at2, DUMMY2, frameIn.XYZ(at1), frameIn.XYZ(at0), frameIn.XYZ(at2), seed2Pos_.Dptr()); } else { - at2 = potential2From1.Idx(); + //seedAt2_ = potential2From1.Idx(); mprintf("DEBUG: 0 - 1 - 2\n"); - mprintf("DEBUG: Seed atoms: %s - %s - %s\n", - topIn.AtomMaskName(at0).c_str(), - topIn.AtomMaskName(at1).c_str(), - topIn.AtomMaskName(at2).c_str()); + seedAt0_ = at0; + seedAt1_ = at1; + seedAt2_ = potential2From1.Idx(); + // D0 D1 D2 A0 - addIc(at0, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); + //addIc(at0, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); // D1 D2 A0 A1 - addIc(at1, at0, DUMMY2, DUMMY1, frameIn.XYZ(at1), frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr()); + //addIc(at1, at0, DUMMY2, DUMMY1, frameIn.XYZ(at1), frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr()); // D2 A0 A1 A2 - addIc(at2, at1, at0, DUMMY2, frameIn.XYZ(at2), frameIn.XYZ(at1), frameIn.XYZ(at0), seed2Pos_.Dptr()); + //addIc(at2, at1, at0, DUMMY2, frameIn.XYZ(at2), frameIn.XYZ(at1), frameIn.XYZ(at0), seed2Pos_.Dptr()); } - + mprintf("DEBUG: Seed atoms: %s - %s - %s\n", + topIn.AtomMaskName(seedAt0_).c_str(), + topIn.AtomMaskName(seedAt1_).c_str(), + topIn.AtomMaskName(seedAt2_).c_str()); + MARK(seedAt0_, hasIC, nHasIC); + MARK(seedAt1_, hasIC, nHasIC); + MARK(seedAt2_, hasIC, nHasIC); + seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); + seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); + seed2Pos_ = Vec3(frameIn.XYZ(seedAt2_)); // mprinterr("Internal Error: Automatic seed generation not yet implemented.\n"); /* mprintf("DEBUG: Generating dummy seed atoms.\n"); @@ -446,15 +463,15 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { // Track which atoms have Cartesian coords set std::vector hasPosition( frameOut.Natom(), false ); // If any seed positions are defined, set them now - if (seedAt0_ > InternalCoords::NO_ATOM) { + if (seedAt0_ != InternalCoords::NO_ATOM) { frameOut.SetXYZ( seedAt0_, seed0Pos_ ); hasPosition[ seedAt0_ ] = true; } - if (seedAt1_ > InternalCoords::NO_ATOM) { + if (seedAt1_ != InternalCoords::NO_ATOM) { frameOut.SetXYZ( seedAt1_, seed1Pos_ ); hasPosition[ seedAt1_ ] = true; } - if (seedAt2_ > InternalCoords::NO_ATOM) { + if (seedAt2_ != InternalCoords::NO_ATOM) { frameOut.SetXYZ( seedAt2_, seed2Pos_ ); hasPosition[ seedAt2_ ] = true; } @@ -500,16 +517,6 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { } // END seed atom 1 } // END seed atom 0 - // Check if there is a DUMMY IC - int dummyIcIdx = -1; - for (const_iterator it = IC_.begin(); it != IC_.end(); ++it) { - if (it->AtJ() == DUMMY2) { - dummyIcIdx = (int)(it - IC_.begin()); - mprintf("DEBUG: IC %i is DUMMY IC\n", dummyIcIdx); - break; - } - } - // Find the lowest unused IC unsigned int lowestUnusedIC = 0; for (; lowestUnusedIC < IC_.size(); ++lowestUnusedIC) @@ -521,20 +528,16 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { // Find the next IC that is not yet used. unsigned int idx = lowestUnusedIC; bool findNextIC = true; - bool isDummyIc = false; while (findNextIC) { while (idx < IC_.size() && isUsed[idx]) idx++; if (idx >= IC_.size()) { mprinterr("Error: Could not find next IC to use.\n"); return 1; } - if ((int)idx == dummyIcIdx) { - isDummyIc = true; - findNextIC = false; // All 3 of the connecting atoms must be set - } else if (hasPosition[ IC_[idx].AtJ() ] && - hasPosition[ IC_[idx].AtK() ] && - hasPosition[ IC_[idx].AtL() ]) + if (hasPosition[ IC_[idx].AtJ() ] && + hasPosition[ IC_[idx].AtK() ] && + hasPosition[ IC_[idx].AtL() ]) { findNextIC = false; } @@ -556,16 +559,9 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { rdist * cosPhi * sinTheta, rdist * sinPhi * sinTheta ); - Vec3 posL, posK, posJ; - if (isDummyIc) { - posL = seed0Pos_; - posK = seed1Pos_; - posJ = seed2Pos_; - } else { - posL = Vec3( frameOut.XYZ( ic.AtL()) ); - posK = Vec3( frameOut.XYZ( ic.AtK()) ); - posJ = Vec3( frameOut.XYZ( ic.AtJ()) ); - } + Vec3 posL = Vec3( frameOut.XYZ( ic.AtL()) ); + Vec3 posK = Vec3( frameOut.XYZ( ic.AtK()) ); + Vec3 posJ = Vec3( frameOut.XYZ( ic.AtJ()) ); Vec3 LK = posK - posL; Vec3 KJ = posJ - posK; @@ -592,7 +588,5 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { //break; // DEBUG } // END loop over internal coordinates - - return 0; } diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index c51459cfbe..d218e3029d 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -37,9 +37,9 @@ class Zmatrix { const_iterator begin() const { return IC_.begin(); } const_iterator end() const { return IC_.end(); } private: - static const int DUMMY0; ///< Used to denote a dummy atom 0 - static const int DUMMY1; ///< Used to denote a dummy atom 1 - static const int DUMMY2; ///< Used to denote a dummy atom 2 + //static const int DUMMY0; ///< Used to denote a dummy atom 0 + //static const int DUMMY1; ///< Used to denote a dummy atom 1 + //static const int DUMMY2; ///< Used to denote a dummy atom 2 void addIc(int,int,int,int,const double*,const double*,const double*,const double*); From 0633c9974504de6aaf8bdd220100625e5d9b326f Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 28 Sep 2023 09:01:38 -0400 Subject: [PATCH 050/245] Comment out function --- src/Structure/Zmatrix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 5e4da3dcb5..4b5ad42b2c 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -133,7 +133,7 @@ static inline int FrontIdx(std::set const& in) { } /// \return Index of first set atom, or atom at front of set -static inline int FirstOrFrontIdx(std::set const& in, std::vector const& isSet) +/*static inline int FirstOrFrontIdx(std::set const& in, std::vector const& isSet) { if (in.empty()) return -1; int firstIdx = FrontIdx( in ); @@ -154,7 +154,7 @@ static inline int FirstOrFrontIdx(std::set const& in, std::vector -1) return firstSetIdx; return firstIdx; -} +}*/ /// Set j k and l indices for given atom i /*static inline int SetJKL(int ai, Topology const& topIn, std::vector const& isSet) From 7c29b56bf16cde82df0615de8334edcbc48397fe Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 28 Sep 2023 09:04:39 -0400 Subject: [PATCH 051/245] Get rid of obsolete code --- src/Structure/Zmatrix.cpp | 97 ++------------------------------------- 1 file changed, 5 insertions(+), 92 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 4b5ad42b2c..af1677176a 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -246,54 +246,27 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu unsigned int nHasIC = 0; // See if we need to assign seed atoms if (!HasCartSeeds()) { - // First seed will be first atom TODO lowest index heavy atom? + // First seed atom will just be first atom TODO lowest index heavy atom? int at0 = 0; -/* - // Generate dummy positions and a "fake" IC for atom 0 - // At0 - DUMMY2 - DUMMY1 - DUMMY0 - // Dummy seed 0 is at the origin - seedAt0_ = DUMMY0; - seed0Pos_ = Vec3(0.0); - seedAt1_ = DUMMY1; - seed1Pos_ = Vec3(1.0, 0.0, 0.0); - seedAt2_ = DUMMY2; - seed2Pos_ = Vec3(1.0, 1.0, 1.0); - int at0 = 0;*/ if (maxnatom < 2) { seedAt0_ = at0; seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); - /*const double* xyz0 = frameIn.XYZ(at0); - IC_.push_back( InternalCoords(at0, DUMMY2, DUMMY1, DUMMY0, - sqrt(DIST2_NoImage(xyz0, seed2Pos_.Dptr())), - CalcAngle(xyz0, seed2Pos_.Dptr(), seed1Pos_.Dptr()) * Constants::RADDEG, - Torsion(xyz0, seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()) * Constants::RADDEG) ); - //Mark(at0, hasIC, nHasIC);*/ return 0; } - // Choose second seed as bonded atom with lowest index. Prefer heavy atoms - // and atoms with more than 1 bond. + // Choose second seed atom as bonded atom with lowest index. Prefer heavy + // atoms and atoms with more than 1 bond. std::set bondedTo0 = getBondedAtomPriorities(at0, topIn, -1); if (bondedTo0.empty()) { mprinterr("Internal Error: Zmatrix::SetFromFrame(): could not get second seed atom.\n"); return 1; } int at1 = FrontIdx( bondedTo0 ); -/* - int at1 = FrontIdx( bondedTo0 );*/ if (maxnatom < 3) { seedAt1_ = at1; seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); - /*const double* xyz0 = frameIn.XYZ(at0); - const double* xyz1 = frameIn.XYZ(at1); - IC_.push_back( InternalCoords(at1, at0, DUMMY2, DUMMY1, - sqrt(DIST2_NoImage(xyz1, xyz0)), - CalcAngle(xyz1, xyz0, seed2Pos_.Dptr()) * Constants::RADDEG, - Torsion(xyz1, xyz0, seed2Pos_.Dptr(), seed1Pos_.Dptr()) * Constants::RADDEG) ); - //Mark(at1, hasIC, nHasIC);*/ return 0; } - // The third atom will either be bonded to seed 0 or seed 1. - //int at2; + // The third seed atom will either be bonded to seed 0 or seed 1. AtnumNbonds potential2From0, potential2From1; std::set bondedTo1 = getBondedAtomPriorities(at1, topIn, at0); if (!bondedTo1.empty()) { @@ -306,7 +279,6 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu potential2From0 = *it; } if (potential2From0 < potential2From1) { - //seedAt2_ = potential2From0.Idx(); mprintf("DEBUG: 2 - 0 - 1\n"); seedAt0_ = potential2From0.Idx(); seedAt1_ = at0; @@ -318,12 +290,10 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu // D2 A2 A0 A1 //addIc(at1, at0, at2, DUMMY2, frameIn.XYZ(at1), frameIn.XYZ(at0), frameIn.XYZ(at2), seed2Pos_.Dptr()); } else { - //seedAt2_ = potential2From1.Idx(); mprintf("DEBUG: 0 - 1 - 2\n"); seedAt0_ = at0; seedAt1_ = at1; seedAt2_ = potential2From1.Idx(); - // D0 D1 D2 A0 //addIc(at0, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); // D1 D2 A0 A1 @@ -341,71 +311,14 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); seed2Pos_ = Vec3(frameIn.XYZ(seedAt2_)); - -// mprinterr("Internal Error: Automatic seed generation not yet implemented.\n"); -/* mprintf("DEBUG: Generating dummy seed atoms.\n"); - seed0_ = InternalCoords::NO_ATOM; - seed1_ = InternalCoords::NO_ATOM; - seed2_ = InternalCoords::NO_ATOM; - // Seed 0 is at the origin - IC_.push_back( InternalCoords() ); - seed0_ = 0; - topIndices_.push_back( -1 ); - seed0Pos_ = Vec3(0.0); - // Seed 1 is at X=1 - IC_.push_back( InternalCoords(0, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, - 1.0, 0, 0) ); - seed1_ = 1; - topIndices_.push_back( -1 ); - seed1Pos_ = Vec3(1.0, 0.0, 0.0); - // Seed 2 is at X=Y=1 - IC_.push_back( InternalCoords(1, 0, InternalCoords::NO_ATOM, - 1.0, 90.0, 0) ); - seed2_ = 2; - topIndices_.push_back( -1 ); - seed2Pos_ = Vec3(1.0, 1.0, 0.0);*/ } else { + // Seed atoms already set mprintf("DEBUG: Cartesian Seed indices: %s %s %s\n", topIn.AtomMaskName(seedAt0_).c_str(), topIn.AtomMaskName(seedAt1_).c_str(), topIn.AtomMaskName(seedAt2_).c_str()); } -/* - // First seed is first atom. No bonds, angles, or torsions. TODO should be lowest heavy atom? - IC_.push_back( InternalCoords() ); - seed0_ = 0; - - // Choose second seed as bonded atom with lowest index. Prefer heavy atoms - // and atoms with more than 1 bond. - std::set bondedAtoms = getBondedAtomPriorities(seed0_, topIn, -1); - if (!bondedAtoms.empty()) { - seed1_ = FrontIdx(bondedAtoms); - IC_.push_back( InternalCoords(seed0_, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, - sqrt(DIST2_NoImage( frameIn.XYZ(seed1_), frameIn.XYZ(seed0_) )), - 0, 0) ); - // Choose third seed, ignoring first seed. - bondedAtoms = getBondedAtomPriorities(seed1_, topIn, seed0_); - if (!bondedAtoms.empty()) { - seed2_ = FrontIdx(bondedAtoms); - IC_.push_back( InternalCoords(seed1_, seed0_, InternalCoords::NO_ATOM, - sqrt(DIST2_NoImage( frameIn.XYZ(seed2_), frameIn.XYZ(seed1_) )), - CalcAngle( frameIn.XYZ(seed2_), - frameIn.XYZ(seed1_), - frameIn.XYZ(seed0_) ) * Constants::RADDEG, - 0) ); - } - } - // If less than 4 atoms, all done. - if (topIn.Natom() < 4) return 0; - - if (seed0_ == InternalCoords::NO_ATOM || - seed1_ == InternalCoords::NO_ATOM || - seed2_ == InternalCoords::NO_ATOM) - { - mprinterr("Internal Error: Zmatrix::SetFromFrame(): Not enough seeds.\n"); - return 1; - }*/ /* // Do the remaining atoms From a6c1b2aa308769b33c0df6db0e6c0beb58a2b29d Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 28 Sep 2023 09:22:51 -0400 Subject: [PATCH 052/245] Start using molecule info --- src/Structure/Zmatrix.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index af1677176a..1cb162fe8e 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -239,15 +239,31 @@ void Zmatrix::addIc(int at0, int at1, int at2, int at3, /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnum) { + if (molnum < 0) { + mprinterr("Internal Error: Zmatrix::SetFromFrame(): Negative molecule index.\n"); + return 1; + } + if (topIn.Nmol() < 1) { + mprinterr("Internal Error: Zmatrix::SetFromFrame(): No molecules.\n"); + return 1; + } IC_.clear(); - int maxnatom = topIn.Natom(); - - std::vector hasIC( maxnatom, false ); + Molecule const& currentMol = topIn.Mol(molnum); + // Flatten the molecule array + std::vector atomIndices; + atomIndices.reserve( currentMol.NumAtoms() ); + for (Unit::const_iterator seg = currentMol.MolUnit().segBegin(); + seg != currentMol.MolUnit().segEnd(); ++seg) + for (int idx = seg->Begin(); idx != seg->End(); ++idx) + atomIndices.push_back( idx ); + unsigned int maxnatom = atomIndices.size(); + // Keep track of which atoms are associated with an internal coordinate + std::vector hasIC( topIn.Natom(), false ); unsigned int nHasIC = 0; // See if we need to assign seed atoms if (!HasCartSeeds()) { // First seed atom will just be first atom TODO lowest index heavy atom? - int at0 = 0; + int at0 = atomIndices.front(); if (maxnatom < 2) { seedAt0_ = at0; seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); From 641f5fa9c3068f3763c5f35c915fa40be6326d37 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 28 Sep 2023 09:56:41 -0400 Subject: [PATCH 053/245] Finish setting IC from Cart --- src/Structure/Zmatrix.cpp | 88 +++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 37 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 1cb162fe8e..ad6d2e90a5 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -133,7 +133,7 @@ static inline int FrontIdx(std::set const& in) { } /// \return Index of first set atom, or atom at front of set -/*static inline int FirstOrFrontIdx(std::set const& in, std::vector const& isSet) +static inline int FirstOrFrontIdx(std::set const& in, std::vector const& isSet) { if (in.empty()) return -1; int firstIdx = FrontIdx( in ); @@ -154,7 +154,7 @@ static inline int FrontIdx(std::set const& in) { if (firstSetIdx > -1) return firstSetIdx; return firstIdx; -}*/ +} /// Set j k and l indices for given atom i /*static inline int SetJKL(int ai, Topology const& topIn, std::vector const& isSet) @@ -250,16 +250,19 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu IC_.clear(); Molecule const& currentMol = topIn.Mol(molnum); // Flatten the molecule array - std::vector atomIndices; + typedef std::vector Iarray; + Iarray atomIndices; atomIndices.reserve( currentMol.NumAtoms() ); for (Unit::const_iterator seg = currentMol.MolUnit().segBegin(); seg != currentMol.MolUnit().segEnd(); ++seg) for (int idx = seg->Begin(); idx != seg->End(); ++idx) atomIndices.push_back( idx ); unsigned int maxnatom = atomIndices.size(); + // Keep track of which atoms are associated with an internal coordinate std::vector hasIC( topIn.Natom(), false ); unsigned int nHasIC = 0; + // See if we need to assign seed atoms if (!HasCartSeeds()) { // First seed atom will just be first atom TODO lowest index heavy atom? @@ -335,49 +338,60 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu topIn.AtomMaskName(seedAt2_).c_str()); } - -/* - // Do the remaining atoms - unsigned int maxAtom = (unsigned int)topIn.Natom(); - std::vector isSet( maxAtom, false ); - isSet[seed0_] = true; - isSet[seed1_] = true; - isSet[seed2_] = true; - unsigned int Nset = 3; - - // Find the lowest unset atom - unsigned int lowestUnsetAtom = 0; - for (; lowestUnsetAtom < maxAtom; ++lowestUnsetAtom) - if (!isSet[lowestUnsetAtom]) break; - //if (debug_ > 0) - mprintf("DEBUG: Lowest unset atom: %u\n", lowestUnsetAtom+1); + // Do the remaining atoms. + // Find the lowest unset atom. + unsigned int lowestUnsetIdx = 0; + for (; lowestUnsetIdx < maxnatom; ++lowestUnsetIdx) + if (!hasIC[atomIndices[lowestUnsetIdx]]) break; + mprintf("DEBUG: Lowest unset atom %i at index %u\n", atomIndices[lowestUnsetIdx]+1, lowestUnsetIdx); // Loop over remaining atoms - while (Nset < maxAtom) { - // Find the next atom that is not yet set. - unsigned int idx = lowestUnsetAtom; + while (nHasIC < maxnatom) { + // Find the next atom that is not yet set. + unsigned int idx = lowestUnsetIdx; bool findNextAtom = true; + int ai = -1; + int aj = -1; + int ak = -1; + int al = -1; while (findNextAtom) { - while (idx < maxAtom && isSet[idx]) idx++; - if (idx >= maxAtom) { + while (idx < maxnatom && hasIC[atomIndices[idx]]) idx++; + if (idx >= maxnatom) { mprinterr("Error: Could not find next atom to set.\n"); return 1; } - SetJKL(idx, topIn, isSet); - break; // DEBUG + ai = atomIndices[idx]; + mprintf("DEBUG:\tAttempting to set atom i %i\n", ai+1); + // Determine j k and l indices. Prefer atoms that have already been set. + std::set bondedAtomsI = getBondedAtomPriorities(ai, topIn, -1); + aj = FirstOrFrontIdx( bondedAtomsI, hasIC ); + mprintf("DEBUG:\t\tAtom j = %i\n", aj+1); + std::set bondedAtomsJ = getBondedAtomPriorities(aj, topIn, ai); // TODO reuse bondedAtomsI? + ak = FirstOrFrontIdx( bondedAtomsJ, hasIC ); + mprintf("DEBUG:\t\tAtom k = %i\n", ak+1); + // FIXME check for cycle here? + std::set bondedAtomsK = getBondedAtomPriorities(ak, topIn, aj); // TODO reuse bondedAtomsI? + al = FirstOrFrontIdx( bondedAtomsK, hasIC ); + mprintf("DEBUG:\t\tAtom l = %i\n", al+1); + if (aj < 0 || ak < 0 || al < 0) { + mprinterr("Internal Error: Could not find torsion for atom %i %s\n", ai+1, topIn.AtomMaskName(ai).c_str()); + return 1; + } // All 3 of the connecting atoms must be set - //if (isSet[ IC_[idx].AtJ() ] && - // isSet[ IC_[idx].AtK() ] && - // isSet[ IC_[idx].AtL() ]) - //{ - // findNextAtom = false; - //} - } // END loop finding next atom to set - //if (debug_ > 0) - mprintf("DEBUG: Next atom to set is %u\n", idx+1); - break; //DEBUG + if (hasIC[aj] && hasIC[ak] && hasIC[al]) { + findNextAtom = false; + } + } // END loop over findNextAtom + // Create IC for i j k l + addIc(ai, aj, ak, al, frameIn.XYZ(ai), frameIn.XYZ(aj), frameIn.XYZ(ak), frameIn.XYZ(al)); + MARK(ai, hasIC, nHasIC); + + // Next lowest unset atom + for (; lowestUnsetIdx < maxnatom; ++lowestUnsetIdx) + if (!hasIC[atomIndices[lowestUnsetIdx]]) break; + + //break; //DEBUG } // END loop over remaining atoms - */ return 0; } From cbc890c99c1e30d6ea97d474188227e981cf8630 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 28 Sep 2023 10:00:05 -0400 Subject: [PATCH 054/245] Test the back-conversion from generated ICs to cart --- src/DataIO_AmberPrep.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 44d56e8c11..4f1ee2aa4b 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -337,9 +337,14 @@ const } // DEBUG - back convert Zmatrix tempZ; + tempZ.SetDebug(10); //tempZ.SetSeedPositions(frm, top, 5, 0, 1); tempZ.SetFromFrame( frm, top, 0 ); tempZ.print(); + Frame tmpFrame(top.Natom()); + tempZ.SetToFrame(tmpFrame); + for (int ii = 0; ii < tmpFrame.Natom(); ii++) + tmpFrame.printAtomCoord(ii); // Output Set up frame set if (CRD->CoordsSetup(top, CoordinateInfo())) { mprinterr("Error: Could not set up COORDS set for prep.\n"); From e7bfba80e85a7ea6dd21875512eeb05b268fd8fe Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 28 Sep 2023 10:06:37 -0400 Subject: [PATCH 055/245] Remove more code, add code docs --- src/Structure/Zmatrix.cpp | 36 +++++++++++++++--------------------- src/Structure/Zmatrix.h | 13 +++++-------- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index ad6d2e90a5..814b38896c 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -27,7 +27,9 @@ void Zmatrix::AddIC(InternalCoords const& ic) { IC_.push_back( ic ); } -/** Add internal coords as a seed. */ +/** Add internal coords as a IC seed. This is intended for use with systems + * that have dummy atoms, such as those from Amber Prep files. + */ int Zmatrix::AddICseed(InternalCoords const& ic) { if (icseed0_ == InternalCoords::NO_ATOM) icseed0_ = IC_.size(); @@ -59,7 +61,11 @@ void Zmatrix::print() const { it->Dist(), it->Theta(), it->Phi()); } +// ------------------------------------- /// For bonded atoms, hold atom index, atom number, and # bonds. +/** Used to determine atom priority when looking for torsions to + * base ICs off of. + */ class AtnumNbonds { public: /// CONSTRUCTOR @@ -126,13 +132,13 @@ static std::set getBondedAtomPriorities(int seed0, Topology const& return bondedAtoms; } -/// \return Index of atom at front of set +/// \return Index of atom at front of the set (highest priority). static inline int FrontIdx(std::set const& in) { std::set::const_iterator it = in.begin(); return it->Idx(); } -/// \return Index of first set atom, or atom at front of set +/// \return Index of first atom that isSet (has coords), or atom at front of the set (highest priority). static inline int FirstOrFrontIdx(std::set const& in, std::vector const& isSet) { if (in.empty()) return -1; @@ -155,26 +161,15 @@ static inline int FirstOrFrontIdx(std::set const& in, std::vector const& isSet) -{ - int aj, ak, al; - - std::set bondedAtoms = getBondedAtomPriorities(ai, topIn, -1); - if (bondedAtoms.empty()) return 1; - int firstIdx = FirstOrFrontIdx( bondedAtoms, isSet ); - - return 0; -}*/ +// ------------------------------------- /** \return True if all IC seeds are set. */ -bool Zmatrix::HasICSeeds() const { +/*bool Zmatrix::HasICSeeds() const { bool has_ic_seed = (icseed0_ != InternalCoords::NO_ATOM && icseed1_ != InternalCoords::NO_ATOM && icseed2_ != InternalCoords::NO_ATOM ); return has_ic_seed; -} +}*/ /** \return True if all Cartesian seeds are set. */ bool Zmatrix::HasCartSeeds() const { @@ -214,10 +209,6 @@ int Zmatrix::SetSeedPositions(Frame const& frameIn, Topology const& topIn, int a return 0; } -//const int Zmatrix::DUMMY0 = -2; -//const int Zmatrix::DUMMY1 = -3; -//const int Zmatrix::DUMMY2 = -4; - /// Mark an IC as used, update used count static inline void MARK(int i, std::vector& isUsed, unsigned int& Nused) { if (!isUsed[i]) { @@ -226,6 +217,9 @@ static inline void MARK(int i, std::vector& isUsed, unsigned int& Nused) { } } +/** Calculate and add an internal coordinate given atom indices + * and corresponding Cartesian coordinates. + */ void Zmatrix::addIc(int at0, int at1, int at2, int at3, const double* xyz0, const double* xyz1, const double* xyz2, const double* xyz3) diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index d218e3029d..d3fbe390de 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -28,20 +28,17 @@ class Zmatrix { int SetToFrame(Frame&) const; /// Print to stdout void print() const; - /// \return True if IC seeds are set - bool HasICSeeds() const; - /// \return True if Cartesian seeds are set - bool HasCartSeeds() const; typedef ICarray::const_iterator const_iterator; const_iterator begin() const { return IC_.begin(); } const_iterator end() const { return IC_.end(); } private: - //static const int DUMMY0; ///< Used to denote a dummy atom 0 - //static const int DUMMY1; ///< Used to denote a dummy atom 1 - //static const int DUMMY2; ///< Used to denote a dummy atom 2 - + /// Calculate and add an internal coordinate given indices and Cartesian coords. void addIc(int,int,int,int,const double*,const double*,const double*,const double*); + /// \return True if IC seeds are set + //bool HasICSeeds() const; + /// \return True if Cartesian seeds are set + bool HasCartSeeds() const; int debug_; ///< Print debug info ICarray IC_; ///< Hold internal coordinates for all atoms From 9a470a0e8102318115bcc9a2e749c732da24aaa5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 28 Sep 2023 11:38:55 -0400 Subject: [PATCH 056/245] Properly increase search indices when suitable atom not found. Init seed positions. --- src/Structure/Zmatrix.cpp | 38 +++++++++++++++++++++++++++----------- src/Structure/Zmatrix.h | 4 +++- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 814b38896c..98d5a78c00 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -17,6 +17,9 @@ Zmatrix::Zmatrix() : icseed0_(InternalCoords::NO_ATOM), icseed1_(InternalCoords::NO_ATOM), icseed2_(InternalCoords::NO_ATOM), + seed0Pos_(0.0), + seed1Pos_(0.0), + seed2Pos_(0.0), seedAt0_(InternalCoords::NO_ATOM), seedAt1_(InternalCoords::NO_ATOM), seedAt2_(InternalCoords::NO_ATOM) @@ -116,12 +119,12 @@ class AtnumNbonds { }; /// Get bonded atom priorities -static std::set getBondedAtomPriorities(int seed0, Topology const& topIn, int ignoreIdx) { +static std::set getBondedAtomPriorities(int seed0, Topology const& topIn, int ignoreIdx0, int ignoreIdx1) { std::set bondedAtoms; for (Atom::bond_iterator bat = topIn[seed0].bondbegin(); bat != topIn[seed0].bondend(); ++bat) { - if (*bat != ignoreIdx) + if (*bat != ignoreIdx0 && *bat != ignoreIdx1) bondedAtoms.insert( AtnumNbonds(*bat, topIn[*bat]) ); } for (std::set::const_iterator it = bondedAtoms.begin(); it != bondedAtoms.end(); ++it) @@ -230,6 +233,11 @@ void Zmatrix::addIc(int at0, int at1, int at2, int at3, Torsion(xyz0, xyz1, xyz2, xyz3) * Constants::RADDEG) ); } +/** Setup Zmatrix from Cartesian coordinates/topology. */ +int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) { + return SetFromFrame(frameIn, topIn, 0); +} + /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnum) { @@ -268,7 +276,7 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu } // Choose second seed atom as bonded atom with lowest index. Prefer heavy // atoms and atoms with more than 1 bond. - std::set bondedTo0 = getBondedAtomPriorities(at0, topIn, -1); + std::set bondedTo0 = getBondedAtomPriorities(at0, topIn, -1, -1); if (bondedTo0.empty()) { mprinterr("Internal Error: Zmatrix::SetFromFrame(): could not get second seed atom.\n"); return 1; @@ -281,7 +289,7 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu } // The third seed atom will either be bonded to seed 0 or seed 1. AtnumNbonds potential2From0, potential2From1; - std::set bondedTo1 = getBondedAtomPriorities(at1, topIn, at0); + std::set bondedTo1 = getBondedAtomPriorities(at1, topIn, at0, -1); if (!bondedTo1.empty()) { std::set::const_iterator it = bondedTo1.begin(); potential2From1 = *it; @@ -357,24 +365,31 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu ai = atomIndices[idx]; mprintf("DEBUG:\tAttempting to set atom i %i\n", ai+1); // Determine j k and l indices. Prefer atoms that have already been set. - std::set bondedAtomsI = getBondedAtomPriorities(ai, topIn, -1); + std::set bondedAtomsI = getBondedAtomPriorities(ai, topIn, -1, -1); aj = FirstOrFrontIdx( bondedAtomsI, hasIC ); mprintf("DEBUG:\t\tAtom j = %i\n", aj+1); - std::set bondedAtomsJ = getBondedAtomPriorities(aj, topIn, ai); // TODO reuse bondedAtomsI? + std::set bondedAtomsJ = getBondedAtomPriorities(aj, topIn, ai, -1); // TODO reuse bondedAtomsI? ak = FirstOrFrontIdx( bondedAtomsJ, hasIC ); mprintf("DEBUG:\t\tAtom k = %i\n", ak+1); // FIXME check for cycle here? - std::set bondedAtomsK = getBondedAtomPriorities(ak, topIn, aj); // TODO reuse bondedAtomsI? + std::set bondedAtomsK = getBondedAtomPriorities(ak, topIn, aj, ai); // TODO reuse bondedAtomsI? al = FirstOrFrontIdx( bondedAtomsK, hasIC ); mprintf("DEBUG:\t\tAtom l = %i\n", al+1); if (aj < 0 || ak < 0 || al < 0) { - mprinterr("Internal Error: Could not find torsion for atom %i %s\n", ai+1, topIn.AtomMaskName(ai).c_str()); - return 1; + //mprinterr("Internal Error: Could not find torsion for atom %i %s\n", ai+1, topIn.AtomMaskName(ai).c_str()); + //return 1; + mprintf("Warning: Could not find torsion for atom %i %s\n", ai+1, topIn.AtomMaskName(ai).c_str()); + mprintf("Warning: Creating pseudo torsion using seed atoms.\n"); + aj = seedAt2_; + ak = seedAt1_; + al = seedAt0_; + // TODO mark such torsions as problematic in InternalCoords? } // All 3 of the connecting atoms must be set if (hasIC[aj] && hasIC[ak] && hasIC[al]) { findNextAtom = false; - } + } else + idx++; } // END loop over findNextAtom // Create IC for i j k l addIc(ai, aj, ak, al, frameIn.XYZ(ai), frameIn.XYZ(aj), frameIn.XYZ(ak), frameIn.XYZ(al)); @@ -477,7 +492,8 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { hasPosition[ IC_[idx].AtL() ]) { findNextIC = false; - } + } else + idx++; } // END loop finding next atom to set if (debug_ > 0) mprintf("DEBUG: Next IC to use is %u\n", idx+1); diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index d3fbe390de..bc7061bcea 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -21,8 +21,10 @@ class Zmatrix { int AddICseed(InternalCoords const&); /// Set seed atoms from frame/top int SetSeedPositions(Frame const&, Topology const&, int, int, int); - /// Convert Frame/Topology to internal coordinates array + /// Convert specifed molecule of Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&, int); + /// Convert molecule 0 of Frame/Topology to internal coordinates array + int SetFromFrame(Frame const&, Topology const&); /// Set Frame from internal coords int SetToFrame(Frame&) const; From 547bd97130616b9729a5bd1afa4c21d25f56daa8 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 28 Sep 2023 11:39:26 -0400 Subject: [PATCH 057/245] Add more debug info --- src/DataIO_AmberPrep.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 4f1ee2aa4b..87dba33859 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -336,15 +336,24 @@ const } } // DEBUG - back convert + mprintf("DEBUG: BACK CONVERT %s\n", resName.c_str()); + mprinterr("DEBUG: BACK CONVERT %s\n", resName.c_str()); Zmatrix tempZ; tempZ.SetDebug(10); //tempZ.SetSeedPositions(frm, top, 5, 0, 1); - tempZ.SetFromFrame( frm, top, 0 ); + int tempErr = tempZ.SetFromFrame( frm, top, 0 ); + if (tempErr != 0) { + mprintf("DEBUG Error: Back converting %s\n", resName.c_str()); + mprinterr("DEBUG Error: Back converting %s\n", resName.c_str()); + return 1; + } tempZ.print(); Frame tmpFrame(top.Natom()); - tempZ.SetToFrame(tmpFrame); - for (int ii = 0; ii < tmpFrame.Natom(); ii++) - tmpFrame.printAtomCoord(ii); + if (tempErr == 0) { + tempZ.SetToFrame(tmpFrame); + for (int ii = 0; ii < tmpFrame.Natom(); ii++) + tmpFrame.printAtomCoord(ii); + } // Output Set up frame set if (CRD->CoordsSetup(top, CoordinateInfo())) { mprinterr("Error: Could not set up COORDS set for prep.\n"); From 8aeee55b021c7f2cd2bfc93c1a35b4b9dd81de4f Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 28 Sep 2023 16:04:15 -0400 Subject: [PATCH 058/245] Add Zmatrix data set class --- src/DataSet_Zmatrix.cpp | 16 ++++++++++++++++ src/DataSet_Zmatrix.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/DataSet_Zmatrix.cpp create mode 100644 src/DataSet_Zmatrix.h diff --git a/src/DataSet_Zmatrix.cpp b/src/DataSet_Zmatrix.cpp new file mode 100644 index 0000000000..9cc9b7d91b --- /dev/null +++ b/src/DataSet_Zmatrix.cpp @@ -0,0 +1,16 @@ +#include "DataSet_Zmatrix.h" +#include "CpptrajStdio.h" +#include "Structure/Zmatrix.h" + +using namespace Cpptraj::Structure; + +/** CONSTRUCTOR */ +DataSet_Zmatrix::DataSet_Zmatrix() : zmatrix_(0) +{ + +} + +/** DESTRUCTOR */ +DataSet_Zmatrix::~DataSet_Zmatrix() { + if (zmatrix_ != 0) delete zmatrix_; +} diff --git a/src/DataSet_Zmatrix.h b/src/DataSet_Zmatrix.h new file mode 100644 index 0000000000..178f07377a --- /dev/null +++ b/src/DataSet_Zmatrix.h @@ -0,0 +1,30 @@ +#ifndef INC_DATASET_ZMATRIX_H +#define INC_DATASET_ZMATRIX_H +#include "DataSet.h" +namespace Cpptraj { +namespace Structure { +class Zmatrix; +} +} +/// Hold a Z matrix +class DataSet_Zmatrix : public DataSet { + public: + DataSet_Zmatrix(); + ~DataSet_Zmatrix(); + static DataSet* Alloc() { return (DataSet*)new DataSet_Zmatrix(); } + // ----- DataSet functions ------------------- + size_t Size() const { return 0; } + void Info() const { return; } + int Allocate(SizeArray const&) { return 1; } + void Add(size_t, const void*) { return; } + void WriteBuffer(CpptrajFile&, SizeArray const&) const { return; } + int Append(DataSet*) { return 1; } + size_t MemUsageInBytes() const { return 0; } +# ifdef MPI + int Sync(size_t, std::vector const&, Parallel::Comm const&) { return 1; } +# endif + // ------------------------------------------- + private: + Cpptraj::Structure::Zmatrix* zmatrix_; +}; +#endif From 5cc7d10ec3129c587cb4284129b1ffbef2f72e12 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 28 Sep 2023 16:05:16 -0400 Subject: [PATCH 059/245] Add zmatrix enum --- src/DataSet.cpp | 1 + src/DataSet.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DataSet.cpp b/src/DataSet.cpp index 5135067fd1..b9e0d5b797 100644 --- a/src/DataSet.cpp +++ b/src/DataSet.cpp @@ -32,6 +32,7 @@ const char* DataSet::Descriptions_[] = { "vector with scalar", // VECTOR_SCALAR "unsigned integer", // UNSIGNED_INTEGER "frames", // FRAMES + "zmatrix", // ZMATRIX "unknown" // UNKNOWN_DATA }; diff --git a/src/DataSet.h b/src/DataSet.h index 98868cef3c..b20d6f8cb8 100644 --- a/src/DataSet.h +++ b/src/DataSet.h @@ -29,7 +29,7 @@ class DataSet { COORDS, VECTOR, MODES, GRID_FLT, GRID_DBL, REMLOG, XYMESH, TRAJ, REF_FRAME, MAT3X3, TOPOLOGY, PH, PH_EXPL, PH_IMPL, PARAMETERS, PMATRIX_MEM, PMATRIX_NC, TENSOR, STRINGVAR, VECTOR_SCALAR, UNSIGNED_INTEGER, - FRAMES, + FRAMES, ZMATRIX, UNKNOWN_DATA }; /// Group DataSet belongs to. From 736dc7b6f83af87ecb3fed3605d62a9752beed9e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 28 Sep 2023 16:06:32 -0400 Subject: [PATCH 060/245] Add zmatrix data set to DSL --- src/DataSetList.cpp | 2 ++ src/cpptrajdepend | 3 ++- src/cpptrajfiles | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/DataSetList.cpp b/src/DataSetList.cpp index 332f90c7a9..a6662da59e 100644 --- a/src/DataSetList.cpp +++ b/src/DataSetList.cpp @@ -35,6 +35,7 @@ #include "DataSet_Vector_Scalar.h" #include "DataSet_unsignedInt.h" #include "DataSet_Coords_FRM.h" +#include "DataSet_Zmatrix.h" bool DataSetList::useDiskCache_ = false; @@ -93,6 +94,7 @@ DataSet* DataSetList::NewSet(DataSet::DataType typeIn) { case DataSet::TENSOR : ds = DataSet_Tensor::Alloc(); break; case DataSet::STRINGVAR : ds = DataSet_StringVar::Alloc(); break; case DataSet::VECTOR_SCALAR : ds = DataSet_Vector_Scalar::Alloc(); break; + case DataSet::ZMATRIX : ds = DataSet_Zmatrix::Alloc(); break; // Sanity check default: mprinterr("Internal Error: No allocator for DataSet type '%s'\n", diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 34f65e0dd5..88ee6c0866 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -227,7 +227,7 @@ DataIO_VecTraj.o : DataIO_VecTraj.cpp ActionFrameCounter.h ArgList.h ArrayIterat DataIO_XVG.o : DataIO_XVG.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_XVG.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_double.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_Xplor.o : DataIO_Xplor.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_Xplor.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridFlt.h Dimension.h FileIO.h FileName.h Frame.h Grid.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ProgressBar.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataSet.o : DataSet.cpp AssociatedData.h CpptrajFile.h CpptrajStdio.h DataSet.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h TextFormat.h -DataSetList.o : DataSetList.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h Box.h Cluster/Cframes.h Cluster/Cmatrix_NC.h CompactFrameArray.h ComplexArray.h Constants.h CoordinateInfo.h Cph.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_FRM.h DataSet_Coords_REF.h DataSet_Coords_TRJ.h DataSet_GridDbl.h DataSet_GridFlt.h DataSet_Mat3x3.h DataSet_MatrixDbl.h DataSet_MatrixFlt.h DataSet_Mesh.h DataSet_Modes.h DataSet_PHREMD.h DataSet_PHREMD_Explicit.h DataSet_PHREMD_Implicit.h DataSet_PairwiseCache.h DataSet_PairwiseCache_MEM.h DataSet_PairwiseCache_NC.h DataSet_Parameters.h DataSet_RemLog.h DataSet_StringVar.h DataSet_Tensor.h DataSet_Topology.h DataSet_Vector.h DataSet_Vector_Scalar.h DataSet_double.h DataSet_float.h DataSet_integer.h DataSet_integer_disk.h DataSet_integer_mem.h DataSet_pH.h DataSet_string.h DataSet_unsignedInt.h Dimension.h FileIO.h FileName.h Frame.h Grid.h GridBin.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 Residue.h Segment.h Spline.h StringRoutines.h SymbolExporting.h SymmetricTensor.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajFrameIndex.h Trajin.h TypeNameHolder.h Unit.h Vec3.h +DataSetList.o : DataSetList.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h Box.h Cluster/Cframes.h Cluster/Cmatrix_NC.h CompactFrameArray.h ComplexArray.h Constants.h CoordinateInfo.h Cph.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_FRM.h DataSet_Coords_REF.h DataSet_Coords_TRJ.h DataSet_GridDbl.h DataSet_GridFlt.h DataSet_Mat3x3.h DataSet_MatrixDbl.h DataSet_MatrixFlt.h DataSet_Mesh.h DataSet_Modes.h DataSet_PHREMD.h DataSet_PHREMD_Explicit.h DataSet_PHREMD_Implicit.h DataSet_PairwiseCache.h DataSet_PairwiseCache_MEM.h DataSet_PairwiseCache_NC.h DataSet_Parameters.h DataSet_RemLog.h DataSet_StringVar.h DataSet_Tensor.h DataSet_Topology.h DataSet_Vector.h DataSet_Vector_Scalar.h DataSet_Zmatrix.h DataSet_double.h DataSet_float.h DataSet_integer.h DataSet_integer_disk.h DataSet_integer_mem.h DataSet_pH.h DataSet_string.h DataSet_unsignedInt.h Dimension.h FileIO.h FileName.h Frame.h Grid.h GridBin.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 Residue.h Segment.h Spline.h StringRoutines.h SymbolExporting.h SymmetricTensor.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajFrameIndex.h Trajin.h TypeNameHolder.h Unit.h Vec3.h DataSet_1D.o : DataSet_1D.cpp ArrayIterator.h AssociatedData.h ComplexArray.h Constants.h Corr.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_1D.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h PubFFT.h Range.h TextFormat.h DataSet_3D.o : DataSet_3D.cpp AssociatedData.h Box.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_3D.h Dimension.h FileIO.h FileName.h GridBin.h Matrix_3x3.h MetaData.h Parallel.h Range.h TextFormat.h Vec3.h DataSet_Coords.o : DataSet_Coords.cpp AssociatedData.h Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Coords.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Topology.h TypeNameHolder.h Unit.h Vec3.h @@ -254,6 +254,7 @@ DataSet_Tensor.o : DataSet_Tensor.cpp AssociatedData.h CpptrajFile.h DataSet.h D DataSet_Topology.o : DataSet_Topology.cpp AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Topology.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ParmFile.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataSet_Vector.o : DataSet_Vector.cpp ArrayIterator.h AssociatedData.h ComplexArray.h Constants.h Corr.h CpptrajFile.h DataSet.h DataSet_1D.h DataSet_Vector.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h PubFFT.h Range.h SymbolExporting.h TextFormat.h Vec3.h DataSet_Vector_Scalar.o : DataSet_Vector_Scalar.cpp AssociatedData.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Vector_Scalar.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h TextFormat.h Vec3.h +DataSet_Zmatrix.o : DataSet_Zmatrix.cpp AssociatedData.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Zmatrix.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h Structure/InternalCoords.h Structure/Zmatrix.h TextFormat.h Vec3.h DataSet_double.o : DataSet_double.cpp AssociatedData.h CpptrajFile.h DataSet.h DataSet_1D.h DataSet_double.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h TextFormat.h DataSet_float.o : DataSet_float.cpp AssociatedData.h CpptrajFile.h DataSet.h DataSet_1D.h DataSet_float.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h TextFormat.h DataSet_integer_disk.o : DataSet_integer_disk.cpp AssociatedData.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_1D.h DataSet_integer.h DataSet_integer_disk.h Dimension.h FileIO.h FileName.h File_TempName.h MetaData.h NC_Routines.h Parallel.h Range.h TextFormat.h diff --git a/src/cpptrajfiles b/src/cpptrajfiles index 03bf21c28a..5e3acafa8d 100644 --- a/src/cpptrajfiles +++ b/src/cpptrajfiles @@ -232,6 +232,7 @@ COMMON_SOURCES= \ DataSet_StringVar.cpp \ DataSet_Tensor.cpp \ DataSet_unsignedInt.cpp \ + DataSet_Zmatrix.cpp \ Deprecated.cpp \ DihedralSearch.cpp \ DiffusionResults.cpp \ From a66d8579859cead445abf750f769e638a8302913 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 28 Sep 2023 16:25:06 -0400 Subject: [PATCH 061/245] Add zmatrix command --- src/Command.cpp | 2 ++ src/DataIO_AmberPrep.cpp | 4 +-- src/DataSet_Zmatrix.cpp | 2 +- src/DataSet_Zmatrix.h | 1 + src/Exec_Zmatrix.cpp | 57 ++++++++++++++++++++++++++++++++++++++++ src/Exec_Zmatrix.h | 12 +++++++++ src/cpptrajdepend | 3 ++- src/cpptrajfiles | 1 + 8 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 src/Exec_Zmatrix.cpp create mode 100644 src/Exec_Zmatrix.h diff --git a/src/Command.cpp b/src/Command.cpp index 2311a4d316..0f92b4588b 100644 --- a/src/Command.cpp +++ b/src/Command.cpp @@ -56,6 +56,7 @@ #include "Exec_CatCrd.h" #include "Exec_CrdTransform.h" #include "Exec_ExtendedComparison.h" +#include "Exec_Zmatrix.h" // ----- TRAJECTORY ------------------------------------------------------------ #include "Exec_Traj.h" // ----- TOPOLOGY -------------------------------------------------------------- @@ -280,6 +281,7 @@ void Command::Init() { Command::AddCmd( new Exec_PrepareForLeap(), Cmd::EXE, 1, "prepareforleap" ); Command::AddCmd( new Exec_RotateDihedral(), Cmd::EXE, 1, "rotatedihedral" ); Command::AddCmd( new Exec_SplitCoords(), Cmd::EXE, 1, "splitcoords" ); + Command::AddCmd( new Exec_Zmatrix(), Cmd::EXE, 1, "zmatrix" ); // TRAJECTORY Command::AddCmd( new Exec_Ensemble(), Cmd::EXE, 1, "ensemble" ); Command::AddCmd( new Exec_EnsembleSize(), Cmd::EXE, 1, "ensemblesize" ); diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 87dba33859..5c9e7a6dbb 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -336,7 +336,7 @@ const } } // DEBUG - back convert - mprintf("DEBUG: BACK CONVERT %s\n", resName.c_str()); +/* mprintf("DEBUG: BACK CONVERT %s\n", resName.c_str()); mprinterr("DEBUG: BACK CONVERT %s\n", resName.c_str()); Zmatrix tempZ; tempZ.SetDebug(10); @@ -353,7 +353,7 @@ const tempZ.SetToFrame(tmpFrame); for (int ii = 0; ii < tmpFrame.Natom(); ii++) tmpFrame.printAtomCoord(ii); - } + }*/ // Output Set up frame set if (CRD->CoordsSetup(top, CoordinateInfo())) { mprinterr("Error: Could not set up COORDS set for prep.\n"); diff --git a/src/DataSet_Zmatrix.cpp b/src/DataSet_Zmatrix.cpp index 9cc9b7d91b..9b281ba889 100644 --- a/src/DataSet_Zmatrix.cpp +++ b/src/DataSet_Zmatrix.cpp @@ -7,7 +7,7 @@ using namespace Cpptraj::Structure; /** CONSTRUCTOR */ DataSet_Zmatrix::DataSet_Zmatrix() : zmatrix_(0) { - + zmatrix_ = new Zmatrix(); } /** DESTRUCTOR */ diff --git a/src/DataSet_Zmatrix.h b/src/DataSet_Zmatrix.h index 178f07377a..7d536f3200 100644 --- a/src/DataSet_Zmatrix.h +++ b/src/DataSet_Zmatrix.h @@ -24,6 +24,7 @@ class DataSet_Zmatrix : public DataSet { int Sync(size_t, std::vector const&, Parallel::Comm const&) { return 1; } # endif // ------------------------------------------- + Cpptraj::Structure::Zmatrix* Zptr() const { return zmatrix_; } private: Cpptraj::Structure::Zmatrix* zmatrix_; }; diff --git a/src/Exec_Zmatrix.cpp b/src/Exec_Zmatrix.cpp new file mode 100644 index 0000000000..636bbcf7ee --- /dev/null +++ b/src/Exec_Zmatrix.cpp @@ -0,0 +1,57 @@ +#include "Exec_Zmatrix.h" +#include "CpptrajStdio.h" +#include "DataSet_Zmatrix.h" +#include "Structure/Zmatrix.h" + +using namespace Cpptraj::Structure; + +// Exec_Zmatrix::Help() +void Exec_Zmatrix::Help() const +{ + +} + +// Exec_Zmatrix::Execute() +Exec::RetType Exec_Zmatrix::Execute(CpptrajState& State, ArgList& argIn) +{ + int molnum = argIn.getKeyInt("molnum", 1) - 1; + int frmidx = argIn.getKeyInt("frame", 1) - 1; + std::string dsname = argIn.GetStringKey("name"); + + std::string setname = argIn.GetStringNext(); + if (setname.empty()) { + mprinterr("Error: %s: Specify COORDS dataset name.\n", argIn.Command()); + return CpptrajState::ERR; + } + DataSet_Coords* CRD = (DataSet_Coords*)State.DSL().FindSetOfGroup( setname, DataSet::COORDINATES ); + if (CRD == 0) { + mprinterr("Error: %s: No COORDS set with name %s found.\n", argIn.Command(), setname.c_str()); + return CpptrajState::ERR; + } + mprintf("\tUsing set '%s'\n", CRD->legend()); + if (CRD->Size() < 1) { + mprinterr("Error: Set '%s' is empty.\n"); + return CpptrajState::ERR; + } + + DataSet_Zmatrix* zset = (DataSet_Zmatrix*)State.DSL().AddSet( DataSet::ZMATRIX, dsname, "ZMATRIX" ); + if (zset == 0) { + mprinterr("Error: Could not allocate zmatrix set.\n"); + return CpptrajState::ERR; + } + + mprintf("\tOutput set : %s\n", zset->legend()); + mprintf("\tMolecule : %i\n", molnum + 1 ); + mprintf("\tFrame : %i\n", frmidx + 1 ); + + Frame frmIn = CRD->AllocateFrame(); + CRD->GetFrame( frmidx, frmIn ); + + Zmatrix& zmatrix = *(zset->Zptr()); + + zmatrix.SetDebug( State.Debug() ); + int errStat = zmatrix.SetFromFrame( frmIn, CRD->Top(), molnum ); + zmatrix.print(); // DEBUG + if (errStat != 0) return CpptrajState::ERR; + return CpptrajState::OK; +} diff --git a/src/Exec_Zmatrix.h b/src/Exec_Zmatrix.h new file mode 100644 index 0000000000..e0c9b5eacb --- /dev/null +++ b/src/Exec_Zmatrix.h @@ -0,0 +1,12 @@ +#ifndef INC_EXEC_ZMATRIX_H +#define INC_EXEC_ZMATRIX_H +#include "Exec.h" +/// Calculate a Zmatrix from a COORDS data set +class Exec_Zmatrix : public Exec { + public: + Exec_Zmatrix() : Exec(COORDS) {} + void Help() const; + DispatchObject* Alloc() const { return (DispatchObject*)new Exec_Zmatrix(); } + RetType Execute(CpptrajState&, ArgList&); +}; +#endif diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 88ee6c0866..62b3cd6b2c 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -186,7 +186,7 @@ ClusterMap.o : ClusterMap.cpp AssociatedData.h ClusterMap.h Constants.h CpptrajF Cmd.o : Cmd.cpp Cmd.h DispatchObject.h CmdInput.o : CmdInput.cpp CmdInput.h StringRoutines.h CmdList.o : CmdList.cpp Cmd.h CmdList.h DispatchObject.h -Command.o : Command.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h ActionTopWriter.h Action_Align.h Action_Angle.h Action_AreaPerMol.h Action_AtomMap.h Action_AtomicCorr.h Action_AtomicFluct.h Action_AutoImage.h Action_Average.h Action_AvgBox.h Action_Bounds.h Action_Box.h Action_Center.h Action_Channel.h Action_CheckChirality.h Action_CheckStructure.h Action_Closest.h Action_ClusterDihedral.h Action_Contacts.h Action_CreateCrd.h Action_CreateReservoir.h Action_DNAionTracker.h Action_DSSP.h Action_Density.h Action_Diffusion.h Action_Dihedral.h Action_DihedralRMS.h Action_Dipole.h Action_DistRmsd.h Action_Distance.h Action_Energy.h Action_Esander.h Action_FilterByData.h Action_FixAtomOrder.h Action_FixImagedBonds.h Action_GIST.h Action_Grid.h Action_GridFreeEnergy.h Action_HydrogenBond.h Action_Image.h Action_InfraredSpectrum.h Action_Jcoupling.h Action_Keep.h Action_LESsplit.h Action_LIE.h Action_LipidOrder.h Action_MakeStructure.h Action_Mask.h Action_Matrix.h Action_MinImage.h Action_Molsurf.h Action_MultiDihedral.h Action_MultiPucker.h Action_MultiVector.h Action_NAstruct.h Action_NMRrst.h Action_NativeContacts.h Action_OrderParameter.h Action_Outtraj.h Action_PairDist.h Action_Pairwise.h Action_Principal.h Action_Projection.h Action_Pucker.h Action_Radgyr.h Action_Radial.h Action_RandomizeIons.h Action_Remap.h Action_ReplicateCell.h Action_Rmsd.h Action_Rotate.h Action_RunningAvg.h Action_STFC_Diffusion.h Action_Scale.h Action_SetVelocity.h Action_Spam.h Action_Strip.h Action_Surf.h Action_SymmetricRmsd.h Action_Temperature.h Action_Time.h Action_ToroidalDiffusion.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_CalcDiffusion.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_TICA.h Analysis_Timecorr.h Analysis_VectorMath.h Analysis_Wavelet.h ArgList.h Array1D.h ArrayIterator.h AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h AxisType.h BaseIOtype.h Box.h BoxArgs.h BufferedLine.h CharMask.h Cluster/Algorithm.h Cluster/BestReps.h Cluster/CentroidArray.h Cluster/Cframes.h Cluster/Control.h Cluster/DrawGraph.h Cluster/List.h Cluster/Metric.h Cluster/MetricArray.h Cluster/Node.h Cluster/Sieve.h Cluster/Silhouette.h ClusterMap.h Cmd.h CmdInput.h CmdList.h Command.h CompactFrameArray.h ComplexArray.h Constants.h Constraints.h ControlBlock.h ControlBlock_For.h CoordinateInfo.h Corr.h Cph.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_REF.h DataSet_GridFlt.h DataSet_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 DiffusionResults.h DihedralSearch.h Dimension.h DispatchObject.h Energy.h Energy_Sander.h EnsembleIn.h EnsembleOutList.h Ewald.h EwaldOptions.h Ewald_ParticleMesh.h ExclusionArray.h Exec.h Exec_AddMissingRes.h Exec_Analyze.h Exec_Calc.h Exec_CatCrd.h Exec_Change.h Exec_ClusterMap.h Exec_CombineCoords.h Exec_Commands.h Exec_CompareClusters.h Exec_CompareEnergy.h Exec_CompareTop.h Exec_CrdAction.h Exec_CrdOut.h Exec_CrdTransform.h Exec_CreateSet.h Exec_DataFile.h Exec_DataFilter.h Exec_DataSetCmd.h Exec_Emin.h Exec_ExtendedComparison.h Exec_Flatten.h Exec_GenerateAmberRst.h Exec_Graft.h Exec_Help.h Exec_HmassRepartition.h Exec_LoadCrd.h Exec_LoadTraj.h Exec_ParallelAnalysis.h Exec_ParmBox.h Exec_ParmSolvent.h Exec_ParmStrip.h Exec_ParmWrite.h Exec_ParseTiming.h Exec_PermuteDihedrals.h Exec_Precision.h Exec_PrepareForLeap.h Exec_PrintData.h Exec_Random.h Exec_ReadData.h Exec_ReadEnsembleData.h Exec_ReadInput.h Exec_RotateDihedral.h Exec_RunAnalysis.h Exec_ScaleDihedralK.h Exec_SequenceAlign.h Exec_Set.h Exec_Show.h Exec_SortEnsembleData.h Exec_SplitCoords.h Exec_System.h Exec_Top.h Exec_Traj.h Exec_UpdateParameters.h Exec_ViewRst.h ExtendedSimilarity.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h GIST_PME.h Grid.h GridAction.h GridBin.h HistBin.h Hungarian.h ImageOption.h ImageTypes.h InputTrajCommon.h MapAtom.h MaskArray.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NC_Routines.h NameType.h NetcdfFile.h OnlineVarT.h OutputTrajCommon.h PDBfile.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h PubFFT.h Pucker.h Pucker_PuckerMask.h Pucker_PuckerSearch.h Pucker_PuckerToken.h RPNcalc.h Random.h Range.h ReferenceAction.h ReferenceFrame.h RemdReservoirNC.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h Spline.h SplineFxnTable.h StructureCheck.h SymbolExporting.h SymmetricRmsdCalc.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h cuda_kernels/GistCudaSetup.cuh helpme_standalone.h molsurf.h +Command.o : Command.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h ActionTopWriter.h Action_Align.h Action_Angle.h Action_AreaPerMol.h Action_AtomMap.h Action_AtomicCorr.h Action_AtomicFluct.h Action_AutoImage.h Action_Average.h Action_AvgBox.h Action_Bounds.h Action_Box.h Action_Center.h Action_Channel.h Action_CheckChirality.h Action_CheckStructure.h Action_Closest.h Action_ClusterDihedral.h Action_Contacts.h Action_CreateCrd.h Action_CreateReservoir.h Action_DNAionTracker.h Action_DSSP.h Action_Density.h Action_Diffusion.h Action_Dihedral.h Action_DihedralRMS.h Action_Dipole.h Action_DistRmsd.h Action_Distance.h Action_Energy.h Action_Esander.h Action_FilterByData.h Action_FixAtomOrder.h Action_FixImagedBonds.h Action_GIST.h Action_Grid.h Action_GridFreeEnergy.h Action_HydrogenBond.h Action_Image.h Action_InfraredSpectrum.h Action_Jcoupling.h Action_Keep.h Action_LESsplit.h Action_LIE.h Action_LipidOrder.h Action_MakeStructure.h Action_Mask.h Action_Matrix.h Action_MinImage.h Action_Molsurf.h Action_MultiDihedral.h Action_MultiPucker.h Action_MultiVector.h Action_NAstruct.h Action_NMRrst.h Action_NativeContacts.h Action_OrderParameter.h Action_Outtraj.h Action_PairDist.h Action_Pairwise.h Action_Principal.h Action_Projection.h Action_Pucker.h Action_Radgyr.h Action_Radial.h Action_RandomizeIons.h Action_Remap.h Action_ReplicateCell.h Action_Rmsd.h Action_Rotate.h Action_RunningAvg.h Action_STFC_Diffusion.h Action_Scale.h Action_SetVelocity.h Action_Spam.h Action_Strip.h Action_Surf.h Action_SymmetricRmsd.h Action_Temperature.h Action_Time.h Action_ToroidalDiffusion.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_CalcDiffusion.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_TICA.h Analysis_Timecorr.h Analysis_VectorMath.h Analysis_Wavelet.h ArgList.h Array1D.h ArrayIterator.h AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h AxisType.h BaseIOtype.h Box.h BoxArgs.h BufferedLine.h CharMask.h Cluster/Algorithm.h Cluster/BestReps.h Cluster/CentroidArray.h Cluster/Cframes.h Cluster/Control.h Cluster/DrawGraph.h Cluster/List.h Cluster/Metric.h Cluster/MetricArray.h Cluster/Node.h Cluster/Sieve.h Cluster/Silhouette.h ClusterMap.h Cmd.h CmdInput.h CmdList.h Command.h CompactFrameArray.h ComplexArray.h Constants.h Constraints.h ControlBlock.h ControlBlock_For.h CoordinateInfo.h Corr.h Cph.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_REF.h DataSet_GridFlt.h DataSet_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 DiffusionResults.h DihedralSearch.h Dimension.h DispatchObject.h Energy.h Energy_Sander.h EnsembleIn.h EnsembleOutList.h Ewald.h EwaldOptions.h Ewald_ParticleMesh.h ExclusionArray.h Exec.h Exec_AddMissingRes.h Exec_Analyze.h Exec_Calc.h Exec_CatCrd.h Exec_Change.h Exec_ClusterMap.h Exec_CombineCoords.h Exec_Commands.h Exec_CompareClusters.h Exec_CompareEnergy.h Exec_CompareTop.h Exec_CrdAction.h Exec_CrdOut.h Exec_CrdTransform.h Exec_CreateSet.h Exec_DataFile.h Exec_DataFilter.h Exec_DataSetCmd.h Exec_Emin.h Exec_ExtendedComparison.h Exec_Flatten.h Exec_GenerateAmberRst.h Exec_Graft.h Exec_Help.h Exec_HmassRepartition.h Exec_LoadCrd.h Exec_LoadTraj.h Exec_ParallelAnalysis.h Exec_ParmBox.h Exec_ParmSolvent.h Exec_ParmStrip.h Exec_ParmWrite.h Exec_ParseTiming.h Exec_PermuteDihedrals.h Exec_Precision.h Exec_PrepareForLeap.h Exec_PrintData.h Exec_Random.h Exec_ReadData.h Exec_ReadEnsembleData.h Exec_ReadInput.h Exec_RotateDihedral.h Exec_RunAnalysis.h Exec_ScaleDihedralK.h Exec_SequenceAlign.h Exec_Set.h Exec_Show.h Exec_SortEnsembleData.h Exec_SplitCoords.h Exec_System.h Exec_Top.h Exec_Traj.h Exec_UpdateParameters.h Exec_ViewRst.h Exec_Zmatrix.h ExtendedSimilarity.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h GIST_PME.h Grid.h GridAction.h GridBin.h HistBin.h Hungarian.h ImageOption.h ImageTypes.h InputTrajCommon.h MapAtom.h MaskArray.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NC_Routines.h NameType.h NetcdfFile.h OnlineVarT.h OutputTrajCommon.h PDBfile.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h PubFFT.h Pucker.h Pucker_PuckerMask.h Pucker_PuckerSearch.h Pucker_PuckerToken.h RPNcalc.h Random.h Range.h ReferenceAction.h ReferenceFrame.h RemdReservoirNC.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h Spline.h SplineFxnTable.h StructureCheck.h SymbolExporting.h SymmetricRmsdCalc.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h cuda_kernels/GistCudaSetup.cuh helpme_standalone.h molsurf.h CompactFrameArray.o : CompactFrameArray.cpp Box.h CompactFrameArray.h CoordinateInfo.h CpptrajStdio.h Matrix_3x3.h Parallel.h ReplicaDimArray.h Vec3.h ComplexArray.o : ComplexArray.cpp ArrayIterator.h ComplexArray.h Constraints.o : Constraints.cpp ArgList.h Atom.h AtomMask.h AtomType.h Box.h CharMask.h Constants.h Constraints.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h @@ -336,6 +336,7 @@ Exec_Top.o : Exec_Top.cpp Action.h ActionList.h ActionState.h Analysis.h Analysi Exec_Traj.o : Exec_Traj.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_Traj.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_UpdateParameters.o : Exec_UpdateParameters.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_Parameters.h DataSet_Topology.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_UpdateParameters.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_ViewRst.o : Exec_ViewRst.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.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_ViewRst.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h ViewRst.h +Exec_Zmatrix.o : Exec_Zmatrix.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_Zmatrix.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Zmatrix.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 Segment.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h ExtendedSimilarity.o : ExtendedSimilarity.cpp AssociatedData.h Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Coords.h Dimension.h ExtendedSimilarity.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Topology.h TypeNameHolder.h Unit.h Vec3.h ExternalFxn.o : ExternalFxn.cpp Random.h FileIO_Bzip2.o : FileIO_Bzip2.cpp CpptrajStdio.h FileIO.h FileIO_Bzip2.h diff --git a/src/cpptrajfiles b/src/cpptrajfiles index 5e3acafa8d..7c923792a1 100644 --- a/src/cpptrajfiles +++ b/src/cpptrajfiles @@ -306,6 +306,7 @@ COMMON_SOURCES= \ Exec_Traj.cpp \ Exec_UpdateParameters.cpp \ Exec_ViewRst.cpp \ + Exec_Zmatrix.cpp \ ExtendedSimilarity.cpp \ File_TempName.cpp \ FileIO_Bzip2.cpp \ From b7e1be9973ab2a48935fa5d4df02e2daf1cb877b Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 08:55:34 -0400 Subject: [PATCH 062/245] Add more zmatrix data set routines --- src/DataSet_Zmatrix.cpp | 32 +++++++++++++++++++++++++++++++- src/DataSet_Zmatrix.h | 8 ++++---- src/Structure/InternalCoords.h | 1 + src/Structure/Zmatrix.h | 11 +++++++++++ 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/DataSet_Zmatrix.cpp b/src/DataSet_Zmatrix.cpp index 9b281ba889..adbb771129 100644 --- a/src/DataSet_Zmatrix.cpp +++ b/src/DataSet_Zmatrix.cpp @@ -5,7 +5,9 @@ using namespace Cpptraj::Structure; /** CONSTRUCTOR */ -DataSet_Zmatrix::DataSet_Zmatrix() : zmatrix_(0) +DataSet_Zmatrix::DataSet_Zmatrix() : + DataSet(ZMATRIX, GENERIC, TextFormat(TextFormat::DOUBLE, 8, 3, 7), 1), // i j k l dist theta phi + zmatrix_(0) { zmatrix_ = new Zmatrix(); } @@ -14,3 +16,31 @@ DataSet_Zmatrix::DataSet_Zmatrix() : zmatrix_(0) DataSet_Zmatrix::~DataSet_Zmatrix() { if (zmatrix_ != 0) delete zmatrix_; } + +/** \return memory usage in bytes. */ +size_t DataSet_Zmatrix::MemUsageInBytes() const { + return zmatrix_->sizeInBytes(); +} + +/** \return number of internal coords */ +size_t DataSet_Zmatrix::Size() const { + return zmatrix_->N_IC(); +} + +/** Reserve space in the IC_ array. */ +int DataSet_Zmatrix::Allocate( SizeArray const& sizeIn ) { + if (!sizeIn.empty()) + zmatrix_->reserve( sizeIn[0] ); + return 0; +} + +/** Write to file. */ +void DataSet_Zmatrix::WriteBuffer(CpptrajFile &cbuffer, SizeArray const& frame) const { + if (frame[0] >= zmatrix_->N_IC()) + cbuffer.Printf(format_.fmt(), 0, 0, 0, 0, 0, 0, 0); + else { + InternalCoords const& ic = (*zmatrix_)[frame[0]]; + cbuffer.Printf(format_.fmt(), ic.AtI()+1, ic.AtJ()+1, ic.AtK()+1, ic.AtL()+1, + ic.Dist(), ic.Theta(), ic.Phi()); + } +} diff --git a/src/DataSet_Zmatrix.h b/src/DataSet_Zmatrix.h index 7d536f3200..6e667b3c16 100644 --- a/src/DataSet_Zmatrix.h +++ b/src/DataSet_Zmatrix.h @@ -13,13 +13,13 @@ class DataSet_Zmatrix : public DataSet { ~DataSet_Zmatrix(); static DataSet* Alloc() { return (DataSet*)new DataSet_Zmatrix(); } // ----- DataSet functions ------------------- - size_t Size() const { return 0; } + size_t Size() const; + int Allocate(SizeArray const&); + void WriteBuffer(CpptrajFile&, SizeArray const&) const; + size_t MemUsageInBytes() const; void Info() const { return; } - int Allocate(SizeArray const&) { return 1; } void Add(size_t, const void*) { return; } - void WriteBuffer(CpptrajFile&, SizeArray const&) const { return; } int Append(DataSet*) { return 1; } - size_t MemUsageInBytes() const { return 0; } # ifdef MPI int Sync(size_t, std::vector const&, Parallel::Comm const&) { return 1; } # endif diff --git a/src/Structure/InternalCoords.h b/src/Structure/InternalCoords.h index 76d1505f3f..9ad2f4fb11 100644 --- a/src/Structure/InternalCoords.h +++ b/src/Structure/InternalCoords.h @@ -35,6 +35,7 @@ class InternalCoords { int AtK() const { return idx_[1]; } int AtL() const { return idx_[2]; } + static unsigned int sizeInBytes() { return (4*sizeof(int)) + (3*sizeof(double)); } private: int ati_; ///< Atom I index int idx_[3]; ///< Atom indices for distance, angle, torsion diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index bc7061bcea..6fe6cf26d8 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -34,6 +34,17 @@ class Zmatrix { typedef ICarray::const_iterator const_iterator; const_iterator begin() const { return IC_.begin(); } const_iterator end() const { return IC_.end(); } + + /// \return number of internal coords + unsigned int N_IC() const { return IC_.size(); } + /// \return memory usage in bytes + unsigned int sizeInBytes() const { return (7*sizeof(int)) + + (9*sizeof(double)) + // 3 Vec3 + (IC_.size() * InternalCoords::sizeInBytes()); } + /// \reserve space for # of internal coords TODO zero out seeds? + void reserve(unsigned int n) { IC_.reserve( n ); } + /// \return Internal coord of specified index + InternalCoords const& operator[](int i) const { return IC_[i]; } private: /// Calculate and add an internal coordinate given indices and Cartesian coords. void addIc(int,int,int,int,const double*,const double*,const double*,const double*); From d86f869a2069023fede092a4595f972bd421bf33 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 08:58:50 -0400 Subject: [PATCH 063/245] Add out keyword to zmatrix. Set dimension for zmatrix set --- src/Exec_Zmatrix.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Exec_Zmatrix.cpp b/src/Exec_Zmatrix.cpp index 636bbcf7ee..2a382bf1bc 100644 --- a/src/Exec_Zmatrix.cpp +++ b/src/Exec_Zmatrix.cpp @@ -17,6 +17,7 @@ Exec::RetType Exec_Zmatrix::Execute(CpptrajState& State, ArgList& argIn) int molnum = argIn.getKeyInt("molnum", 1) - 1; int frmidx = argIn.getKeyInt("frame", 1) - 1; std::string dsname = argIn.GetStringKey("name"); + DataFile* outfile = State.DFL().AddDataFile( argIn.GetStringKey("out"), argIn ); std::string setname = argIn.GetStringNext(); if (setname.empty()) { @@ -39,10 +40,15 @@ Exec::RetType Exec_Zmatrix::Execute(CpptrajState& State, ArgList& argIn) mprinterr("Error: Could not allocate zmatrix set.\n"); return CpptrajState::ERR; } - - mprintf("\tOutput set : %s\n", zset->legend()); - mprintf("\tMolecule : %i\n", molnum + 1 ); - mprintf("\tFrame : %i\n", frmidx + 1 ); + zset->SetDim(Dimension::X, Dimension(1, 1, "IC")); + if (outfile != 0) + outfile->AddDataSet( zset ); + + mprintf("\tOutput set : %s\n", zset->legend()); + mprintf("\tMolecule : %i\n", molnum + 1 ); + mprintf("\tFrame : %i\n", frmidx + 1 ); + if (outfile != 0) + mprintf("\tOutput file : %s\n", outfile->DataFilename().full()); Frame frmIn = CRD->AllocateFrame(); CRD->GetFrame( frmidx, frmIn ); From a8aa4a59e73b5b71afb0aba517b70f8002db72a6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 09:08:35 -0400 Subject: [PATCH 064/245] Do proper casting for printf --- src/DataSet_Zmatrix.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/DataSet_Zmatrix.cpp b/src/DataSet_Zmatrix.cpp index adbb771129..2ea9d8ae29 100644 --- a/src/DataSet_Zmatrix.cpp +++ b/src/DataSet_Zmatrix.cpp @@ -39,8 +39,11 @@ void DataSet_Zmatrix::WriteBuffer(CpptrajFile &cbuffer, SizeArray const& frame) if (frame[0] >= zmatrix_->N_IC()) cbuffer.Printf(format_.fmt(), 0, 0, 0, 0, 0, 0, 0); else { + //mprintf("DEBUG: Format: %s\n", format_.fmt()); InternalCoords const& ic = (*zmatrix_)[frame[0]]; - cbuffer.Printf(format_.fmt(), ic.AtI()+1, ic.AtJ()+1, ic.AtK()+1, ic.AtL()+1, + cbuffer.Printf(format_.fmt(), + (double)(ic.AtI()+1), (double)(ic.AtJ()+1), + (double)(ic.AtK()+1), (double)(ic.AtL()+1), ic.Dist(), ic.Theta(), ic.Phi()); } } From b0653c88359e0a83bf9eece61f71a36162aa4e03 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 09:08:48 -0400 Subject: [PATCH 065/245] Add zmatrix test --- test/Test_Zmatrix/RunTest.sh | 19 +++++++++++++++++++ test/Test_Zmatrix/zmatrix.dat.save | 5 +++++ 2 files changed, 24 insertions(+) create mode 100755 test/Test_Zmatrix/RunTest.sh create mode 100644 test/Test_Zmatrix/zmatrix.dat.save diff --git a/test/Test_Zmatrix/RunTest.sh b/test/Test_Zmatrix/RunTest.sh new file mode 100755 index 0000000000..0e32536c70 --- /dev/null +++ b/test/Test_Zmatrix/RunTest.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +. ../MasterTest.sh + +CleanFiles cpptraj.in zmatrix.dat + +INPUT='-i cpptraj.in' + +TESTNAME='Zmatrix tests' + +cat > cpptraj.in < Date: Fri, 29 Sep 2023 09:09:32 -0400 Subject: [PATCH 066/245] Enable zmatrix test --- test/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index 313bdfda04..21f1de9a5b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -527,6 +527,9 @@ test.parsetiming: test.readprep: @-cd Test_ReadPrep && ./RunTest.sh $(OPT) +test.zmatrix: + @-cd Test_Zmatrix && ./RunTest.sh $(OPT) + # Every test target should go here. COMPLETETESTS=test.general \ test.strip \ @@ -693,7 +696,8 @@ COMPLETETESTS=test.general \ test.tordiff \ test.calcdiffusion \ test.parsetiming \ - test.readprep + test.readprep \ + test.zmatrix test.all: $(MAKE) test.complete summary From 043f0b6a21cbf5bbb8180ef6d3410a80a7eed493 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 09:12:22 -0400 Subject: [PATCH 067/245] Start harder sugar test --- test/Test_Zmatrix/0SB.mol2 | 85 ++++++++++++++++++++++++++++++++++++ test/Test_Zmatrix/RunTest.sh | 19 ++++++-- 2 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 test/Test_Zmatrix/0SB.mol2 diff --git a/test/Test_Zmatrix/0SB.mol2 b/test/Test_Zmatrix/0SB.mol2 new file mode 100644 index 0000000000..1ae0e92d75 --- /dev/null +++ b/test/Test_Zmatrix/0SB.mol2 @@ -0,0 +1,85 @@ +@MOLECULE +Cpptraj Generated mol2 file. + 37 37 1 0 0 +SMALL +USER_CHARGES + + +@ATOM + 1 C2 14.9015 -9.2110 -16.1237 Cy 1 0SB 0.090000 + 2 O6 15.9650 -8.9416 -17.0642 Oy 1 0SB -0.344000 + 3 C6 15.6470 -8.6291 -18.4365 Cg 1 0SB -0.008000 + 4 H6 14.9924 -7.7551 -18.4276 H1 1 0SB 0.000000 + 5 C7 16.9306 -8.1911 -19.1806 Cg 1 0SB 0.278000 + 6 H7 16.6223 -7.7157 -20.1129 H1 1 0SB 0.000000 + 7 O7 17.7162 -9.3572 -19.5311 Oh 1 0SB -0.656000 + 8 H7O 17.2546 -9.8678 -20.2202 Ho 1 0SB 0.390000 + 9 C8 17.8143 -7.1775 -18.3978 Cg 1 0SB 0.367000 + 10 H8 18.2503 -7.6690 -17.5268 H1 1 0SB 0.000000 + 11 O8 16.9766 -6.0764 -17.9315 Oh 1 0SB -0.704000 + 12 H8O 16.3695 -6.4413 -17.2732 Ho 1 0SB 0.392000 + 13 C9 18.9488 -6.5888 -19.2694 Cg 1 0SB 0.201000 + 14 H9S 19.5899 -7.3870 -19.6435 H1 1 0SB 0.000000 + 15 H9R 18.5275 -6.0629 -20.1275 H1 1 0SB 0.000000 + 16 O9 19.7601 -5.6665 -18.5085 Oh 1 0SB -0.672000 + 17 H9O 19.1542 -5.1123 -18.0014 Ho 1 0SB 0.393000 + 18 C5 14.8432 -9.7909 -19.0521 Cg 1 0SB 0.523000 + 19 H5 15.4829 -10.6733 -19.1194 H1 1 0SB 0.000000 + 20 N5 14.3746 -9.4120 -20.3984 Ng 1 0SB -0.669000 + 21 H5N 13.5695 -8.8129 -20.4509 H 1 0SB 0.261000 + 22 C5N 15.0065 -9.7626 -21.5173 C 1 0SB 0.678000 + 23 O5N 16.0693 -10.3734 -21.4932 O 1 0SB -0.634000 + 24 CME 14.3328 -9.3639 -22.8447 Cg 1 0SB -0.005000 + 25 H3M 13.6591 -8.5159 -22.7050 Hc 1 0SB 0.000000 + 26 H2M 13.7643 -10.2118 -23.2293 Hc 1 0SB 0.000000 + 27 H1M 15.0945 -9.0868 -23.5750 Hc 1 0SB 0.000000 + 28 C4 13.6278 -10.1430 -18.1484 Cg 1 0SB 0.203000 + 29 H4 12.9278 -9.3048 -18.1549 H1 1 0SB 0.000000 + 30 O4 12.9124 -11.3226 -18.6262 Oh 1 0SB -0.714000 + 31 H4O 12.5836 -11.1763 -19.5173 Ho 1 0SB 0.390000 + 32 C3 14.0796 -10.3912 -16.6993 Cg 1 0SB 0.133000 + 33 H3E 13.2074 -10.5810 -16.0686 Hc 1 0SB 0.000000 + 34 H3A 14.6688 -11.3112 -16.6672 Hc 1 0SB 0.000000 + 35 C1 15.4479 -9.7079 -14.6785 C 1 0SB 0.979000 + 36 O1B 15.0415 -9.0353 -13.6948 O2 1 0SB -0.839000 + 37 O1A 16.1893 -10.7171 -14.6127 O2 1 0SB -0.839000 +@BOND + 1 2 1 1 + 2 3 2 1 + 3 5 3 1 + 4 7 5 1 + 5 9 5 1 + 6 11 9 1 + 7 13 9 1 + 8 16 13 1 + 9 18 3 1 + 10 20 18 1 + 11 22 20 1 + 12 23 22 1 + 13 24 22 1 + 14 28 18 1 + 15 30 28 1 + 16 32 28 1 + 17 35 1 1 + 18 36 35 1 + 19 37 35 1 + 20 32 1 1 + 21 3 4 1 + 22 5 6 1 + 23 7 8 1 + 24 9 10 1 + 25 11 12 1 + 26 13 14 1 + 27 13 15 1 + 28 16 17 1 + 29 18 19 1 + 30 20 21 1 + 31 24 25 1 + 32 24 26 1 + 33 24 27 1 + 34 28 29 1 + 35 30 31 1 + 36 32 33 1 + 37 32 34 1 +@SUBSTRUCTURE + 1 0SB 1 **** 0 **** **** diff --git a/test/Test_Zmatrix/RunTest.sh b/test/Test_Zmatrix/RunTest.sh index 0e32536c70..1bea8116a6 100755 --- a/test/Test_Zmatrix/RunTest.sh +++ b/test/Test_Zmatrix/RunTest.sh @@ -8,12 +8,25 @@ INPUT='-i cpptraj.in' TESTNAME='Zmatrix tests' -cat > cpptraj.in < cpptraj.in < cpptraj.in < Date: Fri, 29 Sep 2023 09:24:10 -0400 Subject: [PATCH 068/245] Split out seed set functionality --- src/Structure/Zmatrix.cpp | 141 +++++++++++++++++++++----------------- src/Structure/Zmatrix.h | 2 + 2 files changed, 80 insertions(+), 63 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 98d5a78c00..f905ad9ada 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -238,6 +238,75 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) { return SetFromFrame(frameIn, topIn, 0); } +/** Given a first seed, automatically determine remaining 2 seeds. + * Set all seed indices and positions. + */ +int Zmatrix::autoSetSeeds(Frame const& frameIn, Topology const& topIn, unsigned int maxnatom, int firstSeed) +{ + int at0 = firstSeed; + if (maxnatom < 2) { + seedAt0_ = at0; + seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); + return 0; + } + // Choose second seed atom as bonded atom with lowest index. Prefer heavy + // atoms and atoms with more than 1 bond. + std::set bondedTo0 = getBondedAtomPriorities(at0, topIn, -1, -1); + if (bondedTo0.empty()) { + mprinterr("Internal Error: Zmatrix::SetFromFrame(): could not get second seed atom.\n"); + return 1; + } + int at1 = FrontIdx( bondedTo0 ); + if (maxnatom < 3) { + seedAt1_ = at1; + seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); + return 0; + } + // The third seed atom will either be bonded to seed 0 or seed 1. + AtnumNbonds potential2From0, potential2From1; + std::set bondedTo1 = getBondedAtomPriorities(at1, topIn, at0, -1); + if (!bondedTo1.empty()) { + std::set::const_iterator it = bondedTo1.begin(); + potential2From1 = *it; + } + if (bondedTo0.size() >= 2) { + std::set::const_iterator it = bondedTo0.begin(); + ++it; + potential2From0 = *it; + } + if (potential2From0 < potential2From1) { + mprintf("DEBUG: 2 - 0 - 1\n"); + seedAt0_ = potential2From0.Idx(); + seedAt1_ = at0; + seedAt2_ = at1; + // D0 D1 D2 A2 + //addIc(at2, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); + // D1 D2 A2 A0 + //addIc(at0, at2, DUMMY2, DUMMY1, frameIn.XYZ(at0), frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr()); + // D2 A2 A0 A1 + //addIc(at1, at0, at2, DUMMY2, frameIn.XYZ(at1), frameIn.XYZ(at0), frameIn.XYZ(at2), seed2Pos_.Dptr()); + } else { + mprintf("DEBUG: 0 - 1 - 2\n"); + seedAt0_ = at0; + seedAt1_ = at1; + seedAt2_ = potential2From1.Idx(); + // D0 D1 D2 A0 + //addIc(at0, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); + // D1 D2 A0 A1 + //addIc(at1, at0, DUMMY2, DUMMY1, frameIn.XYZ(at1), frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr()); + // D2 A0 A1 A2 + //addIc(at2, at1, at0, DUMMY2, frameIn.XYZ(at2), frameIn.XYZ(at1), frameIn.XYZ(at0), seed2Pos_.Dptr()); + } + mprintf("DEBUG: Seed atoms: %s - %s - %s\n", + topIn.AtomMaskName(seedAt0_).c_str(), + topIn.AtomMaskName(seedAt1_).c_str(), + topIn.AtomMaskName(seedAt2_).c_str()); + seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); + seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); + seed2Pos_ = Vec3(frameIn.XYZ(seedAt2_)); + return 0; +} + /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnum) { @@ -268,70 +337,11 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu // See if we need to assign seed atoms if (!HasCartSeeds()) { // First seed atom will just be first atom TODO lowest index heavy atom? - int at0 = atomIndices.front(); - if (maxnatom < 2) { - seedAt0_ = at0; - seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); - return 0; - } - // Choose second seed atom as bonded atom with lowest index. Prefer heavy - // atoms and atoms with more than 1 bond. - std::set bondedTo0 = getBondedAtomPriorities(at0, topIn, -1, -1); - if (bondedTo0.empty()) { - mprinterr("Internal Error: Zmatrix::SetFromFrame(): could not get second seed atom.\n"); + if (autoSetSeeds(frameIn, topIn, maxnatom, atomIndices.front())) { + mprinterr("Error: Could not automatically determine seed atoms.\n"); return 1; } - int at1 = FrontIdx( bondedTo0 ); - if (maxnatom < 3) { - seedAt1_ = at1; - seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); - return 0; - } - // The third seed atom will either be bonded to seed 0 or seed 1. - AtnumNbonds potential2From0, potential2From1; - std::set bondedTo1 = getBondedAtomPriorities(at1, topIn, at0, -1); - if (!bondedTo1.empty()) { - std::set::const_iterator it = bondedTo1.begin(); - potential2From1 = *it; - } - if (bondedTo0.size() >= 2) { - std::set::const_iterator it = bondedTo0.begin(); - ++it; - potential2From0 = *it; - } - if (potential2From0 < potential2From1) { - mprintf("DEBUG: 2 - 0 - 1\n"); - seedAt0_ = potential2From0.Idx(); - seedAt1_ = at0; - seedAt2_ = at1; - // D0 D1 D2 A2 - //addIc(at2, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); - // D1 D2 A2 A0 - //addIc(at0, at2, DUMMY2, DUMMY1, frameIn.XYZ(at0), frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr()); - // D2 A2 A0 A1 - //addIc(at1, at0, at2, DUMMY2, frameIn.XYZ(at1), frameIn.XYZ(at0), frameIn.XYZ(at2), seed2Pos_.Dptr()); - } else { - mprintf("DEBUG: 0 - 1 - 2\n"); - seedAt0_ = at0; - seedAt1_ = at1; - seedAt2_ = potential2From1.Idx(); - // D0 D1 D2 A0 - //addIc(at0, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); - // D1 D2 A0 A1 - //addIc(at1, at0, DUMMY2, DUMMY1, frameIn.XYZ(at1), frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr()); - // D2 A0 A1 A2 - //addIc(at2, at1, at0, DUMMY2, frameIn.XYZ(at2), frameIn.XYZ(at1), frameIn.XYZ(at0), seed2Pos_.Dptr()); - } - mprintf("DEBUG: Seed atoms: %s - %s - %s\n", - topIn.AtomMaskName(seedAt0_).c_str(), - topIn.AtomMaskName(seedAt1_).c_str(), - topIn.AtomMaskName(seedAt2_).c_str()); - MARK(seedAt0_, hasIC, nHasIC); - MARK(seedAt1_, hasIC, nHasIC); - MARK(seedAt2_, hasIC, nHasIC); - seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); - seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); - seed2Pos_ = Vec3(frameIn.XYZ(seedAt2_)); + } else { // Seed atoms already set mprintf("DEBUG: Cartesian Seed indices: %s %s %s\n", @@ -339,7 +349,12 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu topIn.AtomMaskName(seedAt1_).c_str(), topIn.AtomMaskName(seedAt2_).c_str()); } - + // If there are less than 4 atoms we are done + if (maxnatom < 4) return 0; + // Seeds are already done + MARK(seedAt0_, hasIC, nHasIC); + MARK(seedAt1_, hasIC, nHasIC); + MARK(seedAt2_, hasIC, nHasIC); // Do the remaining atoms. // Find the lowest unset atom. unsigned int lowestUnsetIdx = 0; diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 6fe6cf26d8..585bad4dfe 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -46,6 +46,8 @@ class Zmatrix { /// \return Internal coord of specified index InternalCoords const& operator[](int i) const { return IC_[i]; } private: + /// Automatically set seeds + int autoSetSeeds(Frame const&, Topology const&, unsigned int, int); /// Calculate and add an internal coordinate given indices and Cartesian coords. void addIc(int,int,int,int,const double*,const double*,const double*,const double*); /// \return True if IC seeds are set From 611e843fa7defabdc87a70a3a1328d4e41a600c3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 09:31:58 -0400 Subject: [PATCH 069/245] Start new Zmatrix conversion function --- src/Structure/Zmatrix.cpp | 50 +++++++++++++++++++++++++++++++++++++++ src/Structure/Zmatrix.h | 2 ++ 2 files changed, 52 insertions(+) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index f905ad9ada..a6be9305e5 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -307,6 +307,56 @@ int Zmatrix::autoSetSeeds(Frame const& frameIn, Topology const& topIn, unsigned return 0; } +/** Set up Zmatrix from Cartesian coordinates and topology. + * This algorithm attempts to "trace" the molecule in a manner that + * should make internal coordinate assignment more "natural". + */ +int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int molnum) +{ + if (molnum < 0) { + mprinterr("Internal Error: Zmatrix::SetFromFrame(): Negative molecule index.\n"); + return 1; + } + if (topIn.Nmol() < 1) { + mprinterr("Internal Error: Zmatrix::SetFromFrame(): No molecules.\n"); + return 1; + } + IC_.clear(); + Molecule const& currentMol = topIn.Mol(molnum); + unsigned int maxnatom = currentMol.NumAtoms(); + + // Keep track of which atoms are associated with an internal coordinate + std::vector hasIC( topIn.Natom(), false ); + unsigned int nHasIC = 0; + +// See if we need to assign seed atoms + if (!HasCartSeeds()) { + // First seed atom will just be first atom TODO lowest index heavy atom? + if (autoSetSeeds(frameIn, topIn, maxnatom, currentMol.MolUnit().Front())) { + mprinterr("Error: Could not automatically determine seed atoms.\n"); + return 1; + } + + } else { + // Seed atoms already set + mprintf("DEBUG: Cartesian Seed indices: %s %s %s\n", + topIn.AtomMaskName(seedAt0_).c_str(), + topIn.AtomMaskName(seedAt1_).c_str(), + topIn.AtomMaskName(seedAt2_).c_str()); + } + // If there are less than 4 atoms we are done + if (maxnatom < 4) return 0; + // Seeds are already done + MARK(seedAt0_, hasIC, nHasIC); + MARK(seedAt1_, hasIC, nHasIC); + MARK(seedAt2_, hasIC, nHasIC); + + return 0; +} + + + + /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnum) { diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 585bad4dfe..a06066f4a9 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -23,6 +23,8 @@ class Zmatrix { int SetSeedPositions(Frame const&, Topology const&, int, int, int); /// Convert specifed molecule of Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&, int); + /// Convert from Cartesian to Zmatrix by tracing a molecule + int SetFromFrame_Trace(Frame const&, Topology const&, int); /// Convert molecule 0 of Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&); From 6732f792fb6eedd0d54d47afa61bdb8d9416cd13 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 10:13:36 -0400 Subject: [PATCH 070/245] Start doing the new search --- src/Exec_Zmatrix.cpp | 2 +- src/Structure/Zmatrix.cpp | 60 ++++++++++++++++++++++++++++++++++----- src/Structure/Zmatrix.h | 2 +- 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/src/Exec_Zmatrix.cpp b/src/Exec_Zmatrix.cpp index 2a382bf1bc..1fbc00cecd 100644 --- a/src/Exec_Zmatrix.cpp +++ b/src/Exec_Zmatrix.cpp @@ -56,7 +56,7 @@ Exec::RetType Exec_Zmatrix::Execute(CpptrajState& State, ArgList& argIn) Zmatrix& zmatrix = *(zset->Zptr()); zmatrix.SetDebug( State.Debug() ); - int errStat = zmatrix.SetFromFrame( frmIn, CRD->Top(), molnum ); + int errStat = zmatrix.SetFromFrame_Trace( frmIn, CRD->Top(), molnum ); zmatrix.print(); // DEBUG if (errStat != 0) return CpptrajState::ERR; return CpptrajState::OK; diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index a6be9305e5..93166bd297 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -1,5 +1,7 @@ #include #include +#include // std::sort +#include // cos #include "Zmatrix.h" #include "../Frame.h" #include "../CpptrajStdio.h" @@ -7,7 +9,6 @@ #include "../DistRoutines.h" #include "../Topology.h" #include "../TorsionRoutines.h" -#include // cos using namespace Cpptraj::Structure; @@ -233,11 +234,6 @@ void Zmatrix::addIc(int at0, int at1, int at2, int at3, Torsion(xyz0, xyz1, xyz2, xyz3) * Constants::RADDEG) ); } -/** Setup Zmatrix from Cartesian coordinates/topology. */ -int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) { - return SetFromFrame(frameIn, topIn, 0); -} - /** Given a first seed, automatically determine remaining 2 seeds. * Set all seed indices and positions. */ @@ -307,6 +303,14 @@ int Zmatrix::autoSetSeeds(Frame const& frameIn, Topology const& topIn, unsigned return 0; } +static inline void printIarray(std::vector const& arr, const char* desc, Topology const& topIn) { + mprintf("DEBUG:\t\t%s:", desc); + for (std::vector::const_iterator it = arr.begin(); it != arr.end(); ++it) + //mprintf(" %i", *it); + mprintf(" %s", topIn.AtomMaskName(*it).c_str()); + mprintf("\n"); +} + /** Set up Zmatrix from Cartesian coordinates and topology. * This algorithm attempts to "trace" the molecule in a manner that * should make internal coordinate assignment more "natural". @@ -351,11 +355,54 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int MARK(seedAt1_, hasIC, nHasIC); MARK(seedAt2_, hasIC, nHasIC); + // Do the remaining atoms. + // By convention search like: + // L - K - J - + int atL = seedAt0_; + int atK = seedAt1_; + int atJ = seedAt2_; + + while (nHasIC < maxnatom) { + mprintf("\nDEBUG: nHasIC= %8u / %8u : %s - %s - %s -\n", nHasIC, maxnatom, + topIn.AtomMaskName(atL).c_str(), + topIn.AtomMaskName(atK).c_str(), + topIn.AtomMaskName(atJ).c_str()); + // List all atoms bonded to J with the following priority: + // 1) Atoms with 1 bond. + // 2) Low index atoms. + Iarray OneBondAtoms; // TODO allocate outside loop? + Iarray OtherAtoms; + for (Atom::bond_iterator bat = topIn[atJ].bondbegin(); bat != topIn[atJ].bondend(); ++bat) + { + if (!hasIC[*bat]) { + if (topIn[*bat].Nbonds() == 1) + OneBondAtoms.push_back( *bat ); + else + OtherAtoms.push_back( *bat ); + } + } + if (OtherAtoms.size() > 1) + std::sort( OtherAtoms.begin(), OtherAtoms.end() ); + printIarray( OneBondAtoms, "OneBondAtoms", topIn ); + printIarray( OtherAtoms, "OtherAtoms", topIn ); + // Create ICs for 1 bond atoms + for (Iarray::const_iterator atI = OneBondAtoms.begin(); atI != OneBondAtoms.end(); ++atI) { + addIc(*atI, atJ, atK, atL, frameIn.XYZ(*atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); + MARK(*atI, hasIC, nHasIC); + } + + break; // DEBUG + } + return 0; } +/** Setup Zmatrix from Cartesian coordinates/topology. */ +int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) { + return SetFromFrame(frameIn, topIn, 0); +} /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnum) @@ -371,7 +418,6 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu IC_.clear(); Molecule const& currentMol = topIn.Mol(molnum); // Flatten the molecule array - typedef std::vector Iarray; Iarray atomIndices; atomIndices.reserve( currentMol.NumAtoms() ); for (Unit::const_iterator seg = currentMol.MolUnit().segBegin(); diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index a06066f4a9..3048aa5ce2 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -9,7 +9,6 @@ namespace Structure { /// Hold internal coordinates for a system. class Zmatrix { typedef std::vector ICarray; - typedef std::vector Iarray; public: /// CONSTRUCTOR Zmatrix(); @@ -48,6 +47,7 @@ class Zmatrix { /// \return Internal coord of specified index InternalCoords const& operator[](int i) const { return IC_[i]; } private: + typedef std::vector Iarray; /// Automatically set seeds int autoSetSeeds(Frame const&, Topology const&, unsigned int, int); /// Calculate and add an internal coordinate given indices and Cartesian coords. From 31adf3fb42a9cdbebbcade8f59f13355152fd6b6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 10:50:53 -0400 Subject: [PATCH 071/245] More progress on the new trace routine --- src/Structure/Zmatrix.cpp | 140 +++++++++++++++++++++++++++----------- src/Structure/Zmatrix.h | 3 + 2 files changed, 102 insertions(+), 41 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 93166bd297..1ca76da398 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -1,6 +1,7 @@ #include #include #include // std::sort +#include #include // cos #include "Zmatrix.h" #include "../Frame.h" @@ -311,6 +312,96 @@ static inline void printIarray(std::vector const& arr, const char* desc, To mprintf("\n"); } +/// Hold 4 atoms +class PHI { + public: + PHI(int ai, int aj, int ak, int al) : ai_(ai), aj_(aj), ak_(ak), al_(al) {} + int ai_, aj_, ak_, al_; +}; + +/** Trace molecule starting from L - K - J - ??. */ +int Zmatrix::traceMol(int atL0, int atK0, int atJ0, + Frame const& frameIn, Topology const& topIn, unsigned int maxnatom, + unsigned int& nHasIC, Barray& hasIC) +{ + // Will hold branches that need to be investigated + std::stack Branches; + + int atL = atL0; + int atK = atK0; + int atJ = atJ0; + + int debug_it = 0; // DEBUG + + while (nHasIC < maxnatom) { + mprintf("\nDEBUG: nHasIC= %8u / %8u : %s - %s - %s -\n", nHasIC, maxnatom, + topIn.AtomMaskName(atL).c_str(), + topIn.AtomMaskName(atK).c_str(), + topIn.AtomMaskName(atJ).c_str()); + // List all atoms bonded to J with the following priority: + // 1) Atoms with 1 bond. + // 2) Low index atoms. + Iarray OneBondAtoms; // TODO allocate outside loop? + Iarray OtherAtoms; + for (Atom::bond_iterator bat = topIn[atJ].bondbegin(); bat != topIn[atJ].bondend(); ++bat) + { + if (!hasIC[*bat]) { + if (topIn[*bat].Nbonds() == 1) + OneBondAtoms.push_back( *bat ); + else + OtherAtoms.push_back( *bat ); + } + } + if (OtherAtoms.size() > 1) + std::sort( OtherAtoms.begin(), OtherAtoms.end() ); + printIarray( OneBondAtoms, "OneBondAtoms", topIn ); + printIarray( OtherAtoms, "OtherAtoms", topIn ); + // Create ICs for 1 bond atoms + for (Iarray::const_iterator atI = OneBondAtoms.begin(); atI != OneBondAtoms.end(); ++atI) { + addIc(*atI, atJ, atK, atL, frameIn.XYZ(*atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); + MARK(*atI, hasIC, nHasIC); + } + // If nothing else, check the stack + if (OtherAtoms.empty()) { + // If no branches, done for now. + if (Branches.empty()) { + mprintf("DEBUG: No more branches. Exiting traceMol.\n"); + break; + } + // Add IC for the branch + PHI const& p = Branches.top(); + mprintf("DEBUG:\t\tPopped off stack: %s - %s - %s - %s\n", + topIn.AtomMaskName(p.al_).c_str(), + topIn.AtomMaskName(p.ak_).c_str(), + topIn.AtomMaskName(p.aj_).c_str(), + topIn.AtomMaskName(p.ai_).c_str()); + addIc(p.ai_, p.aj_, p.ak_, p.al_, frameIn.XYZ(p.ai_), frameIn.XYZ(p.aj_), frameIn.XYZ(p.ak_), frameIn.XYZ(p.al_)); + Branches.pop(); + MARK(p.ai_, hasIC, nHasIC); + atL = p.ak_; + atK = p.aj_; + atJ = p.ai_; + } else { + int atI = OtherAtoms.front(); + mprintf("DEBUG:\t\tNext: %s - %s - %s - %s\n", + topIn.AtomMaskName(atL).c_str(), + topIn.AtomMaskName(atK).c_str(), + topIn.AtomMaskName(atJ).c_str(), + topIn.AtomMaskName(atI).c_str()); + addIc(atI, atJ, atK, atL, frameIn.XYZ(atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); + // Designate lowest index as next. Place remainders on the stack. + atL = atK; + atK = atJ; + atJ = atI; + for (unsigned int ii = 1; ii < OtherAtoms.size(); ii++) + Branches.push( PHI(OtherAtoms[ii], atJ, atK, atL) ); + + if (debug_it == 1) break; // DEBUG + debug_it++; // DEBUG + } + return 0; +} + /** Set up Zmatrix from Cartesian coordinates and topology. * This algorithm attempts to "trace" the molecule in a manner that * should make internal coordinate assignment more "natural". @@ -330,7 +421,7 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int unsigned int maxnatom = currentMol.NumAtoms(); // Keep track of which atoms are associated with an internal coordinate - std::vector hasIC( topIn.Natom(), false ); + Barray hasIC( topIn.Natom(), false ); unsigned int nHasIC = 0; // See if we need to assign seed atoms @@ -356,43 +447,10 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int MARK(seedAt2_, hasIC, nHasIC); // Do the remaining atoms. - // By convention search like: - // L - K - J - - int atL = seedAt0_; - int atK = seedAt1_; - int atJ = seedAt2_; - - while (nHasIC < maxnatom) { - mprintf("\nDEBUG: nHasIC= %8u / %8u : %s - %s - %s -\n", nHasIC, maxnatom, - topIn.AtomMaskName(atL).c_str(), - topIn.AtomMaskName(atK).c_str(), - topIn.AtomMaskName(atJ).c_str()); - // List all atoms bonded to J with the following priority: - // 1) Atoms with 1 bond. - // 2) Low index atoms. - Iarray OneBondAtoms; // TODO allocate outside loop? - Iarray OtherAtoms; - for (Atom::bond_iterator bat = topIn[atJ].bondbegin(); bat != topIn[atJ].bondend(); ++bat) - { - if (!hasIC[*bat]) { - if (topIn[*bat].Nbonds() == 1) - OneBondAtoms.push_back( *bat ); - else - OtherAtoms.push_back( *bat ); - } - } - if (OtherAtoms.size() > 1) - std::sort( OtherAtoms.begin(), OtherAtoms.end() ); - printIarray( OneBondAtoms, "OneBondAtoms", topIn ); - printIarray( OtherAtoms, "OtherAtoms", topIn ); - // Create ICs for 1 bond atoms - for (Iarray::const_iterator atI = OneBondAtoms.begin(); atI != OneBondAtoms.end(); ++atI) { - addIc(*atI, atJ, atK, atL, frameIn.XYZ(*atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); - MARK(*atI, hasIC, nHasIC); - } - - break; // DEBUG - } + // L - K - J - ? + if (traceMol(seedAt0_, seedAt1_, seedAt2_, frameIn, topIn, maxnatom, nHasIC, hasIC)) return 1; + // J - K - L - ? + if (traceMol(seedAt2_, seedAt1_, seedAt0_, frameIn, topIn, maxnatom, nHasIC, hasIC)) return 1; return 0; } @@ -427,7 +485,7 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu unsigned int maxnatom = atomIndices.size(); // Keep track of which atoms are associated with an internal coordinate - std::vector hasIC( topIn.Natom(), false ); + Barray hasIC( topIn.Natom(), false ); unsigned int nHasIC = 0; // See if we need to assign seed atoms @@ -524,7 +582,7 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu */ int Zmatrix::SetToFrame(Frame& frameOut) const { // Track which atoms have Cartesian coords set - std::vector hasPosition( frameOut.Natom(), false ); + Barray hasPosition( frameOut.Natom(), false ); // If any seed positions are defined, set them now if (seedAt0_ != InternalCoords::NO_ATOM) { frameOut.SetXYZ( seedAt0_, seed0Pos_ ); @@ -539,7 +597,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { hasPosition[ seedAt2_ ] = true; } // Track which ICs are used - std::vector isUsed( IC_.size(), false ); + Barray isUsed( IC_.size(), false ); unsigned int Nused = 0; // Set positions of atoms from internal coordinate seeds. TODO check for clashes with seedAtX? if (icseed0_ != InternalCoords::NO_ATOM) { diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 3048aa5ce2..fe38535bec 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -48,10 +48,13 @@ class Zmatrix { InternalCoords const& operator[](int i) const { return IC_[i]; } private: typedef std::vector Iarray; + typedef std::vector Barray; /// Automatically set seeds int autoSetSeeds(Frame const&, Topology const&, unsigned int, int); /// Calculate and add an internal coordinate given indices and Cartesian coords. void addIc(int,int,int,int,const double*,const double*,const double*,const double*); + /// Add internal coordiantes by tracing a molecule + int traceMol(int, int, int, Frame const&, Topology const&, unsigned int, unsigned int&, Barray&); /// \return True if IC seeds are set //bool HasICSeeds() const; /// \return True if Cartesian seeds are set From 792cd38ab98b36a079d54e09616872e92fb80192 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 13:01:20 -0400 Subject: [PATCH 072/245] Finish the trace algorithm --- src/Structure/Zmatrix.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 1ca76da398..427b80dc47 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -378,6 +378,7 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, addIc(p.ai_, p.aj_, p.ak_, p.al_, frameIn.XYZ(p.ai_), frameIn.XYZ(p.aj_), frameIn.XYZ(p.ak_), frameIn.XYZ(p.al_)); Branches.pop(); MARK(p.ai_, hasIC, nHasIC); + // Designate branch as next. atL = p.ak_; atK = p.aj_; atJ = p.ai_; @@ -388,15 +389,25 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, topIn.AtomMaskName(atK).c_str(), topIn.AtomMaskName(atJ).c_str(), topIn.AtomMaskName(atI).c_str()); + // Add lowest index as IC addIc(atI, atJ, atK, atL, frameIn.XYZ(atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); - // Designate lowest index as next. Place remainders on the stack. + MARK(atI, hasIC, nHasIC); + // Place all above lowest index on the stack. + for (unsigned int ii = 1; ii < OtherAtoms.size(); ii++) { + Branches.push( PHI(OtherAtoms[ii], atJ, atK, atL) ); + PHI const& p = Branches.top(); + mprintf("DEBUG:\t\tPlaced on stack: %s - %s - %s - %s (%zu)\n", + topIn.AtomMaskName(p.al_).c_str(), + topIn.AtomMaskName(p.ak_).c_str(), + topIn.AtomMaskName(p.aj_).c_str(), + topIn.AtomMaskName(p.ai_).c_str(), Branches.size()); + } + // Designate lowest index as next atL = atK; atK = atJ; atJ = atI; - for (unsigned int ii = 1; ii < OtherAtoms.size(); ii++) - Branches.push( PHI(OtherAtoms[ii], atJ, atK, atL) ); - - if (debug_it == 1) break; // DEBUG + } + //if (debug_it == 1) break; // DEBUG debug_it++; // DEBUG } return 0; @@ -452,6 +463,10 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int // J - K - L - ? if (traceMol(seedAt2_, seedAt1_, seedAt0_, frameIn, topIn, maxnatom, nHasIC, hasIC)) return 1; + if (nHasIC < maxnatom) { + mprintf("Warning: Not all atoms have an associated internal coordinate.\n"); + } + return 0; } From 0d167f062611510cd6c9e2a98cb645f6bfc1ea7c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 13:26:44 -0400 Subject: [PATCH 073/245] Enable sugar test --- test/Test_Zmatrix/RunTest.sh | 4 ++- test/Test_Zmatrix/zmatrix.0SB.dat.save | 35 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 test/Test_Zmatrix/zmatrix.0SB.dat.save diff --git a/test/Test_Zmatrix/RunTest.sh b/test/Test_Zmatrix/RunTest.sh index 1bea8116a6..56dde4e8b4 100755 --- a/test/Test_Zmatrix/RunTest.sh +++ b/test/Test_Zmatrix/RunTest.sh @@ -2,7 +2,7 @@ . ../MasterTest.sh -CleanFiles cpptraj.in zmatrix.dat +CleanFiles cpptraj.in zmatrix.dat zmatrix.0SB.dat INPUT='-i cpptraj.in' @@ -25,8 +25,10 @@ loadcrd 0SB.mol2 name 0SB zmatrix 0SB out zmatrix.0SB.dat EOF RunCpptraj "$TESTNAME, Sugar" + DoTest zmatrix.0SB.dat.save zmatrix.0SB.dat } Basic +Sugar EndTest diff --git a/test/Test_Zmatrix/zmatrix.0SB.dat.save b/test/Test_Zmatrix/zmatrix.0SB.dat.save new file mode 100644 index 0000000000..e84e9c41dc --- /dev/null +++ b/test/Test_Zmatrix/zmatrix.0SB.dat.save @@ -0,0 +1,35 @@ +#IC ZMATRIX_00002 + 1 36.000 35.000 1.000 32.000 1.259 115.055 -118.024 + 2 37.000 35.000 1.000 32.000 1.254 119.483 60.190 + 3 33.000 32.000 1.000 35.000 1.093 109.955 64.239 + 4 34.000 32.000 1.000 35.000 1.093 110.143 -51.599 + 5 28.000 32.000 1.000 35.000 1.538 112.519 -173.146 + 6 29.000 28.000 32.000 1.000 1.092 108.527 -65.433 + 7 18.000 28.000 32.000 1.000 1.555 110.763 54.054 + 8 19.000 18.000 28.000 32.000 1.092 108.104 66.487 + 9 3.000 18.000 28.000 32.000 1.541 110.258 -52.775 + 10 4.000 3.000 18.000 28.000 1.092 107.097 -63.946 + 11 2.000 3.000 18.000 28.000 1.443 109.366 52.047 + 12 5.000 3.000 18.000 28.000 1.547 117.007 177.412 + 13 6.000 5.000 3.000 18.000 1.091 107.454 69.587 + 14 7.000 5.000 3.000 18.000 1.449 109.776 -46.778 + 15 8.000 7.000 5.000 3.000 0.974 109.637 69.177 + 16 9.000 5.000 3.000 18.000 1.556 114.437 -170.688 + 17 10.000 9.000 5.000 3.000 1.091 109.581 68.196 + 18 11.000 9.000 5.000 3.000 1.460 109.032 -50.185 + 19 12.000 11.000 9.000 5.000 0.967 107.041 66.841 + 20 13.000 9.000 5.000 3.000 1.547 112.392 -170.254 + 21 14.000 13.000 9.000 5.000 1.090 110.244 -58.947 + 22 15.000 13.000 9.000 5.000 1.091 110.082 60.184 + 23 16.000 13.000 9.000 5.000 1.445 110.975 -179.231 + 24 17.000 16.000 13.000 9.000 0.965 106.902 -44.062 + 25 20.000 18.000 28.000 32.000 1.475 109.896 -173.786 + 26 21.000 20.000 18.000 28.000 1.005 117.087 42.643 + 27 22.000 20.000 18.000 28.000 1.332 123.257 -141.200 + 28 23.000 22.000 20.000 18.000 1.226 121.726 -3.821 + 29 24.000 22.000 20.000 18.000 1.541 116.620 176.070 + 30 25.000 24.000 22.000 20.000 1.092 111.126 23.276 + 31 26.000 24.000 22.000 20.000 1.091 109.294 -97.180 + 32 27.000 24.000 22.000 20.000 1.091 109.699 143.390 + 33 30.000 28.000 32.000 1.000 1.460 108.777 177.651 + 34 31.000 30.000 28.000 32.000 0.961 110.371 177.367 From 39660b7fafc4152f27a5aa50edffd8c86cdd50ce Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 13:26:58 -0400 Subject: [PATCH 074/245] Deal with impropers on second seed atom --- src/Structure/Zmatrix.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 427b80dc47..d6ea1f86f2 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -462,6 +462,25 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int if (traceMol(seedAt0_, seedAt1_, seedAt2_, frameIn, topIn, maxnatom, nHasIC, hasIC)) return 1; // J - K - L - ? if (traceMol(seedAt2_, seedAt1_, seedAt0_, frameIn, topIn, maxnatom, nHasIC, hasIC)) return 1; + if (topIn[seedAt1_].Nbonds() > 2) { + unsigned int nUnfollowedBranches = 0; + for (Atom::bond_iterator bat = topIn[seedAt1_].bondbegin(); bat != topIn[seedAt1_].bondend(); ++bat) + if (!hasIC[*bat]) ++nUnfollowedBranches; + if (nUnfollowedBranches > 0) { + mprintf("Warning: Second seed atom %s has more than 2 bonds.\n", topIn.AtomMaskName(seedAt1_).c_str()); + // Potential tetrahedral or more. + for (Atom::bond_iterator bat = topIn[seedAt1_].bondbegin(); bat != topIn[seedAt1_].bondend(); ++bat) { + // Improper based off of seed + // I + // | + // L - K - J + addIc(*bat, seedAt2_, seedAt1_, seedAt0_, frameIn.XYZ(*bat), frameIn.XYZ(seedAt2_), frameIn.XYZ(seedAt1_), frameIn.XYZ(seedAt0_)); + MARK(*bat, hasIC, nHasIC); + // Follow improper branch if needed + if (traceMol(seedAt0_, seedAt1_, *bat, frameIn, topIn, maxnatom, nHasIC, hasIC)) return 1; + } + } + } if (nHasIC < maxnatom) { mprintf("Warning: Not all atoms have an associated internal coordinate.\n"); @@ -470,8 +489,6 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int return 0; } - - /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) { return SetFromFrame(frameIn, topIn, 0); From ce5a6b9153746b695efaa69d2465241d3b286fdc Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 13:36:31 -0400 Subject: [PATCH 075/245] Split off functionality --- src/Exec_Zmatrix.cpp | 50 +++++++++++++++++++++++---------------- src/Exec_Zmatrix.h | 2 ++ src/Structure/Zmatrix.cpp | 2 +- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/Exec_Zmatrix.cpp b/src/Exec_Zmatrix.cpp index 1fbc00cecd..a443063bb7 100644 --- a/src/Exec_Zmatrix.cpp +++ b/src/Exec_Zmatrix.cpp @@ -11,34 +11,20 @@ void Exec_Zmatrix::Help() const } -// Exec_Zmatrix::Execute() -Exec::RetType Exec_Zmatrix::Execute(CpptrajState& State, ArgList& argIn) +int Exec_Zmatrix::getZmatrix(DataSet_Coords* CRD, int molnum, int frmidx, + std::string const& dsname, DataFile* outfile, CpptrajState& State) +const { - int molnum = argIn.getKeyInt("molnum", 1) - 1; - int frmidx = argIn.getKeyInt("frame", 1) - 1; - std::string dsname = argIn.GetStringKey("name"); - DataFile* outfile = State.DFL().AddDataFile( argIn.GetStringKey("out"), argIn ); - - std::string setname = argIn.GetStringNext(); - if (setname.empty()) { - mprinterr("Error: %s: Specify COORDS dataset name.\n", argIn.Command()); - return CpptrajState::ERR; - } - DataSet_Coords* CRD = (DataSet_Coords*)State.DSL().FindSetOfGroup( setname, DataSet::COORDINATES ); - if (CRD == 0) { - mprinterr("Error: %s: No COORDS set with name %s found.\n", argIn.Command(), setname.c_str()); - return CpptrajState::ERR; - } mprintf("\tUsing set '%s'\n", CRD->legend()); if (CRD->Size() < 1) { - mprinterr("Error: Set '%s' is empty.\n"); - return CpptrajState::ERR; + mprinterr("Error: Set '%s' is empty.\n", CRD->legend()); + return 1; } DataSet_Zmatrix* zset = (DataSet_Zmatrix*)State.DSL().AddSet( DataSet::ZMATRIX, dsname, "ZMATRIX" ); if (zset == 0) { mprinterr("Error: Could not allocate zmatrix set.\n"); - return CpptrajState::ERR; + return 1; } zset->SetDim(Dimension::X, Dimension(1, 1, "IC")); if (outfile != 0) @@ -58,6 +44,30 @@ Exec::RetType Exec_Zmatrix::Execute(CpptrajState& State, ArgList& argIn) zmatrix.SetDebug( State.Debug() ); int errStat = zmatrix.SetFromFrame_Trace( frmIn, CRD->Top(), molnum ); zmatrix.print(); // DEBUG + return errStat; +} + +// Exec_Zmatrix::Execute() +Exec::RetType Exec_Zmatrix::Execute(CpptrajState& State, ArgList& argIn) +{ + int molnum = argIn.getKeyInt("molnum", 1) - 1; + int frmidx = argIn.getKeyInt("frame", 1) - 1; + std::string dsname = argIn.GetStringKey("name"); + DataFile* outfile = State.DFL().AddDataFile( argIn.GetStringKey("out"), argIn ); + + std::string setname = argIn.GetStringNext(); + if (setname.empty()) { + mprinterr("Error: %s: Specify COORDS dataset name.\n", argIn.Command()); + return CpptrajState::ERR; + } + DataSet_Coords* CRD = (DataSet_Coords*)State.DSL().FindSetOfGroup( setname, DataSet::COORDINATES ); + if (CRD == 0) { + mprinterr("Error: %s: No COORDS set with name %s found.\n", argIn.Command(), setname.c_str()); + return CpptrajState::ERR; + } + + int errStat = getZmatrix(CRD, molnum, frmidx, dsname, outfile, State); + if (errStat != 0) return CpptrajState::ERR; return CpptrajState::OK; } diff --git a/src/Exec_Zmatrix.h b/src/Exec_Zmatrix.h index e0c9b5eacb..bf3c53985e 100644 --- a/src/Exec_Zmatrix.h +++ b/src/Exec_Zmatrix.h @@ -8,5 +8,7 @@ class Exec_Zmatrix : public Exec { void Help() const; DispatchObject* Alloc() const { return (DispatchObject*)new Exec_Zmatrix(); } RetType Execute(CpptrajState&, ArgList&); + private: + int getZmatrix(DataSet_Coords*, int, int, std::string const&, DataFile*, CpptrajState&) const; }; #endif diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index d6ea1f86f2..1ead41db37 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -476,7 +476,7 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int // L - K - J addIc(*bat, seedAt2_, seedAt1_, seedAt0_, frameIn.XYZ(*bat), frameIn.XYZ(seedAt2_), frameIn.XYZ(seedAt1_), frameIn.XYZ(seedAt0_)); MARK(*bat, hasIC, nHasIC); - // Follow improper branch if needed + // Follow improper branch if needed: L - K - I - ? if (traceMol(seedAt0_, seedAt1_, *bat, frameIn, topIn, maxnatom, nHasIC, hasIC)) return 1; } } From 6c4fa0d743c5658b0cb7e0cd950c3e073dfd66aa Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 13:55:39 -0400 Subject: [PATCH 076/245] Update set name --- test/Test_Zmatrix/zmatrix.0SB.dat.save | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Test_Zmatrix/zmatrix.0SB.dat.save b/test/Test_Zmatrix/zmatrix.0SB.dat.save index e84e9c41dc..e58dca4e9a 100644 --- a/test/Test_Zmatrix/zmatrix.0SB.dat.save +++ b/test/Test_Zmatrix/zmatrix.0SB.dat.save @@ -1,4 +1,4 @@ -#IC ZMATRIX_00002 +#IC MyZ 1 36.000 35.000 1.000 32.000 1.259 115.055 -118.024 2 37.000 35.000 1.000 32.000 1.254 119.483 60.190 3 33.000 32.000 1.000 35.000 1.093 109.955 64.239 From d3aee7bcb855acc721d86f3184ee9da64fc9f1ee Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 13:57:00 -0400 Subject: [PATCH 077/245] Test going from extracted internal coords to cartesian --- src/Exec_Zmatrix.cpp | 47 ++++++++++++++++++++++++++++++++++-- src/Exec_Zmatrix.h | 1 + test/Test_Zmatrix/RunTest.sh | 7 ++++-- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/Exec_Zmatrix.cpp b/src/Exec_Zmatrix.cpp index a443063bb7..a474acd6c0 100644 --- a/src/Exec_Zmatrix.cpp +++ b/src/Exec_Zmatrix.cpp @@ -11,6 +11,7 @@ void Exec_Zmatrix::Help() const } +/** Get Zmatrix for specified molecule at specified frame number. */ int Exec_Zmatrix::getZmatrix(DataSet_Coords* CRD, int molnum, int frmidx, std::string const& dsname, DataFile* outfile, CpptrajState& State) const @@ -47,13 +48,50 @@ const return errStat; } +/** Create COORDS using Zmatrix. */ +int Exec_Zmatrix::putZmatrix(DataSet_Coords* CRD, std::string const& zsetname, + std::string const& dsname, CpptrajState& State) +const +{ + // Get zmatrix set + DataSet_Zmatrix* zmatrix = (DataSet_Zmatrix*)State.DSL().FindSetOfType( zsetname, DataSet::ZMATRIX ); + if (zmatrix == 0) { + mprinterr("Error: No zmatrix set with name '%s' found.\n", zsetname.c_str()); + return 1; + } + mprintf("\tZmatrix set : %s\n", zmatrix->legend()); + + // Create COORDS set + DataSet_Coords* out = (DataSet_Coords*)State.DSL().AddSet(DataSet::COORDS, dsname, "ZMCRD"); + if (out == 0) { + mprinterr("Error: Could not create COORDS set for assigning from Zmatrix.\n"); + return 1; + } + out->CoordsSetup( CRD->Top(), CRD->CoordsInfo()); + mprintf("\tOutput coords set : %s\n", out->legend()); + + // Assign + Frame frm = out->AllocateFrame(); + frm.ZeroCoords(); + if (zmatrix->Zptr()->SetToFrame( frm )) { + mprinterr("Error: Zmatrix to Cartesian coords failed.\n"); + return 1; + } + out->SetCRD(0, frm); + + return 0; +} + // Exec_Zmatrix::Execute() Exec::RetType Exec_Zmatrix::Execute(CpptrajState& State, ArgList& argIn) { int molnum = argIn.getKeyInt("molnum", 1) - 1; int frmidx = argIn.getKeyInt("frame", 1) - 1; std::string dsname = argIn.GetStringKey("name"); - DataFile* outfile = State.DFL().AddDataFile( argIn.GetStringKey("out"), argIn ); + + DataFile* outfile = State.DFL().AddDataFile( argIn.GetStringKey("out"), argIn ); // TODO not if zset + + std::string zsetname = argIn.GetStringKey("zset"); std::string setname = argIn.GetStringNext(); if (setname.empty()) { @@ -66,7 +104,12 @@ Exec::RetType Exec_Zmatrix::Execute(CpptrajState& State, ArgList& argIn) return CpptrajState::ERR; } - int errStat = getZmatrix(CRD, molnum, frmidx, dsname, outfile, State); + int errStat = 0; + if (!zsetname.empty()) { + errStat = putZmatrix(CRD, zsetname, dsname, State); + } else { + errStat = getZmatrix(CRD, molnum, frmidx, dsname, outfile, State); + } if (errStat != 0) return CpptrajState::ERR; return CpptrajState::OK; diff --git a/src/Exec_Zmatrix.h b/src/Exec_Zmatrix.h index bf3c53985e..3b4b32bbc4 100644 --- a/src/Exec_Zmatrix.h +++ b/src/Exec_Zmatrix.h @@ -10,5 +10,6 @@ class Exec_Zmatrix : public Exec { RetType Execute(CpptrajState&, ArgList&); private: int getZmatrix(DataSet_Coords*, int, int, std::string const&, DataFile*, CpptrajState&) const; + int putZmatrix(DataSet_Coords*, std::string const&, std::string const&, CpptrajState&) const; }; #endif diff --git a/test/Test_Zmatrix/RunTest.sh b/test/Test_Zmatrix/RunTest.sh index 56dde4e8b4..b430e19158 100755 --- a/test/Test_Zmatrix/RunTest.sh +++ b/test/Test_Zmatrix/RunTest.sh @@ -2,7 +2,7 @@ . ../MasterTest.sh -CleanFiles cpptraj.in zmatrix.dat zmatrix.0SB.dat +CleanFiles cpptraj.in zmatrix.dat zmatrix.0SB.dat fromZmatrix.0SB.mol2 INPUT='-i cpptraj.in' @@ -22,10 +22,13 @@ Sugar() { cat > cpptraj.in < Date: Fri, 29 Sep 2023 15:56:46 -0400 Subject: [PATCH 078/245] Add MEX test molecule --- test/Test_Zmatrix/MEX.mol2 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/Test_Zmatrix/MEX.mol2 diff --git a/test/Test_Zmatrix/MEX.mol2 b/test/Test_Zmatrix/MEX.mol2 new file mode 100644 index 0000000000..0af6b6b340 --- /dev/null +++ b/test/Test_Zmatrix/MEX.mol2 @@ -0,0 +1,18 @@ +@MOLECULE +Cpptraj Generated mol2 file. + 4 3 1 0 0 +SMALL +USER_CHARGES + + +@ATOM + 1 CH3 7.4849 -0.7179 -1.6206 Cg 1 MEX 0.000000 + 2 H1 6.7230 -0.0077 -1.9247 H1 1 MEX 0.233000 + 3 H2 7.0157 -1.6856 -1.4777 H1 1 MEX 0.000000 + 4 H3 8.2022 -0.8197 -2.4283 H1 1 MEX 0.000000 +@BOND + 1 1 2 1 + 2 1 3 1 + 3 1 4 1 +@SUBSTRUCTURE + 1 MEX 1 **** 0 **** **** From 85eb00ca5db2a285104daf9c3cda046713dde3b5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 29 Sep 2023 16:05:49 -0400 Subject: [PATCH 079/245] Try to test new way to do seeds --- src/Structure/Zmatrix.cpp | 91 +++++++++++++++++++++++++++++++++++- src/Structure/Zmatrix.h | 3 ++ test/Test_Zmatrix/RunTest.sh | 16 ++++++- 3 files changed, 108 insertions(+), 2 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 1ead41db37..e2b7dff53c 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -235,6 +235,94 @@ void Zmatrix::addIc(int at0, int at1, int at2, int at3, Torsion(xyz0, xyz1, xyz2, xyz3) * Constants::RADDEG) ); } +/** Simple automatic setting of seeds for a molecule. + * seed0 - seed1 - seed 2 + * Prefer that seed1 has only exactly 2 bonds. It cannot have 1. + */ +int Zmatrix::autoSetSeeds_simple(Frame const& frameIn, Topology const& topIn, Molecule const& mol) +{ + seedAt0_ = InternalCoords::NO_ATOM; + seedAt1_ = InternalCoords::NO_ATOM; + seedAt2_ = InternalCoords::NO_ATOM; + + // Handle special cases + if (mol.NumAtoms() < 1) { + mprinterr("Internal Error: Zmatrix::autoSetSeeds_simple() called with an empty molecule.\n"); + return 1; + } + if (mol.NumAtoms() == 1) { + seedAt0_ = mol.MolUnit().Front(); + seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); + return 0; + } else if (mol.NumAtoms() == 2) { + seedAt0_ = mol.MolUnit().Front(); + seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); + if (topIn[seedAt0_].Nbonds() != 1) { + mprinterr("Internal Error: Zmatrix::autoSetSeeds_simple(): 2 atoms but no bonds.\n"); + return 1; + } + seedAt1_ = topIn[seedAt0_].Bond(0); + seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); + return 0; + } + + int potentialSeed1 = -1; + int potentialSeedNbonds = -1; + for (Unit::const_iterator seg = mol.MolUnit().segBegin(); + seg != mol.MolUnit().segEnd(); ++seg) + { + for (int idx = seg->Begin(); idx != seg->End(); ++idx) { + if (topIn[idx].Nbonds() > 1) { + // New seed1 if this seed1 has fewer bonds + if (potentialSeed1 == -1 || topIn[idx].Nbonds() < potentialSeedNbonds) { + potentialSeed1 = idx; + potentialSeedNbonds = topIn[idx].Nbonds(); + if (potentialSeedNbonds == 2) { + seedAt1_ = idx; + break; + } + } + } + } // END loop over segment atoms + // Exit if a good seed was found + if (seedAt1_ != InternalCoords::NO_ATOM) break; + } + if (seedAt1_ == InternalCoords::NO_ATOM) { + mprintf("DEBUG: No seed1 with just 2 bonds found. Using seed1 with %i bonds.\n", potentialSeedNbonds); + seedAt1_ = potentialSeed1; + } + if (seedAt1_ == InternalCoords::NO_ATOM) { + mprinterr("Error: No seed1 could be found.\n"); + return 1; + } + + // seed0 will be lowest index, seed 1 will be highest + int lowestidx = -1; + int highestidx = -1; + for (Atom::bond_iterator bat = topIn[seedAt1_].bondbegin(); bat != topIn[seedAt1_].bondend(); ++bat) + { + if (lowestidx == -1) { + lowestidx = *bat; + highestidx = *bat; + } else { + lowestidx = std::min(lowestidx, *bat); + highestidx = std::max(highestidx, *bat); + } + } + seedAt0_ = lowestidx; + seedAt2_ = highestidx; + + mprintf("DEBUG: Potential seed 0: %i %s\n", seedAt0_+1, topIn.AtomMaskName(seedAt0_).c_str()); + mprintf("DEBUG: Potential seed 1: %i %s\n", seedAt1_+1, topIn.AtomMaskName(seedAt1_).c_str()); + mprintf("DEBUG: Potential seed 2: %i %s\n", seedAt2_+1, topIn.AtomMaskName(seedAt2_).c_str()); + + seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); + seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); + seed2Pos_ = Vec3(frameIn.XYZ(seedAt2_)); + + return 0; +} + /** Given a first seed, automatically determine remaining 2 seeds. * Set all seed indices and positions. */ @@ -438,7 +526,8 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int // See if we need to assign seed atoms if (!HasCartSeeds()) { // First seed atom will just be first atom TODO lowest index heavy atom? - if (autoSetSeeds(frameIn, topIn, maxnatom, currentMol.MolUnit().Front())) { + if (autoSetSeeds_simple(frameIn, topIn, currentMol)) { + //if (autoSetSeeds(frameIn, topIn, maxnatom, currentMol.MolUnit().Front())) { mprinterr("Error: Could not automatically determine seed atoms.\n"); return 1; } diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index fe38535bec..4f78d78f00 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -4,6 +4,7 @@ #include "../Vec3.h" class Frame; class Topology; +class Molecule; namespace Cpptraj { namespace Structure { /// Hold internal coordinates for a system. @@ -49,6 +50,8 @@ class Zmatrix { private: typedef std::vector Iarray; typedef std::vector Barray; + /// Simple version of auto set seeds based on connectivity only + int autoSetSeeds_simple(Frame const&, Topology const&, Molecule const&); /// Automatically set seeds int autoSetSeeds(Frame const&, Topology const&, unsigned int, int); /// Calculate and add an internal coordinate given indices and Cartesian coords. diff --git a/test/Test_Zmatrix/RunTest.sh b/test/Test_Zmatrix/RunTest.sh index b430e19158..4c88a0ff5b 100755 --- a/test/Test_Zmatrix/RunTest.sh +++ b/test/Test_Zmatrix/RunTest.sh @@ -2,7 +2,8 @@ . ../MasterTest.sh -CleanFiles cpptraj.in zmatrix.dat zmatrix.0SB.dat fromZmatrix.0SB.mol2 +CleanFiles cpptraj.in zmatrix.dat zmatrix.0SB.dat fromZmatrix.0SB.mol2 \ + zmatrix.MEX.dat fromZmatrix.MEX.mol2 INPUT='-i cpptraj.in' @@ -31,7 +32,20 @@ EOF DoTest 0SB.mol2 fromZmatrix.0SB.mol2 } +MEX() { + cat > cpptraj.in < Date: Sat, 30 Sep 2023 06:42:00 -0400 Subject: [PATCH 080/245] When following branches off of seed1 ignore seed0 and seed2 --- src/Structure/Zmatrix.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index e2b7dff53c..9f45f3d0ac 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -559,14 +559,17 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int mprintf("Warning: Second seed atom %s has more than 2 bonds.\n", topIn.AtomMaskName(seedAt1_).c_str()); // Potential tetrahedral or more. for (Atom::bond_iterator bat = topIn[seedAt1_].bondbegin(); bat != topIn[seedAt1_].bondend(); ++bat) { - // Improper based off of seed - // I - // | - // L - K - J - addIc(*bat, seedAt2_, seedAt1_, seedAt0_, frameIn.XYZ(*bat), frameIn.XYZ(seedAt2_), frameIn.XYZ(seedAt1_), frameIn.XYZ(seedAt0_)); - MARK(*bat, hasIC, nHasIC); - // Follow improper branch if needed: L - K - I - ? - if (traceMol(seedAt0_, seedAt1_, *bat, frameIn, topIn, maxnatom, nHasIC, hasIC)) return 1; + // Ignore seed atoms + if (*bat != seedAt0_ && *bat != seedAt2_) { + // Improper based off of seed + // I + // | + // L - K - J + addIc(*bat, seedAt2_, seedAt1_, seedAt0_, frameIn.XYZ(*bat), frameIn.XYZ(seedAt2_), frameIn.XYZ(seedAt1_), frameIn.XYZ(seedAt0_)); + MARK(*bat, hasIC, nHasIC); + // Follow improper branch if needed: L - K - I - ? + if (traceMol(seedAt0_, seedAt1_, *bat, frameIn, topIn, maxnatom, nHasIC, hasIC)) return 1; + } } } } From 96c1b2a0c78cac80469b6343ae2124f5881aef3c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sat, 30 Sep 2023 08:55:44 -0400 Subject: [PATCH 081/245] Do not use internal coord seeds if cartesian seeds have been set/used. --- src/Structure/Zmatrix.cpp | 75 ++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 9f45f3d0ac..a5dec48b68 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -723,45 +723,46 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { // Track which ICs are used Barray isUsed( IC_.size(), false ); unsigned int Nused = 0; - // Set positions of atoms from internal coordinate seeds. TODO check for clashes with seedAtX? - if (icseed0_ != InternalCoords::NO_ATOM) { - // First seed IC atom - frameOut.SetXYZ(IC_[icseed0_].AtI(), Vec3(0.0)); - hasPosition[IC_[icseed0_].AtI()] = true; - MARK(icseed0_, isUsed, Nused); - // Set position of the second atom. - if (icseed1_ != InternalCoords::NO_ATOM) { - if (IC_[icseed1_].AtJ() != IC_[icseed0_].AtI()) { - mprinterr("Internal Error: Atom j of seed 1 is not Atom i of seed 0.\n"); - return 1; - } - double r1 = IC_[icseed1_].Dist(); - frameOut.SetXYZ(IC_[icseed1_].AtI(), Vec3(r1, 0, 0)); - hasPosition[IC_[icseed1_].AtI()] = true; - MARK(icseed1_, isUsed, Nused); - // Set position of the third atom - if (icseed2_ != InternalCoords::NO_ATOM) { - if (IC_[icseed2_].AtJ() != IC_[icseed1_].AtI()) { - mprinterr("Internal Error: Atom j of seed 2 is not Atom i of seed 1.\n"); - return 1; - } - if (IC_[icseed2_].AtK() != IC_[icseed0_].AtI()) { - mprinterr("Internal Error: Atom k of seed 2 is not Atom i of seed 0.\n"); + if (!HasCartSeeds()) { + // Set positions of atoms from internal coordinate seeds. TODO check for clashes with seedAtX? + if (icseed0_ != InternalCoords::NO_ATOM) { + // First seed IC atom + frameOut.SetXYZ(IC_[icseed0_].AtI(), Vec3(0.0)); + hasPosition[IC_[icseed0_].AtI()] = true; + MARK(icseed0_, isUsed, Nused); + // Set position of the second atom. + if (icseed1_ != InternalCoords::NO_ATOM) { + if (IC_[icseed1_].AtJ() != IC_[icseed0_].AtI()) { + mprinterr("Internal Error: Atom j of seed 1 is not Atom i of seed 0.\n"); return 1; } - double r2 = IC_[icseed2_].Dist(); - double theta = IC_[icseed2_].Theta(); - - double x = r2 * cos(180.0 - theta) * Constants::DEGRAD; - double y = r2 * cos(180.0 - theta) * Constants::DEGRAD; - - frameOut.SetXYZ( IC_[icseed2_].AtI(), Vec3(r1 + x, y, 0) ); - hasPosition[IC_[icseed2_].AtI()] = true; - MARK(icseed2_, isUsed, Nused); - } // END seed atom 2 - } // END seed atom 1 - } // END seed atom 0 - + double r1 = IC_[icseed1_].Dist(); + frameOut.SetXYZ(IC_[icseed1_].AtI(), Vec3(r1, 0, 0)); + hasPosition[IC_[icseed1_].AtI()] = true; + MARK(icseed1_, isUsed, Nused); + // Set position of the third atom + if (icseed2_ != InternalCoords::NO_ATOM) { + if (IC_[icseed2_].AtJ() != IC_[icseed1_].AtI()) { + mprinterr("Internal Error: Atom j of seed 2 is not Atom i of seed 1.\n"); + return 1; + } + if (IC_[icseed2_].AtK() != IC_[icseed0_].AtI()) { + mprinterr("Internal Error: Atom k of seed 2 is not Atom i of seed 0.\n"); + return 1; + } + double r2 = IC_[icseed2_].Dist(); + double theta = IC_[icseed2_].Theta(); + + double x = r2 * cos(180.0 - theta) * Constants::DEGRAD; + double y = r2 * cos(180.0 - theta) * Constants::DEGRAD; + + frameOut.SetXYZ( IC_[icseed2_].AtI(), Vec3(r1 + x, y, 0) ); + hasPosition[IC_[icseed2_].AtI()] = true; + MARK(icseed2_, isUsed, Nused); + } // END seed atom 2 + } // END seed atom 1 + } // END seed atom 0 + } // END Does not have Cart. seeds // Find the lowest unused IC unsigned int lowestUnusedIC = 0; for (; lowestUnusedIC < IC_.size(); ++lowestUnusedIC) From 82d094ccb2e0da8284d37ffa592fbd1bf701dc2b Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sat, 30 Sep 2023 08:56:26 -0400 Subject: [PATCH 082/245] Update zmatrix output for new algorithm --- test/Test_Zmatrix/zmatrix.0SB.dat.save | 68 +++++++++++++------------- test/Test_Zmatrix/zmatrix.dat.save | 8 +-- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/test/Test_Zmatrix/zmatrix.0SB.dat.save b/test/Test_Zmatrix/zmatrix.0SB.dat.save index e58dca4e9a..8754bea67a 100644 --- a/test/Test_Zmatrix/zmatrix.0SB.dat.save +++ b/test/Test_Zmatrix/zmatrix.0SB.dat.save @@ -1,35 +1,35 @@ #IC MyZ - 1 36.000 35.000 1.000 32.000 1.259 115.055 -118.024 - 2 37.000 35.000 1.000 32.000 1.254 119.483 60.190 - 3 33.000 32.000 1.000 35.000 1.093 109.955 64.239 - 4 34.000 32.000 1.000 35.000 1.093 110.143 -51.599 - 5 28.000 32.000 1.000 35.000 1.538 112.519 -173.146 - 6 29.000 28.000 32.000 1.000 1.092 108.527 -65.433 - 7 18.000 28.000 32.000 1.000 1.555 110.763 54.054 - 8 19.000 18.000 28.000 32.000 1.092 108.104 66.487 - 9 3.000 18.000 28.000 32.000 1.541 110.258 -52.775 - 10 4.000 3.000 18.000 28.000 1.092 107.097 -63.946 - 11 2.000 3.000 18.000 28.000 1.443 109.366 52.047 - 12 5.000 3.000 18.000 28.000 1.547 117.007 177.412 - 13 6.000 5.000 3.000 18.000 1.091 107.454 69.587 - 14 7.000 5.000 3.000 18.000 1.449 109.776 -46.778 - 15 8.000 7.000 5.000 3.000 0.974 109.637 69.177 - 16 9.000 5.000 3.000 18.000 1.556 114.437 -170.688 - 17 10.000 9.000 5.000 3.000 1.091 109.581 68.196 - 18 11.000 9.000 5.000 3.000 1.460 109.032 -50.185 - 19 12.000 11.000 9.000 5.000 0.967 107.041 66.841 - 20 13.000 9.000 5.000 3.000 1.547 112.392 -170.254 - 21 14.000 13.000 9.000 5.000 1.090 110.244 -58.947 - 22 15.000 13.000 9.000 5.000 1.091 110.082 60.184 - 23 16.000 13.000 9.000 5.000 1.445 110.975 -179.231 - 24 17.000 16.000 13.000 9.000 0.965 106.902 -44.062 - 25 20.000 18.000 28.000 32.000 1.475 109.896 -173.786 - 26 21.000 20.000 18.000 28.000 1.005 117.087 42.643 - 27 22.000 20.000 18.000 28.000 1.332 123.257 -141.200 - 28 23.000 22.000 20.000 18.000 1.226 121.726 -3.821 - 29 24.000 22.000 20.000 18.000 1.541 116.620 176.070 - 30 25.000 24.000 22.000 20.000 1.092 111.126 23.276 - 31 26.000 24.000 22.000 20.000 1.091 109.294 -97.180 - 32 27.000 24.000 22.000 20.000 1.091 109.699 143.390 - 33 30.000 28.000 32.000 1.000 1.460 108.777 177.651 - 34 31.000 30.000 28.000 32.000 0.961 110.371 177.367 + 1 4.000 3.000 2.000 1.000 1.092 107.320 57.481 + 2 5.000 3.000 2.000 1.000 1.547 109.628 172.109 + 3 6.000 5.000 3.000 2.000 1.091 107.454 -165.180 + 4 7.000 5.000 3.000 2.000 1.449 109.776 78.456 + 5 8.000 7.000 5.000 3.000 0.974 109.637 69.177 + 6 9.000 5.000 3.000 2.000 1.556 114.437 -45.455 + 7 10.000 9.000 5.000 3.000 1.091 109.581 68.196 + 8 11.000 9.000 5.000 3.000 1.460 109.032 -50.185 + 9 12.000 11.000 9.000 5.000 0.967 107.041 66.841 + 10 13.000 9.000 5.000 3.000 1.547 112.392 -170.254 + 11 14.000 13.000 9.000 5.000 1.090 110.244 -58.947 + 12 15.000 13.000 9.000 5.000 1.091 110.082 60.184 + 13 16.000 13.000 9.000 5.000 1.445 110.975 -179.231 + 14 17.000 16.000 13.000 9.000 0.965 106.902 -44.062 + 15 18.000 3.000 2.000 1.000 1.541 109.366 -58.369 + 16 19.000 18.000 3.000 2.000 1.092 109.164 -66.569 + 17 20.000 18.000 3.000 2.000 1.475 109.673 173.191 + 18 21.000 20.000 18.000 3.000 1.005 117.087 -78.719 + 19 22.000 20.000 18.000 3.000 1.332 123.257 97.438 + 20 23.000 22.000 20.000 18.000 1.226 121.726 -3.821 + 21 24.000 22.000 20.000 18.000 1.541 116.620 176.070 + 22 25.000 24.000 22.000 20.000 1.092 111.126 23.276 + 23 26.000 24.000 22.000 20.000 1.091 109.294 -97.180 + 24 27.000 24.000 22.000 20.000 1.091 109.699 143.390 + 25 28.000 18.000 3.000 2.000 1.555 110.258 52.047 + 26 29.000 28.000 18.000 3.000 1.092 108.890 66.493 + 27 30.000 28.000 18.000 3.000 1.460 112.071 -174.457 + 28 31.000 30.000 28.000 18.000 0.961 110.371 -59.820 + 29 32.000 28.000 18.000 3.000 1.538 110.763 -52.775 + 30 33.000 32.000 28.000 18.000 1.093 109.712 176.806 + 31 34.000 32.000 28.000 18.000 1.093 108.775 -68.268 + 32 35.000 1.000 2.000 3.000 1.623 112.883 173.396 + 33 36.000 35.000 1.000 2.000 1.259 115.055 125.259 + 34 37.000 35.000 1.000 2.000 1.254 119.483 -56.528 diff --git a/test/Test_Zmatrix/zmatrix.dat.save b/test/Test_Zmatrix/zmatrix.dat.save index 4aea1bdca8..32fd230af2 100644 --- a/test/Test_Zmatrix/zmatrix.dat.save +++ b/test/Test_Zmatrix/zmatrix.dat.save @@ -1,5 +1,5 @@ #IC ZMATRIX_00002 - 1 3.000 2.000 1.000 6.000 1.088 109.303 113.518 - 2 4.000 2.000 1.000 6.000 1.088 109.698 -125.442 - 3 5.000 2.000 1.000 6.000 1.090 108.799 -5.800 - 4 7.000 6.000 1.000 2.000 1.727 179.995 -28.942 + 1 7.000 6.000 1.000 2.000 1.727 179.995 -28.942 + 2 3.000 2.000 1.000 6.000 1.088 109.303 113.518 + 3 4.000 2.000 1.000 6.000 1.088 109.698 -125.442 + 4 5.000 2.000 1.000 6.000 1.090 108.799 -5.800 From ecb600a6882bc55d8bdd5a13ec832d56c8183879 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sat, 30 Sep 2023 09:03:08 -0400 Subject: [PATCH 083/245] Comment out old algorithm --- src/Structure/Zmatrix.cpp | 16 +++++++++------- src/Structure/Zmatrix.h | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index a5dec48b68..5b37f8e877 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -1,6 +1,5 @@ #include -#include -#include // std::sort +#include // std::sort, std::min, std::max #include #include // cos #include "Zmatrix.h" @@ -71,7 +70,7 @@ void Zmatrix::print() const { /** Used to determine atom priority when looking for torsions to * base ICs off of. */ -class AtnumNbonds { +/*class AtnumNbonds { public: /// CONSTRUCTOR AtnumNbonds() : idx_(-1), priority_(-1), nbonds_(-1) {} @@ -165,7 +164,7 @@ static inline int FirstOrFrontIdx(std::set const& in, std::vector -1) return firstSetIdx; return firstIdx; -} +}*/ // ------------------------------------- /** \return True if all IC seeds are set. */ @@ -326,6 +325,7 @@ int Zmatrix::autoSetSeeds_simple(Frame const& frameIn, Topology const& topIn, Mo /** Given a first seed, automatically determine remaining 2 seeds. * Set all seed indices and positions. */ +/* int Zmatrix::autoSetSeeds(Frame const& frameIn, Topology const& topIn, unsigned int maxnatom, int firstSeed) { int at0 = firstSeed; @@ -390,7 +390,7 @@ int Zmatrix::autoSetSeeds(Frame const& frameIn, Topology const& topIn, unsigned seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); seed2Pos_ = Vec3(frameIn.XYZ(seedAt2_)); return 0; -} +}*/ static inline void printIarray(std::vector const& arr, const char* desc, Topology const& topIn) { mprintf("DEBUG:\t\t%s:", desc); @@ -583,12 +583,14 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) { - return SetFromFrame(frameIn, topIn, 0); + return SetFromFrame_Trace(frameIn, topIn, 0); } /** Setup Zmatrix from Cartesian coordinates/topology. */ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnum) { + return SetFromFrame_Trace(frameIn, topIn, molnum); +/* if (molnum < 0) { mprinterr("Internal Error: Zmatrix::SetFromFrame(): Negative molecule index.\n"); return 1; @@ -695,7 +697,7 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu //break; //DEBUG } // END loop over remaining atoms - return 0; + return 0;*/ } /** Set Cartesian coordinates in Frame from internal coordinates. diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 4f78d78f00..c128ccaab4 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -53,7 +53,7 @@ class Zmatrix { /// Simple version of auto set seeds based on connectivity only int autoSetSeeds_simple(Frame const&, Topology const&, Molecule const&); /// Automatically set seeds - int autoSetSeeds(Frame const&, Topology const&, unsigned int, int); +// int autoSetSeeds(Frame const&, Topology const&, unsigned int, int); /// Calculate and add an internal coordinate given indices and Cartesian coords. void addIc(int,int,int,int,const double*,const double*,const double*,const double*); /// Add internal coordiantes by tracing a molecule From b9c7199bc6e5d6170fd9dcf4769c96ab012d9240 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sat, 30 Sep 2023 09:19:25 -0400 Subject: [PATCH 084/245] Ensure IC seeds are added for Cart. seed atoms so each atom has an associated IC --- src/Structure/Zmatrix.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 5b37f8e877..54c78a3452 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -523,7 +523,7 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int Barray hasIC( topIn.Natom(), false ); unsigned int nHasIC = 0; -// See if we need to assign seed atoms + // See if we need to assign seed atoms if (!HasCartSeeds()) { // First seed atom will just be first atom TODO lowest index heavy atom? if (autoSetSeeds_simple(frameIn, topIn, currentMol)) { @@ -539,6 +539,16 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int topIn.AtomMaskName(seedAt1_).c_str(), topIn.AtomMaskName(seedAt2_).c_str()); } + // Add IC seeds + AddICseed( InternalCoords(seedAt0_, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, + 0, 0, 0) ); + AddICseed( InternalCoords(seedAt1_, seedAt0_, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, + sqrt(DIST2_NoImage(frameIn.XYZ(seedAt1_), frameIn.XYZ(seedAt0_))), + 0, 0) ); + AddICseed( InternalCoords(seedAt2_, seedAt1_, seedAt0_, InternalCoords::NO_ATOM, + sqrt(DIST2_NoImage(frameIn.XYZ(seedAt2_), frameIn.XYZ(seedAt1_))), + CalcAngle(frameIn.XYZ(seedAt2_), frameIn.XYZ(seedAt1_), frameIn.XYZ(seedAt0_))*Constants::RADDEG, + 0) ); // If there are less than 4 atoms we are done if (maxnatom < 4) return 0; // Seeds are already done @@ -725,7 +735,11 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { // Track which ICs are used Barray isUsed( IC_.size(), false ); unsigned int Nused = 0; - if (!HasCartSeeds()) { + if (HasCartSeeds()) { + if (icseed0_ != InternalCoords::NO_ATOM) MARK(icseed0_, isUsed, Nused); + if (icseed1_ != InternalCoords::NO_ATOM) MARK(icseed1_, isUsed, Nused); + if (icseed2_ != InternalCoords::NO_ATOM) MARK(icseed2_, isUsed, Nused); + } else { // Set positions of atoms from internal coordinate seeds. TODO check for clashes with seedAtX? if (icseed0_ != InternalCoords::NO_ATOM) { // First seed IC atom From 671bc55c2fb3d779dfedb22f995393335afe6cc5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sat, 30 Sep 2023 09:21:41 -0400 Subject: [PATCH 085/245] Update zmatrix output for IC seeds --- test/Test_Zmatrix/zmatrix.0SB.dat.save | 71 ++++++++++++++------------ test/Test_Zmatrix/zmatrix.dat.save | 11 ++-- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/test/Test_Zmatrix/zmatrix.0SB.dat.save b/test/Test_Zmatrix/zmatrix.0SB.dat.save index 8754bea67a..91dc2649ae 100644 --- a/test/Test_Zmatrix/zmatrix.0SB.dat.save +++ b/test/Test_Zmatrix/zmatrix.0SB.dat.save @@ -1,35 +1,38 @@ #IC MyZ - 1 4.000 3.000 2.000 1.000 1.092 107.320 57.481 - 2 5.000 3.000 2.000 1.000 1.547 109.628 172.109 - 3 6.000 5.000 3.000 2.000 1.091 107.454 -165.180 - 4 7.000 5.000 3.000 2.000 1.449 109.776 78.456 - 5 8.000 7.000 5.000 3.000 0.974 109.637 69.177 - 6 9.000 5.000 3.000 2.000 1.556 114.437 -45.455 - 7 10.000 9.000 5.000 3.000 1.091 109.581 68.196 - 8 11.000 9.000 5.000 3.000 1.460 109.032 -50.185 - 9 12.000 11.000 9.000 5.000 0.967 107.041 66.841 - 10 13.000 9.000 5.000 3.000 1.547 112.392 -170.254 - 11 14.000 13.000 9.000 5.000 1.090 110.244 -58.947 - 12 15.000 13.000 9.000 5.000 1.091 110.082 60.184 - 13 16.000 13.000 9.000 5.000 1.445 110.975 -179.231 - 14 17.000 16.000 13.000 9.000 0.965 106.902 -44.062 - 15 18.000 3.000 2.000 1.000 1.541 109.366 -58.369 - 16 19.000 18.000 3.000 2.000 1.092 109.164 -66.569 - 17 20.000 18.000 3.000 2.000 1.475 109.673 173.191 - 18 21.000 20.000 18.000 3.000 1.005 117.087 -78.719 - 19 22.000 20.000 18.000 3.000 1.332 123.257 97.438 - 20 23.000 22.000 20.000 18.000 1.226 121.726 -3.821 - 21 24.000 22.000 20.000 18.000 1.541 116.620 176.070 - 22 25.000 24.000 22.000 20.000 1.092 111.126 23.276 - 23 26.000 24.000 22.000 20.000 1.091 109.294 -97.180 - 24 27.000 24.000 22.000 20.000 1.091 109.699 143.390 - 25 28.000 18.000 3.000 2.000 1.555 110.258 52.047 - 26 29.000 28.000 18.000 3.000 1.092 108.890 66.493 - 27 30.000 28.000 18.000 3.000 1.460 112.071 -174.457 - 28 31.000 30.000 28.000 18.000 0.961 110.371 -59.820 - 29 32.000 28.000 18.000 3.000 1.538 110.763 -52.775 - 30 33.000 32.000 28.000 18.000 1.093 109.712 176.806 - 31 34.000 32.000 28.000 18.000 1.093 108.775 -68.268 - 32 35.000 1.000 2.000 3.000 1.623 112.883 173.396 - 33 36.000 35.000 1.000 2.000 1.259 115.055 125.259 - 34 37.000 35.000 1.000 2.000 1.254 119.483 -56.528 + 1 1.000 0.000 0.000 0.000 0.000 0.000 0.000 + 2 2.000 1.000 0.000 0.000 1.445 0.000 0.000 + 3 3.000 2.000 1.000 0.000 1.443 119.813 0.000 + 4 4.000 3.000 2.000 1.000 1.092 107.320 57.481 + 5 5.000 3.000 2.000 1.000 1.547 109.628 172.109 + 6 6.000 5.000 3.000 2.000 1.091 107.454 -165.180 + 7 7.000 5.000 3.000 2.000 1.449 109.776 78.456 + 8 8.000 7.000 5.000 3.000 0.974 109.637 69.177 + 9 9.000 5.000 3.000 2.000 1.556 114.437 -45.455 + 10 10.000 9.000 5.000 3.000 1.091 109.581 68.196 + 11 11.000 9.000 5.000 3.000 1.460 109.032 -50.185 + 12 12.000 11.000 9.000 5.000 0.967 107.041 66.841 + 13 13.000 9.000 5.000 3.000 1.547 112.392 -170.254 + 14 14.000 13.000 9.000 5.000 1.090 110.244 -58.947 + 15 15.000 13.000 9.000 5.000 1.091 110.082 60.184 + 16 16.000 13.000 9.000 5.000 1.445 110.975 -179.231 + 17 17.000 16.000 13.000 9.000 0.965 106.902 -44.062 + 18 18.000 3.000 2.000 1.000 1.541 109.366 -58.369 + 19 19.000 18.000 3.000 2.000 1.092 109.164 -66.569 + 20 20.000 18.000 3.000 2.000 1.475 109.673 173.191 + 21 21.000 20.000 18.000 3.000 1.005 117.087 -78.719 + 22 22.000 20.000 18.000 3.000 1.332 123.257 97.438 + 23 23.000 22.000 20.000 18.000 1.226 121.726 -3.821 + 24 24.000 22.000 20.000 18.000 1.541 116.620 176.070 + 25 25.000 24.000 22.000 20.000 1.092 111.126 23.276 + 26 26.000 24.000 22.000 20.000 1.091 109.294 -97.180 + 27 27.000 24.000 22.000 20.000 1.091 109.699 143.390 + 28 28.000 18.000 3.000 2.000 1.555 110.258 52.047 + 29 29.000 28.000 18.000 3.000 1.092 108.890 66.493 + 30 30.000 28.000 18.000 3.000 1.460 112.071 -174.457 + 31 31.000 30.000 28.000 18.000 0.961 110.371 -59.820 + 32 32.000 28.000 18.000 3.000 1.538 110.763 -52.775 + 33 33.000 32.000 28.000 18.000 1.093 109.712 176.806 + 34 34.000 32.000 28.000 18.000 1.093 108.775 -68.268 + 35 35.000 1.000 2.000 3.000 1.623 112.883 173.396 + 36 36.000 35.000 1.000 2.000 1.259 115.055 125.259 + 37 37.000 35.000 1.000 2.000 1.254 119.483 -56.528 diff --git a/test/Test_Zmatrix/zmatrix.dat.save b/test/Test_Zmatrix/zmatrix.dat.save index 32fd230af2..a01118dc98 100644 --- a/test/Test_Zmatrix/zmatrix.dat.save +++ b/test/Test_Zmatrix/zmatrix.dat.save @@ -1,5 +1,8 @@ #IC ZMATRIX_00002 - 1 7.000 6.000 1.000 2.000 1.727 179.995 -28.942 - 2 3.000 2.000 1.000 6.000 1.088 109.303 113.518 - 3 4.000 2.000 1.000 6.000 1.088 109.698 -125.442 - 4 5.000 2.000 1.000 6.000 1.090 108.799 -5.800 + 1 2.000 0.000 0.000 0.000 0.000 0.000 0.000 + 2 1.000 2.000 0.000 0.000 1.510 0.000 0.000 + 3 6.000 1.000 2.000 0.000 1.223 120.091 0.000 + 4 7.000 6.000 1.000 2.000 1.727 179.995 -28.942 + 5 3.000 2.000 1.000 6.000 1.088 109.303 113.518 + 6 4.000 2.000 1.000 6.000 1.088 109.698 -125.442 + 7 5.000 2.000 1.000 6.000 1.090 108.799 -5.800 From 39d884ef2b58be05b756de654efaa91e6faf1ecc Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sat, 30 Sep 2023 11:27:40 -0400 Subject: [PATCH 086/245] Dont add IC seed if the seed atom isnt set --- src/Structure/Zmatrix.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 54c78a3452..291646213d 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -540,15 +540,18 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int topIn.AtomMaskName(seedAt2_).c_str()); } // Add IC seeds - AddICseed( InternalCoords(seedAt0_, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, - 0, 0, 0) ); - AddICseed( InternalCoords(seedAt1_, seedAt0_, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, - sqrt(DIST2_NoImage(frameIn.XYZ(seedAt1_), frameIn.XYZ(seedAt0_))), - 0, 0) ); - AddICseed( InternalCoords(seedAt2_, seedAt1_, seedAt0_, InternalCoords::NO_ATOM, - sqrt(DIST2_NoImage(frameIn.XYZ(seedAt2_), frameIn.XYZ(seedAt1_))), - CalcAngle(frameIn.XYZ(seedAt2_), frameIn.XYZ(seedAt1_), frameIn.XYZ(seedAt0_))*Constants::RADDEG, - 0) ); + if (seedAt0_ != InternalCoords::NO_ATOM) + AddICseed( InternalCoords(seedAt0_, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, + 0, 0, 0) ); + if (seedAt1_ != InternalCoords::NO_ATOM) + AddICseed( InternalCoords(seedAt1_, seedAt0_, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, + sqrt(DIST2_NoImage(frameIn.XYZ(seedAt1_), frameIn.XYZ(seedAt0_))), + 0, 0) ); + if (seedAt2_ != InternalCoords::NO_ATOM) + AddICseed( InternalCoords(seedAt2_, seedAt1_, seedAt0_, InternalCoords::NO_ATOM, + sqrt(DIST2_NoImage(frameIn.XYZ(seedAt2_), frameIn.XYZ(seedAt1_))), + CalcAngle(frameIn.XYZ(seedAt2_), frameIn.XYZ(seedAt1_), frameIn.XYZ(seedAt0_))*Constants::RADDEG, + 0) ); // If there are less than 4 atoms we are done if (maxnatom < 4) return 0; // Seeds are already done From 9c532d5a346fee341aac70160323e2097dc18003 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 2 Oct 2023 10:39:11 -0400 Subject: [PATCH 087/245] Only have one version of AddIC, automatically determine IC seed --- src/DataIO_AmberPrep.cpp | 8 ++++---- src/Structure/Zmatrix.cpp | 43 ++++++++++++++++++++++++++++++++------- src/Structure/Zmatrix.h | 4 ++-- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/DataIO_AmberPrep.cpp b/src/DataIO_AmberPrep.cpp index 5c9e7a6dbb..1424ec29cd 100644 --- a/src/DataIO_AmberPrep.cpp +++ b/src/DataIO_AmberPrep.cpp @@ -230,11 +230,11 @@ const double dist = convertToDouble(args[7]); double theta = convertToDouble(args[8]); double phi = convertToDouble(args[9]); - if (args[2] == ISYMDU) { - if (zmatrix.AddICseed( InternalCoords(atIdx, atJ, atK, atL, dist, theta, phi) )) + //if (args[2] == ISYMDU) { + if (zmatrix.AddIC( InternalCoords(atIdx, atJ, atK, atL, dist, theta, phi) )) return 1; - } else - zmatrix.AddIC( InternalCoords(atIdx, atJ, atK, atL, dist, theta, phi) ); + //} else + // zmatrix.AddIC( InternalCoords(atIdx, atJ, atK, atL, dist, theta, phi) ); atIdx++; line = infile.Line(); if (line == 0) break; diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 291646213d..be994215d2 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -26,15 +26,44 @@ Zmatrix::Zmatrix() : seedAt2_(InternalCoords::NO_ATOM) {} -/** Add internal coords */ -void Zmatrix::AddIC(InternalCoords const& ic) { +/// Error message for seed already set +static inline int seed_err(int iseed) { + mprinterr("Internal Error: Internal coord seed %i is already set.\n", iseed); + return 1; +} + +/** Add internal coords. If any of the atoms are not set assume this is one + * of the 3 seed atoms and determine which one. + */ +int Zmatrix::AddIC(InternalCoords const& ic) { + if (ic.AtJ() == InternalCoords::NO_ATOM && + ic.AtK() == InternalCoords::NO_ATOM && + ic.AtL() == InternalCoords::NO_ATOM) + { // Potential seed0 + if (icseed0_ != InternalCoords::NO_ATOM) + return seed_err(0); + icseed0_ = IC_.size(); + } else if (ic.AtK() == InternalCoords::NO_ATOM && + ic.AtL() == InternalCoords::NO_ATOM) + { // Potential seed1 + if (icseed1_ != InternalCoords::NO_ATOM) + return seed_err(1); + icseed1_ = IC_.size(); + } else if (ic.AtL() == InternalCoords::NO_ATOM) { + // Potential seed2 + if (icseed2_ != InternalCoords::NO_ATOM) + return seed_err(2); + icseed2_ = IC_.size(); + } + IC_.push_back( ic ); + return 0; } /** Add internal coords as a IC seed. This is intended for use with systems * that have dummy atoms, such as those from Amber Prep files. */ -int Zmatrix::AddICseed(InternalCoords const& ic) { +/*int Zmatrix::AddICseed(InternalCoords const& ic) { if (icseed0_ == InternalCoords::NO_ATOM) icseed0_ = IC_.size(); else if (icseed1_ == InternalCoords::NO_ATOM) @@ -47,7 +76,7 @@ int Zmatrix::AddICseed(InternalCoords const& ic) { } IC_.push_back( ic ); return 0; -} +}*/ /** Print to stdout */ void Zmatrix::print() const { @@ -541,14 +570,14 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int } // Add IC seeds if (seedAt0_ != InternalCoords::NO_ATOM) - AddICseed( InternalCoords(seedAt0_, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, + AddIC( InternalCoords(seedAt0_, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, 0, 0, 0) ); if (seedAt1_ != InternalCoords::NO_ATOM) - AddICseed( InternalCoords(seedAt1_, seedAt0_, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, + AddIC( InternalCoords(seedAt1_, seedAt0_, InternalCoords::NO_ATOM, InternalCoords::NO_ATOM, sqrt(DIST2_NoImage(frameIn.XYZ(seedAt1_), frameIn.XYZ(seedAt0_))), 0, 0) ); if (seedAt2_ != InternalCoords::NO_ATOM) - AddICseed( InternalCoords(seedAt2_, seedAt1_, seedAt0_, InternalCoords::NO_ATOM, + AddIC( InternalCoords(seedAt2_, seedAt1_, seedAt0_, InternalCoords::NO_ATOM, sqrt(DIST2_NoImage(frameIn.XYZ(seedAt2_), frameIn.XYZ(seedAt1_))), CalcAngle(frameIn.XYZ(seedAt2_), frameIn.XYZ(seedAt1_), frameIn.XYZ(seedAt0_))*Constants::RADDEG, 0) ); diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index c128ccaab4..f214a8bbf4 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -16,9 +16,9 @@ class Zmatrix { /// Set debug level void SetDebug(int d) { debug_ = d; } /// Add internal coordinate - void AddIC(InternalCoords const&); + int AddIC(InternalCoords const&); /// Add internal coordinate as next available IC seed - int AddICseed(InternalCoords const&); + //int AddICseed(InternalCoords const&); /// Set seed atoms from frame/top int SetSeedPositions(Frame const&, Topology const&, int, int, int); /// Convert specifed molecule of Frame/Topology to internal coordinates array From 2b415dc565c07194969a220071ce58a4738307fc Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 2 Oct 2023 11:20:52 -0400 Subject: [PATCH 088/245] Hide debug info. Allow one to specify a different topology if desired for zmatrix zset --- src/Exec_Zmatrix.cpp | 57 +++++++++++++++++------ src/Exec_Zmatrix.h | 6 ++- src/Structure/Zmatrix.cpp | 97 ++++++++++++++++++++++++--------------- 3 files changed, 107 insertions(+), 53 deletions(-) diff --git a/src/Exec_Zmatrix.cpp b/src/Exec_Zmatrix.cpp index a474acd6c0..b42fa97b9d 100644 --- a/src/Exec_Zmatrix.cpp +++ b/src/Exec_Zmatrix.cpp @@ -16,7 +16,11 @@ int Exec_Zmatrix::getZmatrix(DataSet_Coords* CRD, int molnum, int frmidx, std::string const& dsname, DataFile* outfile, CpptrajState& State) const { - mprintf("\tUsing set '%s'\n", CRD->legend()); + if (CRD == 0) { + mprinterr("Error: No COORDS set specified.\n"); + return CpptrajState::ERR; + } + mprintf("\tGetting Z-matrix from set '%s'\n", CRD->legend()); if (CRD->Size() < 1) { mprinterr("Error: Set '%s' is empty.\n", CRD->legend()); return 1; @@ -44,12 +48,13 @@ const zmatrix.SetDebug( State.Debug() ); int errStat = zmatrix.SetFromFrame_Trace( frmIn, CRD->Top(), molnum ); - zmatrix.print(); // DEBUG + if (debug_ > 0) zmatrix.print(); // DEBUG return errStat; } /** Create COORDS using Zmatrix. */ -int Exec_Zmatrix::putZmatrix(DataSet_Coords* CRD, std::string const& zsetname, +int Exec_Zmatrix::putZmatrix(DataSet_Coords* CRD, Topology* topIn, + std::string const& zsetname, std::string const& dsname, CpptrajState& State) const { @@ -59,7 +64,7 @@ const mprinterr("Error: No zmatrix set with name '%s' found.\n", zsetname.c_str()); return 1; } - mprintf("\tZmatrix set : %s\n", zmatrix->legend()); + mprintf("\tCreating COORDS from Zmatrix set : %s\n", zmatrix->legend()); // Create COORDS set DataSet_Coords* out = (DataSet_Coords*)State.DSL().AddSet(DataSet::COORDS, dsname, "ZMCRD"); @@ -67,13 +72,36 @@ const mprinterr("Error: Could not create COORDS set for assigning from Zmatrix.\n"); return 1; } - out->CoordsSetup( CRD->Top(), CRD->CoordsInfo()); - mprintf("\tOutput coords set : %s\n", out->legend()); + mprintf("\tOutput COORDS set: %s\n", out->legend()); + + Topology* myTop = 0; + if (topIn != 0) { + mprintf("\tTopology: %s\n", topIn->c_str()); + myTop = topIn; + } else if (CRD != 0) { + mprintf("\tTopology from COORDS set: %s\n", CRD->legend()); + myTop = CRD->TopPtr(); + } else { + mprinterr("Error: No COORDS set or Topology specified for 'zset'.\n"); + return 1; + } + CoordinateInfo myInfo; + if (CRD != 0) + myInfo = CRD->CoordsInfo(); + out->CoordsSetup( *myTop, myInfo); // Assign Frame frm = out->AllocateFrame(); frm.ZeroCoords(); - if (zmatrix->Zptr()->SetToFrame( frm )) { + int err = 0; + if (debug_ > 0) { + Zmatrix tmpZ = *(zmatrix->Zptr()); // TODO just pass debug level into Zmatrix? + tmpZ.SetDebug( debug_ ); + err = tmpZ.SetToFrame( frm ); + } else { + err = zmatrix->Zptr()->SetToFrame( frm ); + } + if (err != 0) { mprinterr("Error: Zmatrix to Cartesian coords failed.\n"); return 1; } @@ -85,28 +113,29 @@ const // Exec_Zmatrix::Execute() Exec::RetType Exec_Zmatrix::Execute(CpptrajState& State, ArgList& argIn) { + debug_ = State.Debug(); int molnum = argIn.getKeyInt("molnum", 1) - 1; int frmidx = argIn.getKeyInt("frame", 1) - 1; std::string dsname = argIn.GetStringKey("name"); - DataFile* outfile = State.DFL().AddDataFile( argIn.GetStringKey("out"), argIn ); // TODO not if zset std::string zsetname = argIn.GetStringKey("zset"); - + Topology* topIn = 0; + if (argIn.Contains("parm") || argIn.Contains("parmindex")) + topIn = (Topology*)State.DSL().GetTopology(argIn); + // Get COORDS set name std::string setname = argIn.GetStringNext(); + // ----- No more args below here ----- if (setname.empty()) { mprinterr("Error: %s: Specify COORDS dataset name.\n", argIn.Command()); return CpptrajState::ERR; } DataSet_Coords* CRD = (DataSet_Coords*)State.DSL().FindSetOfGroup( setname, DataSet::COORDINATES ); - if (CRD == 0) { - mprinterr("Error: %s: No COORDS set with name %s found.\n", argIn.Command(), setname.c_str()); - return CpptrajState::ERR; - } + int errStat = 0; if (!zsetname.empty()) { - errStat = putZmatrix(CRD, zsetname, dsname, State); + errStat = putZmatrix(CRD, topIn, zsetname, dsname, State); } else { errStat = getZmatrix(CRD, molnum, frmidx, dsname, outfile, State); } diff --git a/src/Exec_Zmatrix.h b/src/Exec_Zmatrix.h index 3b4b32bbc4..0b89547724 100644 --- a/src/Exec_Zmatrix.h +++ b/src/Exec_Zmatrix.h @@ -4,12 +4,14 @@ /// Calculate a Zmatrix from a COORDS data set class Exec_Zmatrix : public Exec { public: - Exec_Zmatrix() : Exec(COORDS) {} + Exec_Zmatrix() : Exec(COORDS), debug_(0) {} void Help() const; DispatchObject* Alloc() const { return (DispatchObject*)new Exec_Zmatrix(); } RetType Execute(CpptrajState&, ArgList&); private: int getZmatrix(DataSet_Coords*, int, int, std::string const&, DataFile*, CpptrajState&) const; - int putZmatrix(DataSet_Coords*, std::string const&, std::string const&, CpptrajState&) const; + int putZmatrix(DataSet_Coords*, Topology*, std::string const&, std::string const&, CpptrajState&) const; + + int debug_; }; #endif diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index be994215d2..1b7ff99e52 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -234,10 +234,11 @@ int Zmatrix::SetSeedPositions(Frame const& frameIn, Topology const& topIn, int a seed1Pos_ = Vec3(frameIn.XYZ(a2)); seedAt2_ = a3; seed2Pos_ = Vec3(frameIn.XYZ(a3)); - mprintf("DEBUG: Seed atoms: %s - %s - %s\n", - topIn.AtomMaskName(a1).c_str(), - topIn.AtomMaskName(a2).c_str(), - topIn.AtomMaskName(a3).c_str()); + if (debug_ > 0) + mprintf("DEBUG: Seed atoms: %s - %s - %s\n", + topIn.AtomMaskName(a1).c_str(), + topIn.AtomMaskName(a2).c_str(), + topIn.AtomMaskName(a3).c_str()); return 0; } @@ -316,7 +317,8 @@ int Zmatrix::autoSetSeeds_simple(Frame const& frameIn, Topology const& topIn, Mo if (seedAt1_ != InternalCoords::NO_ATOM) break; } if (seedAt1_ == InternalCoords::NO_ATOM) { - mprintf("DEBUG: No seed1 with just 2 bonds found. Using seed1 with %i bonds.\n", potentialSeedNbonds); + if (debug_ > 0) + mprintf("DEBUG: No seed1 with just 2 bonds found. Using seed1 with %i bonds.\n", potentialSeedNbonds); seedAt1_ = potentialSeed1; } if (seedAt1_ == InternalCoords::NO_ATOM) { @@ -340,9 +342,11 @@ int Zmatrix::autoSetSeeds_simple(Frame const& frameIn, Topology const& topIn, Mo seedAt0_ = lowestidx; seedAt2_ = highestidx; - mprintf("DEBUG: Potential seed 0: %i %s\n", seedAt0_+1, topIn.AtomMaskName(seedAt0_).c_str()); - mprintf("DEBUG: Potential seed 1: %i %s\n", seedAt1_+1, topIn.AtomMaskName(seedAt1_).c_str()); - mprintf("DEBUG: Potential seed 2: %i %s\n", seedAt2_+1, topIn.AtomMaskName(seedAt2_).c_str()); + if (debug_ > 0) { + mprintf("DEBUG: Potential seed 0: %i %s\n", seedAt0_+1, topIn.AtomMaskName(seedAt0_).c_str()); + mprintf("DEBUG: Potential seed 1: %i %s\n", seedAt1_+1, topIn.AtomMaskName(seedAt1_).c_str()); + mprintf("DEBUG: Potential seed 2: %i %s\n", seedAt2_+1, topIn.AtomMaskName(seedAt2_).c_str()); + } seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); @@ -448,13 +452,15 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, int atK = atK0; int atJ = atJ0; - int debug_it = 0; // DEBUG + //int debug_it = 0; // DEBUG + unsigned int maxStack = 0; while (nHasIC < maxnatom) { - mprintf("\nDEBUG: nHasIC= %8u / %8u : %s - %s - %s -\n", nHasIC, maxnatom, - topIn.AtomMaskName(atL).c_str(), - topIn.AtomMaskName(atK).c_str(), - topIn.AtomMaskName(atJ).c_str()); + if (debug_ > 1) + mprintf("\nDEBUG: nHasIC= %8u / %8u : %s - %s - %s -\n", nHasIC, maxnatom, + topIn.AtomMaskName(atL).c_str(), + topIn.AtomMaskName(atK).c_str(), + topIn.AtomMaskName(atJ).c_str()); // List all atoms bonded to J with the following priority: // 1) Atoms with 1 bond. // 2) Low index atoms. @@ -471,8 +477,10 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, } if (OtherAtoms.size() > 1) std::sort( OtherAtoms.begin(), OtherAtoms.end() ); - printIarray( OneBondAtoms, "OneBondAtoms", topIn ); - printIarray( OtherAtoms, "OtherAtoms", topIn ); + if (debug_ > 1) { + printIarray( OneBondAtoms, "OneBondAtoms", topIn ); + printIarray( OtherAtoms, "OtherAtoms", topIn ); + } // Create ICs for 1 bond atoms for (Iarray::const_iterator atI = OneBondAtoms.begin(); atI != OneBondAtoms.end(); ++atI) { addIc(*atI, atJ, atK, atL, frameIn.XYZ(*atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); @@ -482,16 +490,19 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, if (OtherAtoms.empty()) { // If no branches, done for now. if (Branches.empty()) { - mprintf("DEBUG: No more branches. Exiting traceMol.\n"); + if (debug_ > 1) + mprintf("DEBUG: No more branches. Exiting traceMol.\n"); break; } // Add IC for the branch PHI const& p = Branches.top(); - mprintf("DEBUG:\t\tPopped off stack: %s - %s - %s - %s\n", - topIn.AtomMaskName(p.al_).c_str(), - topIn.AtomMaskName(p.ak_).c_str(), - topIn.AtomMaskName(p.aj_).c_str(), - topIn.AtomMaskName(p.ai_).c_str()); + if (debug_ > 1) { + mprintf("DEBUG:\t\tPopped off stack: %s - %s - %s - %s\n", + topIn.AtomMaskName(p.al_).c_str(), + topIn.AtomMaskName(p.ak_).c_str(), + topIn.AtomMaskName(p.aj_).c_str(), + topIn.AtomMaskName(p.ai_).c_str()); + } addIc(p.ai_, p.aj_, p.ak_, p.al_, frameIn.XYZ(p.ai_), frameIn.XYZ(p.aj_), frameIn.XYZ(p.ak_), frameIn.XYZ(p.al_)); Branches.pop(); MARK(p.ai_, hasIC, nHasIC); @@ -501,23 +512,28 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, atJ = p.ai_; } else { int atI = OtherAtoms.front(); - mprintf("DEBUG:\t\tNext: %s - %s - %s - %s\n", - topIn.AtomMaskName(atL).c_str(), - topIn.AtomMaskName(atK).c_str(), - topIn.AtomMaskName(atJ).c_str(), - topIn.AtomMaskName(atI).c_str()); + if (debug_ > 1) { + mprintf("DEBUG:\t\tNext: %s - %s - %s - %s\n", + topIn.AtomMaskName(atL).c_str(), + topIn.AtomMaskName(atK).c_str(), + topIn.AtomMaskName(atJ).c_str(), + topIn.AtomMaskName(atI).c_str()); + } // Add lowest index as IC addIc(atI, atJ, atK, atL, frameIn.XYZ(atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); MARK(atI, hasIC, nHasIC); // Place all above lowest index on the stack. for (unsigned int ii = 1; ii < OtherAtoms.size(); ii++) { Branches.push( PHI(OtherAtoms[ii], atJ, atK, atL) ); - PHI const& p = Branches.top(); - mprintf("DEBUG:\t\tPlaced on stack: %s - %s - %s - %s (%zu)\n", - topIn.AtomMaskName(p.al_).c_str(), - topIn.AtomMaskName(p.ak_).c_str(), - topIn.AtomMaskName(p.aj_).c_str(), - topIn.AtomMaskName(p.ai_).c_str(), Branches.size()); + maxStack = std::max(maxStack, (unsigned int)Branches.size()); + if (debug_ > 1) { + PHI const& p = Branches.top(); + mprintf("DEBUG:\t\tPlaced on stack: %s - %s - %s - %s (%zu)\n", + topIn.AtomMaskName(p.al_).c_str(), + topIn.AtomMaskName(p.ak_).c_str(), + topIn.AtomMaskName(p.aj_).c_str(), + topIn.AtomMaskName(p.ai_).c_str(), Branches.size()); + } } // Designate lowest index as next atL = atK; @@ -525,8 +541,14 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, atJ = atI; } //if (debug_it == 1) break; // DEBUG - debug_it++; // DEBUG + //debug_it++; // DEBUG } + if (debug_ > 0) + mprintf("DEBUG: Max stack size (%s - %s - %s - ?)= %u\n", + topIn.AtomMaskName(atL0).c_str(), + topIn.AtomMaskName(atK0).c_str(), + topIn.AtomMaskName(atJ0).c_str(), + maxStack); return 0; } @@ -563,10 +585,11 @@ int Zmatrix::SetFromFrame_Trace(Frame const& frameIn, Topology const& topIn, int } else { // Seed atoms already set - mprintf("DEBUG: Cartesian Seed indices: %s %s %s\n", - topIn.AtomMaskName(seedAt0_).c_str(), - topIn.AtomMaskName(seedAt1_).c_str(), - topIn.AtomMaskName(seedAt2_).c_str()); + if (debug_ > 0) + mprintf("DEBUG: Cartesian Seed indices: %s %s %s\n", + topIn.AtomMaskName(seedAt0_).c_str(), + topIn.AtomMaskName(seedAt1_).c_str(), + topIn.AtomMaskName(seedAt2_).c_str()); } // Add IC seeds if (seedAt0_ != InternalCoords::NO_ATOM) From d2259e006be44934449bc50fa42707c8d67f0784 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 2 Oct 2023 14:08:24 -0400 Subject: [PATCH 089/245] Start adding a graft using internal coords mode --- src/Exec_Graft.cpp | 114 ++++++++++++++++++++++++++++++++++++++++++++- src/Exec_Graft.h | 9 ++++ 2 files changed, 122 insertions(+), 1 deletion(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index a1319c7b94..431d3ac271 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -41,7 +41,119 @@ static int UpdateIndices(std::vector& Idxs, AtomMask const& maskIn, int off // Exec_Graft::Execute() Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) { - typedef std::vector Iarray; + if (argIn.hasKey("ic")) + return graft_ic(State,argIn); + else + return graft_rms(State, argIn); +} + +/** Get atoms to bond , from keyword(s). */ +int Exec_Graft::get_bond_atoms(ArgList& argIn, Iarray& tgtBondAtoms, Iarray& srcBondAtoms, + Topology const& tgtTop, Topology const& srcTop) +{ + tgtBondAtoms.clear(); + srcBondAtoms.clear(); + std::string 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 1; + } + AtomMask tb, sb; + if (tb.SetMaskString(bndarg[0])) return 1; + if (sb.SetMaskString(bndarg[1])) return 1; + if (tgtTop.SetupIntegerMask(tb)) return 1; + if (srcTop.SetupIntegerMask(sb)) return 1; + if (tb.Nselected() != 1) { + mprinterr("Error: 'bond' target mask does not select only 1 atom.\n"); + return 1; + } + if (sb.Nselected() != 1) { + mprinterr("Error: 'bond' source mask does not select only 1 atom.\n"); + return 1; + } + 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"); + } + return 0; +} + +/** Get COORDS set. */ +DataSet_Coords* Exec_Graft::get_crd(ArgList& argIn, DataSetList const& DSL, + const char* key, const char* desc, Frame& srcFrame, const char* frameKey) +{ + std::string kw = argIn.GetStringKey(key); + if (kw.empty()) { + mprinterr("Error: %s must be specified with '%s'.\n", desc, key); + return 0; + } + DataSet_Coords* srcCoords = (DataSet_Coords*)DSL.FindSetOfGroup(kw, DataSet::COORDINATES); + if (srcCoords == 0) { + mprinterr("Error: %s %s not found.\n", desc, kw.c_str()); + return 0; + } + srcFrame = srcCoords->AllocateFrame(); + srcCoords->GetFrame(argIn.getKeyInt(frameKey, 1)-1, srcFrame); + return srcCoords; +} + +/** Graft using internal coordinates to build the final structure. */ +Exec::RetType Exec_Graft::graft_ic(CpptrajState& State, ArgList& argIn) +const +{ + // Source (fragment) + Frame mol1frm; + DataSet_Coords* mol1crd = get_crd(argIn, State.DSL(), "src", "Source COORDS", mol1frm, "srcframe"); + if (mol1crd == 0) return CpptrajState::ERR; + // Target (base) + Frame mol0frm; + DataSet_Coords* mol0crd = get_crd(argIn, State.DSL(), "tgt", "Target COORDS", mol0frm, "tgtframe"); + if (mol0crd == 0) return CpptrajState::ERR; + // Create output coords + std::string 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 bond + Iarray tgtBondAtoms, srcBondAtoms; + if (get_bond_atoms(argIn, tgtBondAtoms, srcBondAtoms, mol0crd->Top(), mol1crd->Top())) + return CpptrajState::ERR; + // Combine topologies. + Topology combinedTop; + combinedTop.SetDebug( State.Debug() ); + combinedTop.SetParmName( outCoords->Meta().Name(), FileName() ); + combinedTop.AppendTop( mol0crd->Top() ); + combinedTop.AppendTop( mol1crd->Top() ); + // Combine coords. + // Only coords+box for now. + CoordinateInfo outInfo(mol0frm.BoxCrd(), false, false, false); + if (outCoords->CoordsSetup(combinedTop, outInfo)) return CpptrajState::ERR; + Frame CombinedFrame = outCoords->AllocateFrame(); + std::copy(mol0frm.xAddress(), mol0frm.xAddress()+mol0frm.size(), CombinedFrame.xAddress()); + std::copy(mol1frm.xAddress(), mol1frm.xAddress()+mol1frm.size(), CombinedFrame.xAddress()+mol0frm.size()); + // Use target box TODO reset the box? + CombinedFrame.SetBox( mol0frm.BoxCrd() ); + outCoords->AddFrame( CombinedFrame ); + + + return CpptrajState::OK; +} + +/** Graft with RMS-fitting. */ +Exec::RetType Exec_Graft::graft_rms(CpptrajState& State, ArgList& argIn) +const +{ // Get source coords std::string kw = argIn.GetStringKey("src"); if (kw.empty()) { diff --git a/src/Exec_Graft.h b/src/Exec_Graft.h index d3f8840626..43da2cbbd0 100644 --- a/src/Exec_Graft.h +++ b/src/Exec_Graft.h @@ -8,5 +8,14 @@ class Exec_Graft : public Exec { void Help() const; DispatchObject* Alloc() const { return (DispatchObject*)new Exec_Graft(); } RetType Execute(CpptrajState&, ArgList&); + private: + typedef std::vector Iarray; + + static int get_bond_atoms(ArgList&, Iarray&, Iarray&, Topology const&, Topology const&); + + static DataSet_Coords* get_crd(ArgList&, DataSetList const&, const char*, const char*, Frame&, const char*); + + RetType graft_ic(CpptrajState&, ArgList&) const; + RetType graft_rms(CpptrajState&, ArgList&) const; }; #endif From 38af6e625c152570da2393ba673373e1b67623b0 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 2 Oct 2023 15:09:03 -0400 Subject: [PATCH 090/245] Do topology modification --- src/Exec_Graft.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++--- src/Exec_Graft.h | 2 ++ 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 431d3ac271..6d5bb2a600 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -102,6 +102,30 @@ DataSet_Coords* Exec_Graft::get_crd(ArgList& argIn, DataSetList const& DSL, return srcCoords; } +/** Modify given topology and frame by specified mask. Ensure the bonding + * atom will be present in the stripped topology. + * \return topology modified by mask. + */ +Topology* Exec_Graft::modify_top(Topology const& topIn, AtomMask const& mask, Frame& srcFrame) + +{ + mprintf("\tAtoms to keep from '%s' : ", topIn.c_str()); + mask.BriefMaskInfo(); + mprintf("\n"); + + Topology* srcTopPtr = topIn.modifyStateByMask( mask ); + if (srcTopPtr == 0) { + mprinterr("Error: Could not modify topology %s.\n", topIn.c_str()); + return 0; + } + Frame* srcFrmPtr = new Frame(); + srcFrmPtr->SetupFrameV(srcTopPtr->Atoms(), srcFrame.CoordsInfo()); + srcFrmPtr->SetFrame(srcFrame, mask); + srcFrame = *srcFrmPtr; + delete srcFrmPtr; + return srcTopPtr; +} + /** Graft using internal coordinates to build the final structure. */ Exec::RetType Exec_Graft::graft_ic(CpptrajState& State, ArgList& argIn) const @@ -125,20 +149,66 @@ const mprinterr("Error: Output COORDS %s could not be created.\n", kw.c_str()); return CpptrajState::ERR; } - // Get atoms to bond + + // Get atoms to bond Iarray tgtBondAtoms, srcBondAtoms; if (get_bond_atoms(argIn, tgtBondAtoms, srcBondAtoms, mol0crd->Top(), mol1crd->Top())) return CpptrajState::ERR; + // Get atoms to keep from source. + AtomMask mol1Mask; + if (mol1Mask.SetMaskString( argIn.GetStringKey("srcmask") )) + return CpptrajState::ERR; + if (mol1crd->Top().SetupIntegerMask(mol1Mask)) + return CpptrajState::ERR; + // Get atoms to keep from target. + AtomMask mol0Mask; + if (mol0Mask.SetMaskString( argIn.GetStringKey("tgtmask") )) + return CpptrajState::ERR; + if (mol0crd->Top().SetupIntegerMask(mol0Mask)) + return CpptrajState::ERR; + // Update the bond indices for the new topologies + if (UpdateIndices(tgtBondAtoms, mol0Mask, 0)) + return CpptrajState::ERR; + if (UpdateIndices(srcBondAtoms, mol1Mask, mol0Mask.Nselected())) + return CpptrajState::ERR; + + // Modify the target (mol0) topology, update bond atom indices. + bool newMol0Top = false; + Topology* mol0Top = 0; + if (mol0Mask.Nselected() == mol0crd->Top().Natom()) { + mol0Top = mol0crd->TopPtr(); + } else { + newMol0Top = true; + mol0Top = modify_top(mol0crd->Top(), mol0Mask, mol0frm); + if (mol0Top == 0) return CpptrajState::ERR; // FIXME need to free mol0Top memory + } + // Modify the source (mol1) topology, update bond atom indices. + bool newMol1Top = false; + Topology* mol1Top = 0; + if (mol1Mask.Nselected() == mol1crd->Top().Natom()) { + mol1Top = mol1crd->TopPtr(); + } else { + newMol1Top = true; + mol1Top = modify_top(mol1crd->Top(), mol1Mask, mol1frm); + if (mol1Top == 0) return CpptrajState::ERR; // FIXME need to free mol1Top memory + } + // Combine topologies. Topology combinedTop; combinedTop.SetDebug( State.Debug() ); combinedTop.SetParmName( outCoords->Meta().Name(), FileName() ); - combinedTop.AppendTop( mol0crd->Top() ); - combinedTop.AppendTop( mol1crd->Top() ); + combinedTop.AppendTop( *mol0Top ); + combinedTop.AppendTop( *mol1Top ); + // Create bonds + for (unsigned int idx = 0; idx != tgtBondAtoms.size(); idx++) { + mprintf("DEBUG: Bond %i %s to %i %s\n", + tgtBondAtoms[idx]+1, combinedTop.AtomMaskName(tgtBondAtoms[idx]).c_str(), + srcBondAtoms[idx]+1, combinedTop.AtomMaskName(srcBondAtoms[idx]).c_str()); + } // Combine coords. // Only coords+box for now. CoordinateInfo outInfo(mol0frm.BoxCrd(), false, false, false); - if (outCoords->CoordsSetup(combinedTop, outInfo)) return CpptrajState::ERR; + if (outCoords->CoordsSetup(combinedTop, outInfo)) return CpptrajState::ERR; // FIXME free molXTop memory Frame CombinedFrame = outCoords->AllocateFrame(); std::copy(mol0frm.xAddress(), mol0frm.xAddress()+mol0frm.size(), CombinedFrame.xAddress()); std::copy(mol1frm.xAddress(), mol1frm.xAddress()+mol1frm.size(), CombinedFrame.xAddress()+mol0frm.size()); @@ -146,6 +216,8 @@ const CombinedFrame.SetBox( mol0frm.BoxCrd() ); outCoords->AddFrame( CombinedFrame ); + if (newMol0Top) delete mol0Top; + if (newMol1Top) delete mol1Top; return CpptrajState::OK; } diff --git a/src/Exec_Graft.h b/src/Exec_Graft.h index 43da2cbbd0..992d09acad 100644 --- a/src/Exec_Graft.h +++ b/src/Exec_Graft.h @@ -13,6 +13,8 @@ class Exec_Graft : public Exec { static int get_bond_atoms(ArgList&, Iarray&, Iarray&, Topology const&, Topology const&); + static Topology* modify_top(Topology const&, AtomMask const&, Frame&); + static DataSet_Coords* get_crd(ArgList&, DataSetList const&, const char*, const char*, Frame&, const char*); RetType graft_ic(CpptrajState&, ArgList&) const; From d8b86f1bf2700b014668724f7beb4081cf768292 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 2 Oct 2023 15:17:17 -0400 Subject: [PATCH 091/245] Calculate zmatrix for combined structure --- src/Exec_Graft.cpp | 16 +++++++++++++++- src/cpptrajdepend | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 6d5bb2a600..261551106e 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 "Structure/Zmatrix.h" #include // std::copy // Exec_Graft::Help() @@ -130,6 +131,7 @@ Topology* Exec_Graft::modify_top(Topology const& topIn, AtomMask const& mask, Fr Exec::RetType Exec_Graft::graft_ic(CpptrajState& State, ArgList& argIn) const { + using namespace Cpptraj::Structure; // Source (fragment) Frame mol1frm; DataSet_Coords* mol1crd = get_crd(argIn, State.DSL(), "src", "Source COORDS", mol1frm, "srcframe"); @@ -204,16 +206,28 @@ const mprintf("DEBUG: Bond %i %s to %i %s\n", tgtBondAtoms[idx]+1, combinedTop.AtomMaskName(tgtBondAtoms[idx]).c_str(), srcBondAtoms[idx]+1, combinedTop.AtomMaskName(srcBondAtoms[idx]).c_str()); + combinedTop.AddBond( tgtBondAtoms[idx], srcBondAtoms[idx] ); } - // Combine coords. // Only coords+box for now. CoordinateInfo outInfo(mol0frm.BoxCrd(), false, false, false); if (outCoords->CoordsSetup(combinedTop, outInfo)) return CpptrajState::ERR; // FIXME free molXTop memory + // Combine coords. Frame CombinedFrame = outCoords->AllocateFrame(); std::copy(mol0frm.xAddress(), mol0frm.xAddress()+mol0frm.size(), CombinedFrame.xAddress()); std::copy(mol1frm.xAddress(), mol1frm.xAddress()+mol1frm.size(), CombinedFrame.xAddress()+mol0frm.size()); // Use target box TODO reset the box? CombinedFrame.SetBox( mol0frm.BoxCrd() ); + + // Generate Z matrix FIXME ensure mol 0 is the one we are interested in + Zmatrix zmatrix; + zmatrix.SetDebug( 2 ); // FIXME + if (zmatrix.SetFromFrame(CombinedFrame, combinedTop)) { + mprinterr("Error: Zmatrix setup failed.\n"); + return CpptrajState::ERR; + } + zmatrix.print(); // DEBUG + + // Add frame to the output data set outCoords->AddFrame( CombinedFrame ); if (newMol0Top) delete mol0Top; diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 62b3cd6b2c..4cf7d66875 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -304,7 +304,7 @@ Exec_Emin.o : Exec_Emin.cpp Action.h ActionList.h ActionState.h Analysis.h Analy Exec_ExtendedComparison.o : Exec_ExtendedComparison.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_ExtendedComparison.h ExtendedSimilarity.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_Flatten.o : Exec_Flatten.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Flatten.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 ImageOption.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_HmassRepartition.o : Exec_HmassRepartition.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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 EnsembleIn.h EnsembleOutList.h Exec.h Exec_HmassRepartition.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h Trajin_Single.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h From ddeff83141e15d9209af3b3eccb7bc6d80b53fb6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 2 Oct 2023 15:25:35 -0400 Subject: [PATCH 092/245] Regenerate molecule info after bonds are added --- src/Exec_Graft.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 261551106e..028d5a1292 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -208,6 +208,8 @@ const srcBondAtoms[idx]+1, combinedTop.AtomMaskName(srcBondAtoms[idx]).c_str()); combinedTop.AddBond( tgtBondAtoms[idx], srcBondAtoms[idx] ); } + // Regenerate the molecule info FIXME should Topology just do this? + if (combinedTop.DetermineMolecules()) return CpptrajState::ERR; // Only coords+box for now. CoordinateInfo outInfo(mol0frm.BoxCrd(), false, false, false); if (outCoords->CoordsSetup(combinedTop, outInfo)) return CpptrajState::ERR; // FIXME free molXTop memory From 16d728600fd4425717ad52d6bf51bda5c27129d6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 2 Oct 2023 15:57:29 -0400 Subject: [PATCH 093/245] First attempt at "fixing" internal coords --- src/Exec_Graft.cpp | 20 ++++++++++++++++++++ src/Structure/Zmatrix.cpp | 4 ++++ src/Structure/Zmatrix.h | 8 +++++--- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 028d5a1292..64fad3a0e8 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -228,6 +228,26 @@ const return CpptrajState::ERR; } zmatrix.print(); // DEBUG + // Update ICs corresponding to added bonds + for (unsigned int idx = 0; idx != tgtBondAtoms.size(); idx++) { + int a0 = tgtBondAtoms[idx]; + int a1 = srcBondAtoms[idx]; + for (unsigned int icidx = 0; icidx < zmatrix.N_IC(); icidx++) { + if ( (zmatrix[icidx].AtI() == a0 && zmatrix[icidx].AtJ() == a1) || + (zmatrix[icidx].AtI() == a1 && zmatrix[icidx].AtJ() == a0) ) + { + mprintf("DEBUG: Found IC for bond %i %i\n", a0+1, a1+1); + InternalCoords const& oic = zmatrix[icidx]; + // TODO be smarter about these values + InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), 1.6, 120.0, 0.0 ); + zmatrix.SetIC( icidx, newIc ); + } + } // END loop over ICs + } // END loop over bonds + if (zmatrix.SetToFrame( CombinedFrame )) { + mprinterr("Error: Conversion from Zmatrix to Cartesian coords failed.\n"); + return CpptrajState::ERR; + } // Add frame to the output data set outCoords->AddFrame( CombinedFrame ); diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 1b7ff99e52..a95df187a1 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -60,6 +60,10 @@ int Zmatrix::AddIC(InternalCoords const& ic) { return 0; } +void Zmatrix::SetIC(unsigned int idx, InternalCoords const& ic) { + IC_[idx] = ic; +} + /** Add internal coords as a IC seed. This is intended for use with systems * that have dummy atoms, such as those from Amber Prep files. */ diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index f214a8bbf4..eadb375750 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -17,13 +17,15 @@ class Zmatrix { void SetDebug(int d) { debug_ = d; } /// Add internal coordinate int AddIC(InternalCoords const&); + /// Set specified IC + void SetIC(unsigned int, InternalCoords const&); /// Add internal coordinate as next available IC seed //int AddICseed(InternalCoords const&); /// Set seed atoms from frame/top int SetSeedPositions(Frame const&, Topology const&, int, int, int); /// Convert specifed molecule of Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&, int); - /// Convert from Cartesian to Zmatrix by tracing a molecule + /// Convert from Cartesian to Zmatrix by tracing a molecule FIXME fix naming int SetFromFrame_Trace(Frame const&, Topology const&, int); /// Convert molecule 0 of Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&); @@ -37,6 +39,8 @@ class Zmatrix { const_iterator begin() const { return IC_.begin(); } const_iterator end() const { return IC_.end(); } + /// \return Specified internal coord + InternalCoords const& operator[](int idx) const { return IC_[idx]; } /// \return number of internal coords unsigned int N_IC() const { return IC_.size(); } /// \return memory usage in bytes @@ -45,8 +49,6 @@ class Zmatrix { (IC_.size() * InternalCoords::sizeInBytes()); } /// \reserve space for # of internal coords TODO zero out seeds? void reserve(unsigned int n) { IC_.reserve( n ); } - /// \return Internal coord of specified index - InternalCoords const& operator[](int i) const { return IC_[i]; } private: typedef std::vector Iarray; typedef std::vector Barray; From 4ad70e4d437c2727561e353feaadbe62e603132f Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 2 Oct 2023 16:10:46 -0400 Subject: [PATCH 094/245] Ensure mol info regened --- 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 64fad3a0e8..02e7817f70 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -239,7 +239,7 @@ const mprintf("DEBUG: Found IC for bond %i %i\n", a0+1, a1+1); InternalCoords const& oic = zmatrix[icidx]; // TODO be smarter about these values - InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), 1.6, 120.0, 0.0 ); + InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), 1.6, 120.0, 180.0 ); zmatrix.SetIC( icidx, newIc ); } } // END loop over ICs @@ -443,6 +443,8 @@ const // Add any bonds for (unsigned int ii = 0; ii != tgtBondAtoms.size(); ii++) combinedTop.AddBond( tgtBondAtoms[ii], srcBondAtoms[ii] ); + // Regenerate the molecule info FIXME should Topology just do this? + if (combinedTop.DetermineMolecules()) return CpptrajState::ERR; combinedTop.SetParmBox( tgtFrmPtr->BoxCrd() ); combinedTop.Brief("Grafted parm:"); From 09ed564bbc3af7103d1c3e4aaddc38f797069730 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 3 Oct 2023 15:14:44 -0400 Subject: [PATCH 095/245] Add some debug --- src/Exec_Graft.cpp | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 02e7817f70..e0bf7fe9d4 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -4,6 +4,7 @@ #include "Structure/Zmatrix.h" #include // std::copy +using namespace Cpptraj::Structure; // Exec_Graft::Help() void Exec_Graft::Help() const { @@ -127,11 +128,21 @@ Topology* Exec_Graft::modify_top(Topology const& topIn, AtomMask const& mask, Fr return srcTopPtr; } +/// Print IC to stdout +static inline void printIC(InternalCoords const& oic, Topology const& top) +{ + mprintf(" %6i %6i %6i %6i [%s - %s - %s - %s]\n", + oic.AtI()+1, oic.AtJ()+1, oic.AtK()+1, oic.AtL()+1, + top.AtomMaskName(oic.AtI()).c_str(), + top.AtomMaskName(oic.AtJ()).c_str(), + top.AtomMaskName(oic.AtK()).c_str(), + top.AtomMaskName(oic.AtL()).c_str()); +} + /** Graft using internal coordinates to build the final structure. */ Exec::RetType Exec_Graft::graft_ic(CpptrajState& State, ArgList& argIn) const { - using namespace Cpptraj::Structure; // Source (fragment) Frame mol1frm; DataSet_Coords* mol1crd = get_crd(argIn, State.DSL(), "src", "Source COORDS", mol1frm, "srcframe"); @@ -233,14 +244,31 @@ const int a0 = tgtBondAtoms[idx]; int a1 = srcBondAtoms[idx]; for (unsigned int icidx = 0; icidx < zmatrix.N_IC(); icidx++) { - if ( (zmatrix[icidx].AtI() == a0 && zmatrix[icidx].AtJ() == a1) || - (zmatrix[icidx].AtI() == a1 && zmatrix[icidx].AtJ() == a0) ) + InternalCoords const& oic = zmatrix[icidx]; + if ( (oic.AtI() == a0 && oic.AtJ() == a1) || + (oic.AtI() == a1 && oic.AtJ() == a0) ) { - mprintf("DEBUG: Found IC for bond %i %i\n", a0+1, a1+1); - InternalCoords const& oic = zmatrix[icidx]; + // Set dist, theta, phi + double newDist = Atom::GetBondLength( combinedTop[oic.AtI()].Element(), combinedTop[oic.AtJ()].Element() ); + mprintf("DEBUG: Found IC for bond %i %i (i j)", a0+1, a1+1); + printIC(oic, combinedTop); + mprintf("DEBUG:\t\tNew dist= %g\n", newDist); // TODO be smarter about these values - InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), 1.6, 120.0, 180.0 ); + InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), newDist, 120.0, 180.0 ); zmatrix.SetIC( icidx, newIc ); + } else if ( (oic.AtJ() == a0 && oic.AtK() == a1) || + (oic.AtJ() == a1 && oic.AtK() == a0) ) + { + // Set theta, phi + mprintf("DEBUG: Found IC for bond %i %i (j k)", a0+1, a1+1); + printIC(oic, combinedTop); + //InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), oic.Dist(), 120.0, oic.Phi() ); // FIXME phi + //zmatrix.SetIC( icidx, newIc ); + } else if ( (oic.AtK() == a0 && oic.AtL() == a1) || + (oic.AtK() == a1 && oic.AtL() == a0) ) + { + mprintf("DEBUG: Found IC for bond %i %i (k l)", a0+1, a1+1); + printIC(oic, combinedTop); } } // END loop over ICs } // END loop over bonds From e3782d0b54a00f88f38e7b9208ee399b3da3b925 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 3 Oct 2023 15:29:37 -0400 Subject: [PATCH 096/245] Try to Figure out a pattern --- 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 e0bf7fe9d4..bced35533f 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -254,8 +254,8 @@ const printIC(oic, combinedTop); mprintf("DEBUG:\t\tNew dist= %g\n", newDist); // TODO be smarter about these values - InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), newDist, 120.0, 180.0 ); - zmatrix.SetIC( icidx, newIc ); + //InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), newDist, 120.0, 180.0 ); + //zmatrix.SetIC( icidx, newIc ); } else if ( (oic.AtJ() == a0 && oic.AtK() == a1) || (oic.AtJ() == a1 && oic.AtK() == a0) ) { From 20f7d0c5aeecf2b235b82d115559048b0a605c0d Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 5 Oct 2023 07:02:50 -0400 Subject: [PATCH 097/245] DNA graft test --- test/Test_Graft/RunTest.sh | 41 +++++++++++++++++++ test/Test_Graft/template-base-adenine.pdb | 20 +++++++++ .../Test_Graft/template-dimethylphosphate.pdb | 13 ++++++ test/Test_Graft/template-sugar.pdb | 24 +++++++++++ 4 files changed, 98 insertions(+) create mode 100644 test/Test_Graft/template-base-adenine.pdb create mode 100644 test/Test_Graft/template-dimethylphosphate.pdb create mode 100644 test/Test_Graft/template-sugar.pdb diff --git a/test/Test_Graft/RunTest.sh b/test/Test_Graft/RunTest.sh index b2d201f68e..c4bc20d182 100755 --- a/test/Test_Graft/RunTest.sh +++ b/test/Test_Graft/RunTest.sh @@ -34,5 +34,46 @@ EOF RunCpptraj "$TESTNAME" DoTest Final.graft.mol2.save Final.graft.mol2 +# DNA Graft +cat > cpptraj.in < Date: Thu, 5 Oct 2023 07:03:08 -0400 Subject: [PATCH 098/245] Try to take into account ICs bonded to the same atom --- src/Exec_Graft.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index bced35533f..4306e4070b 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -3,6 +3,7 @@ #include "DataSet_Coords.h" #include "Structure/Zmatrix.h" #include // std::copy +#include using namespace Cpptraj::Structure; // Exec_Graft::Help() @@ -139,6 +140,21 @@ static inline void printIC(InternalCoords const& oic, Topology const& top) top.AtomMaskName(oic.AtL()).c_str()); } +/// Hold IC that needs to be reset +class ICholder { + public: + typedef std::vector Uarray; + enum ICtype { IJ = 0, JK, KL, NO_IC_TYPE }; + + ICholder(unsigned int i, ICtype t) : icidxs_(1, i), ictype_(t) {} + void AddIdx(unsigned int i) { icidxs_.push_back(i); } + Uarray const& Idxs() const { return icidxs_; } + ICtype Type() const { return ictype_; } + private: + Uarray icidxs_; ///< Indices of ICs in zmatrix + ICtype ictype_; ///< Type of reset (IJ=all, JK=theta,phi, KL=phi) +}; + /** Graft using internal coordinates to build the final structure. */ Exec::RetType Exec_Graft::graft_ic(CpptrajState& State, ArgList& argIn) const @@ -239,20 +255,27 @@ const return CpptrajState::ERR; } zmatrix.print(); // DEBUG + // Map atom j to ICs to change + typedef std::map ICmapType; + typedef std::pair ICpairType; + ICmapType ICsToChange; // Update ICs corresponding to added bonds for (unsigned int idx = 0; idx != tgtBondAtoms.size(); idx++) { int a0 = tgtBondAtoms[idx]; int a1 = srcBondAtoms[idx]; + // Loop over ICs for (unsigned int icidx = 0; icidx < zmatrix.N_IC(); icidx++) { InternalCoords const& oic = zmatrix[icidx]; + ICholder::ICtype ictype = ICholder::NO_IC_TYPE; if ( (oic.AtI() == a0 && oic.AtJ() == a1) || (oic.AtI() == a1 && oic.AtJ() == a0) ) { // Set dist, theta, phi - double newDist = Atom::GetBondLength( combinedTop[oic.AtI()].Element(), combinedTop[oic.AtJ()].Element() ); mprintf("DEBUG: Found IC for bond %i %i (i j)", a0+1, a1+1); printIC(oic, combinedTop); - mprintf("DEBUG:\t\tNew dist= %g\n", newDist); + ictype = ICholder::IJ; + //double newDist = Atom::GetBondLength( combinedTop[oic.AtI()].Element(), combinedTop[oic.AtJ()].Element() ); + //mprintf("DEBUG:\t\tNew dist= %g\n", newDist); // TODO be smarter about these values //InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), newDist, 120.0, 180.0 ); //zmatrix.SetIC( icidx, newIc ); @@ -262,6 +285,7 @@ const // Set theta, phi mprintf("DEBUG: Found IC for bond %i %i (j k)", a0+1, a1+1); printIC(oic, combinedTop); + ictype = ICholder::JK; //InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), oic.Dist(), 120.0, oic.Phi() ); // FIXME phi //zmatrix.SetIC( icidx, newIc ); } else if ( (oic.AtK() == a0 && oic.AtL() == a1) || @@ -269,9 +293,44 @@ const { mprintf("DEBUG: Found IC for bond %i %i (k l)", a0+1, a1+1); printIC(oic, combinedTop); + ictype = ICholder::KL; + } + if (ictype != ICholder::NO_IC_TYPE) { + ICmapType::iterator it = ICsToChange.lower_bound( oic.AtJ() ); + if (it == ICsToChange.end() || it->first != oic.AtJ()) + ICsToChange.insert( ICpairType(oic.AtJ(), ICholder(icidx, ictype)) ); + else + it->second.AddIdx( icidx ); } } // END loop over ICs } // END loop over bonds + // Loop over ICs to change + for (ICmapType::const_iterator it = ICsToChange.begin(); it != ICsToChange.end(); ++it) { + mprintf("DEBUG: IC atomj= %i :\n", it->first+1); + // FIXME. Probably going to have to fix this if atom j is a chiral center + //double phi = -180.0; + //double interval = 360.0 / it->second.Idxs().size(); + for (ICholder::Uarray::const_iterator jt = it->second.Idxs().begin(); + jt != it->second.Idxs().end(); ++jt) + { + InternalCoords const& oic = zmatrix[*jt]; + mprintf("DEBUG:\t\t"); + printIC(oic, combinedTop); + double dist = oic.Dist(); + double theta = oic.Theta(); + double phi = oic.Phi(); + if (it->second.Type() == ICholder::IJ) { + dist = Atom::GetBondLength( combinedTop[oic.AtI()].Element(), combinedTop[oic.AtJ()].Element() ); + theta = 120.0; + phi = 180.0; + } //else if (it->second.Type() == ICholder::JK) { + //theta = 120.0; + //} + InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), dist, theta, phi ); + zmatrix.SetIC( *jt, newIc ); + //phi += interval; + } + } if (zmatrix.SetToFrame( CombinedFrame )) { mprinterr("Error: Conversion from Zmatrix to Cartesian coords failed.\n"); return CpptrajState::ERR; From 592666cd03bdbc18164fc06a5843fbbbd1d4447f Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 13 Oct 2023 16:12:58 -0400 Subject: [PATCH 099/245] Get rid of duplicated test --- test/Test_Graft/RunTest.sh | 41 -------------------------------------- 1 file changed, 41 deletions(-) diff --git a/test/Test_Graft/RunTest.sh b/test/Test_Graft/RunTest.sh index 359c584eae..c6952006e2 100755 --- a/test/Test_Graft/RunTest.sh +++ b/test/Test_Graft/RunTest.sh @@ -122,46 +122,5 @@ TyrPry DNA DNAcharge -# DNA Graft -cat > cpptraj.in < Date: Sun, 15 Oct 2023 10:12:08 -0400 Subject: [PATCH 100/245] Add ability to save atom indices sorted by priority in Chirality --- src/Chirality.cpp | 12 ++++++++++-- src/Chirality.h | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Chirality.cpp b/src/Chirality.cpp index 4c44a23fac..23e92777af 100644 --- a/src/Chirality.cpp +++ b/src/Chirality.cpp @@ -78,7 +78,8 @@ class priority_element { * 1-2-3-0 * where 0 is the chiral center. Negative is S, positive is R. */ -Chirality::ChiralType Chirality::DetermineChirality(double& tors, int atnum, +Chirality::ChiralType Chirality::DetermineChirality(double& tors, int* AtomIndices, + int atnum, Topology const& topIn, Frame const& frameIn, int debugIn) { @@ -142,6 +143,13 @@ Chirality::ChiralType Chirality::DetermineChirality(double& tors, int atnum, mprintf("\n"); } + if (AtomIndices != 0) { + AtomIndices[0] = priority[0].AtNum(); + AtomIndices[1] = priority[1].AtNum(); + AtomIndices[2] = priority[2].AtNum(); + AtomIndices[3] = atnum; + } + tors = Torsion( frameIn.XYZ(priority[0].AtNum()), frameIn.XYZ(priority[1].AtNum()), frameIn.XYZ(priority[2].AtNum()), @@ -165,5 +173,5 @@ Chirality::ChiralType Chirality::DetermineChirality(int atnum, Frame const& frameIn, int debugIn) { double tors; - return DetermineChirality(tors, atnum, topIn, frameIn, debugIn); + return DetermineChirality(tors, 0, atnum, topIn, frameIn, debugIn); } diff --git a/src/Chirality.h b/src/Chirality.h index 01e02db151..e44bbff82b 100644 --- a/src/Chirality.h +++ b/src/Chirality.h @@ -8,7 +8,7 @@ namespace Chirality { enum ChiralType { ERR = 0, IS_S, IS_R }; /// \return Chirality at specified atom, set torsion value -ChiralType DetermineChirality(double&, int, Topology const&, Frame const&, int); +ChiralType DetermineChirality(double&, int*, int, Topology const&, Frame const&, int); /// \return Chirality at specified atom ChiralType DetermineChirality(int, Topology const&, Frame const&, int); From 0c3f56580172fcc42a466b4737bf8dba8cc51ff6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 15 Oct 2023 11:48:42 -0400 Subject: [PATCH 101/245] Start Model namespace --- src/Structure/Model.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ src/Structure/Model.h | 15 +++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/Structure/Model.cpp create mode 100644 src/Structure/Model.h diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp new file mode 100644 index 0000000000..9f006160c0 --- /dev/null +++ b/src/Structure/Model.cpp @@ -0,0 +1,40 @@ +#include "Model.h" +#include "../CpptrajStdio.h" +#include "../Topology.h" +#include "../Chirality.h" + +using namespace Cpptraj::Structure::Model; + +/** Attempt to assign a reasonable value for phi internal coordinate for atom i + * given that atoms j k and l have known positions. + * j - k + * / \ + * i l + */ +int AssignPhi(double& phi, int ai, int aj, int ak, int al, Topology const& topIn, Frame const& frameIn) +{ + using namespace Cpptraj::Chirality; + // Figure out hybridization and chirality of atom j. + mprintf("DEBUG: AssignPhi for atom j : %s\n", topIn.AtomMaskName(aj).c_str()); + + Atom const& AJ = topIn[aj]; + mprintf("DEBUG:\t\tNbonds: %i\n", AJ.Nbonds()); + + int priority[4]; + double tors = 0; + ChiralType chirality = DetermineChirality(tors, priority, aj, topIn, frameIn, 0); // FIXME debug + if (chirality == ERR) { + mprinterr("Error: Could not determine chirality around atom %s\n", topIn.AtomMaskName(aj).c_str()); + return 1; + } else if (chirality == IS_S) { + mprintf("DEBUG:\t\tChirality is S\n"); + } else { + mprintf("DEBUG:\t\tChirality is R\n"); + } + mprintf("DEBUG:\t\tPriority around J:"); + for (int idx = 0; idx < 3; idx++) + mprintf(" %s", topIn.AtomMaskName(priority[idx]).c_str()); + mprintf("\n"); + + return 0; +} diff --git a/src/Structure/Model.h b/src/Structure/Model.h new file mode 100644 index 0000000000..5a31f8fab4 --- /dev/null +++ b/src/Structure/Model.h @@ -0,0 +1,15 @@ +#ifndef INC_STRUCTURE_MODEL_H +#define INC_STRUCTURE_MODEL_H +class Topology; +class Frame; +namespace Cpptraj { +namespace Structure { +/// Routines to generate model parameters +namespace Model { +/// Given atoms J K and L, attempt to assign a reasonable value for phi for atom I +int AssignPhi(double&, int, int, int, int, Topology const&, Frame const&); + +} // END namespace Model +} // END namespace Structure +} // END namespace Cpptraj +#endif From a0ce4869e4f64c9725427bf0a72feb942883f6b7 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 15 Oct 2023 11:53:45 -0400 Subject: [PATCH 102/245] Add Model, start trying a better phi assignment --- src/Exec_Graft.cpp | 7 +++++++ src/Structure/CMakeLists.txt | 3 ++- src/Structure/structuredepend | 1 + src/Structure/structurefiles | 3 ++- src/cpptrajdepend | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 0520b02265..8278f0ce8c 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -2,6 +2,7 @@ #include "CpptrajStdio.h" #include "DataSet_Coords.h" #include "Structure/Zmatrix.h" +#include "Structure/Model.h" #include // std::copy #include @@ -317,6 +318,11 @@ const ictype = ICholder::IJ; //double newDist = Atom::GetBondLength( combinedTop[oic.AtI()].Element(), combinedTop[oic.AtJ()].Element() ); //mprintf("DEBUG:\t\tNew dist= %g\n", newDist); + double newPhi = 0; + if (Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame)) { + mprinterr("Error: phi assignment failed.\n"); + return CpptrajState::ERR; + } // TODO be smarter about these values //InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), newDist, 120.0, 180.0 ); //zmatrix.SetIC( icidx, newIc ); @@ -332,6 +338,7 @@ const } else if ( (oic.AtK() == a0 && oic.AtL() == a1) || (oic.AtK() == a1 && oic.AtL() == a0) ) { + // Set phi mprintf("DEBUG: Found IC for bond %i %i (k l)", a0+1, a1+1); printIC(oic, combinedTop); ictype = ICholder::KL; diff --git a/src/Structure/CMakeLists.txt b/src/Structure/CMakeLists.txt index de4fbb2379..d5320afb9f 100644 --- a/src/Structure/CMakeLists.txt +++ b/src/Structure/CMakeLists.txt @@ -5,9 +5,10 @@ target_sources(cpptraj_common_obj PRIVATE ${CMAKE_CURRENT_LIST_DIR}/FxnGroupBuilder.cpp ${CMAKE_CURRENT_LIST_DIR}/HisProt.cpp ${CMAKE_CURRENT_LIST_DIR}/InternalCoords.cpp + ${CMAKE_CURRENT_LIST_DIR}/Model.cpp ${CMAKE_CURRENT_LIST_DIR}/StructureRoutines.cpp - ${CMAKE_CURRENT_LIST_DIR}/SugarBuilder.cpp ${CMAKE_CURRENT_LIST_DIR}/Sugar.cpp + ${CMAKE_CURRENT_LIST_DIR}/SugarBuilder.cpp ${CMAKE_CURRENT_LIST_DIR}/SugarLinkAtoms.cpp ${CMAKE_CURRENT_LIST_DIR}/SugarToken.cpp ${CMAKE_CURRENT_LIST_DIR}/Zmatrix.cpp diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index f9b00b1003..11848cbf08 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -3,6 +3,7 @@ FunctionalGroup.o : FunctionalGroup.cpp ../Atom.h ../AtomMap.h ../AtomMask.h ../ FxnGroupBuilder.o : FxnGroupBuilder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h StructureRoutines.h Sugar.h SugarToken.h HisProt.o : HisProt.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h HisProt.h StructureRoutines.h InternalCoords.o : InternalCoords.cpp InternalCoords.h +Model.o : Model.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Model.h StructureRoutines.o : StructureRoutines.cpp ../Atom.h ../CpptrajStdio.h ../NameType.h ../Residue.h ../SymbolExporting.h StructureRoutines.h Sugar.o : Sugar.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Sugar.h SugarToken.h SugarBuilder.o : SugarBuilder.cpp ../ArgList.h ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../CharMask.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajFile.h ../CpptrajStdio.h ../DistRoutines.h ../FileIO.h ../FileName.h ../Frame.h ../ImageOption.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h LinkAtom.h ResStatArray.h StructureRoutines.h Sugar.h SugarBuilder.h SugarLinkAtoms.h SugarToken.h diff --git a/src/Structure/structurefiles b/src/Structure/structurefiles index ea6bded7d2..2810508a12 100644 --- a/src/Structure/structurefiles +++ b/src/Structure/structurefiles @@ -5,9 +5,10 @@ STRUCTURE_SOURCES= \ FxnGroupBuilder.cpp \ HisProt.cpp \ InternalCoords.cpp \ + Model.cpp \ StructureRoutines.cpp \ - SugarBuilder.cpp \ Sugar.cpp \ + SugarBuilder.cpp \ SugarLinkAtoms.cpp \ SugarToken.cpp \ Zmatrix.cpp diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 4cf7d66875..72ff2f19e9 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -304,7 +304,7 @@ Exec_Emin.o : Exec_Emin.cpp Action.h ActionList.h ActionState.h Analysis.h Analy Exec_ExtendedComparison.o : Exec_ExtendedComparison.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_ExtendedComparison.h ExtendedSimilarity.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_Flatten.o : Exec_Flatten.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Flatten.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 ImageOption.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h Structure/InternalCoords.h Structure/Model.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_HmassRepartition.o : Exec_HmassRepartition.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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 EnsembleIn.h EnsembleOutList.h Exec.h Exec_HmassRepartition.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h Trajin_Single.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h From ccdde250859e7c57309e4dc507a76de3f7fcbd2f Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 15 Oct 2023 11:54:25 -0400 Subject: [PATCH 103/245] Update depenencies --- src/cpptrajdepend | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 72ff2f19e9..40ca251f7a 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -436,6 +436,7 @@ Structure/FunctionalGroup.o : Structure/FunctionalGroup.cpp Atom.h AtomMap.h Ato Structure/FxnGroupBuilder.o : Structure/FxnGroupBuilder.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/HisProt.o : Structure/HisProt.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/HisProt.h Structure/StructureRoutines.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/InternalCoords.o : Structure/InternalCoords.cpp Structure/InternalCoords.h +Structure/Model.o : Structure/Model.cpp Atom.h AtomMask.h AtomType.h Box.h Chirality.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Model.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/StructureRoutines.o : Structure/StructureRoutines.cpp Atom.h CpptrajStdio.h NameType.h Residue.h Structure/StructureRoutines.h SymbolExporting.h Structure/Sugar.o : Structure/Sugar.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarBuilder.o : Structure/SugarBuilder.cpp ArgList.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h CharMask.h Chirality.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DistRoutines.h FileIO.h FileName.h Frame.h ImageOption.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/LinkAtom.h Structure/ResStatArray.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarBuilder.h Structure/SugarLinkAtoms.h Structure/SugarToken.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h From d344635ca034766a002ad3c5c193461769b4b408 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 15 Oct 2023 12:41:45 -0400 Subject: [PATCH 104/245] Make unknown chirality a warning, but trap it as an error when determining sugar atom chirality --- src/Chirality.cpp | 10 ++++++++-- src/Chirality.h | 2 +- src/Structure/SugarBuilder.cpp | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Chirality.cpp b/src/Chirality.cpp index 23e92777af..d26124479f 100644 --- a/src/Chirality.cpp +++ b/src/Chirality.cpp @@ -125,9 +125,15 @@ Chirality::ChiralType Chirality::DetermineChirality(double& tors, int* AtomIndic break; } if (depth == 10) { - mprinterr("Error: Could not determine priority around '%s'\n", + mprintf("Warning: Could not determine priority around '%s'\n", topIn.AtomMaskName(atnum).c_str()); - return ERR; + if (AtomIndices != 0) { + AtomIndices[0] = priority[0].AtNum(); + AtomIndices[1] = priority[1].AtNum(); + AtomIndices[2] = priority[2].AtNum(); + AtomIndices[3] = atnum; + } + return IS_UNKNOWN_CHIRALITY; } depth++; } // END while identical priorities diff --git a/src/Chirality.h b/src/Chirality.h index e44bbff82b..4bc4abf3ae 100644 --- a/src/Chirality.h +++ b/src/Chirality.h @@ -5,7 +5,7 @@ class Frame; namespace Cpptraj { namespace Chirality { -enum ChiralType { ERR = 0, IS_S, IS_R }; +enum ChiralType { ERR = 0, IS_S, IS_R, IS_UNKNOWN_CHIRALITY }; /// \return Chirality at specified atom, set torsion value ChiralType DetermineChirality(double&, int*, int, Topology const&, Frame const&, int); diff --git a/src/Structure/SugarBuilder.cpp b/src/Structure/SugarBuilder.cpp index 7322bf9ded..e60368b356 100644 --- a/src/Structure/SugarBuilder.cpp +++ b/src/Structure/SugarBuilder.cpp @@ -1116,7 +1116,7 @@ const Cpptraj::Chirality::ChiralType ctypeR = Cpptraj::Chirality:: DetermineChirality(sugar.HighestStereocenter(), topIn, frameIn, cdebug); - if (ctypeR == Cpptraj::Chirality::ERR) { + if (ctypeR == Cpptraj::Chirality::ERR || ctypeR == Cpptraj::Chirality::IS_UNKNOWN_CHIRALITY) { mprinterr("Error: Could not determine configuration for furanose.\n"); // TODO warn? return 1; } @@ -1128,7 +1128,7 @@ const Cpptraj::Chirality::ChiralType ctypeA = Cpptraj::Chirality:: DetermineChirality(sugar.AnomericAtom(), topIn, frameIn, cdebug); - if (ctypeA == Cpptraj::Chirality::ERR) { + if (ctypeA == Cpptraj::Chirality::ERR || ctypeA == Cpptraj::Chirality::IS_UNKNOWN_CHIRALITY) { mprinterr("Error: Could not determine chirality around anomeric atom for furanose.\n"); // TODO warn? return 1; } From d07772aab21d2aa913e50c0d007d2e1570632957 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 15 Oct 2023 12:48:17 -0400 Subject: [PATCH 105/245] Add concept of 'known' and 'unknown' atom positions to graft. Idea is to build pseudo coordinates out for use in determinining good values for internal coordinates. --- src/Exec_Graft.cpp | 17 ++++++++++++++++- src/Structure/Model.cpp | 27 ++++++++++++++++++++++----- src/Structure/Model.h | 3 ++- src/Structure/structuredepend | 2 +- src/cpptrajdepend | 2 +- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 8278f0ce8c..6e7cd2bb75 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -288,6 +288,11 @@ const std::copy(mol1frm.xAddress(), mol1frm.xAddress()+mol1frm.size(), CombinedFrame.xAddress()+mol0frm.size()); // Use target box TODO reset the box? CombinedFrame.SetBox( mol0frm.BoxCrd() ); + // Declare source atoms as 'known'. Source atoms are in residue 1 + typedef std::vector Barray; + Barray atomPositionKnown( combinedTop.Natom(), false ); + for (int aidx = combinedTop.Res(1).FirstAtom(); aidx != combinedTop.Res(1).LastAtom(); aidx++) + atomPositionKnown[aidx] = true; // Generate Z matrix FIXME ensure mol 0 is the one we are interested in Zmatrix zmatrix; @@ -319,7 +324,7 @@ const //double newDist = Atom::GetBondLength( combinedTop[oic.AtI()].Element(), combinedTop[oic.AtJ()].Element() ); //mprintf("DEBUG:\t\tNew dist= %g\n", newDist); double newPhi = 0; - if (Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame)) { + if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown)) { mprinterr("Error: phi assignment failed.\n"); return CpptrajState::ERR; } @@ -333,6 +338,11 @@ const mprintf("DEBUG: Found IC for bond %i %i (j k)", a0+1, a1+1); printIC(oic, combinedTop); ictype = ICholder::JK; + double newPhi = 0; + if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown)) { + mprinterr("Error: phi assignment failed.\n"); + return CpptrajState::ERR; + } //InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), oic.Dist(), 120.0, oic.Phi() ); // FIXME phi //zmatrix.SetIC( icidx, newIc ); } else if ( (oic.AtK() == a0 && oic.AtL() == a1) || @@ -342,6 +352,11 @@ const mprintf("DEBUG: Found IC for bond %i %i (k l)", a0+1, a1+1); printIC(oic, combinedTop); ictype = ICholder::KL; + double newPhi = 0; + if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown)) { + mprinterr("Error: phi assignment failed.\n"); + return CpptrajState::ERR; + } } if (ictype != ICholder::NO_IC_TYPE) { ICmapType::iterator it = ICsToChange.lower_bound( oic.AtJ() ); diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index 9f006160c0..6924efa639 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -2,8 +2,8 @@ #include "../CpptrajStdio.h" #include "../Topology.h" #include "../Chirality.h" - -using namespace Cpptraj::Structure::Model; +#include "../TorsionRoutines.h" +#include "../Constants.h" /** Attempt to assign a reasonable value for phi internal coordinate for atom i * given that atoms j k and l have known positions. @@ -11,7 +11,7 @@ using namespace Cpptraj::Structure::Model; * / \ * i l */ -int AssignPhi(double& phi, int ai, int aj, int ak, int al, Topology const& topIn, Frame const& frameIn) +int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, int al, Topology const& topIn, Frame const& frameIn, std::vector const& atomPositionKnown) { using namespace Cpptraj::Chirality; // Figure out hybridization and chirality of atom j. @@ -20,12 +20,16 @@ int AssignPhi(double& phi, int ai, int aj, int ak, int al, Topology const& topIn Atom const& AJ = topIn[aj]; mprintf("DEBUG:\t\tNbonds: %i\n", AJ.Nbonds()); + // FIXME aj ak and al should be known + // TODO check that atom i actually ends up on the list? int priority[4]; double tors = 0; ChiralType chirality = DetermineChirality(tors, priority, aj, topIn, frameIn, 0); // FIXME debug if (chirality == ERR) { - mprinterr("Error: Could not determine chirality around atom %s\n", topIn.AtomMaskName(aj).c_str()); + mprinterr("Error: Problem determining chirality around atom %s\n", topIn.AtomMaskName(aj).c_str()); return 1; + } else if (chirality == IS_UNKNOWN_CHIRALITY) { + mprintf("DEBUG:\t\tChirality is unknown\n"); } else if (chirality == IS_S) { mprintf("DEBUG:\t\tChirality is S\n"); } else { @@ -33,8 +37,21 @@ int AssignPhi(double& phi, int ai, int aj, int ak, int al, Topology const& topIn } mprintf("DEBUG:\t\tPriority around J:"); for (int idx = 0; idx < 3; idx++) - mprintf(" %s", topIn.AtomMaskName(priority[idx]).c_str()); + mprintf(" %s(%i)", topIn.AtomMaskName(priority[idx]).c_str(), (int)atomPositionKnown[priority[idx]]); mprintf("\n"); + // Fill in what values we can for known atoms + double knownPhi[3]; + for (int idx = 0; idx < 3; idx++) { + int atnum = priority[idx]; + if (atnum != ak && atomPositionKnown[atnum]) { + knownPhi[idx] = Torsion(frameIn.XYZ(atnum), + frameIn.XYZ(aj), + frameIn.XYZ(ak), + frameIn.XYZ(al)); + mprintf("DEBUG:\t\tKnown phi for %s = %g\n", topIn.AtomMaskName(atnum).c_str(), knownPhi[idx]*Constants::RADDEG); + } + } + return 0; } diff --git a/src/Structure/Model.h b/src/Structure/Model.h index 5a31f8fab4..90dacf540f 100644 --- a/src/Structure/Model.h +++ b/src/Structure/Model.h @@ -1,5 +1,6 @@ #ifndef INC_STRUCTURE_MODEL_H #define INC_STRUCTURE_MODEL_H +#include class Topology; class Frame; namespace Cpptraj { @@ -7,7 +8,7 @@ namespace Structure { /// Routines to generate model parameters namespace Model { /// Given atoms J K and L, attempt to assign a reasonable value for phi for atom I -int AssignPhi(double&, int, int, int, int, Topology const&, Frame const&); +int AssignPhi(double&, int, int, int, int, Topology const&, Frame const&, std::vector const&); } // END namespace Model } // END namespace Structure diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index 11848cbf08..74df765c8a 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -3,7 +3,7 @@ FunctionalGroup.o : FunctionalGroup.cpp ../Atom.h ../AtomMap.h ../AtomMask.h ../ FxnGroupBuilder.o : FxnGroupBuilder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h StructureRoutines.h Sugar.h SugarToken.h HisProt.o : HisProt.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h HisProt.h StructureRoutines.h InternalCoords.o : InternalCoords.cpp InternalCoords.h -Model.o : Model.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Model.h +Model.o : Model.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Model.h StructureRoutines.o : StructureRoutines.cpp ../Atom.h ../CpptrajStdio.h ../NameType.h ../Residue.h ../SymbolExporting.h StructureRoutines.h Sugar.o : Sugar.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Sugar.h SugarToken.h SugarBuilder.o : SugarBuilder.cpp ../ArgList.h ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../CharMask.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajFile.h ../CpptrajStdio.h ../DistRoutines.h ../FileIO.h ../FileName.h ../Frame.h ../ImageOption.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h LinkAtom.h ResStatArray.h StructureRoutines.h Sugar.h SugarBuilder.h SugarLinkAtoms.h SugarToken.h diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 40ca251f7a..b91620bae2 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -436,7 +436,7 @@ Structure/FunctionalGroup.o : Structure/FunctionalGroup.cpp Atom.h AtomMap.h Ato Structure/FxnGroupBuilder.o : Structure/FxnGroupBuilder.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/HisProt.o : Structure/HisProt.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/HisProt.h Structure/StructureRoutines.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/InternalCoords.o : Structure/InternalCoords.cpp Structure/InternalCoords.h -Structure/Model.o : Structure/Model.cpp Atom.h AtomMask.h AtomType.h Box.h Chirality.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Model.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h +Structure/Model.o : Structure/Model.cpp Atom.h AtomMask.h AtomType.h Box.h Chirality.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Model.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Structure/StructureRoutines.o : Structure/StructureRoutines.cpp Atom.h CpptrajStdio.h NameType.h Residue.h Structure/StructureRoutines.h SymbolExporting.h Structure/Sugar.o : Structure/Sugar.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarBuilder.o : Structure/SugarBuilder.cpp ArgList.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h CharMask.h Chirality.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DistRoutines.h FileIO.h FileName.h Frame.h ImageOption.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/LinkAtom.h Structure/ResStatArray.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarBuilder.h Structure/SugarLinkAtoms.h Structure/SugarToken.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h From eabe003bd906c5ed74bab3351f233e860b7a33c3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 15 Oct 2023 12:59:00 -0400 Subject: [PATCH 106/245] Dont hardcode the number of bonds. Start trying to determine a reasonable interval for phi around atom j. --- src/Structure/Model.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index 6924efa639..1ef3c398cd 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -22,8 +22,10 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in // FIXME aj ak and al should be known // TODO check that atom i actually ends up on the list? - int priority[4]; + std::vector Priority( AJ.Nbonds() + 1 ); + int* priority = static_cast( &Priority[0] ); double tors = 0; + // DetermineChirality will always put aj as the last index. ChiralType chirality = DetermineChirality(tors, priority, aj, topIn, frameIn, 0); // FIXME debug if (chirality == ERR) { mprinterr("Error: Problem determining chirality around atom %s\n", topIn.AtomMaskName(aj).c_str()); @@ -36,13 +38,13 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in mprintf("DEBUG:\t\tChirality is R\n"); } mprintf("DEBUG:\t\tPriority around J:"); - for (int idx = 0; idx < 3; idx++) + for (int idx = 0; idx < AJ.Nbonds(); idx++) mprintf(" %s(%i)", topIn.AtomMaskName(priority[idx]).c_str(), (int)atomPositionKnown[priority[idx]]); mprintf("\n"); // Fill in what values we can for known atoms - double knownPhi[3]; - for (int idx = 0; idx < 3; idx++) { + std::vector knownPhi( AJ.Nbonds() ); + for (int idx = 0; idx < AJ.Nbonds(); idx++) { int atnum = priority[idx]; if (atnum != ak && atomPositionKnown[atnum]) { knownPhi[idx] = Torsion(frameIn.XYZ(atnum), @@ -53,5 +55,11 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in } } + if (AJ.Nbonds() > 1) { + // The interval will be 360 / (number of bonds - 1) + double interval = Constants::TWOPI / (AJ.Nbonds() - 1); + mprintf("DEBUG:\t\tInterval is %g degrees\n", interval * Constants::RADDEG); + } + return 0; } From 3ec253a389688ea7a4b8345ee61c848ef3e879b6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 15 Oct 2023 21:30:00 -0400 Subject: [PATCH 107/245] Fix saving priorities. Code for assigning phi based on atom priority. Not sure if need to correct for R vs S. --- src/Chirality.cpp | 17 ++++++----------- src/Structure/Model.cpp | 32 +++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/Chirality.cpp b/src/Chirality.cpp index d26124479f..5fe893b46d 100644 --- a/src/Chirality.cpp +++ b/src/Chirality.cpp @@ -101,6 +101,7 @@ Chirality::ChiralType Chirality::DetermineChirality(double& tors, int* AtomIndic mprintf("DEBUG:\t\t%i Priority for %s is %i\n", idx, topIn.AtomMaskName(atom.Bond(idx)).c_str(), priority.back().Priority1()); } // For any identical priorities, need to check who they are bonded to. + bool depth_limit_hit = false; for (int idx1 = 0; idx1 != atom.Nbonds(); idx1++) { for (int idx2 = idx1+1; idx2 != atom.Nbonds(); idx2++) { if (priority[idx1] == priority[idx2]) { @@ -127,13 +128,8 @@ Chirality::ChiralType Chirality::DetermineChirality(double& tors, int* AtomIndic if (depth == 10) { mprintf("Warning: Could not determine priority around '%s'\n", topIn.AtomMaskName(atnum).c_str()); - if (AtomIndices != 0) { - AtomIndices[0] = priority[0].AtNum(); - AtomIndices[1] = priority[1].AtNum(); - AtomIndices[2] = priority[2].AtNum(); - AtomIndices[3] = atnum; - } - return IS_UNKNOWN_CHIRALITY; + depth_limit_hit = true; + break; } depth++; } // END while identical priorities @@ -150,11 +146,10 @@ Chirality::ChiralType Chirality::DetermineChirality(double& tors, int* AtomIndic } if (AtomIndices != 0) { - AtomIndices[0] = priority[0].AtNum(); - AtomIndices[1] = priority[1].AtNum(); - AtomIndices[2] = priority[2].AtNum(); - AtomIndices[3] = atnum; + for (unsigned int ip = 0; ip != priority.size(); ++ip) + AtomIndices[ip] = priority[ip].AtNum(); } + if (depth_limit_hit) return IS_UNKNOWN_CHIRALITY; tors = Torsion( frameIn.XYZ(priority[0].AtNum()), frameIn.XYZ(priority[1].AtNum()), diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index 1ef3c398cd..6d6a8ec8a5 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -22,11 +22,11 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in // FIXME aj ak and al should be known // TODO check that atom i actually ends up on the list? - std::vector Priority( AJ.Nbonds() + 1 ); + std::vector Priority( AJ.Nbonds() ); int* priority = static_cast( &Priority[0] ); double tors = 0; // DetermineChirality will always put aj as the last index. - ChiralType chirality = DetermineChirality(tors, priority, aj, topIn, frameIn, 0); // FIXME debug + ChiralType chirality = DetermineChirality(tors, priority, aj, topIn, frameIn, 1); // FIXME debug if (chirality == ERR) { mprinterr("Error: Problem determining chirality around atom %s\n", topIn.AtomMaskName(aj).c_str()); return 1; @@ -37,13 +37,14 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in } else { mprintf("DEBUG:\t\tChirality is R\n"); } - mprintf("DEBUG:\t\tPriority around J:"); + mprintf("DEBUG:\t\tPriority around J (tors=%g):", tors*Constants::RADDEG); for (int idx = 0; idx < AJ.Nbonds(); idx++) mprintf(" %s(%i)", topIn.AtomMaskName(priority[idx]).c_str(), (int)atomPositionKnown[priority[idx]]); mprintf("\n"); // Fill in what values we can for known atoms std::vector knownPhi( AJ.Nbonds() ); + int knownIdx = -1; for (int idx = 0; idx < AJ.Nbonds(); idx++) { int atnum = priority[idx]; if (atnum != ak && atomPositionKnown[atnum]) { @@ -52,13 +53,38 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in frameIn.XYZ(ak), frameIn.XYZ(al)); mprintf("DEBUG:\t\tKnown phi for %s = %g\n", topIn.AtomMaskName(atnum).c_str(), knownPhi[idx]*Constants::RADDEG); + if (knownIdx == -1) knownIdx = idx; // FIXME handle more than 1 known } } + double startPhi; + if (knownIdx == -1) { + mprintf("DEBUG:\t\tNo known phi. Setting to 0.\n"); + knownIdx = 0; + startPhi = 0; + } else + startPhi = knownPhi[knownIdx]; if (AJ.Nbonds() > 1) { // The interval will be 360 / (number of bonds - 1) double interval = Constants::TWOPI / (AJ.Nbonds() - 1); mprintf("DEBUG:\t\tInterval is %g degrees\n", interval * Constants::RADDEG); + // Forward direction + double currentPhi = startPhi; + for (int idx = knownIdx; idx < AJ.Nbonds(); idx++) { + int atnum = priority[idx]; + if (atnum != ak) { + mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); + currentPhi += interval; + } + } + currentPhi = startPhi - interval; + for (int idx = knownIdx - 1; idx > -1; idx--) { + int atnum = priority[idx]; + if (atnum != ak) { + mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); + currentPhi -= interval; + } + } } return 0; From 4ee92e7c0d08ae0c73ed1050641e07ae24725cf9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 15 Oct 2023 22:00:33 -0400 Subject: [PATCH 108/245] Actually assign phi --- src/Exec_Graft.cpp | 3 +++ src/Structure/Model.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 6e7cd2bb75..23ee752e1b 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -328,6 +328,7 @@ const mprinterr("Error: phi assignment failed.\n"); return CpptrajState::ERR; } + mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); // TODO be smarter about these values //InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), newDist, 120.0, 180.0 ); //zmatrix.SetIC( icidx, newIc ); @@ -343,6 +344,7 @@ const mprinterr("Error: phi assignment failed.\n"); return CpptrajState::ERR; } + mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); //InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), oic.Dist(), 120.0, oic.Phi() ); // FIXME phi //zmatrix.SetIC( icidx, newIc ); } else if ( (oic.AtK() == a0 && oic.AtL() == a1) || @@ -357,6 +359,7 @@ const mprinterr("Error: phi assignment failed.\n"); return CpptrajState::ERR; } + mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); } if (ictype != ICholder::NO_IC_TYPE) { ICmapType::iterator it = ICsToChange.lower_bound( oic.AtJ() ); diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index 6d6a8ec8a5..4eeaf9587f 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -73,6 +73,7 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in for (int idx = knownIdx; idx < AJ.Nbonds(); idx++) { int atnum = priority[idx]; if (atnum != ak) { + if (atnum == ai) phi = currentPhi; mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); currentPhi += interval; } @@ -81,6 +82,7 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in for (int idx = knownIdx - 1; idx > -1; idx--) { int atnum = priority[idx]; if (atnum != ak) { + if (atnum == ai) phi = currentPhi; mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); currentPhi -= interval; } From fc288bcdd5ab09ac2839eb8789aee6bab34d28d5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 15 Oct 2023 22:46:00 -0400 Subject: [PATCH 109/245] Add angle assignment routine. Use new assignment routines. --- src/Exec_Graft.cpp | 32 +++++++++++++++++++++++--------- src/Structure/Model.cpp | 39 +++++++++++++++++++++++++++++++++++++++ src/Structure/Model.h | 2 ++ 3 files changed, 64 insertions(+), 9 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 23ee752e1b..6fba4addcf 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -321,8 +321,14 @@ const mprintf("DEBUG: Found IC for bond %i %i (i j)", a0+1, a1+1); printIC(oic, combinedTop); ictype = ICholder::IJ; - //double newDist = Atom::GetBondLength( combinedTop[oic.AtI()].Element(), combinedTop[oic.AtJ()].Element() ); - //mprintf("DEBUG:\t\tNew dist= %g\n", newDist); + double newDist = Atom::GetBondLength( combinedTop[oic.AtI()].Element(), combinedTop[oic.AtJ()].Element() ); + mprintf("DEBUG:\t\tnewDist= %g\n", newDist); + double newTheta = 0; + if (Cpptraj::Structure::Model::AssignTheta(newTheta, oic.AtI(), oic.AtJ(), oic.AtK(), combinedTop, CombinedFrame, atomPositionKnown)) { + mprinterr("Error: theta assignment failed.\n"); + return CpptrajState::ERR; + } + mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); double newPhi = 0; if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown)) { mprinterr("Error: phi assignment failed.\n"); @@ -330,8 +336,8 @@ const } mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); // TODO be smarter about these values - //InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), newDist, 120.0, 180.0 ); - //zmatrix.SetIC( icidx, newIc ); + InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), newDist, newTheta*Constants::RADDEG, newPhi*Constants::RADDEG ); + zmatrix.SetIC( icidx, newIc ); } else if ( (oic.AtJ() == a0 && oic.AtK() == a1) || (oic.AtJ() == a1 && oic.AtK() == a0) ) { @@ -339,14 +345,20 @@ const mprintf("DEBUG: Found IC for bond %i %i (j k)", a0+1, a1+1); printIC(oic, combinedTop); ictype = ICholder::JK; + double newTheta = 0; + if (Cpptraj::Structure::Model::AssignTheta(newTheta, oic.AtI(), oic.AtJ(), oic.AtK(), combinedTop, CombinedFrame, atomPositionKnown)) { + mprinterr("Error: theta assignment failed.\n"); + return CpptrajState::ERR; + } + mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); double newPhi = 0; if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown)) { mprinterr("Error: phi assignment failed.\n"); return CpptrajState::ERR; } - mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); - //InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), oic.Dist(), 120.0, oic.Phi() ); // FIXME phi - //zmatrix.SetIC( icidx, newIc ); + mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); // FIXME Internal coords should be radians + InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), oic.Dist(), newTheta*Constants::RADDEG, newPhi*Constants::RADDEG ); + zmatrix.SetIC( icidx, newIc ); } else if ( (oic.AtK() == a0 && oic.AtL() == a1) || (oic.AtK() == a1 && oic.AtL() == a0) ) { @@ -360,6 +372,8 @@ const return CpptrajState::ERR; } mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); + InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), oic.Dist(), oic.Theta(), newPhi*Constants::RADDEG ); + zmatrix.SetIC( icidx, newIc ); } if (ictype != ICholder::NO_IC_TYPE) { ICmapType::iterator it = ICsToChange.lower_bound( oic.AtJ() ); @@ -382,7 +396,7 @@ const InternalCoords const& oic = zmatrix[*jt]; mprintf("DEBUG:\t\t"); printIC(oic, combinedTop); - double dist = oic.Dist(); + /*double dist = oic.Dist(); double theta = oic.Theta(); double phi = oic.Phi(); if (it->second.Type() == ICholder::IJ) { @@ -394,7 +408,7 @@ const //} InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), dist, theta, phi ); zmatrix.SetIC( *jt, newIc ); - //phi += interval; + //phi += interval;*/ } } if (zmatrix.SetToFrame( CombinedFrame )) { diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index 4eeaf9587f..56bde6eb3e 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -5,6 +5,45 @@ #include "../TorsionRoutines.h" #include "../Constants.h" +/** Attempt to assign a reasonable value for theta internal coordinate for + * atom i given that atoms j and k have known positions. + */ +int Cpptraj::Structure::Model::AssignTheta(double& theta, int ai, int aj, int ak, Topology const& topIn, Frame const& frameIn, std::vector const& atomPositionKnown) +{ + // Figure out hybridization and chirality of atom j. + mprintf("DEBUG: AssignTheta for atom j : %s\n", topIn.AtomMaskName(aj).c_str()); + + Atom const& AJ = topIn[aj]; + mprintf("DEBUG:\t\tNbonds: %i\n", AJ.Nbonds()); + // Fill in what values we can for known atoms + std::vector knownTheta( AJ.Nbonds() ); + int knownIdx = -1; + for (int idx = 0; idx < AJ.Nbonds(); idx++) { + int atnum = AJ.Bond(idx); + if (atnum != ak && atomPositionKnown[atnum]) { + knownTheta[idx] = CalcAngle(frameIn.XYZ(atnum), + frameIn.XYZ(aj), + frameIn.XYZ(ak)); + mprintf("DEBUG:\t\tKnown theta for %s = %g\n", topIn.AtomMaskName(atnum).c_str(), knownTheta[idx]*Constants::RADDEG); + if (knownIdx == -1) knownIdx = idx; // FIXME handle more than 1 known + } + } + if (knownIdx == -1) { + mprintf("DEBUG:\t\tNo known theta.\n"); + // Assign a theta based on hybridization + switch (AJ.Nbonds()) { + case 4 : theta = 109.5 * Constants::DEGRAD; break; + case 3 : theta = 120.0 * Constants::DEGRAD; break; + case 2 : theta = 180.0 * Constants::DEGRAD; break; + default : mprinterr("Internal Error: AssignTheta(): Unhandled # bonds for %s (%i)\n", topIn.AtomMaskName(aj).c_str(), AJ.Nbonds()); return 1; + } + } else { + theta = knownTheta[knownIdx]; // TODO just use above guess via hybrid? + } + + return 0; +} + /** Attempt to assign a reasonable value for phi internal coordinate for atom i * given that atoms j k and l have known positions. * j - k diff --git a/src/Structure/Model.h b/src/Structure/Model.h index 90dacf540f..975e41fd2c 100644 --- a/src/Structure/Model.h +++ b/src/Structure/Model.h @@ -9,6 +9,8 @@ namespace Structure { namespace Model { /// Given atoms J K and L, attempt to assign a reasonable value for phi for atom I int AssignPhi(double&, int, int, int, int, Topology const&, Frame const&, std::vector const&); +/// Given atoms J and K, attempt to assign a reasonable value for theta for atom I +int AssignTheta(double&, int, int, int, Topology const&, Frame const&, std::vector const&); } // END namespace Model } // END namespace Structure From f5d82daac361b640f7f2bbb15ca52312f0e0dfb2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 15 Oct 2023 23:31:18 -0400 Subject: [PATCH 110/245] Try to be more clever about what atom positions are known --- src/Exec_Graft.cpp | 19 +++++++++++++++++-- src/Structure/Model.cpp | 16 ++++++++++------ test/Test_Graft/RunTest.sh | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 6fba4addcf..b3e9b5f064 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -290,9 +290,9 @@ const CombinedFrame.SetBox( mol0frm.BoxCrd() ); // Declare source atoms as 'known'. Source atoms are in residue 1 typedef std::vector Barray; - Barray atomPositionKnown( combinedTop.Natom(), false ); + Barray atomPositionKnown;/*( combinedTop.Natom(), false ); for (int aidx = combinedTop.Res(1).FirstAtom(); aidx != combinedTop.Res(1).LastAtom(); aidx++) - atomPositionKnown[aidx] = true; + atomPositionKnown[aidx] = true;*/ // Generate Z matrix FIXME ensure mol 0 is the one we are interested in Zmatrix zmatrix; @@ -317,6 +317,21 @@ const if ( (oic.AtI() == a0 && oic.AtJ() == a1) || (oic.AtI() == a1 && oic.AtJ() == a0) ) { + if (!atomPositionKnown.empty()) { + mprinterr("Internal Error: i j IC is not first one encountered.\n"); + return CpptrajState::ERR; + } + // Declare atoms in residue with j k l atoms as 'known' + if ( combinedTop[oic.AtJ()].ResNum() != combinedTop[oic.AtK()].ResNum() || + combinedTop[oic.AtJ()].ResNum() != combinedTop[oic.AtL()].ResNum() ) + { + mprinterr("Internal Error: j k l atoms not part of same residue for i j IC.\n"); + return CpptrajState::ERR; + } + int jresnum = combinedTop[oic.AtJ()].ResNum(); + atomPositionKnown.assign( combinedTop.Natom(), false ); + for (int aidx = combinedTop.Res(jresnum).FirstAtom(); aidx != combinedTop.Res(jresnum).LastAtom(); aidx++) + atomPositionKnown[aidx] = true; // Set dist, theta, phi mprintf("DEBUG: Found IC for bond %i %i (i j)", a0+1, a1+1); printIC(oic, combinedTop); diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index 56bde6eb3e..d34f72c4cc 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -16,7 +16,7 @@ int Cpptraj::Structure::Model::AssignTheta(double& theta, int ai, int aj, int ak Atom const& AJ = topIn[aj]; mprintf("DEBUG:\t\tNbonds: %i\n", AJ.Nbonds()); // Fill in what values we can for known atoms - std::vector knownTheta( AJ.Nbonds() ); +/* std::vector knownTheta( AJ.Nbonds() ); int knownIdx = -1; for (int idx = 0; idx < AJ.Nbonds(); idx++) { int atnum = AJ.Bond(idx); @@ -28,18 +28,18 @@ int Cpptraj::Structure::Model::AssignTheta(double& theta, int ai, int aj, int ak if (knownIdx == -1) knownIdx = idx; // FIXME handle more than 1 known } } - if (knownIdx == -1) { - mprintf("DEBUG:\t\tNo known theta.\n"); + if (knownIdx == -1) {*/ + //mprintf("DEBUG:\t\tNo known theta.\n"); // Assign a theta based on hybridization switch (AJ.Nbonds()) { case 4 : theta = 109.5 * Constants::DEGRAD; break; case 3 : theta = 120.0 * Constants::DEGRAD; break; case 2 : theta = 180.0 * Constants::DEGRAD; break; default : mprinterr("Internal Error: AssignTheta(): Unhandled # bonds for %s (%i)\n", topIn.AtomMaskName(aj).c_str(), AJ.Nbonds()); return 1; - } + }/* } else { theta = knownTheta[knownIdx]; // TODO just use above guess via hybrid? - } + }*/ return 0; } @@ -86,7 +86,11 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in int knownIdx = -1; for (int idx = 0; idx < AJ.Nbonds(); idx++) { int atnum = priority[idx]; - if (atnum != ak && atomPositionKnown[atnum]) { + if (atnum != ak && atomPositionKnown[atnum] && + atomPositionKnown[aj] && + atomPositionKnown[ak] && + atomPositionKnown[al]) + { knownPhi[idx] = Torsion(frameIn.XYZ(atnum), frameIn.XYZ(aj), frameIn.XYZ(ak), diff --git a/test/Test_Graft/RunTest.sh b/test/Test_Graft/RunTest.sh index c6952006e2..24cf119331 100755 --- a/test/Test_Graft/RunTest.sh +++ b/test/Test_Graft/RunTest.sh @@ -2,7 +2,8 @@ . ../MasterTest.sh -CleanFiles cpptraj.in Final.graft.mol2 Nucleotide.pdb Nucleotide.mol2 +CleanFiles cpptraj.in Final.graft.mol2 Nucleotide.pdb Nucleotide.mol2 \ + IC.Final.graft.mol2 TESTNAME='Graft test' Requires notparallel @@ -31,12 +32,39 @@ graft \ tgtmask @C,O,CA,HA,N,H,CB,HB2,HB3 \ bond :1@CB,:1@C2 crdout Final Final.graft.mol2 - +zmatrix Final out zFinal.dat EOF RunCpptraj "$TESTNAME, Prenylated Tyrosine" DoTest Final.graft.mol2.save Final.graft.mol2 } +# Combine Tyr FF14SB backbone + CB with PRY fragment, use internal coords +TyrPryIC() { + cat > cpptraj.in < cpptraj.in < Date: Mon, 16 Oct 2023 01:38:57 -0400 Subject: [PATCH 111/245] Fix phi assignment based on valid internal chiralities --- src/Exec_Graft.cpp | 12 ++++++++++++ src/Structure/Model.cpp | 22 +++++++++++++++++++--- src/Structure/Zmatrix.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/Structure/Zmatrix.h | 3 +++ 4 files changed, 71 insertions(+), 3 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index b3e9b5f064..4726f1c39d 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -353,6 +353,10 @@ const // TODO be smarter about these values InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), newDist, newTheta*Constants::RADDEG, newPhi*Constants::RADDEG ); zmatrix.SetIC( icidx, newIc ); + // Update frame + //Vec3 posI = Zmatrix::AtomIposition( newIc, CombinedFrame ); + //CombinedFrame.SetXYZ( newIc.AtI(), posI ); + //atomPositionKnown[newIc.AtI()] = true; } else if ( (oic.AtJ() == a0 && oic.AtK() == a1) || (oic.AtJ() == a1 && oic.AtK() == a0) ) { @@ -374,6 +378,10 @@ const mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); // FIXME Internal coords should be radians InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), oic.Dist(), newTheta*Constants::RADDEG, newPhi*Constants::RADDEG ); zmatrix.SetIC( icidx, newIc ); + // Update frame + //Vec3 posI = Zmatrix::AtomIposition( newIc, CombinedFrame ); + //CombinedFrame.SetXYZ( newIc.AtI(), posI ); + //atomPositionKnown[newIc.AtI()] = true; } else if ( (oic.AtK() == a0 && oic.AtL() == a1) || (oic.AtK() == a1 && oic.AtL() == a0) ) { @@ -389,6 +397,10 @@ const mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), oic.Dist(), oic.Theta(), newPhi*Constants::RADDEG ); zmatrix.SetIC( icidx, newIc ); + // Update frame + //Vec3 posI = Zmatrix::AtomIposition( newIc, CombinedFrame ); + //CombinedFrame.SetXYZ( newIc.AtI(), posI ); + //atomPositionKnown[newIc.AtI()] = true; } if (ictype != ICholder::NO_IC_TYPE) { ICmapType::iterator it = ICsToChange.lower_bound( oic.AtJ() ); diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index d34f72c4cc..f53d24dd29 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -76,10 +76,20 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in } else { mprintf("DEBUG:\t\tChirality is R\n"); } - mprintf("DEBUG:\t\tPriority around J (tors=%g):", tors*Constants::RADDEG); + mprintf("DEBUG:\t\tPriority around J %s(%i) (tors=%g):", + topIn.AtomMaskName(aj).c_str(), (int)atomPositionKnown[aj], tors*Constants::RADDEG); for (int idx = 0; idx < AJ.Nbonds(); idx++) mprintf(" %s(%i)", topIn.AtomMaskName(priority[idx]).c_str(), (int)atomPositionKnown[priority[idx]]); mprintf("\n"); + // Determine if chirality is valid + bool chirality_is_valid = true; + for (unsigned int idx = 0; idx < Priority.size(); idx++) { + if (atomPositionKnown[priority[idx]] != atomPositionKnown[aj]) { + chirality_is_valid = false; + break; + } + } + mprintf("DEBUG:\t\tChirality is valid: %i\n", (int)chirality_is_valid); // Fill in what values we can for known atoms std::vector knownPhi( AJ.Nbonds() ); @@ -101,9 +111,15 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in } double startPhi; if (knownIdx == -1) { - mprintf("DEBUG:\t\tNo known phi. Setting to 0.\n"); - knownIdx = 0; startPhi = 0; + // If all atom statuses match the chirality is valid. Have R start -180. + if (chirality_is_valid) + { + if (chirality == IS_R) // FIXME just always start -180? + startPhi = -180*Constants::DEGRAD; + } + mprintf("DEBUG:\t\tNo known phi. Setting to %g.\n", startPhi*Constants::RADDEG); + knownIdx = 0; } else startPhi = knownPhi[knownIdx]; diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index a95df187a1..d22c41c2eb 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -769,6 +769,43 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu return 0;*/ } +/** \return Position of atom I from given internal coordinate. */ +Vec3 Zmatrix::AtomIposition(InternalCoords const& ic, Frame const& frameOut) +{ + double rdist = ic.Dist(); + double theta = ic.Theta(); + double phi = ic.Phi(); + + double sinTheta = sin(theta * Constants::DEGRAD); + double cosTheta = cos(theta * Constants::DEGRAD); + double sinPhi = sin(phi * Constants::DEGRAD); + double cosPhi = cos(phi * Constants::DEGRAD); + + // NOTE: Want -x + Vec3 xyz( -(rdist * cosTheta), + rdist * cosPhi * sinTheta, + rdist * sinPhi * sinTheta ); + + Vec3 posL = Vec3( frameOut.XYZ( ic.AtL()) ); + Vec3 posK = Vec3( frameOut.XYZ( ic.AtK()) ); + Vec3 posJ = Vec3( frameOut.XYZ( ic.AtJ()) ); + + Vec3 LK = posK - posL; + Vec3 KJ = posJ - posK; + KJ.Normalize(); + Vec3 Norm = LK.Cross(KJ); + Norm.Normalize(); + Vec3 NxKJ = Norm.Cross(KJ); + + Matrix_3x3 Rot( KJ[0], NxKJ[0], Norm[0], + KJ[1], NxKJ[1], Norm[1], + KJ[2], NxKJ[2], Norm[2] ); + + Vec3 posI = (Rot * xyz) + posJ; + + return posI; +} + /** Set Cartesian coordinates in Frame from internal coordinates. * The procedure used here is from: * Parsons et al., "Practical Conversion from Torsion Space to diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index eadb375750..3a0d6f42c7 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -49,6 +49,9 @@ class Zmatrix { (IC_.size() * InternalCoords::sizeInBytes()); } /// \reserve space for # of internal coords TODO zero out seeds? void reserve(unsigned int n) { IC_.reserve( n ); } + + /// \return XYZ position of atom I for given internal coordinate + static Vec3 AtomIposition(InternalCoords const&, Frame const&); private: typedef std::vector Iarray; typedef std::vector Barray; From 4957cee2d70212b83fa09e080fc16c4a931fa111 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 16 Oct 2023 01:57:18 -0400 Subject: [PATCH 112/245] Might not need to worry about chirality --- src/Structure/Model.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index f53d24dd29..7c7293e063 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -111,13 +111,13 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in } double startPhi; if (knownIdx == -1) { - startPhi = 0; + startPhi = -180*Constants::DEGRAD; // If all atom statuses match the chirality is valid. Have R start -180. - if (chirality_is_valid) - { - if (chirality == IS_R) // FIXME just always start -180? - startPhi = -180*Constants::DEGRAD; - } + //if (chirality_is_valid) + //{ + // if (chirality == IS_R) // FIXME just always start -180? + // startPhi = -180*Constants::DEGRAD; + //} mprintf("DEBUG:\t\tNo known phi. Setting to %g.\n", startPhi*Constants::RADDEG); knownIdx = 0; } else From b9cc83eb388d04c7af368af156c5502c8dfb25b4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 16 Oct 2023 02:04:46 -0400 Subject: [PATCH 113/245] Add a test save --- test/Test_Graft/IC.Final.graft.mol2.save | 80 ++++++++++++++++++++++++ test/Test_Graft/RunTest.sh | 2 +- 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 test/Test_Graft/IC.Final.graft.mol2.save diff --git a/test/Test_Graft/IC.Final.graft.mol2.save b/test/Test_Graft/IC.Final.graft.mol2.save new file mode 100644 index 0000000000..1dd1d7d37f --- /dev/null +++ b/test/Test_Graft/IC.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.2807 5.0231 1.1949 CA 2 PRY 0.033204 + 11 C3 4.0732 5.9437 2.2258 CA 2 PRY -0.149016 + 12 H4 3.4195 5.6866 3.0420 HA 2 PRY 0.153372 + 13 C4 4.6848 7.1755 2.2255 CA 2 PRY -0.336291 + 14 H5 4.5207 7.8790 3.0207 HA 2 PRY 0.167425 + 15 C5 5.5370 7.5371 1.1825 CA 2 PRY 0.423974 + 16 O1 6.0903 8.7648 1.2743 OS 2 PRY -0.391815 + 17 C6 5.7578 6.6416 0.1526 CA 2 PRY -0.336291 + 18 H6 6.4078 6.8827 -0.6661 HA 2 PRY 0.167425 + 19 C7 5.1166 5.3413 0.1431 CA 2 PRY -0.149016 + 20 H7 5.3150 4.7180 -0.6406 HA 2 PRY 0.153372 + 21 C8 6.9403 9.2285 0.2534 CT 2 PRY 0.358047 + 22 C9 7.3211 10.6373 0.5988 CM 2 PRY -0.496680 + 23 C10 8.5229 11.1923 0.5638 CM 2 PRY 0.317549 + 24 C11 8.7059 12.6481 0.9206 CT 2 PRY -0.394216 + 25 C12 9.8029 10.4926 0.1773 CT 2 PRY -0.394216 + 26 H8 6.4054 9.2100 -0.6945 H1 2 PRY 0.001584 + 27 H9 7.7993 8.5763 0.1638 H1 2 PRY 0.001584 + 28 H10 6.4802 11.2448 0.8902 HA 2 PRY 0.192041 + 29 H11 9.1371 13.1988 0.0882 HC 2 PRY 0.110363 + 30 H12 9.3919 12.7545 1.7582 HC 2 PRY 0.110363 + 31 H13 7.7685 13.1197 1.1886 HC 2 PRY 0.110363 + 32 H14 10.2231 10.9445 -0.7190 HC 2 PRY 0.110363 + 33 H15 9.6811 9.4354 -0.0125 HC 2 PRY 0.110363 + 34 H16 10.5435 10.6065 0.9639 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 24cf119331..0ca3a241b7 100755 --- a/test/Test_Graft/RunTest.sh +++ b/test/Test_Graft/RunTest.sh @@ -62,7 +62,7 @@ crdout Final IC.Final.graft.mol2 zmatrix Final out zicFinal.dat EOF RunCpptraj "$TESTNAME, Prenylated Tyrosine (interncal coords)" - #DoTest Final.graft.mol2.save Final.graft.mol2 + DoTest IC.Final.graft.mol2.save IC.Final.graft.mol2 } # Link nucleic acid base + sugar + phosphate From 8154bf6b8aafa449872135f8e8150cb335b83083 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 16 Oct 2023 02:36:16 -0400 Subject: [PATCH 114/245] Trap 2 bond case --- src/Structure/Model.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index 7c7293e063..2bb1cd14ad 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -58,6 +58,12 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in Atom const& AJ = topIn[aj]; mprintf("DEBUG:\t\tNbonds: %i\n", AJ.Nbonds()); + // If atom J only has 2 bonds, ai-aj-ak-al is the only possibility. + if (AJ.Nbonds() < 3) { + mprintf("DEBUG:\t\tFewer than 3 bonds. Setting phi to -180.\n"); + phi = -180 * Constants::DEGRAD; + return 0; + } // FIXME aj ak and al should be known // TODO check that atom i actually ends up on the list? @@ -123,7 +129,7 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in } else startPhi = knownPhi[knownIdx]; - if (AJ.Nbonds() > 1) { + //if (AJ.Nbonds() > 1) { // The interval will be 360 / (number of bonds - 1) double interval = Constants::TWOPI / (AJ.Nbonds() - 1); mprintf("DEBUG:\t\tInterval is %g degrees\n", interval * Constants::RADDEG); @@ -146,7 +152,7 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in currentPhi -= interval; } } - } + //} return 0; } From 0a65481ed728e5f55cc2da53aaab8a726ec295c8 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 17 Oct 2023 03:23:15 -0400 Subject: [PATCH 115/245] Get chirality before the bond is added. Try to preserve that chirality when assigning new Phi --- src/Chirality.cpp | 11 ++++++++ src/Chirality.h | 3 ++- src/Exec_Graft.cpp | 44 ++++++++++++++++++++++--------- src/Structure/Model.cpp | 53 +++++++++++++++++++++----------------- src/Structure/Model.h | 3 ++- src/Structure/Zmatrix.cpp | 44 ++++++++++++++++++++----------- test/Test_Graft/RunTest.sh | 45 +++++++++++++++++++++++++++++++- 7 files changed, 149 insertions(+), 54 deletions(-) diff --git a/src/Chirality.cpp b/src/Chirality.cpp index 5fe893b46d..90ed5a7c9b 100644 --- a/src/Chirality.cpp +++ b/src/Chirality.cpp @@ -9,6 +9,17 @@ using namespace Cpptraj; +/** \return string corresponding to ChiralType */ +const char* Chirality::chiralStr(ChiralType ct) { + switch (ct) { + case ERR : return "Error"; + case IS_S : return "S"; + case IS_R : return "R"; + case IS_UNKNOWN_CHIRALITY : return "Unknown"; + } + return 0; +} + /// \return Total priority (i.e. sum of atomic numbers) of atoms bonded to given atom. static int totalPriority(Topology const& topIn, int atnum, int rnum, int depth, int tgtdepth, std::vector& Visited) diff --git a/src/Chirality.h b/src/Chirality.h index 4bc4abf3ae..3dd091d85d 100644 --- a/src/Chirality.h +++ b/src/Chirality.h @@ -6,7 +6,8 @@ namespace Cpptraj { namespace Chirality { enum ChiralType { ERR = 0, IS_S, IS_R, IS_UNKNOWN_CHIRALITY }; - +/// \return String corresponding to ChiralType +const char* chiralStr(ChiralType); /// \return Chirality at specified atom, set torsion value ChiralType DetermineChirality(double&, int*, int, Topology const&, Frame const&, int); /// \return Chirality at specified atom diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 4726f1c39d..7f62ec28d6 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 "Chirality.h" #include "Structure/Zmatrix.h" #include "Structure/Model.h" #include // std::copy @@ -270,6 +271,30 @@ const combinedTop.SetParmName( outCoords->Meta().Name(), FileName() ); combinedTop.AppendTop( *mol0Top ); combinedTop.AppendTop( *mol1Top ); + + // Only coords+box for now. + CoordinateInfo outInfo(mol0frm.BoxCrd(), false, false, false); + + // Combine coords. + Frame CombinedFrame; // = outCoords->AllocateFrame(); + CombinedFrame.SetupFrameV( combinedTop.Atoms(), outInfo ); + std::copy(mol0frm.xAddress(), mol0frm.xAddress()+mol0frm.size(), CombinedFrame.xAddress()); + std::copy(mol1frm.xAddress(), mol1frm.xAddress()+mol1frm.size(), CombinedFrame.xAddress()+mol0frm.size()); + // Use target box TODO reset the box? + CombinedFrame.SetBox( mol0frm.BoxCrd() ); + + // Get chirality for each atom before we add the bond + using namespace Cpptraj::Chirality; + std::vector atomChirality; + atomChirality.reserve( combinedTop.Natom() ); + for (int at = 0; at < combinedTop.Natom(); at++) { + if (combinedTop[at].Nbonds() > 2) + atomChirality.push_back( DetermineChirality(at, combinedTop, CombinedFrame, 0) ); + else + atomChirality.push_back( IS_UNKNOWN_CHIRALITY ); + mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(at).c_str(), chiralStr(atomChirality.back())); + } + // Create bonds for (unsigned int idx = 0; idx != tgtBondAtoms.size(); idx++) { mprintf("DEBUG: Bond %i %s to %i %s\n", @@ -279,16 +304,11 @@ const } // Regenerate the molecule info FIXME should Topology just do this? if (combinedTop.DetermineMolecules()) return CpptrajState::ERR; - // Only coords+box for now. - CoordinateInfo outInfo(mol0frm.BoxCrd(), false, false, false); + + // Add to output COORDS set if (outCoords->CoordsSetup(combinedTop, outInfo)) return CpptrajState::ERR; // FIXME free molXTop memory - // Combine coords. - Frame CombinedFrame = outCoords->AllocateFrame(); - std::copy(mol0frm.xAddress(), mol0frm.xAddress()+mol0frm.size(), CombinedFrame.xAddress()); - std::copy(mol1frm.xAddress(), mol1frm.xAddress()+mol1frm.size(), CombinedFrame.xAddress()+mol0frm.size()); - // Use target box TODO reset the box? - CombinedFrame.SetBox( mol0frm.BoxCrd() ); - // Declare source atoms as 'known'. Source atoms are in residue 1 + + // Track atoms as 'known'. Target atoms are residue 0, Source atoms are in residue 1 typedef std::vector Barray; Barray atomPositionKnown;/*( combinedTop.Natom(), false ); for (int aidx = combinedTop.Res(1).FirstAtom(); aidx != combinedTop.Res(1).LastAtom(); aidx++) @@ -345,7 +365,7 @@ const } mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); double newPhi = 0; - if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown)) { + if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown, atomChirality)) { mprinterr("Error: phi assignment failed.\n"); return CpptrajState::ERR; } @@ -371,7 +391,7 @@ const } mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); double newPhi = 0; - if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown)) { + if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown, atomChirality)) { mprinterr("Error: phi assignment failed.\n"); return CpptrajState::ERR; } @@ -390,7 +410,7 @@ const printIC(oic, combinedTop); ictype = ICholder::KL; double newPhi = 0; - if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown)) { + if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown, atomChirality)) { mprinterr("Error: phi assignment failed.\n"); return CpptrajState::ERR; } diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index 2bb1cd14ad..781a31cc66 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -1,7 +1,6 @@ #include "Model.h" #include "../CpptrajStdio.h" #include "../Topology.h" -#include "../Chirality.h" #include "../TorsionRoutines.h" #include "../Constants.h" @@ -50,7 +49,7 @@ int Cpptraj::Structure::Model::AssignTheta(double& theta, int ai, int aj, int ak * / \ * i l */ -int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, int al, Topology const& topIn, Frame const& frameIn, std::vector const& atomPositionKnown) +int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, int al, Topology const& topIn, Frame const& frameIn, std::vector const& atomPositionKnown, std::vector const& atomChirality) { using namespace Cpptraj::Chirality; // Figure out hybridization and chirality of atom j. @@ -115,6 +114,10 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in if (knownIdx == -1) knownIdx = idx; // FIXME handle more than 1 known } } + + // The interval will be 360 / (number of bonds - 1) + double interval = Constants::TWOPI / (AJ.Nbonds() - 1); + double startPhi; if (knownIdx == -1) { startPhi = -180*Constants::DEGRAD; @@ -129,30 +132,32 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in } else startPhi = knownPhi[knownIdx]; - //if (AJ.Nbonds() > 1) { - // The interval will be 360 / (number of bonds - 1) - double interval = Constants::TWOPI / (AJ.Nbonds() - 1); - mprintf("DEBUG:\t\tInterval is %g degrees\n", interval * Constants::RADDEG); - // Forward direction - double currentPhi = startPhi; - for (int idx = knownIdx; idx < AJ.Nbonds(); idx++) { - int atnum = priority[idx]; - if (atnum != ak) { - if (atnum == ai) phi = currentPhi; - mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); - currentPhi += interval; - } + if (atomChirality[aj] == IS_R) { + startPhi = -startPhi; + interval = -interval; + } + mprintf("DEBUG:\t\tStart phi is %g degrees\n", startPhi*Constants::RADDEG); + mprintf("DEBUG:\t\tInterval is %g degrees\n", interval * Constants::RADDEG); + + // Forward direction + double currentPhi = startPhi; + for (int idx = knownIdx; idx < AJ.Nbonds(); idx++) { + int atnum = priority[idx]; + if (atnum != ak) { + if (atnum == ai) phi = currentPhi; + mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); + currentPhi += interval; } - currentPhi = startPhi - interval; - for (int idx = knownIdx - 1; idx > -1; idx--) { - int atnum = priority[idx]; - if (atnum != ak) { - if (atnum == ai) phi = currentPhi; - mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); - currentPhi -= interval; - } + } + currentPhi = startPhi - interval; + for (int idx = knownIdx - 1; idx > -1; idx--) { + int atnum = priority[idx]; + if (atnum != ak) { + if (atnum == ai) phi = currentPhi; + mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); + currentPhi -= interval; } - //} + } return 0; } diff --git a/src/Structure/Model.h b/src/Structure/Model.h index 975e41fd2c..7230cd5051 100644 --- a/src/Structure/Model.h +++ b/src/Structure/Model.h @@ -1,6 +1,7 @@ #ifndef INC_STRUCTURE_MODEL_H #define INC_STRUCTURE_MODEL_H #include +#include "../Chirality.h" class Topology; class Frame; namespace Cpptraj { @@ -8,7 +9,7 @@ namespace Structure { /// Routines to generate model parameters namespace Model { /// Given atoms J K and L, attempt to assign a reasonable value for phi for atom I -int AssignPhi(double&, int, int, int, int, Topology const&, Frame const&, std::vector const&); +int AssignPhi(double&, int, int, int, int, Topology const&, Frame const&, std::vector const&, std::vector const&); /// Given atoms J and K, attempt to assign a reasonable value for theta for atom I int AssignTheta(double&, int, int, int, Topology const&, Frame const&, std::vector const&); diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index d22c41c2eb..e37aa84902 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -499,21 +499,35 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, break; } // Add IC for the branch - PHI const& p = Branches.top(); - if (debug_ > 1) { - mprintf("DEBUG:\t\tPopped off stack: %s - %s - %s - %s\n", - topIn.AtomMaskName(p.al_).c_str(), - topIn.AtomMaskName(p.ak_).c_str(), - topIn.AtomMaskName(p.aj_).c_str(), - topIn.AtomMaskName(p.ai_).c_str()); - } - addIc(p.ai_, p.aj_, p.ak_, p.al_, frameIn.XYZ(p.ai_), frameIn.XYZ(p.aj_), frameIn.XYZ(p.ak_), frameIn.XYZ(p.al_)); - Branches.pop(); - MARK(p.ai_, hasIC, nHasIC); - // Designate branch as next. - atL = p.ak_; - atK = p.aj_; - atJ = p.ai_; + bool has_next = false; + while (!Branches.empty()) { + PHI const& p = Branches.top(); + if (debug_ > 1) { + mprintf("DEBUG:\t\tPopped off stack: %s - %s - %s - %s\n", + topIn.AtomMaskName(p.al_).c_str(), + topIn.AtomMaskName(p.ak_).c_str(), + topIn.AtomMaskName(p.aj_).c_str(), + topIn.AtomMaskName(p.ai_).c_str()); + } + if (!hasIC[p.ai_]) { + addIc(p.ai_, p.aj_, p.ak_, p.al_, frameIn.XYZ(p.ai_), frameIn.XYZ(p.aj_), frameIn.XYZ(p.ak_), frameIn.XYZ(p.al_)); + Branches.pop(); + MARK(p.ai_, hasIC, nHasIC); + // Designate branch as next. + atL = p.ak_; + atK = p.aj_; + atJ = p.ai_; + has_next = true; + break; + } else { + mprintf("DEBUG:\t\t%s already has an IC.\n", topIn.AtomMaskName(p.ai_).c_str()); + Branches.pop(); + } + } // END while branches remain on stack + if (!has_next) { + mprintf("DEBUG:\t\tNothing left on the stack.\n"); + break; + } } else { int atI = OtherAtoms.front(); if (debug_ > 1) { diff --git a/test/Test_Graft/RunTest.sh b/test/Test_Graft/RunTest.sh index 0ca3a241b7..06dd64072e 100755 --- a/test/Test_Graft/RunTest.sh +++ b/test/Test_Graft/RunTest.sh @@ -61,7 +61,7 @@ graft ic \ crdout Final IC.Final.graft.mol2 zmatrix Final out zicFinal.dat EOF - RunCpptraj "$TESTNAME, Prenylated Tyrosine (interncal coords)" + RunCpptraj "$TESTNAME, Prenylated Tyrosine (internal coords)" DoTest IC.Final.graft.mol2.save IC.Final.graft.mol2 } @@ -83,6 +83,7 @@ graft \\ tgtmask !(@C1',1H1',2H1',3H1') \\ srcmask !(@C10,1H10,2H10,3H10,HO3',O2',HO2') \\ bond @N9,@C1' +zmatrix BaseSugar out zBaseSugar.dat #crdout BaseSugar BaseSugar.mol2 # BaseSugar + Phosphate graft \\ @@ -106,6 +107,47 @@ EOF DoTest Nucleotide.pdb.save Nucleotide.pdb } +# Link nucleic acid base + sugar + phosphate, IC +DNAic() { + cat > cpptraj.in < cpptraj.in < Date: Tue, 17 Oct 2023 04:30:18 -0400 Subject: [PATCH 116/245] Print original chirality instead of new --- src/Structure/Model.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index 781a31cc66..facc4f1e6f 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -69,18 +69,19 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in std::vector Priority( AJ.Nbonds() ); int* priority = static_cast( &Priority[0] ); double tors = 0; - // DetermineChirality will always put aj as the last index. + // FIXME - Only need priority here. ChiralType chirality = DetermineChirality(tors, priority, aj, topIn, frameIn, 1); // FIXME debug if (chirality == ERR) { mprinterr("Error: Problem determining chirality around atom %s\n", topIn.AtomMaskName(aj).c_str()); return 1; - } else if (chirality == IS_UNKNOWN_CHIRALITY) { + } /*else if (chirality == IS_UNKNOWN_CHIRALITY) { mprintf("DEBUG:\t\tChirality is unknown\n"); } else if (chirality == IS_S) { mprintf("DEBUG:\t\tChirality is S\n"); } else { mprintf("DEBUG:\t\tChirality is R\n"); - } + }*/ + mprintf("DEBUG: Original chirality around J %s is %s\n", topIn.AtomMaskName(aj).c_str(), chiralStr(atomChirality[aj])); mprintf("DEBUG:\t\tPriority around J %s(%i) (tors=%g):", topIn.AtomMaskName(aj).c_str(), (int)atomPositionKnown[aj], tors*Constants::RADDEG); for (int idx = 0; idx < AJ.Nbonds(); idx++) From 1e524022dd770291ed0905f054c93b6cd5af2afb Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 17 Oct 2023 04:33:38 -0400 Subject: [PATCH 117/245] Update test save --- test/Test_Graft/IC.Final.graft.mol2.save | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Test_Graft/IC.Final.graft.mol2.save b/test/Test_Graft/IC.Final.graft.mol2.save index 1dd1d7d37f..c03030078c 100644 --- a/test/Test_Graft/IC.Final.graft.mol2.save +++ b/test/Test_Graft/IC.Final.graft.mol2.save @@ -24,7 +24,7 @@ USER_CHARGES 16 O1 6.0903 8.7648 1.2743 OS 2 PRY -0.391815 17 C6 5.7578 6.6416 0.1526 CA 2 PRY -0.336291 18 H6 6.4078 6.8827 -0.6661 HA 2 PRY 0.167425 - 19 C7 5.1166 5.3413 0.1431 CA 2 PRY -0.149016 + 19 C7 5.1278 5.3990 0.1715 CA 2 PRY -0.149016 20 H7 5.3150 4.7180 -0.6406 HA 2 PRY 0.153372 21 C8 6.9403 9.2285 0.2534 CT 2 PRY 0.358047 22 C9 7.3211 10.6373 0.5988 CM 2 PRY -0.496680 From 3e41bed627c201620d76f0fa04ac583ea4364f73 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 17 Oct 2023 04:44:47 -0400 Subject: [PATCH 118/245] Test grafting phosphate onto base sugar with IC --- test/Test_Graft/RunTest.sh | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/test/Test_Graft/RunTest.sh b/test/Test_Graft/RunTest.sh index 06dd64072e..2f31caacac 100755 --- a/test/Test_Graft/RunTest.sh +++ b/test/Test_Graft/RunTest.sh @@ -124,25 +124,23 @@ graft ic \\ srcmask !(@C10,1H10,2H10,3H10,HO3',O2',HO2') \\ bond @N9,@C1' zmatrix BaseSugar out zicBaseSugar.dat -crdout BaseSugar BaseSugar.mol2 -quit +#crdout BaseSugar BaseSugar.mol2 +#quit # BaseSugar + Phosphate -graft \\ +graft ic \\ tgt BaseSugar \\ src Phos \\ name Nucleotide \\ - tgtfitmask @C5',O5',HO5' \\ - srcfitmask @C2,O5',P \\ tgtmask !(@O5',HO5') \\ srcmask !(@C2,H21,H22,H23,O3',C1,H11,H12,H13) \\ bond @C5',@O5' -#crdout Nucleotide Nucleotide.mol2 +crdout Nucleotide Nucleotide.ic.mol2 # Format the PDB -change crdset Nucleotide resname from * to DA -change crdset Nucleotide oresnums of :1 min 1 max 1 -change crdset Nucleotide oresnums of :2 min 1 max 1 -change crdset Nucleotide oresnums of :3 min 1 max 1 -crdout Nucleotide Nucleotide.pdb +#change crdset Nucleotide resname from * to DA +#change crdset Nucleotide oresnums of :1 min 1 max 1 +#change crdset Nucleotide oresnums of :2 min 1 max 1 +#change crdset Nucleotide oresnums of :3 min 1 max 1 +#crdout Nucleotide Nucleotide.pdb EOF RunCpptraj "$TESTNAME, Construct Nucleic Acid, IC" #DoTest Nucleotide.pdb.save Nucleotide.pdb From 5da298d46aa6b216682cd956313cdb6eb2703adc Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 17 Oct 2023 05:47:09 -0400 Subject: [PATCH 119/245] Try to be smarter about hybridization --- src/Structure/Model.cpp | 55 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index facc4f1e6f..7b788fe930 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -12,8 +12,44 @@ int Cpptraj::Structure::Model::AssignTheta(double& theta, int ai, int aj, int ak // Figure out hybridization and chirality of atom j. mprintf("DEBUG: AssignTheta for atom j : %s\n", topIn.AtomMaskName(aj).c_str()); + enum HybridizationType { SP = 0, SP2, SP3, UNKNOWN_HYBRIDIZATION }; + Atom const& AJ = topIn[aj]; mprintf("DEBUG:\t\tNbonds: %i\n", AJ.Nbonds()); + // Sanity check + if (AJ.Nbonds() < 2) { + mprinterr("Internal Error: AssignTheta() called for atom J %s with fewer than 2 bonds.\n", topIn.AtomMaskName(aj).c_str()); + return 1; + } + + HybridizationType hybrid = UNKNOWN_HYBRIDIZATION; + // Handle specific elements + switch (AJ.Element()) { + case Atom::CARBON : + switch (AJ.Nbonds()) { + case 2 : hybrid = SP; break; + case 3 : hybrid = SP2; break; + case 4 : hybrid = SP3; break; + } + break; + case Atom::NITROGEN : + switch (AJ.Nbonds()) { + case 2 : hybrid = SP2; break; + case 3 : hybrid = SP3; break; + } + break; + case Atom::OXYGEN : + switch (AJ.Nbonds()) { + case 2 : hybrid = SP3; break; + } + break; + case Atom::SULFUR : + switch (AJ.Nbonds()) { + case 2 : hybrid = SP3; break; + } + break; + default: hybrid = UNKNOWN_HYBRIDIZATION; break; + } // Fill in what values we can for known atoms /* std::vector knownTheta( AJ.Nbonds() ); int knownIdx = -1; @@ -29,13 +65,22 @@ int Cpptraj::Structure::Model::AssignTheta(double& theta, int ai, int aj, int ak } if (knownIdx == -1) {*/ //mprintf("DEBUG:\t\tNo known theta.\n"); - // Assign a theta based on hybridization + if (hybrid == UNKNOWN_HYBRIDIZATION) { + // Assign a theta based on number of bonds switch (AJ.Nbonds()) { - case 4 : theta = 109.5 * Constants::DEGRAD; break; - case 3 : theta = 120.0 * Constants::DEGRAD; break; - case 2 : theta = 180.0 * Constants::DEGRAD; break; + case 4 : hybrid = SP3; break; + case 3 : hybrid = SP2; break; + case 2 : hybrid = SP; break; default : mprinterr("Internal Error: AssignTheta(): Unhandled # bonds for %s (%i)\n", topIn.AtomMaskName(aj).c_str(), AJ.Nbonds()); return 1; - }/* + } + } + // Assign a theta based on hybridization + switch (hybrid) { + case SP3 : theta = 109.5 * Constants::DEGRAD; break; + case SP2 : theta = 120.0 * Constants::DEGRAD; break; + case SP : theta = 180.0 * Constants::DEGRAD; break; + default : mprinterr("Internal Error: AssignTheta(): Unhandled hybridization for %s (%i)\n", topIn.AtomMaskName(aj).c_str(), AJ.Nbonds()); return 1; + }/* } else { theta = knownTheta[knownIdx]; // TODO just use above guess via hybrid? }*/ From efed8b95a188fdbb564e91d7c139aca4020012f7 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 17 Oct 2023 06:33:57 -0400 Subject: [PATCH 120/245] Use separate routine for coords. Add routine to find ic indices --- src/Structure/Zmatrix.cpp | 14 +++++++++++++- src/Structure/Zmatrix.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index e37aa84902..b159a5c215 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -64,6 +64,16 @@ void Zmatrix::SetIC(unsigned int idx, InternalCoords const& ic) { IC_[idx] = ic; } +/** \return Array containing indices of ICs with specified atom i. */ +std::vector Zmatrix::AtomI_indices(int atomi) const { + std::vector indices; + for (unsigned int idx = 0; idx != IC_.size(); idx++) { + if (IC_[idx].AtI() == atomi) + indices.push_back( (int)idx ); + } + return indices; +} + /** Add internal coords as a IC seed. This is intended for use with systems * that have dummy atoms, such as those from Amber Prep files. */ @@ -918,6 +928,8 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { if (debug_ > 0) mprintf("DEBUG: Next IC to use is %u\n", idx+1); InternalCoords const& ic = IC_[idx]; + Vec3 posI = AtomIposition(ic, frameOut); +/* double rdist = ic.Dist(); double theta = ic.Theta(); double phi = ic.Phi(); @@ -947,7 +959,7 @@ int Zmatrix::SetToFrame(Frame& frameOut) const { KJ[1], NxKJ[1], Norm[1], KJ[2], NxKJ[2], Norm[2] ); - Vec3 posI = (Rot * xyz) + posJ; + Vec3 posI = (Rot * xyz) + posJ;*/ frameOut.SetXYZ( ic.AtI(), posI ); hasPosition[ ic.AtI() ] = true; diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 3a0d6f42c7..f7982388dc 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -41,6 +41,8 @@ class Zmatrix { /// \return Specified internal coord InternalCoords const& operator[](int idx) const { return IC_[idx]; } + /// \return Array containing indices of ICs involving specified atom I + std::vector AtomI_indices(int) const; /// \return number of internal coords unsigned int N_IC() const { return IC_.size(); } /// \return memory usage in bytes From f6f1d6d3a77516da65ae2e2d10b7fcb8337a4e51 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 17 Oct 2023 10:18:32 -0400 Subject: [PATCH 121/245] Use InternalCoords printIC --- src/Exec_Graft.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 7f62ec28d6..676647b435 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -172,17 +172,6 @@ Topology* Exec_Graft::modify_top(Topology const& topIn, AtomMask const& mask, Fr return srcTopPtr; } -/// Print IC to stdout -static inline void printIC(InternalCoords const& oic, Topology const& top) -{ - mprintf(" %6i %6i %6i %6i [%s - %s - %s - %s]\n", - oic.AtI()+1, oic.AtJ()+1, oic.AtK()+1, oic.AtL()+1, - top.AtomMaskName(oic.AtI()).c_str(), - top.AtomMaskName(oic.AtJ()).c_str(), - top.AtomMaskName(oic.AtK()).c_str(), - top.AtomMaskName(oic.AtL()).c_str()); -} - /// Hold IC that needs to be reset class ICholder { public: @@ -354,7 +343,7 @@ const atomPositionKnown[aidx] = true; // Set dist, theta, phi mprintf("DEBUG: Found IC for bond %i %i (i j)", a0+1, a1+1); - printIC(oic, combinedTop); + oic.printIC(combinedTop); ictype = ICholder::IJ; double newDist = Atom::GetBondLength( combinedTop[oic.AtI()].Element(), combinedTop[oic.AtJ()].Element() ); mprintf("DEBUG:\t\tnewDist= %g\n", newDist); @@ -382,7 +371,7 @@ const { // Set theta, phi mprintf("DEBUG: Found IC for bond %i %i (j k)", a0+1, a1+1); - printIC(oic, combinedTop); + oic.printIC(combinedTop); ictype = ICholder::JK; double newTheta = 0; if (Cpptraj::Structure::Model::AssignTheta(newTheta, oic.AtI(), oic.AtJ(), oic.AtK(), combinedTop, CombinedFrame, atomPositionKnown)) { @@ -407,7 +396,7 @@ const { // Set phi mprintf("DEBUG: Found IC for bond %i %i (k l)", a0+1, a1+1); - printIC(oic, combinedTop); + oic.printIC(combinedTop); ictype = ICholder::KL; double newPhi = 0; if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown, atomChirality)) { @@ -442,7 +431,7 @@ const { InternalCoords const& oic = zmatrix[*jt]; mprintf("DEBUG:\t\t"); - printIC(oic, combinedTop); + oic.printIC(combinedTop); /*double dist = oic.Dist(); double theta = oic.Theta(); double phi = oic.Phi(); From ff000c5332ea77678ebf7a23f5bc490008b7eff6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 17 Oct 2023 10:18:55 -0400 Subject: [PATCH 122/245] Clean up IC printing --- src/Structure/InternalCoords.cpp | 13 ++++++++++++- src/Structure/InternalCoords.h | 4 +++- src/Structure/Zmatrix.cpp | 21 ++++++++++++--------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/Structure/InternalCoords.cpp b/src/Structure/InternalCoords.cpp index df8eb5ec05..74c08fb182 100644 --- a/src/Structure/InternalCoords.cpp +++ b/src/Structure/InternalCoords.cpp @@ -1,6 +1,7 @@ #include #include "InternalCoords.h" -//#incl ude "../Vec3.h" +#include "../Topology.h" +#include "../CpptrajStdio.h" using namespace Cpptraj::Structure; @@ -55,3 +56,13 @@ InternalCoords& InternalCoords::operator=(InternalCoords const& rhs) { std::copy( rhs.val_, rhs.val_+3, val_ ); return *this; } + +/** Print to stdout */ +void InternalCoords::printIC(Topology const& top) const { + mprintf(" %6i %6i %6i %6i [%s - %s - %s - %s]\n", + AtI()+1, AtJ()+1, AtK()+1, AtL()+1, + top.AtomMaskName(AtI()).c_str(), + top.AtomMaskName(AtJ()).c_str(), + top.AtomMaskName(AtK()).c_str(), + top.AtomMaskName(AtL()).c_str()); +} diff --git a/src/Structure/InternalCoords.h b/src/Structure/InternalCoords.h index 9ad2f4fb11..3be154e9d8 100644 --- a/src/Structure/InternalCoords.h +++ b/src/Structure/InternalCoords.h @@ -1,6 +1,6 @@ #ifndef INC_STRUCTURE_INTERNALCOORDS_H #define INC_STRUCTURE_INTERNALCOORDS_H -//class Vec3; +class Topology; namespace Cpptraj { namespace Structure { /// Hold internal coordinates for an atom @@ -36,6 +36,8 @@ class InternalCoords { int AtL() const { return idx_[2]; } static unsigned int sizeInBytes() { return (4*sizeof(int)) + (3*sizeof(double)); } + + void printIC(Topology const&) const; private: int ati_; ///< Atom I index int idx_[3]; ///< Atom indices for distance, angle, torsion diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index b159a5c215..d10bd606cf 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -514,10 +514,10 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, PHI const& p = Branches.top(); if (debug_ > 1) { mprintf("DEBUG:\t\tPopped off stack: %s - %s - %s - %s\n", - topIn.AtomMaskName(p.al_).c_str(), - topIn.AtomMaskName(p.ak_).c_str(), + topIn.AtomMaskName(p.ai_).c_str(), topIn.AtomMaskName(p.aj_).c_str(), - topIn.AtomMaskName(p.ai_).c_str()); + topIn.AtomMaskName(p.ak_).c_str(), + topIn.AtomMaskName(p.al_).c_str()); } if (!hasIC[p.ai_]) { addIc(p.ai_, p.aj_, p.ak_, p.al_, frameIn.XYZ(p.ai_), frameIn.XYZ(p.aj_), frameIn.XYZ(p.ak_), frameIn.XYZ(p.al_)); @@ -531,6 +531,9 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, break; } else { mprintf("DEBUG:\t\t%s already has an IC.\n", topIn.AtomMaskName(p.ai_).c_str()); + std::vector indices = AtomI_indices(p.ai_); + // FIXME check empty or size > 1 + IC_[indices.front()].printIC( topIn ); Branches.pop(); } } // END while branches remain on stack @@ -542,10 +545,10 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, int atI = OtherAtoms.front(); if (debug_ > 1) { mprintf("DEBUG:\t\tNext: %s - %s - %s - %s\n", - topIn.AtomMaskName(atL).c_str(), - topIn.AtomMaskName(atK).c_str(), + topIn.AtomMaskName(atI).c_str(), topIn.AtomMaskName(atJ).c_str(), - topIn.AtomMaskName(atI).c_str()); + topIn.AtomMaskName(atK).c_str(), + topIn.AtomMaskName(atL).c_str()); } // Add lowest index as IC addIc(atI, atJ, atK, atL, frameIn.XYZ(atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); @@ -557,10 +560,10 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, if (debug_ > 1) { PHI const& p = Branches.top(); mprintf("DEBUG:\t\tPlaced on stack: %s - %s - %s - %s (%zu)\n", - topIn.AtomMaskName(p.al_).c_str(), - topIn.AtomMaskName(p.ak_).c_str(), + topIn.AtomMaskName(p.ai_).c_str(), topIn.AtomMaskName(p.aj_).c_str(), - topIn.AtomMaskName(p.ai_).c_str(), Branches.size()); + topIn.AtomMaskName(p.ak_).c_str(), + topIn.AtomMaskName(p.al_).c_str(), Branches.size()); } } // Designate lowest index as next From 6078af89ee94e79fa8e6fb730d2396bae7d1ee43 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 08:53:02 -0400 Subject: [PATCH 123/245] Update dependencies --- src/Structure/structuredepend | 2 +- src/cpptrajdepend | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index 74df765c8a..2f1ac25057 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -2,7 +2,7 @@ Disulfide.o : Disulfide.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Co FunctionalGroup.o : FunctionalGroup.cpp ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.o : FxnGroupBuilder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h StructureRoutines.h Sugar.h SugarToken.h HisProt.o : HisProt.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h HisProt.h StructureRoutines.h -InternalCoords.o : InternalCoords.cpp InternalCoords.h +InternalCoords.o : InternalCoords.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h InternalCoords.h Model.o : Model.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Model.h StructureRoutines.o : StructureRoutines.cpp ../Atom.h ../CpptrajStdio.h ../NameType.h ../Residue.h ../SymbolExporting.h StructureRoutines.h Sugar.o : Sugar.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Sugar.h SugarToken.h diff --git a/src/cpptrajdepend b/src/cpptrajdepend index b91620bae2..cb7f699e84 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -304,7 +304,7 @@ Exec_Emin.o : Exec_Emin.cpp Action.h ActionList.h ActionState.h Analysis.h Analy Exec_ExtendedComparison.o : Exec_ExtendedComparison.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_ExtendedComparison.h ExtendedSimilarity.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_Flatten.o : Exec_Flatten.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Flatten.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 ImageOption.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h Structure/InternalCoords.h Structure/Model.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 AtomMask.h AtomType.h BaseIOtype.h Box.h Chirality.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 Segment.h Structure/InternalCoords.h Structure/Model.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_HmassRepartition.o : Exec_HmassRepartition.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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 EnsembleIn.h EnsembleOutList.h Exec.h Exec_HmassRepartition.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h Trajin_Single.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h @@ -435,7 +435,7 @@ Structure/Disulfide.o : Structure/Disulfide.cpp Atom.h AtomMask.h AtomType.h Box Structure/FunctionalGroup.o : Structure/FunctionalGroup.cpp Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/FxnGroupBuilder.o : Structure/FxnGroupBuilder.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/HisProt.o : Structure/HisProt.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/HisProt.h Structure/StructureRoutines.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h -Structure/InternalCoords.o : Structure/InternalCoords.cpp Structure/InternalCoords.h +Structure/InternalCoords.o : Structure/InternalCoords.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/InternalCoords.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/Model.o : Structure/Model.cpp Atom.h AtomMask.h AtomType.h Box.h Chirality.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Model.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Structure/StructureRoutines.o : Structure/StructureRoutines.cpp Atom.h CpptrajStdio.h NameType.h Residue.h Structure/StructureRoutines.h SymbolExporting.h Structure/Sugar.o : Structure/Sugar.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h From 99abe791879d4cab379a7ccacb0629cbc214dbdc Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 10:34:35 -0400 Subject: [PATCH 124/245] Clean up Zmatrix. Add routine where some initial Frame positions can be used for ICs. --- src/Exec_Zmatrix.cpp | 2 +- src/Structure/Zmatrix.cpp | 33 ++++++++++++--------------------- src/Structure/Zmatrix.h | 21 ++++++++++++--------- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/Exec_Zmatrix.cpp b/src/Exec_Zmatrix.cpp index b42fa97b9d..e27a72fdb6 100644 --- a/src/Exec_Zmatrix.cpp +++ b/src/Exec_Zmatrix.cpp @@ -47,7 +47,7 @@ const Zmatrix& zmatrix = *(zset->Zptr()); zmatrix.SetDebug( State.Debug() ); - int errStat = zmatrix.SetFromFrame_Trace( frmIn, CRD->Top(), molnum ); + int errStat = zmatrix.SetFromFrame( frmIn, CRD->Top(), molnum ); if (debug_ > 0) zmatrix.print(); // DEBUG return errStat; } diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index d10bd606cf..1f0017ed35 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -74,24 +74,6 @@ std::vector Zmatrix::AtomI_indices(int atomi) const { return indices; } -/** Add internal coords as a IC seed. This is intended for use with systems - * that have dummy atoms, such as those from Amber Prep files. - */ -/*int Zmatrix::AddICseed(InternalCoords const& ic) { - if (icseed0_ == InternalCoords::NO_ATOM) - icseed0_ = IC_.size(); - else if (icseed1_ == InternalCoords::NO_ATOM) - icseed1_ = IC_.size(); - else if (icseed2_ == InternalCoords::NO_ATOM) - icseed2_ = IC_.size(); - else { - mprinterr("Error: Too many seed ICs.\n"); - return 1; - } - IC_.push_back( ic ); - return 0; -}*/ - /** Print to stdout */ void Zmatrix::print() const { mprintf("%zu internal coords.\n", IC_.size()); @@ -834,14 +816,23 @@ Vec3 Zmatrix::AtomIposition(InternalCoords const& ic, Frame const& frameOut) } /** Set Cartesian coordinates in Frame from internal coordinates. + * Assume none of the positions in frameOut can be used initially. + */ +int Zmatrix::SetToFrame(Frame& frameOut) const { + // Track which atoms have Cartesian coords set + Barray hasPosition( frameOut.Natom(), false ); + return SetToFrame(frameOut, hasPosition); +} + +/** Set Cartesian coordinates in Frame from internal coordinates. + * Any atom with hasPosition set to true is considered a "good" + * position that other ICs can use. * The procedure used here is from: * Parsons et al., "Practical Conversion from Torsion Space to * Cartesian Space for In Silico Protein Synthesis", * J Comput Chem 26: 1063–1068, 2005. */ -int Zmatrix::SetToFrame(Frame& frameOut) const { - // Track which atoms have Cartesian coords set - Barray hasPosition( frameOut.Natom(), false ); +int Zmatrix::SetToFrame(Frame& frameOut, Barray& hasPosition) const { // If any seed positions are defined, set them now if (seedAt0_ != InternalCoords::NO_ATOM) { frameOut.SetXYZ( seedAt0_, seed0Pos_ ); diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index f7982388dc..983a655649 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -11,29 +11,33 @@ namespace Structure { class Zmatrix { typedef std::vector ICarray; public: + typedef std::vector Barray; /// CONSTRUCTOR Zmatrix(); /// Set debug level void SetDebug(int d) { debug_ = d; } + /// Print to stdout + void print() const; + + /// \reserve space for # of internal coords TODO zero out seeds? + void reserve(unsigned int n) { IC_.reserve( n ); } /// Add internal coordinate int AddIC(InternalCoords const&); /// Set specified IC void SetIC(unsigned int, InternalCoords const&); - /// Add internal coordinate as next available IC seed - //int AddICseed(InternalCoords const&); + /// Set seed atoms from frame/top int SetSeedPositions(Frame const&, Topology const&, int, int, int); + /// Convert specifed molecule of Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&, int); - /// Convert from Cartesian to Zmatrix by tracing a molecule FIXME fix naming - int SetFromFrame_Trace(Frame const&, Topology const&, int); /// Convert molecule 0 of Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&); /// Set Frame from internal coords int SetToFrame(Frame&) const; - /// Print to stdout - void print() const; + /// Set Frame from internal coords with some positions already set + int SetToFrame(Frame&, Barray&) const; typedef ICarray::const_iterator const_iterator; const_iterator begin() const { return IC_.begin(); } @@ -49,14 +53,11 @@ class Zmatrix { unsigned int sizeInBytes() const { return (7*sizeof(int)) + (9*sizeof(double)) + // 3 Vec3 (IC_.size() * InternalCoords::sizeInBytes()); } - /// \reserve space for # of internal coords TODO zero out seeds? - void reserve(unsigned int n) { IC_.reserve( n ); } /// \return XYZ position of atom I for given internal coordinate static Vec3 AtomIposition(InternalCoords const&, Frame const&); private: typedef std::vector Iarray; - typedef std::vector Barray; /// Simple version of auto set seeds based on connectivity only int autoSetSeeds_simple(Frame const&, Topology const&, Molecule const&); /// Automatically set seeds @@ -65,6 +66,8 @@ class Zmatrix { void addIc(int,int,int,int,const double*,const double*,const double*,const double*); /// Add internal coordiantes by tracing a molecule int traceMol(int, int, int, Frame const&, Topology const&, unsigned int, unsigned int&, Barray&); + /// Convert from Cartesian to minimal Zmatrix by tracing a molecule + int SetFromFrame_Trace(Frame const&, Topology const&, int); /// \return True if IC seeds are set //bool HasICSeeds() const; /// \return True if Cartesian seeds are set From 060ca6aff4d656f3214b7bce203232cfc2ad0174 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 11:11:10 -0400 Subject: [PATCH 125/245] Get rid of extra zmatrix command --- test/Test_Graft/RunTest.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Test_Graft/RunTest.sh b/test/Test_Graft/RunTest.sh index 2f31caacac..a1599c458d 100755 --- a/test/Test_Graft/RunTest.sh +++ b/test/Test_Graft/RunTest.sh @@ -83,7 +83,6 @@ graft \\ tgtmask !(@C1',1H1',2H1',3H1') \\ srcmask !(@C10,1H10,2H10,3H10,HO3',O2',HO2') \\ bond @N9,@C1' -zmatrix BaseSugar out zBaseSugar.dat #crdout BaseSugar BaseSugar.mol2 # BaseSugar + Phosphate graft \\ From 5f6b215304214884dbaa7470a712ddec00ec8514 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 11:34:24 -0400 Subject: [PATCH 126/245] Start SetFromFrameAroundBond() function --- src/Exec_Graft.cpp | 30 +++++++++++++++++++++++++ src/Structure/Zmatrix.cpp | 47 +++++++++++++++++++++++++++++++++++++++ src/Structure/Zmatrix.h | 2 ++ 3 files changed, 79 insertions(+) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 676647b435..4b551267fa 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -187,6 +187,17 @@ class ICholder { ICtype ictype_; ///< Type of reset (IJ=all, JK=theta,phi, KL=phi) }; +/// \return Heavy atom count +int heavy_atom_count(Topology const& topIn) { + int hac = 0; + for (int i = 0; i != topIn.Natom(); i++) { + if (topIn[i].Element() != Atom::HYDROGEN && + topIn[i].Element() != Atom::EXTRAPT) + hac++; + } + return hac; +} + /** Graft using internal coordinates to build the final structure. */ Exec::RetType Exec_Graft::graft_ic(CpptrajState& State, ArgList& argIn) const @@ -311,6 +322,25 @@ const return CpptrajState::ERR; } zmatrix.print(); // DEBUG + // Generate Zmatrix only for ICs involving bonded atoms + Zmatrix bondZmatrix; + // Make atA belong to the smaller fragment + int atA, atB; + if (heavy_atom_count(*mol0Top) < heavy_atom_count(*mol1Top)) { + atA = tgtBondAtoms[0]; + atB = srcBondAtoms[0]; + } else { + atA = srcBondAtoms[0]; + atB = tgtBondAtoms[0]; + } + bondZmatrix.SetDebug( 2 ); // FIXME + if (bondZmatrix.SetFromFrameAroundBond(atA, atB, CombinedFrame, combinedTop)) { + mprinterr("Error: Zmatrix setup for ICs around %s and %s failed.\n", + combinedTop.AtomMaskName(atA).c_str(), + combinedTop.AtomMaskName(atB).c_str()); + return CpptrajState::ERR; + } + // Map atom j to ICs to change typedef std::map ICmapType; typedef std::pair ICpairType; diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 1f0017ed35..35364933e8 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -2,6 +2,7 @@ #include // std::sort, std::min, std::max #include #include // cos +#include // std::pair #include "Zmatrix.h" #include "../Frame.h" #include "../CpptrajStdio.h" @@ -778,6 +779,52 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu return 0;*/ } +/** Given two bonded atoms A and B, where B has a depth of at least 2 + * (i.e., it is possible to have B be atom J where we can form J-K-L), + * set up a complete set of internal coordinates involving A and B in the + * direction of atom A. This means all internal coordinates with A and B + * as I and J (should be only 1), as J and K, and as K and L. + */ +int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topology const& topIn) +{ + mprintf("DEBUG: SetFromFrameAroundBond: atA= %s (%i) atB= %s (%i)\n", + topIn.AtomMaskName(atA).c_str(), atA+1, + topIn.AtomMaskName(atB).c_str(), atB+1); + // Sanity check. A and B must be bonded + if (!topIn[atA].IsBondedTo(atB)) { + mprinterr("Internal Error: SetFromFrameAroundBond(): Atoms %s and %s are not bonded.\n", + topIn.AtomMaskName(atA).c_str(), topIn.AtomMaskName(atB).c_str()); + return 1; + } + IC_.clear(); + + // First, make sure atom B as a bond depth of at least 2. + Atom const& AJ = topIn[atB]; + typedef std::pair Apair; + std::vector KLpairs; + for (Atom::bond_iterator kat = AJ.bondbegin(); kat != AJ.bondend(); ++kat) + { + if (*kat != atA) { + mprintf("DEBUG: kat= %s\n", topIn.AtomMaskName(*kat).c_str()); + Atom const& AK = topIn[*kat]; + for (Atom::bond_iterator lat = AK.bondbegin(); lat != AK.bondend(); ++lat) + { + if (*lat != atB) { + mprintf("DEBUG: lat= %s\n", topIn.AtomMaskName(*lat).c_str()); + KLpairs.push_back( Apair(*kat, *lat) ); + } + } + } + } + for (std::vector::const_iterator it = KLpairs.begin(); + it != KLpairs.end(); ++it) + mprintf("DEBUG:\t\tKL pair %s - %s\n", topIn.AtomMaskName(it->first).c_str(), + topIn.AtomMaskName(it->second).c_str()); + + return 0; +} + +// ----------------------------------------------------------------------------- /** \return Position of atom I from given internal coordinate. */ Vec3 Zmatrix::AtomIposition(InternalCoords const& ic, Frame const& frameOut) { diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 983a655649..35d6a995b4 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -33,6 +33,8 @@ class Zmatrix { int SetFromFrame(Frame const&, Topology const&, int); /// Convert molecule 0 of Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&); + /// Get internal coordinates around bond in one direction. + int SetFromFrameAroundBond(int, int, Frame const&, Topology const&); /// Set Frame from internal coords int SetToFrame(Frame&) const; From 8a14f27d50590883d65c60901e586e291c21aefc Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 12:11:38 -0400 Subject: [PATCH 127/245] Select K and L atom candidates for initial IC, set up initial IC. --- src/Exec_Graft.cpp | 10 +++++-- src/Structure/Zmatrix.cpp | 50 ++++++++++++++++++++++++++++++++--- src/Structure/Zmatrix.h | 4 ++- src/Structure/structuredepend | 2 +- src/cpptrajdepend | 8 +++--- 5 files changed, 62 insertions(+), 12 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 4b551267fa..fddcd8a733 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -324,17 +324,23 @@ const zmatrix.print(); // DEBUG // Generate Zmatrix only for ICs involving bonded atoms Zmatrix bondZmatrix; - // Make atA belong to the smaller fragment + // Make atA belong to the smaller fragment. atB fragment will be "known" + Barray posKnown( combinedTop.Natom(), false ); int atA, atB; + // NOTE: mol0 is tgt. mol1 is src. if (heavy_atom_count(*mol0Top) < heavy_atom_count(*mol1Top)) { atA = tgtBondAtoms[0]; atB = srcBondAtoms[0]; + for (int at = mol0Top->Natom(); at != combinedTop.Natom(); at++) + posKnown[at] = true; } else { atA = srcBondAtoms[0]; atB = tgtBondAtoms[0]; + for (int at = 0; at != mol0Top->Natom(); at++) + posKnown[at] = true; } bondZmatrix.SetDebug( 2 ); // FIXME - if (bondZmatrix.SetFromFrameAroundBond(atA, atB, CombinedFrame, combinedTop)) { + if (bondZmatrix.SetFromFrameAroundBond(atA, atB, CombinedFrame, combinedTop, posKnown, atomChirality)) { mprinterr("Error: Zmatrix setup for ICs around %s and %s failed.\n", combinedTop.AtomMaskName(atA).c_str(), combinedTop.AtomMaskName(atB).c_str()); diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 35364933e8..1ce9be0cfb 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -4,6 +4,7 @@ #include // cos #include // std::pair #include "Zmatrix.h" +#include "Model.h" #include "../Frame.h" #include "../CpptrajStdio.h" #include "../Constants.h" @@ -785,7 +786,9 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu * direction of atom A. This means all internal coordinates with A and B * as I and J (should be only 1), as J and K, and as K and L. */ -int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topology const& topIn) +int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topology const& topIn, + std::vector const& atomPositionKnown, + std::vector const& atomChirality) { mprintf("DEBUG: SetFromFrameAroundBond: atA= %s (%i) atB= %s (%i)\n", topIn.AtomMaskName(atA).c_str(), atA+1, @@ -799,18 +802,19 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo IC_.clear(); // First, make sure atom B as a bond depth of at least 2. + // Choose K and L atoms given atA is I and atB is J. Atom const& AJ = topIn[atB]; typedef std::pair Apair; std::vector KLpairs; for (Atom::bond_iterator kat = AJ.bondbegin(); kat != AJ.bondend(); ++kat) { if (*kat != atA) { - mprintf("DEBUG: kat= %s\n", topIn.AtomMaskName(*kat).c_str()); + //mprintf("DEBUG: kat= %s\n", topIn.AtomMaskName(*kat).c_str()); Atom const& AK = topIn[*kat]; for (Atom::bond_iterator lat = AK.bondbegin(); lat != AK.bondend(); ++lat) { - if (*lat != atB) { - mprintf("DEBUG: lat= %s\n", topIn.AtomMaskName(*lat).c_str()); + if (*lat != atB && *lat != atA) { + //mprintf("DEBUG: lat= %s\n", topIn.AtomMaskName(*lat).c_str()); KLpairs.push_back( Apair(*kat, *lat) ); } } @@ -820,6 +824,44 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo it != KLpairs.end(); ++it) mprintf("DEBUG:\t\tKL pair %s - %s\n", topIn.AtomMaskName(it->first).c_str(), topIn.AtomMaskName(it->second).c_str()); + if (KLpairs.empty()) { + mprinterr("Error: SetFromFrameAroundBond(): Could not find an atom pair bonded to atom %s\n", + topIn.AtomMaskName(atB).c_str()); + return 1; + } + // TODO be smarter about how K and L are selected? + double maxMass = topIn[KLpairs[0].first].Mass() + topIn[KLpairs[0].second].Mass(); + unsigned int maxIdx = 0; + for (unsigned int idx = 1; idx < KLpairs.size(); idx++) { + double sumMass = topIn[KLpairs[idx].first].Mass() + topIn[KLpairs[idx].second].Mass(); + if (sumMass > maxMass) { + maxMass = sumMass; + maxIdx = idx; + } + } + int atk0 = KLpairs[maxIdx].first; + int atl0 = KLpairs[maxIdx].second; + mprintf("DEBUG: Chosen KL pair: %s - %s\n",topIn.AtomMaskName(atk0).c_str(), + topIn.AtomMaskName(atl0).c_str()); + // Set dist, theta, phi for atA atB K L internal coord + mprintf("DEBUG: IC (i j) %i - %i - %i - %i\n", atA+1, atB+1, atk0+1, atl0+1); + double newDist = Atom::GetBondLength( topIn[atA].Element(), topIn[atB].Element() ); + mprintf("DEBUG:\t\tnewDist= %g\n", newDist); + double newTheta = 0; + if (Cpptraj::Structure::Model::AssignTheta(newTheta, atA, atB, atk0, topIn, frameIn, atomPositionKnown)) { + mprinterr("Error: theta assignment failed.\n"); + return 1; + } + mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); + double newPhi = 0; + if (Cpptraj::Structure::Model::AssignPhi(newPhi, atA, atB, atk0, atl0, topIn, frameIn, atomPositionKnown, atomChirality)) { + mprinterr("Error: phi assignment failed.\n"); + return 1; + } + mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); + // TODO be smarter about these values + InternalCoords newIc( atA, atB, atk0, atl0, newDist, newTheta*Constants::RADDEG, newPhi*Constants::RADDEG ); + newIc.printIC(topIn); return 0; } diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 35d6a995b4..0be8053f98 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -2,6 +2,7 @@ #define INC_STRUCTURE_ZMATRIX_H #include "InternalCoords.h" #include "../Vec3.h" +#include "../Chirality.h" class Frame; class Topology; class Molecule; @@ -34,7 +35,8 @@ class Zmatrix { /// Convert molecule 0 of Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&); /// Get internal coordinates around bond in one direction. - int SetFromFrameAroundBond(int, int, Frame const&, Topology const&); + int SetFromFrameAroundBond(int, int, Frame const&, Topology const&, + std::vector const&, std::vector const&); /// Set Frame from internal coords int SetToFrame(Frame&) const; diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index 2f1ac25057..9a5cbf54fc 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -9,4 +9,4 @@ Sugar.o : Sugar.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants. SugarBuilder.o : SugarBuilder.cpp ../ArgList.h ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../CharMask.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajFile.h ../CpptrajStdio.h ../DistRoutines.h ../FileIO.h ../FileName.h ../Frame.h ../ImageOption.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h LinkAtom.h ResStatArray.h StructureRoutines.h Sugar.h SugarBuilder.h SugarLinkAtoms.h SugarToken.h SugarLinkAtoms.o : SugarLinkAtoms.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../StringRoutines.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h LinkAtom.h SugarLinkAtoms.h SugarToken.o : SugarToken.cpp ../ArgList.h ../CpptrajStdio.h SugarToken.h -Zmatrix.o : Zmatrix.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h InternalCoords.h Zmatrix.h +Zmatrix.o : Zmatrix.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h InternalCoords.h Model.h Zmatrix.h diff --git a/src/cpptrajdepend b/src/cpptrajdepend index cb7f699e84..639e57164c 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -204,7 +204,7 @@ DataFileList.o : DataFileList.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h A DataFilter.o : DataFilter.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_integer.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO.o : DataIO.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataSet.h DataSetList.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixDbl.h Dimension.h FileIO.h FileName.h Frame.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 Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_AmberEne.o : DataIO_AmberEne.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberEne.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h -DataIO_AmberPrep.o : DataIO_AmberPrep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h BondSearch.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberPrep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h +DataIO_AmberPrep.o : DataIO_AmberPrep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h BondSearch.h Box.h BufferedLine.h Chirality.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberPrep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CCP4.o : DataIO_CCP4.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ByteRoutines.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CCP4.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridFlt.h Dimension.h FileIO.h FileName.h Frame.h Grid.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmFastRep.o : DataIO_CharmmFastRep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmFastRep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_RemLog.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmOutput.o : DataIO_CharmmOutput.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmOutput.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_double.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h @@ -254,7 +254,7 @@ DataSet_Tensor.o : DataSet_Tensor.cpp AssociatedData.h CpptrajFile.h DataSet.h D DataSet_Topology.o : DataSet_Topology.cpp AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Topology.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ParmFile.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataSet_Vector.o : DataSet_Vector.cpp ArrayIterator.h AssociatedData.h ComplexArray.h Constants.h Corr.h CpptrajFile.h DataSet.h DataSet_1D.h DataSet_Vector.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h PubFFT.h Range.h SymbolExporting.h TextFormat.h Vec3.h DataSet_Vector_Scalar.o : DataSet_Vector_Scalar.cpp AssociatedData.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Vector_Scalar.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h TextFormat.h Vec3.h -DataSet_Zmatrix.o : DataSet_Zmatrix.cpp AssociatedData.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Zmatrix.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h Structure/InternalCoords.h Structure/Zmatrix.h TextFormat.h Vec3.h +DataSet_Zmatrix.o : DataSet_Zmatrix.cpp AssociatedData.h Chirality.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Zmatrix.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h Structure/InternalCoords.h Structure/Zmatrix.h TextFormat.h Vec3.h DataSet_double.o : DataSet_double.cpp AssociatedData.h CpptrajFile.h DataSet.h DataSet_1D.h DataSet_double.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h TextFormat.h DataSet_float.o : DataSet_float.cpp AssociatedData.h CpptrajFile.h DataSet.h DataSet_1D.h DataSet_float.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h TextFormat.h DataSet_integer_disk.o : DataSet_integer_disk.cpp AssociatedData.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_1D.h DataSet_integer.h DataSet_integer_disk.h Dimension.h FileIO.h FileName.h File_TempName.h MetaData.h NC_Routines.h Parallel.h Range.h TextFormat.h @@ -336,7 +336,7 @@ Exec_Top.o : Exec_Top.cpp Action.h ActionList.h ActionState.h Analysis.h Analysi Exec_Traj.o : Exec_Traj.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_Traj.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_UpdateParameters.o : Exec_UpdateParameters.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_Parameters.h DataSet_Topology.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_UpdateParameters.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_ViewRst.o : Exec_ViewRst.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.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_ViewRst.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h ViewRst.h -Exec_Zmatrix.o : Exec_Zmatrix.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_Zmatrix.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Zmatrix.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 Segment.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h +Exec_Zmatrix.o : Exec_Zmatrix.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Chirality.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_Zmatrix.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Zmatrix.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 Segment.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h ExtendedSimilarity.o : ExtendedSimilarity.cpp AssociatedData.h Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Coords.h Dimension.h ExtendedSimilarity.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Topology.h TypeNameHolder.h Unit.h Vec3.h ExternalFxn.o : ExternalFxn.cpp Random.h FileIO_Bzip2.o : FileIO_Bzip2.cpp CpptrajStdio.h FileIO.h FileIO_Bzip2.h @@ -442,7 +442,7 @@ Structure/Sugar.o : Structure/Sugar.cpp Atom.h AtomMask.h AtomType.h Box.h Const Structure/SugarBuilder.o : Structure/SugarBuilder.cpp ArgList.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h CharMask.h Chirality.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DistRoutines.h FileIO.h FileName.h Frame.h ImageOption.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/LinkAtom.h Structure/ResStatArray.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarBuilder.h Structure/SugarLinkAtoms.h Structure/SugarToken.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarLinkAtoms.o : Structure/SugarLinkAtoms.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/LinkAtom.h Structure/SugarLinkAtoms.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarToken.o : Structure/SugarToken.cpp ArgList.h CpptrajStdio.h Structure/SugarToken.h -Structure/Zmatrix.o : Structure/Zmatrix.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h +Structure/Zmatrix.o : Structure/Zmatrix.cpp Atom.h AtomMask.h AtomType.h Box.h Chirality.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/InternalCoords.h Structure/Model.h Structure/Zmatrix.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h StructureCheck.o : StructureCheck.cpp Atom.h AtomMask.h AtomType.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h ExclusionArray.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StructureCheck.h SymbolExporting.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h StructureMapper.o : StructureMapper.cpp AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StructureMapper.h SymbolExporting.h TextFormat.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h SymmetricRmsdCalc.o : SymmetricRmsdCalc.cpp ArrayIterator.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h Hungarian.h ImageOption.h MapAtom.h MaskToken.h Matrix.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h SymmetricRmsdCalc.h Topology.h TypeNameHolder.h Unit.h Vec3.h From 075fb75b5221d671cf17a1e8633783c6170b49c3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 14:49:08 -0400 Subject: [PATCH 128/245] Print the new z matrix --- src/Exec_Graft.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index fddcd8a733..f91749c542 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -346,6 +346,7 @@ const combinedTop.AtomMaskName(atB).c_str()); return CpptrajState::ERR; } + bondZmatrix.print(); // Map atom j to ICs to change typedef std::map ICmapType; From cca82fca7e1a1177df91a546f3504da69785296b Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 14:49:24 -0400 Subject: [PATCH 129/245] Print values --- src/Structure/InternalCoords.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Structure/InternalCoords.cpp b/src/Structure/InternalCoords.cpp index 74c08fb182..3161f023c7 100644 --- a/src/Structure/InternalCoords.cpp +++ b/src/Structure/InternalCoords.cpp @@ -59,10 +59,11 @@ InternalCoords& InternalCoords::operator=(InternalCoords const& rhs) { /** Print to stdout */ void InternalCoords::printIC(Topology const& top) const { - mprintf(" %6i %6i %6i %6i [%s - %s - %s - %s]\n", + mprintf(" %6i %6i %6i %6i [%s - %s - %s - %s] r=%g t=%g p=%g\n", AtI()+1, AtJ()+1, AtK()+1, AtL()+1, top.AtomMaskName(AtI()).c_str(), top.AtomMaskName(AtJ()).c_str(), top.AtomMaskName(AtK()).c_str(), - top.AtomMaskName(AtL()).c_str()); + top.AtomMaskName(AtL()).c_str(), + val_[0], val_[1], val_[2]); } From 3b950fdc65e5b936fc4a45bcff37bca4a2bfeb86 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 15:00:16 -0400 Subject: [PATCH 130/245] Model in the J K and K L ICs --- src/Structure/Zmatrix.cpp | 70 +++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 6 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 1ce9be0cfb..da7bee8211 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -793,6 +793,9 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo mprintf("DEBUG: SetFromFrameAroundBond: atA= %s (%i) atB= %s (%i)\n", topIn.AtomMaskName(atA).c_str(), atA+1, topIn.AtomMaskName(atB).c_str(), atB+1); + mprintf("DEBUG: Atoms:\n"); + for (int at = 0; at != topIn.Natom(); ++at) + mprintf("DEBUG:\t\t%s (%i) %s\n", topIn.AtomMaskName(at).c_str(), (int)atomPositionKnown[at], Cpptraj::Chirality::chiralStr(atomChirality[at])); // Sanity check. A and B must be bonded if (!topIn[atA].IsBondedTo(atB)) { mprinterr("Internal Error: SetFromFrameAroundBond(): Atoms %s and %s are not bonded.\n", @@ -801,6 +804,9 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo } IC_.clear(); + Barray hasIC( topIn.Natom(), false ); + unsigned int nHasIC = 0; + // First, make sure atom B as a bond depth of at least 2. // Choose K and L atoms given atA is I and atB is J. Atom const& AJ = topIn[atB]; @@ -843,25 +849,77 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo int atl0 = KLpairs[maxIdx].second; mprintf("DEBUG: Chosen KL pair: %s - %s\n",topIn.AtomMaskName(atk0).c_str(), topIn.AtomMaskName(atl0).c_str()); - // Set dist, theta, phi for atA atB K L internal coord + // ---- I J: Set dist, theta, phi for atA atB K L internal coord --- mprintf("DEBUG: IC (i j) %i - %i - %i - %i\n", atA+1, atB+1, atk0+1, atl0+1); double newDist = Atom::GetBondLength( topIn[atA].Element(), topIn[atB].Element() ); mprintf("DEBUG:\t\tnewDist= %g\n", newDist); double newTheta = 0; if (Cpptraj::Structure::Model::AssignTheta(newTheta, atA, atB, atk0, topIn, frameIn, atomPositionKnown)) { - mprinterr("Error: theta assignment failed.\n"); + mprinterr("Error: theta (i j) assignment failed.\n"); return 1; } mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); double newPhi = 0; if (Cpptraj::Structure::Model::AssignPhi(newPhi, atA, atB, atk0, atl0, topIn, frameIn, atomPositionKnown, atomChirality)) { - mprinterr("Error: phi assignment failed.\n"); + mprinterr("Error: phi (i j) assignment failed.\n"); return 1; } mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); - // TODO be smarter about these values - InternalCoords newIc( atA, atB, atk0, atl0, newDist, newTheta*Constants::RADDEG, newPhi*Constants::RADDEG ); - newIc.printIC(topIn); + IC_.push_back(InternalCoords( atA, atB, atk0, atl0, newDist, newTheta*Constants::RADDEG, newPhi*Constants::RADDEG )); + mprintf("DEBUG: MODEL I J IC: "); + IC_.back().printIC(topIn); + MARK( atA, hasIC, nHasIC ); + // ----- J K: Set up ICs for X atA atB K --------------------------- + Atom const& AJ1 = topIn[atA]; + //Atom const& AK1 = topIn[atB]; + //Atom const& AL1 = topIn[atk0]; + for (Atom::bond_iterator iat = AJ1.bondbegin(); iat != AJ1.bondend(); ++iat) + { + if (*iat != atB) { + // Use existing dist + newDist = sqrt( DIST2_NoImage(frameIn.XYZ(*iat), frameIn.XYZ(atA)) ); + // Set theta and phi for I atA atB K + newTheta = 0; + if (Cpptraj::Structure::Model::AssignTheta(newTheta, *iat, atA, atB, topIn, frameIn, atomPositionKnown)) { + mprinterr("Error: theta (j k) assignment failed.\n"); + return 1; + } + mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); + newPhi = 0; + if (Cpptraj::Structure::Model::AssignPhi(newPhi, *iat, atA, atB, atk0, topIn, frameIn, atomPositionKnown, atomChirality)) { + mprinterr("Error: phi (j k) assignment failed.\n"); + return 1; + } + mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); + IC_.push_back(InternalCoords( *iat, atA, atB, atk0, newDist, newTheta*Constants::RADDEG, newPhi*Constants::RADDEG )); + mprintf("DEBUG: MODEL J K IC: "); + IC_.back().printIC(topIn); + MARK( *iat, hasIC, nHasIC ); + // ----- K L: Set up ICs for X iat atA atB --------------------- + Atom const& AJ2 = topIn[*iat]; + for (Atom::bond_iterator i2at = AJ2.bondbegin(); i2at != AJ2.bondend(); ++i2at) + { + if (*i2at != atA && *i2at != atB) { + // Use existing dist and theta + newDist = sqrt( DIST2_NoImage(frameIn.XYZ(*i2at), frameIn.XYZ(*iat)) ); + newTheta = CalcAngle( frameIn.XYZ(*i2at), frameIn.XYZ(*iat), frameIn.XYZ(atA) ); + // Set phi for X iat atA atB + newPhi = 0; + if (Cpptraj::Structure::Model::AssignPhi(newPhi, *i2at, *iat, atA, atB, topIn, frameIn, atomPositionKnown, atomChirality)) { + mprinterr("Error: phi (k l) assignment failed.\n"); + return 1; + } + mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); + IC_.push_back(InternalCoords( *i2at, *iat, atA, atB, newDist, newTheta*Constants::RADDEG, newPhi*Constants::RADDEG )); + mprintf("DEBUG: MODEL K L IC: "); + IC_.back().printIC(topIn); + MARK( *i2at, hasIC, nHasIC ); + } + } + } + } + // Add the rest + //if (traceMol(atl0, atk0, atB, frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) return 1; return 0; } From df04b2ca62d2b560c916d07f88af704a49e1eb33 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 15:02:48 -0400 Subject: [PATCH 131/245] Mark known atoms as having an IC --- src/Structure/Zmatrix.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index da7bee8211..8619b64315 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -806,6 +806,12 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo Barray hasIC( topIn.Natom(), false ); unsigned int nHasIC = 0; + // Mark known atoms as already having IC + for (std::vector::const_iterator it = atomPositionKnown.begin(); + it != atomPositionKnown.end(); ++it) + { + if (*it) MARK( it - atomPositionKnown.begin(), hasIC, nHasIC ); + } // First, make sure atom B as a bond depth of at least 2. // Choose K and L atoms given atA is I and atB is J. @@ -919,7 +925,7 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo } } // Add the rest - //if (traceMol(atl0, atk0, atB, frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) return 1; + if (traceMol(atl0, atk0, atB, frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) return 1; return 0; } From 8ac3965176229695cd58d404ba717cf3331620c0 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 15:13:29 -0400 Subject: [PATCH 132/245] Add some debug print. Dont put atomk on the next atoms list when tracing. Dont add ICs if one is present --- src/Structure/Zmatrix.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 8619b64315..e1ef3f5509 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -469,7 +469,7 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, if (!hasIC[*bat]) { if (topIn[*bat].Nbonds() == 1) OneBondAtoms.push_back( *bat ); - else + else if (*bat != atK) OtherAtoms.push_back( *bat ); } } @@ -482,6 +482,8 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, // Create ICs for 1 bond atoms for (Iarray::const_iterator atI = OneBondAtoms.begin(); atI != OneBondAtoms.end(); ++atI) { addIc(*atI, atJ, atK, atL, frameIn.XYZ(*atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); + mprintf("DEBUG: Added (1 atom) "); + IC_.back().printIC(topIn); MARK(*atI, hasIC, nHasIC); } // If nothing else, check the stack @@ -505,6 +507,8 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, } if (!hasIC[p.ai_]) { addIc(p.ai_, p.aj_, p.ak_, p.al_, frameIn.XYZ(p.ai_), frameIn.XYZ(p.aj_), frameIn.XYZ(p.ak_), frameIn.XYZ(p.al_)); + mprintf("DEBUG: Added (stack) "); + IC_.back().printIC(topIn); Branches.pop(); MARK(p.ai_, hasIC, nHasIC); // Designate branch as next. @@ -535,8 +539,12 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, topIn.AtomMaskName(atL).c_str()); } // Add lowest index as IC - addIc(atI, atJ, atK, atL, frameIn.XYZ(atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); - MARK(atI, hasIC, nHasIC); + if (!hasIC[atI]) { + addIc(atI, atJ, atK, atL, frameIn.XYZ(atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); + mprintf("DEBUG: Added (next) "); + IC_.back().printIC(topIn); + MARK(atI, hasIC, nHasIC); + } // Place all above lowest index on the stack. for (unsigned int ii = 1; ii < OtherAtoms.size(); ii++) { Branches.push( PHI(OtherAtoms[ii], atJ, atK, atL) ); From 619db99bff029831f0a02d2cf1d3400894952461 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 15:24:37 -0400 Subject: [PATCH 133/245] Only trace remaining branches once all the ICs to be modeled in have been added. --- src/Structure/Zmatrix.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index e1ef3f5509..e49aad908b 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -887,6 +887,8 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo Atom const& AJ1 = topIn[atA]; //Atom const& AK1 = topIn[atB]; //Atom const& AL1 = topIn[atk0]; + // ToTrace will hold atoms we need to trace after the modeled ones are done. + std::vector ToTrace; for (Atom::bond_iterator iat = AJ1.bondbegin(); iat != AJ1.bondend(); ++iat) { if (*iat != atB) { @@ -928,12 +930,20 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo mprintf("DEBUG: MODEL K L IC: "); IC_.back().printIC(topIn); MARK( *i2at, hasIC, nHasIC ); + // Trace from atA *iat *i2at outwards + ToTrace.push_back(atA); + ToTrace.push_back(*iat); + ToTrace.push_back(*i2at); + //if (traceMol(atA, *iat, *i2at, frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) return 1; } } } } // Add the rest - if (traceMol(atl0, atk0, atB, frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) return 1; + for (unsigned int idx = 0; idx < ToTrace.size(); idx += 3) { + if (traceMol(ToTrace[idx], ToTrace[idx+1], ToTrace[idx+2], frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) + return 1; + } return 0; } From d8ac49de8c3f52703585a20ee0345912ee7fb099 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 15:28:37 -0400 Subject: [PATCH 134/245] Just in case, dont add a K L IC if we've already modeled it from somewhere else --- src/Structure/Zmatrix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index e49aad908b..3674722c09 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -915,7 +915,7 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo Atom const& AJ2 = topIn[*iat]; for (Atom::bond_iterator i2at = AJ2.bondbegin(); i2at != AJ2.bondend(); ++i2at) { - if (*i2at != atA && *i2at != atB) { + if (*i2at != atA && *i2at != atB && !hasIC[*i2at]) { // Use existing dist and theta newDist = sqrt( DIST2_NoImage(frameIn.XYZ(*i2at), frameIn.XYZ(*iat)) ); newTheta = CalcAngle( frameIn.XYZ(*i2at), frameIn.XYZ(*iat), frameIn.XYZ(atA) ); From 404df07d15a500b373cd276f853a32c6a2a60681 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 15:36:09 -0400 Subject: [PATCH 135/245] Use bondZmatrix to set coordinates instead of zmatrix --- src/Exec_Graft.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index f91749c542..f55dba8e64 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -315,13 +315,13 @@ const atomPositionKnown[aidx] = true;*/ // Generate Z matrix FIXME ensure mol 0 is the one we are interested in - Zmatrix zmatrix; +/* Zmatrix zmatrix; zmatrix.SetDebug( 2 ); // FIXME if (zmatrix.SetFromFrame(CombinedFrame, combinedTop)) { mprinterr("Error: Zmatrix setup failed.\n"); return CpptrajState::ERR; } - zmatrix.print(); // DEBUG + zmatrix.print(); // DEBUG*/ // Generate Zmatrix only for ICs involving bonded atoms Zmatrix bondZmatrix; // Make atA belong to the smaller fragment. atB fragment will be "known" @@ -347,7 +347,11 @@ const return CpptrajState::ERR; } bondZmatrix.print(); - + if (bondZmatrix.SetToFrame( CombinedFrame, posKnown )) { + mprinterr("Error: Conversion from bondZmatrix to Cartesian coords failed.\n"); + return CpptrajState::ERR; + } +/* // Map atom j to ICs to change typedef std::map ICmapType; typedef std::pair ICpairType; @@ -469,7 +473,7 @@ const InternalCoords const& oic = zmatrix[*jt]; mprintf("DEBUG:\t\t"); oic.printIC(combinedTop); - /*double dist = oic.Dist(); + *double dist = oic.Dist(); double theta = oic.Theta(); double phi = oic.Phi(); if (it->second.Type() == ICholder::IJ) { @@ -481,13 +485,13 @@ const //} InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), dist, theta, phi ); zmatrix.SetIC( *jt, newIc ); - //phi += interval;*/ + //phi += interval;* } - } + } if (zmatrix.SetToFrame( CombinedFrame )) { mprinterr("Error: Conversion from Zmatrix to Cartesian coords failed.\n"); return CpptrajState::ERR; - } + }*/ // Add frame to the output data set outCoords->AddFrame( CombinedFrame ); From 3f5603d58220f7853969a7a3a122347a182ec04e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 19 Oct 2023 16:47:05 -0400 Subject: [PATCH 136/245] Update output for new graft ic behavior. --- test/Test_Graft/IC.Final.graft.mol2.save | 68 ++++++++++++------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/test/Test_Graft/IC.Final.graft.mol2.save b/test/Test_Graft/IC.Final.graft.mol2.save index c03030078c..21a2d93021 100644 --- a/test/Test_Graft/IC.Final.graft.mol2.save +++ b/test/Test_Graft/IC.Final.graft.mol2.save @@ -6,40 +6,40 @@ 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.2807 5.0231 1.1949 CA 2 PRY 0.033204 - 11 C3 4.0732 5.9437 2.2258 CA 2 PRY -0.149016 - 12 H4 3.4195 5.6866 3.0420 HA 2 PRY 0.153372 - 13 C4 4.6848 7.1755 2.2255 CA 2 PRY -0.336291 - 14 H5 4.5207 7.8790 3.0207 HA 2 PRY 0.167425 - 15 C5 5.5370 7.5371 1.1825 CA 2 PRY 0.423974 - 16 O1 6.0903 8.7648 1.2743 OS 2 PRY -0.391815 - 17 C6 5.7578 6.6416 0.1526 CA 2 PRY -0.336291 - 18 H6 6.4078 6.8827 -0.6661 HA 2 PRY 0.167425 - 19 C7 5.1278 5.3990 0.1715 CA 2 PRY -0.149016 - 20 H7 5.3150 4.7180 -0.6406 HA 2 PRY 0.153372 - 21 C8 6.9403 9.2285 0.2534 CT 2 PRY 0.358047 - 22 C9 7.3211 10.6373 0.5988 CM 2 PRY -0.496680 - 23 C10 8.5229 11.1923 0.5638 CM 2 PRY 0.317549 - 24 C11 8.7059 12.6481 0.9206 CT 2 PRY -0.394216 - 25 C12 9.8029 10.4926 0.1773 CT 2 PRY -0.394216 - 26 H8 6.4054 9.2100 -0.6945 H1 2 PRY 0.001584 - 27 H9 7.7993 8.5763 0.1638 H1 2 PRY 0.001584 - 28 H10 6.4802 11.2448 0.8902 HA 2 PRY 0.192041 - 29 H11 9.1371 13.1988 0.0882 HC 2 PRY 0.110363 - 30 H12 9.3919 12.7545 1.7582 HC 2 PRY 0.110363 - 31 H13 7.7685 13.1197 1.1886 HC 2 PRY 0.110363 - 32 H14 10.2231 10.9445 -0.7190 HC 2 PRY 0.110363 - 33 H15 9.6811 9.4354 -0.0125 HC 2 PRY 0.110363 - 34 H16 10.5435 10.6065 0.9639 HC 2 PRY 0.110363 + 1 N 6.9477 2.0476 -0.1594 N 1 TYR -0.415700 + 2 H 7.2851 2.7522 0.4807 H 1 TYR 0.271900 + 3 CA 5.5211 1.8009 -0.2198 CX 1 TYR -0.001400 + 4 HA 5.0154 2.4586 0.4872 H1 1 TYR 0.087600 + 5 CB 5.1981 0.3552 0.1428 CT 1 TYR -0.015200 + 6 HB2 5.5459 0.1487 1.1550 HC 1 TYR 0.029500 + 7 HB3 5.6984 -0.3147 -0.5565 HC 1 TYR 0.029500 + 8 C 5.0218 2.0478 -1.6362 C 1 TYR 0.597300 + 9 O 4.2047 2.9373 -1.8633 O 1 TYR -0.567900 + 10 C2 3.6760 0.1340 0.0670 CA 2 PRY 0.033204 + 11 C3 3.1370 -1.1220 0.3590 CA 2 PRY -0.149016 + 12 H4 3.7940 -1.9290 0.6360 HA 2 PRY 0.153372 + 13 C4 1.7830 -1.3560 0.3010 CA 2 PRY -0.336291 + 14 H5 1.3750 -2.3240 0.5260 HA 2 PRY 0.167425 + 15 C5 0.9070 -0.3310 -0.0550 CA 2 PRY 0.423974 + 16 O1 -0.4020 -0.6590 -0.0810 OS 2 PRY -0.391815 + 17 C6 1.4180 0.9200 -0.3470 CA 2 PRY -0.336291 + 18 H6 0.7760 1.7340 -0.6230 HA 2 PRY 0.167425 + 19 C7 2.7930 1.1360 -0.2830 CA 2 PRY -0.149016 + 20 H7 3.1680 2.1180 -0.5140 HA 2 PRY 0.153372 + 21 C8 -1.3580 0.3020 -0.4580 CT 2 PRY 0.358047 + 22 C9 -2.6930 -0.3810 -0.4700 CM 2 PRY -0.496680 + 23 C10 -3.8370 0.0490 0.0400 CM 2 PRY 0.317549 + 24 C11 -5.0960 -0.7730 -0.1000 CT 2 PRY -0.394216 + 25 C12 -4.0350 1.3480 0.7820 CT 2 PRY -0.394216 + 26 H8 -1.1210 0.6720 -1.4540 H1 2 PRY 0.001584 + 27 H9 -1.3270 1.1410 0.2250 H1 2 PRY 0.001584 + 28 H10 -2.6800 -1.3290 -0.9820 HA 2 PRY 0.192041 + 29 H11 -5.8660 -0.2140 -0.6260 HC 2 PRY 0.110363 + 30 H12 -5.5010 -1.0240 0.8780 HC 2 PRY 0.110363 + 31 H13 -4.9190 -1.6950 -0.6400 HC 2 PRY 0.110363 + 32 H14 -4.7240 1.9910 0.2380 HC 2 PRY 0.110363 + 33 H15 -3.1210 1.9030 0.9400 HC 2 PRY 0.110363 + 34 H16 -4.4820 1.1590 1.7540 HC 2 PRY 0.110363 @BOND 1 1 3 1 2 3 5 1 From 2fff3afcfe83c210e9c20019f6a8dc43887cc7f1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 20 Oct 2023 08:26:50 -0400 Subject: [PATCH 137/245] Change name of output for DNA graft with charges test --- .../{Nucleotide.mol2.save => Nucleotide.charge.mol2.save} | 0 test/Test_Graft/RunTest.sh | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) rename test/Test_Graft/{Nucleotide.mol2.save => Nucleotide.charge.mol2.save} (100%) diff --git a/test/Test_Graft/Nucleotide.mol2.save b/test/Test_Graft/Nucleotide.charge.mol2.save similarity index 100% rename from test/Test_Graft/Nucleotide.mol2.save rename to test/Test_Graft/Nucleotide.charge.mol2.save diff --git a/test/Test_Graft/RunTest.sh b/test/Test_Graft/RunTest.sh index a1599c458d..adfb0ae69b 100755 --- a/test/Test_Graft/RunTest.sh +++ b/test/Test_Graft/RunTest.sh @@ -2,7 +2,7 @@ . ../MasterTest.sh -CleanFiles cpptraj.in Final.graft.mol2 Nucleotide.pdb Nucleotide.mol2 \ +CleanFiles cpptraj.in Final.graft.mol2 Nucleotide.pdb Nucleotide.charge.mol2 \ IC.Final.graft.mol2 TESTNAME='Graft test' Requires notparallel @@ -178,11 +178,11 @@ graft \ srcmask !(@C3,H4,H5,H6,O1,C1,H1,H2,H3) \ bond @C1,@O3 charge crdset Nucleotide * -crdout Nucleotide Nucleotide.mol2 +crdout Nucleotide Nucleotide.charge.mol2 quit EOF RunCpptraj "$TESTNAME, Construct Nucleic Acid and adjust charge" - DoTest Nucleotide.mol2.save Nucleotide.mol2 + DoTest Nucleotide.charge.mol2.save Nucleotide.charge.mol2 } TyrPry From 49f66e6fbeb13afd878f893743512a440f8da72a Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 20 Oct 2023 09:01:26 -0400 Subject: [PATCH 138/245] Write out IC nucleotide pdb --- test/Test_Graft/RunTest.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/Test_Graft/RunTest.sh b/test/Test_Graft/RunTest.sh index adfb0ae69b..cc21222d80 100755 --- a/test/Test_Graft/RunTest.sh +++ b/test/Test_Graft/RunTest.sh @@ -3,7 +3,7 @@ . ../MasterTest.sh CleanFiles cpptraj.in Final.graft.mol2 Nucleotide.pdb Nucleotide.charge.mol2 \ - IC.Final.graft.mol2 + IC.Final.graft.mol2 IC.Nucleotide.pdb TESTNAME='Graft test' Requires notparallel @@ -135,11 +135,11 @@ graft ic \\ bond @C5',@O5' crdout Nucleotide Nucleotide.ic.mol2 # Format the PDB -#change crdset Nucleotide resname from * to DA -#change crdset Nucleotide oresnums of :1 min 1 max 1 -#change crdset Nucleotide oresnums of :2 min 1 max 1 -#change crdset Nucleotide oresnums of :3 min 1 max 1 -#crdout Nucleotide Nucleotide.pdb +change crdset Nucleotide resname from * to DA +change crdset Nucleotide oresnums of :1 min 1 max 1 +change crdset Nucleotide oresnums of :2 min 1 max 1 +change crdset Nucleotide oresnums of :3 min 1 max 1 +crdout Nucleotide IC.Nucleotide.pdb EOF RunCpptraj "$TESTNAME, Construct Nucleic Acid, IC" #DoTest Nucleotide.pdb.save Nucleotide.pdb From cd76373eb2caac4957a229048623c785d2c437cd Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 20 Oct 2023 14:43:14 -0400 Subject: [PATCH 139/245] Debug print zmatrix with atom names --- src/Exec_Graft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index f55dba8e64..8b6f6d3c4a 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -346,7 +346,7 @@ const combinedTop.AtomMaskName(atB).c_str()); return CpptrajState::ERR; } - bondZmatrix.print(); + bondZmatrix.print(&combinedTop); if (bondZmatrix.SetToFrame( CombinedFrame, posKnown )) { mprinterr("Error: Conversion from bondZmatrix to Cartesian coords failed.\n"); return CpptrajState::ERR; From b1d15ca80e1956269400725d2003553f1c323d80 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 20 Oct 2023 14:43:43 -0400 Subject: [PATCH 140/245] Add atom names to zmatrix print if topology is given. When modelling system, only go out to the J-K level; beyond that try as much as possible to use the existing conformation of fragment 1 --- src/Structure/Zmatrix.cpp | 83 ++++++++++++++++++++++++++++++++------- src/Structure/Zmatrix.h | 4 +- 2 files changed, 71 insertions(+), 16 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 3674722c09..803b19ddfb 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -77,19 +77,31 @@ std::vector Zmatrix::AtomI_indices(int atomi) const { } /** Print to stdout */ -void Zmatrix::print() const { +void Zmatrix::print(Topology* topIn) const { mprintf("%zu internal coords.\n", IC_.size()); mprintf("Seed IC indices : %i %i %i\n", icseed0_+1, icseed1_+1, icseed2_+1); mprintf("Seed Cart. indices : %i %i %i\n", seedAt0_+1, seedAt1_+1, seedAt2_+1); seed0Pos_.Print("Seed0"); seed1Pos_.Print("Seed1"); seed2Pos_.Print("Seed2"); - mprintf("%-8s %8s %8s %8s %8s %12s %12s %12s\n", - "#Idx", "AtI", "AtJ", "AtK", "AtL", "Dist", "Theta", "Phi"); - for (ICarray::const_iterator it = IC_.begin(); it != IC_.end(); ++it) - mprintf("%-8li %8i %8i %8i %8i %12.4f %12.4f %12.4f\n", it - IC_.begin()+1, - it->AtI()+1, it->AtJ()+1, it->AtK()+1, it->AtL()+1, - it->Dist(), it->Theta(), it->Phi()); + if (topIn == 0) { + mprintf("%-8s %8s %8s %8s %8s %12s %12s %12s\n", + "#Idx", "AtI", "AtJ", "AtK", "AtL", "Dist", "Theta", "Phi"); + for (ICarray::const_iterator it = IC_.begin(); it != IC_.end(); ++it) + mprintf("%-8li %8i %8i %8i %8i %12.4f %12.4f %12.4f\n", it - IC_.begin()+1, + it->AtI()+1, it->AtJ()+1, it->AtK()+1, it->AtL()+1, + it->Dist(), it->Theta(), it->Phi()); + } else { + mprintf("%-6s %6s %8s %6s %8s %6s %8s %6s %8s %6s %6s %6s\n", + "#Idx", "AtI", "NmI", "AtJ", "NmJ", "AtK", "NmK", "AtL", "NmL", "Dist", "Theta", "Phi"); + for (ICarray::const_iterator it = IC_.begin(); it != IC_.end(); ++it) + mprintf("%-6li %6i %8s %6i %8s %6i %8s %6i %8s %6.2f %6.2f %6.2f\n", it - IC_.begin()+1, + it->AtI()+1, topIn->AtomMaskName(it->AtI()).c_str(), + it->AtJ()+1, topIn->AtomMaskName(it->AtJ()).c_str(), + it->AtK()+1, topIn->AtomMaskName(it->AtK()).c_str(), + it->AtL()+1, topIn->AtomMaskName(it->AtL()).c_str(), + it->Dist(), it->Theta(), it->Phi()); + } } // ------------------------------------- @@ -885,22 +897,23 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo MARK( atA, hasIC, nHasIC ); // ----- J K: Set up ICs for X atA atB K --------------------------- Atom const& AJ1 = topIn[atA]; + int ati = -1; //Atom const& AK1 = topIn[atB]; //Atom const& AL1 = topIn[atk0]; - // ToTrace will hold atoms we need to trace after the modeled ones are done. - std::vector ToTrace; for (Atom::bond_iterator iat = AJ1.bondbegin(); iat != AJ1.bondend(); ++iat) { if (*iat != atB) { + if (ati == -1) ati = *iat; // Use existing dist newDist = sqrt( DIST2_NoImage(frameIn.XYZ(*iat), frameIn.XYZ(atA)) ); - // Set theta and phi for I atA atB K + // Set theta for I atA atB newTheta = 0; if (Cpptraj::Structure::Model::AssignTheta(newTheta, *iat, atA, atB, topIn, frameIn, atomPositionKnown)) { mprinterr("Error: theta (j k) assignment failed.\n"); return 1; } mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); + // Set phi for I atA atB K newPhi = 0; if (Cpptraj::Structure::Model::AssignPhi(newPhi, *iat, atA, atB, atk0, topIn, frameIn, atomPositionKnown, atomChirality)) { mprinterr("Error: phi (j k) assignment failed.\n"); @@ -912,7 +925,7 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo IC_.back().printIC(topIn); MARK( *iat, hasIC, nHasIC ); // ----- K L: Set up ICs for X iat atA atB --------------------- - Atom const& AJ2 = topIn[*iat]; + /*Atom const& AJ2 = topIn[*iat]; for (Atom::bond_iterator i2at = AJ2.bondbegin(); i2at != AJ2.bondend(); ++i2at) { if (*i2at != atA && *i2at != atB && !hasIC[*i2at]) { @@ -936,14 +949,54 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo ToTrace.push_back(*i2at); //if (traceMol(atA, *iat, *i2at, frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) return 1; } + } */ + } + } + // Handle remaining atoms. + if (AJ1.Nbonds() > 1) { + if (AJ1.Nbonds() == 2) { + mprintf("DEBUG: 2 bonds to %s.\n", topIn.AtomMaskName(atA).c_str()); + if (traceMol(atB, atA, ati, frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) + return 1; + } else { + // 3 or more bonds + double tors; + std::vector priority( AJ1.Nbonds() ); + int at0 = -1; + int at1 = -1; + std::vector remainingAtoms; + Cpptraj::Chirality::DetermineChirality(tors, &priority[0], atA, topIn, frameIn, 0); // FIXME debug level + mprintf("DEBUG: %i bonds to %s\n", AJ1.Nbonds(), topIn.AtomMaskName(atA).c_str()); + for (std::vector::const_iterator it = priority.begin(); it != priority.end(); ++it) { + if (*it != atB) { + mprintf("DEBUG:\t\t%s\n", topIn.AtomMaskName(*it).c_str()); + if (at0 == -1) + at0 = *it; + else if (at1 == -1) + at1 = *it; + else + remainingAtoms.push_back( *it ); + } + } + // at0 atA at1 + if (traceMol(at1, atA, at0, frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) + return 1; + // at1 atA, at0 + if (traceMol(at0, atA, at1, frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) + return 1; + // Remaining atoms. + for (std::vector::const_iterator it = remainingAtoms.begin(); it != remainingAtoms.end(); ++it) { + if (traceMol(at0, atA, *it, frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) + return 1; } } } + // Add the rest - for (unsigned int idx = 0; idx < ToTrace.size(); idx += 3) { - if (traceMol(ToTrace[idx], ToTrace[idx+1], ToTrace[idx+2], frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) - return 1; - } + //for (unsigned int idx = 0; idx < ToTrace.size(); idx += 3) { + // if (traceMol(ToTrace[idx], ToTrace[idx+1], ToTrace[idx+2], frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) + // return 1; + // } return 0; } diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 0be8053f98..6dc6b598ef 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -18,7 +18,9 @@ class Zmatrix { /// Set debug level void SetDebug(int d) { debug_ = d; } /// Print to stdout - void print() const; + void print(Topology*) const; + /// Print to stdout, no atom names + void print() const { print(0); } /// \reserve space for # of internal coords TODO zero out seeds? void reserve(unsigned int n) { IC_.reserve( n ); } From a59de6be664d066d2f65d0d83fe1ac9cfe3042e1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 20 Oct 2023 14:44:40 -0400 Subject: [PATCH 141/245] Update test results --- test/Test_Graft/IC.Final.graft.mol2.save | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/Test_Graft/IC.Final.graft.mol2.save b/test/Test_Graft/IC.Final.graft.mol2.save index 21a2d93021..ea8fa731b2 100644 --- a/test/Test_Graft/IC.Final.graft.mol2.save +++ b/test/Test_Graft/IC.Final.graft.mol2.save @@ -6,15 +6,15 @@ USER_CHARGES @ATOM - 1 N 6.9477 2.0476 -0.1594 N 1 TYR -0.415700 - 2 H 7.2851 2.7522 0.4807 H 1 TYR 0.271900 + 1 N 4.8738 2.7240 0.6904 N 1 TYR -0.415700 + 2 H 4.2210 3.3937 0.3091 H 1 TYR 0.271900 3 CA 5.5211 1.8009 -0.2198 CX 1 TYR -0.001400 - 4 HA 5.0154 2.4586 0.4872 H1 1 TYR 0.087600 + 4 HA 6.6012 1.9392 -0.1712 H1 1 TYR 0.087600 5 CB 5.1981 0.3552 0.1428 CT 1 TYR -0.015200 6 HB2 5.5459 0.1487 1.1550 HC 1 TYR 0.029500 7 HB3 5.6984 -0.3147 -0.5565 HC 1 TYR 0.029500 - 8 C 5.0218 2.0478 -1.6362 C 1 TYR 0.597300 - 9 O 4.2047 2.9373 -1.8633 O 1 TYR -0.567900 + 8 C 5.0649 2.0340 -1.6530 C 1 TYR 0.597300 + 9 O 4.2484 2.9152 -1.9122 O 1 TYR -0.567900 10 C2 3.6760 0.1340 0.0670 CA 2 PRY 0.033204 11 C3 3.1370 -1.1220 0.3590 CA 2 PRY -0.149016 12 H4 3.7940 -1.9290 0.6360 HA 2 PRY 0.153372 From 42a4e1b0b97e8add44d1643ba3e35a5d7afbbebd Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 20 Oct 2023 14:47:56 -0400 Subject: [PATCH 142/245] Add test for building nucleotide with internal coords --- test/Test_Graft/IC.Nucleotide.pdb.save | 33 ++++++++++++++++++++++++++ test/Test_Graft/RunTest.sh | 4 ++-- 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 test/Test_Graft/IC.Nucleotide.pdb.save diff --git a/test/Test_Graft/IC.Nucleotide.pdb.save b/test/Test_Graft/IC.Nucleotide.pdb.save new file mode 100644 index 0000000000..633e3e4fa8 --- /dev/null +++ b/test/Test_Graft/IC.Nucleotide.pdb.save @@ -0,0 +1,33 @@ +ATOM 1 N9 DA 1 4.539 -0.297 3.316 1.00 0.00 N +ATOM 2 C8 DA 1 4.337 -0.846 2.077 1.00 0.00 C +ATOM 3 H8 DA 1 4.152 -0.207 1.226 1.00 0.00 H +ATOM 4 N7 DA 1 4.453 -2.141 2.049 1.00 0.00 N +ATOM 5 C5 DA 1 4.754 -2.480 3.363 1.00 0.00 C +ATOM 6 C6 DA 1 4.998 -3.708 3.989 1.00 0.00 C +ATOM 7 N6 DA 1 4.977 -4.883 3.346 1.00 0.00 N +ATOM 8 H61 DA 1 5.161 -5.739 3.851 1.00 0.00 H +ATOM 9 H62 DA 1 4.777 -4.914 2.356 1.00 0.00 H +ATOM 10 N1 DA 1 5.265 -3.689 5.302 1.00 0.00 N +ATOM 11 C2 DA 1 5.285 -2.520 5.935 1.00 0.00 C +ATOM 12 H2 DA 1 5.498 -2.482 6.993 1.00 0.00 H +ATOM 13 N3 DA 1 5.073 -1.309 5.456 1.00 0.00 N +ATOM 14 C4 DA 1 4.806 -1.356 4.133 1.00 0.00 C +ATOM 15 C5' DA 1 2.648 1.767 5.965 1.00 0.00 C +ATOM 16 H5' DA 1 3.340 1.199 6.588 1.00 0.00 H +ATOM 17 H5'' DA 1 2.100 2.476 6.586 1.00 0.00 H +ATOM 18 C4' DA 1 3.435 2.528 4.911 1.00 0.00 C +ATOM 19 H4' DA 1 3.859 3.430 5.353 1.00 0.00 H +ATOM 20 O4' DA 1 4.595 1.732 4.521 1.00 0.00 O +ATOM 21 C1' DA 1 4.385 1.163 3.237 1.00 0.00 C +ATOM 22 H1' DA 1 5.115 1.568 2.538 1.00 0.00 H +ATOM 23 C3' DA 1 2.698 2.797 3.597 1.00 0.00 C +ATOM 24 H3' DA 1 1.629 2.885 3.790 1.00 0.00 H +ATOM 25 C2' DA 1 2.974 1.502 2.753 1.00 0.00 C +ATOM 26 H2' DA 1 2.040 1.006 2.489 1.00 0.00 H +ATOM 27 O3' DA 1 3.160 3.896 2.824 1.00 0.00 O +ATOM 28 P DA 1 0.884 0.051 6.465 0.00 0.00 P +ATOM 29 O1P DA 1 0.522 1.032 7.498 0.00 0.00 O +ATOM 30 O2P DA 1 -0.065 -0.845 5.788 0.00 0.00 O +ATOM 31 O5' DA 1 1.734 0.873 5.326 0.00 0.00 O +TER 32 DA 1 +END diff --git a/test/Test_Graft/RunTest.sh b/test/Test_Graft/RunTest.sh index cc21222d80..e5b32c2f2b 100755 --- a/test/Test_Graft/RunTest.sh +++ b/test/Test_Graft/RunTest.sh @@ -133,7 +133,7 @@ graft ic \\ tgtmask !(@O5',HO5') \\ srcmask !(@C2,H21,H22,H23,O3',C1,H11,H12,H13) \\ bond @C5',@O5' -crdout Nucleotide Nucleotide.ic.mol2 +#crdout Nucleotide Nucleotide.ic.mol2 # Format the PDB change crdset Nucleotide resname from * to DA change crdset Nucleotide oresnums of :1 min 1 max 1 @@ -142,7 +142,7 @@ change crdset Nucleotide oresnums of :3 min 1 max 1 crdout Nucleotide IC.Nucleotide.pdb EOF RunCpptraj "$TESTNAME, Construct Nucleic Acid, IC" - #DoTest Nucleotide.pdb.save Nucleotide.pdb + DoTest IC.Nucleotide.pdb.save IC.Nucleotide.pdb } # Link nucleic acid base + sugar + phosphate, fix charges. From ac28c2335cc54804d6900dd26a781790a873b324 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sat, 21 Oct 2023 08:42:30 -0400 Subject: [PATCH 143/245] Protect topology append when only some bonds have parameters --- src/Topology.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Topology.cpp b/src/Topology.cpp index 703e866f3f..c040ec8aa4 100644 --- a/src/Topology.cpp +++ b/src/Topology.cpp @@ -1975,12 +1975,17 @@ void Topology::StripDihedralParmArray(DihedralArray& newDihedralArray, std::vect // Topology::AddBondArray() void Topology::AddBondArray(BondArray const& barray, BondParmArray const& bp, int atomOffset) { - if (bp.empty()) + if (bp.empty()) { for (BondArray::const_iterator bond = barray.begin(); bond != barray.end(); ++bond) AddBond( bond->A1() + atomOffset, bond->A2() + atomOffset ); - else - for (BondArray::const_iterator bond = barray.begin(); bond != barray.end(); ++bond) - AddBond( bond->A1() + atomOffset, bond->A2() + atomOffset, bp[bond->Idx()] ); + } else { + for (BondArray::const_iterator bond = barray.begin(); bond != barray.end(); ++bond) { + if (bond->Idx() > -1) + AddBond( bond->A1() + atomOffset, bond->A2() + atomOffset, bp[bond->Idx()] ); + else + AddBond( bond->A1() + atomOffset, bond->A2() + atomOffset ); + } + } } // Topology::AddAngleArray() From cf0f1f2a0b54f2bee0512d752b5b89a234b1fbeb Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sat, 21 Oct 2023 08:47:39 -0400 Subject: [PATCH 144/245] If some bond parameters are present, warn if any bonds are missing parameters during append --- src/Topology.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Topology.cpp b/src/Topology.cpp index c040ec8aa4..f22765506a 100644 --- a/src/Topology.cpp +++ b/src/Topology.cpp @@ -1979,12 +1979,17 @@ void Topology::AddBondArray(BondArray const& barray, BondParmArray const& bp, in for (BondArray::const_iterator bond = barray.begin(); bond != barray.end(); ++bond) AddBond( bond->A1() + atomOffset, bond->A2() + atomOffset ); } else { + bool missingParameters = false; for (BondArray::const_iterator bond = barray.begin(); bond != barray.end(); ++bond) { if (bond->Idx() > -1) AddBond( bond->A1() + atomOffset, bond->A2() + atomOffset, bp[bond->Idx()] ); - else + else { + missingParameters = true; AddBond( bond->A1() + atomOffset, bond->A2() + atomOffset ); + } } + if (missingParameters) + mprintf("Warning: Some bonds were missing parameters.\n"); } } From cd6c4778ae35cbda33a0621a297795676730e097 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sat, 21 Oct 2023 08:55:31 -0400 Subject: [PATCH 145/245] Start Builder class --- src/Structure/Builder.cpp | 7 +++++++ src/Structure/Builder.h | 22 ++++++++++++++++++++++ src/Structure/CMakeLists.txt | 1 + src/Structure/structuredepend | 1 + src/Structure/structurefiles | 1 + src/cpptrajdepend | 1 + 6 files changed, 33 insertions(+) create mode 100644 src/Structure/Builder.cpp create mode 100644 src/Structure/Builder.h diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp new file mode 100644 index 0000000000..bd02ac8b74 --- /dev/null +++ b/src/Structure/Builder.cpp @@ -0,0 +1,7 @@ +#include "Builder.h" + +using namespace Cpptraj::Structure; + +/** CONSTRUCTOR */ +Builder::Builder() {} + diff --git a/src/Structure/Builder.h b/src/Structure/Builder.h new file mode 100644 index 0000000000..fb682ce0a3 --- /dev/null +++ b/src/Structure/Builder.h @@ -0,0 +1,22 @@ +#ifndef INC_STRUCTURE_BUILDER_H +#define INC_STRUCTURE_BUILDER_H +#include +#include "../Chirality.h" +namespace Cpptraj { +namespace Structure { +/// Used to attach different topology/frame combos using internal coordinates +class Builder { + public: + /// CONSTRUCTOR + Builder(); + private: + typedef std::vector Carray; + typedef std::vector Iarray; + typedef std::vector Parray; + + Carray atomChirality_; ///< Hold chirality for each atom in the combined system. + Parray atomPriority_; ///< Hold bonded atom index priority array for each atom. +}; +} +} +#endif diff --git a/src/Structure/CMakeLists.txt b/src/Structure/CMakeLists.txt index d5320afb9f..ac173392c5 100644 --- a/src/Structure/CMakeLists.txt +++ b/src/Structure/CMakeLists.txt @@ -1,5 +1,6 @@ #CMake buildfile for CPPTRAJ Structure subdirectory. target_sources(cpptraj_common_obj PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/Builder.cpp ${CMAKE_CURRENT_LIST_DIR}/Disulfide.cpp ${CMAKE_CURRENT_LIST_DIR}/FunctionalGroup.cpp ${CMAKE_CURRENT_LIST_DIR}/FxnGroupBuilder.cpp diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index 9a5cbf54fc..4efa724616 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -1,3 +1,4 @@ +Builder.o : Builder.cpp ../Chirality.h Builder.h Disulfide.o : Disulfide.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Disulfide.h ResStatArray.h StructureRoutines.h FunctionalGroup.o : FunctionalGroup.cpp ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.o : FxnGroupBuilder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h StructureRoutines.h Sugar.h SugarToken.h diff --git a/src/Structure/structurefiles b/src/Structure/structurefiles index 2810508a12..d7a7372378 100644 --- a/src/Structure/structurefiles +++ b/src/Structure/structurefiles @@ -1,5 +1,6 @@ # Files for Structure subdirectory. STRUCTURE_SOURCES= \ + Builder.cpp \ Disulfide.cpp \ FunctionalGroup.cpp \ FxnGroupBuilder.cpp \ diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 639e57164c..a81597eae6 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -431,6 +431,7 @@ SpaceGroup.o : SpaceGroup.cpp Matrix_3x3.h Parallel.h SpaceGroup.h Vec3.h Spline.o : Spline.cpp CpptrajStdio.h Spline.h SplineFxnTable.o : SplineFxnTable.cpp Constants.h CpptrajStdio.h Spline.h SplineFxnTable.h StringRoutines.h StringRoutines.o : StringRoutines.cpp CpptrajStdio.h StringRoutines.h +Structure/Builder.o : Structure/Builder.cpp Chirality.h Structure/Builder.h Structure/Disulfide.o : Structure/Disulfide.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Disulfide.h Structure/ResStatArray.h Structure/StructureRoutines.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/FunctionalGroup.o : Structure/FunctionalGroup.cpp Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/FxnGroupBuilder.o : Structure/FxnGroupBuilder.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h From ce7e4cd59a6fb78c2b7148c22d59bab01986fa30 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 22 Oct 2023 08:30:07 -0400 Subject: [PATCH 146/245] Fix typo --- src/Frame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Frame.cpp b/src/Frame.cpp index ef3f206fcc..8a63853801 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -368,7 +368,7 @@ void Frame::CopyFrom(Frame const& tgtIn, Unit const& unit) { } // ---------- FRAME MEMORY ALLOCATION/REALLOCATION ----------------------------- -/** \return True if reallocation of coordinate arrray must occur based on +/** \return True if reallocation of coordinate array must occur based on * given number of atoms. */ bool Frame::ReallocateX(int natomIn) { From 8fe3c255b88bd188c8169878e3a2cbdcdbcfbf58 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 22 Oct 2023 08:30:23 -0400 Subject: [PATCH 147/245] Start the combine function --- src/Structure/Builder.cpp | 56 ++++++++++++++++++++++++++++++++++- src/Structure/Builder.h | 3 ++ src/Structure/structuredepend | 2 +- src/cpptrajdepend | 2 +- 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index bd02ac8b74..3eae35c445 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -1,7 +1,61 @@ #include "Builder.h" +#include "../CpptrajStdio.h" +#include "../Topology.h" +#include "../Frame.h" +#include // std::copy using namespace Cpptraj::Structure; /** CONSTRUCTOR */ -Builder::Builder() {} +Builder::Builder() : + debug_(0) +{} +/// Wrapper for DetermineChirality that checks number of bonds TODO bake into DetermineChirality? +static inline +Cpptraj::Chirality::ChiralType determineChiral(int at, Topology const& topIn, Frame const& frmIn, int dbg) +{ + if (topIn[at].Nbonds() > 2) + return Cpptraj::Chirality::DetermineChirality(at, topIn, frmIn, dbg); + else + return Cpptraj::Chirality::IS_UNKNOWN_CHIRALITY; +} + +/** Combine two units. Fragment 1 will be merged into Fragment 0. */ +int Builder::Combine(Topology& frag0Top, Frame& frag0frm, + Topology const& frag1Top, Frame const& frag1frm, + int bondAt0, int bondAt1) +{ + using namespace Cpptraj::Chirality; + // Determine what bondAt1 will be in the combined topology. + int bondAt1_new = bondAt1 + frag0Top.Natom(); + + int newNatom = frag0Top.Natom() + frag1Top.Natom(); + + // Reserve space in atom chirality and priority arrays. + atomChirality_.assign( newNatom, IS_UNKNOWN_CHIRALITY ); + atomPriority_.resize( newNatom ); + + // Get the chirality of each atom before the bond is added. + // This is because when the bond is added the geometry will likely + // not be correct, so while priority can be determined, the + // actual chirality can not. + // TODO store priorities as well? + for (int at = 0; at != frag0Top.Natom(); ++at) + atomChirality_[at] = determineChiral(at, frag0Top, frag0frm, debug_); + int at1 = 0; + for (int at = frag0Top.Natom(); at != newNatom; at++, at1++) + atomChirality_[at1] = determineChiral(at, frag1Top, frag1frm, debug_); + + // Merge fragment 1 topology into fragment 0 + frag0Top.AppendTop( frag1Top ); + // Merge fragment 1 coords into fragment 0 + double* tmpcrd = new double[ frag0frm.size() ]; + unsigned int tmpsize = frag0frm.size(); + std::copy( frag0frm.xAddress(), frag0frm.xAddress()+frag0frm.size(), tmpcrd ); + frag0frm.SetupFrameV( frag0Top.Atoms(), CoordinateInfo(frag0frm.BoxCrd(), false, false, false) ); + std::copy( tmpcrd, tmpcrd+tmpsize, frag0frm.xAddress() ); + std::copy( frag1frm.xAddress(), frag1frm.xAddress()+frag1frm.size(), frag0frm.xAddress()+tmpsize ); + + return 0; +} diff --git a/src/Structure/Builder.h b/src/Structure/Builder.h index fb682ce0a3..1c771dab0e 100644 --- a/src/Structure/Builder.h +++ b/src/Structure/Builder.h @@ -9,6 +9,8 @@ class Builder { public: /// CONSTRUCTOR Builder(); + /// Combine fragment1 into fragment 0 + int Combine(Topology&, Frame&, Topology const&, Frame const&, int, int); private: typedef std::vector Carray; typedef std::vector Iarray; @@ -16,6 +18,7 @@ class Builder { Carray atomChirality_; ///< Hold chirality for each atom in the combined system. Parray atomPriority_; ///< Hold bonded atom index priority array for each atom. + int debug_; }; } } diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index 4efa724616..9b67ce3e8c 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -1,4 +1,4 @@ -Builder.o : Builder.cpp ../Chirality.h Builder.h +Builder.o : Builder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Builder.h Disulfide.o : Disulfide.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Disulfide.h ResStatArray.h StructureRoutines.h FunctionalGroup.o : FunctionalGroup.cpp ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.o : FxnGroupBuilder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h StructureRoutines.h Sugar.h SugarToken.h diff --git a/src/cpptrajdepend b/src/cpptrajdepend index a81597eae6..326bf3a390 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -431,7 +431,7 @@ SpaceGroup.o : SpaceGroup.cpp Matrix_3x3.h Parallel.h SpaceGroup.h Vec3.h Spline.o : Spline.cpp CpptrajStdio.h Spline.h SplineFxnTable.o : SplineFxnTable.cpp Constants.h CpptrajStdio.h Spline.h SplineFxnTable.h StringRoutines.h StringRoutines.o : StringRoutines.cpp CpptrajStdio.h StringRoutines.h -Structure/Builder.o : Structure/Builder.cpp Chirality.h Structure/Builder.h +Structure/Builder.o : Structure/Builder.cpp Atom.h AtomMask.h AtomType.h Box.h Chirality.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Builder.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/Disulfide.o : Structure/Disulfide.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Disulfide.h Structure/ResStatArray.h Structure/StructureRoutines.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/FunctionalGroup.o : Structure/FunctionalGroup.cpp Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/FxnGroupBuilder.o : Structure/FxnGroupBuilder.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h From 35262e52fa2a91e905e027ca3cb8b8d68c0d68fe Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 22 Oct 2023 08:41:08 -0400 Subject: [PATCH 148/245] Create the bond --- src/Structure/Builder.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index 3eae35c445..e242b8df2c 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -41,6 +41,7 @@ int Builder::Combine(Topology& frag0Top, Frame& frag0frm, // not be correct, so while priority can be determined, the // actual chirality can not. // TODO store priorities as well? + // TODO only store for fragment 1? for (int at = 0; at != frag0Top.Natom(); ++at) atomChirality_[at] = determineChiral(at, frag0Top, frag0frm, debug_); int at1 = 0; @@ -57,5 +58,16 @@ int Builder::Combine(Topology& frag0Top, Frame& frag0frm, std::copy( tmpcrd, tmpcrd+tmpsize, frag0frm.xAddress() ); std::copy( frag1frm.xAddress(), frag1frm.xAddress()+frag1frm.size(), frag0frm.xAddress()+tmpsize ); + // Create the bond + mprintf("DEBUG: Bond %i %s to %i %s\n", + bondAt0+1, frag0Top.AtomMaskName(bondAt0).c_str(), + bondAt1_new+1, frag0Top.AtomMaskName(bondAt1_new).c_str()); + frag0Top.AddBond( bondAt0, bondAt1_new ); // TODO create pseudo-parameter? + // Regenerate the molecule info TODO should AddBond do this automatically? + if (frag0Top.DetermineMolecules()) { + mprinterr("Error: Could not determine molecule info after combining fragments.\n"); + return 1; + } + return 0; } From 1797c1cc7138567b52069b03710b7144c2ca89db Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 22 Oct 2023 09:26:24 -0400 Subject: [PATCH 149/245] Ensure the smaller fragment is merged into the larger one --- src/Structure/Builder.cpp | 36 +++++++++++++++++++++++++++++++++--- src/Structure/Builder.h | 10 ++++++++-- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index e242b8df2c..fc07133273 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -21,17 +21,47 @@ Cpptraj::Chirality::ChiralType determineChiral(int at, Topology const& topIn, Fr return Cpptraj::Chirality::IS_UNKNOWN_CHIRALITY; } -/** Combine two units. Fragment 1 will be merged into Fragment 0. */ +/** Combine two units. The smaller fragment will be merged into + * the larger fragment. + */ int Builder::Combine(Topology& frag0Top, Frame& frag0frm, + Topology& frag1Top, Frame& frag1frm, + int bondAt0, int bondAt1) +{ + if (heavy_atom_count(frag0Top) < heavy_atom_count(frag1Top)) { + return combine01(frag1Top, frag1frm, frag0Top, frag0frm, bondAt1, bondAt0); + } else { + return combine01(frag0Top, frag0frm, frag1Top, frag1frm, bondAt0, bondAt1); + } +} + +/** \return Heavy atom count */ +int Builder::heavy_atom_count(Topology const& topIn) { + int hac = 0; + for (int i = 0; i != topIn.Natom(); i++) { + if (topIn[i].Element() != Atom::HYDROGEN && + topIn[i].Element() != Atom::EXTRAPT) + hac++; + } + return hac; +} + +/** Combine two units. Fragment 1 will be merged into Fragment 0. */ +int Builder::combine01(Topology& frag0Top, Frame& frag0frm, Topology const& frag1Top, Frame const& frag1frm, int bondAt0, int bondAt1) { using namespace Cpptraj::Chirality; + int newNatom = frag0Top.Natom() + frag1Top.Natom(); + + // The positions of atoms in fragment 0 will be "known" + Barray posKnown( newNatom, false ); + for (int at = 0; at != frag0Top.Natom(); at++) + posKnown[at] = true; + // Determine what bondAt1 will be in the combined topology. int bondAt1_new = bondAt1 + frag0Top.Natom(); - int newNatom = frag0Top.Natom() + frag1Top.Natom(); - // Reserve space in atom chirality and priority arrays. atomChirality_.assign( newNatom, IS_UNKNOWN_CHIRALITY ); atomPriority_.resize( newNatom ); diff --git a/src/Structure/Builder.h b/src/Structure/Builder.h index 1c771dab0e..8ae1cadbe4 100644 --- a/src/Structure/Builder.h +++ b/src/Structure/Builder.h @@ -9,12 +9,18 @@ class Builder { public: /// CONSTRUCTOR Builder(); - /// Combine fragment1 into fragment 0 - int Combine(Topology&, Frame&, Topology const&, Frame const&, int, int); + /// Combine smaller fragment into larger fragment + int Combine(Topology&, Frame&, Topology&, Frame&, int, int); private: typedef std::vector Carray; typedef std::vector Iarray; typedef std::vector Parray; + typedef std::vector Barray; + + /// \return heavy atom count + static inline int heavy_atom_count(Topology const&); + /// Combine fragment1 into fragment 0 + int combine01(Topology&, Frame&, Topology const&, Frame const&, int, int); Carray atomChirality_; ///< Hold chirality for each atom in the combined system. Parray atomPriority_; ///< Hold bonded atom index priority array for each atom. From a24e27d9435a9b977cf096c55b0584121f961b35 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 22 Oct 2023 09:27:02 -0400 Subject: [PATCH 150/245] Reposition the function --- src/Structure/Builder.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index fc07133273..c7a2181072 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -21,6 +21,17 @@ Cpptraj::Chirality::ChiralType determineChiral(int at, Topology const& topIn, Fr return Cpptraj::Chirality::IS_UNKNOWN_CHIRALITY; } +/** \return Heavy atom count */ +int Builder::heavy_atom_count(Topology const& topIn) { + int hac = 0; + for (int i = 0; i != topIn.Natom(); i++) { + if (topIn[i].Element() != Atom::HYDROGEN && + topIn[i].Element() != Atom::EXTRAPT) + hac++; + } + return hac; +} + /** Combine two units. The smaller fragment will be merged into * the larger fragment. */ @@ -35,17 +46,6 @@ int Builder::Combine(Topology& frag0Top, Frame& frag0frm, } } -/** \return Heavy atom count */ -int Builder::heavy_atom_count(Topology const& topIn) { - int hac = 0; - for (int i = 0; i != topIn.Natom(); i++) { - if (topIn[i].Element() != Atom::HYDROGEN && - topIn[i].Element() != Atom::EXTRAPT) - hac++; - } - return hac; -} - /** Combine two units. Fragment 1 will be merged into Fragment 0. */ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, Topology const& frag1Top, Frame const& frag1frm, From c1b5bd06d54815ea3736833f5244a58d6e46d763 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 22 Oct 2023 09:29:15 -0400 Subject: [PATCH 151/245] Comment out unused array --- src/Exec_Graft.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 8b6f6d3c4a..e9ef301ffb 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -310,9 +310,9 @@ const // Track atoms as 'known'. Target atoms are residue 0, Source atoms are in residue 1 typedef std::vector Barray; - Barray atomPositionKnown;/*( combinedTop.Natom(), false ); - for (int aidx = combinedTop.Res(1).FirstAtom(); aidx != combinedTop.Res(1).LastAtom(); aidx++) - atomPositionKnown[aidx] = true;*/ + //Barray atomPositionKnown;/*( combinedTop.Natom(), false ); + //for (int aidx = combinedTop.Res(1).FirstAtom(); aidx != combinedTop.Res(1).LastAtom(); aidx++) + // atomPositionKnown[aidx] = true;*/ // Generate Z matrix FIXME ensure mol 0 is the one we are interested in /* Zmatrix zmatrix; From 6ea8edd841a379fde9c4a4ccdc729d9c247bf8bf Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 08:54:17 -0400 Subject: [PATCH 152/245] Add code comment --- src/Structure/Builder.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index c7a2181072..31decfbcbf 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -99,5 +99,7 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, return 1; } + // Generate a zmatrix for the smaller fragment + return 0; } From 6dc9f4032c9660c356da3be9e288ba53261a5f39 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 09:25:21 -0400 Subject: [PATCH 153/245] Fix chirality determination for fragment 1 --- src/Structure/Builder.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index 31decfbcbf..e97408e340 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -11,16 +11,6 @@ Builder::Builder() : debug_(0) {} -/// Wrapper for DetermineChirality that checks number of bonds TODO bake into DetermineChirality? -static inline -Cpptraj::Chirality::ChiralType determineChiral(int at, Topology const& topIn, Frame const& frmIn, int dbg) -{ - if (topIn[at].Nbonds() > 2) - return Cpptraj::Chirality::DetermineChirality(at, topIn, frmIn, dbg); - else - return Cpptraj::Chirality::IS_UNKNOWN_CHIRALITY; -} - /** \return Heavy atom count */ int Builder::heavy_atom_count(Topology const& topIn) { int hac = 0; @@ -67,16 +57,18 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, atomPriority_.resize( newNatom ); // Get the chirality of each atom before the bond is added. - // This is because when the bond is added the geometry will likely - // not be correct, so while priority can be determined, the - // actual chirality can not. + // This is because when the bond is added the geometry between the + // bonded atoms will likely not be correct, so while priority can be + // determined, the actual chirality can not. // TODO store priorities as well? // TODO only store for fragment 1? for (int at = 0; at != frag0Top.Natom(); ++at) - atomChirality_[at] = determineChiral(at, frag0Top, frag0frm, debug_); + if (frag0Top[at].Nbonds() > 2) + atomChirality_[at] = DetermineChirality(at, frag0Top, frag0frm, debug_); int at1 = 0; for (int at = frag0Top.Natom(); at != newNatom; at++, at1++) - atomChirality_[at1] = determineChiral(at, frag1Top, frag1frm, debug_); + if (frag1Top[at1].Nbonds() > 2) + atomChirality_[at] = DetermineChirality(at1, frag1Top, frag1frm, debug_); // Merge fragment 1 topology into fragment 0 frag0Top.AppendTop( frag1Top ); @@ -99,6 +91,9 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, return 1; } + // Store priorities around each atom. + // TODO only fragment 1? + // Generate a zmatrix for the smaller fragment return 0; From 5c04a6de1d42d325aee6f94e84cb74e6256daf8c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 09:33:27 -0400 Subject: [PATCH 154/245] Save atom priorities --- src/Structure/Builder.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index e97408e340..fdb66acf22 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -42,15 +42,16 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, int bondAt0, int bondAt1) { using namespace Cpptraj::Chirality; - int newNatom = frag0Top.Natom() + frag1Top.Natom(); + int natom0 = frag0Top.Natom(); + int newNatom = natom0 + frag1Top.Natom(); // The positions of atoms in fragment 0 will be "known" Barray posKnown( newNatom, false ); - for (int at = 0; at != frag0Top.Natom(); at++) + for (int at = 0; at != natom0; at++) posKnown[at] = true; // Determine what bondAt1 will be in the combined topology. - int bondAt1_new = bondAt1 + frag0Top.Natom(); + int bondAt1_new = bondAt1 + natom0; // Reserve space in atom chirality and priority arrays. atomChirality_.assign( newNatom, IS_UNKNOWN_CHIRALITY ); @@ -62,11 +63,11 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, // determined, the actual chirality can not. // TODO store priorities as well? // TODO only store for fragment 1? - for (int at = 0; at != frag0Top.Natom(); ++at) + for (int at = 0; at != natom0; ++at) if (frag0Top[at].Nbonds() > 2) atomChirality_[at] = DetermineChirality(at, frag0Top, frag0frm, debug_); int at1 = 0; - for (int at = frag0Top.Natom(); at != newNatom; at++, at1++) + for (int at = natom0; at != newNatom; at++, at1++) if (frag1Top[at1].Nbonds() > 2) atomChirality_[at] = DetermineChirality(at1, frag1Top, frag1frm, debug_); @@ -93,7 +94,19 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, // Store priorities around each atom. // TODO only fragment 1? - + double tors = 0; + for (int at = 0; at != natom0; ++at) { + if (frag0Top[at].Nbonds() > 2) { + atomPriority_[at].assign(frag0Top[at].Nbonds(), -1); + DetermineChirality(tors, &(atomPriority_[at][0]), at, frag0Top, frag0frm, debug_); + } + } + for (int at = natom0; at != newNatom; at++) { + if (frag0Top[at].Nbonds() > 2) { + atomPriority_[at].assign(frag0Top[at].Nbonds(), -1); + DetermineChirality(tors, &(atomPriority_[at][0]), at, frag0Top, frag0frm, debug_); + } + } // Generate a zmatrix for the smaller fragment return 0; From a32f7bf1ee8283c6fba1234b4f9b809643b6375e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 09:44:31 -0400 Subject: [PATCH 155/245] Move Chirality into the Structure namespace --- src/Structure/BuildAtom.h | 12 ++++++++++ src/Structure/CMakeLists.txt | 4 +++- src/{ => Structure}/Chirality.cpp | 39 +++++++++++-------------------- src/{ => Structure}/Chirality.h | 10 ++++---- src/Structure/structuredepend | 2 ++ src/Structure/structurefiles | 4 +++- 6 files changed, 38 insertions(+), 33 deletions(-) create mode 100644 src/Structure/BuildAtom.h rename src/{ => Structure}/Chirality.cpp (86%) rename src/{ => Structure}/Chirality.h (59%) diff --git a/src/Structure/BuildAtom.h b/src/Structure/BuildAtom.h new file mode 100644 index 0000000000..65018bc2b4 --- /dev/null +++ b/src/Structure/BuildAtom.h @@ -0,0 +1,12 @@ +#ifndef INC_STRUCTURE_BUILDATOM_H +#define INC_STRUCTURE_BUILDATOM_H +namespace Cpptraj { +namespace Structure { +/// Hold information for an atom used when building/modelling new coordinates. +class BuildAtom { + public: + BuildAtom(); + private: + bool positionKnown_; ///< True if position is "known", i.e. can be used to build. + +#endif diff --git a/src/Structure/CMakeLists.txt b/src/Structure/CMakeLists.txt index ac173392c5..88701e311c 100644 --- a/src/Structure/CMakeLists.txt +++ b/src/Structure/CMakeLists.txt @@ -1,15 +1,17 @@ #CMake buildfile for CPPTRAJ Structure subdirectory. target_sources(cpptraj_common_obj PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Builder.cpp + ${CMAKE_CURRENT_LIST_DIR}/Chirality.cpp ${CMAKE_CURRENT_LIST_DIR}/Disulfide.cpp ${CMAKE_CURRENT_LIST_DIR}/FunctionalGroup.cpp ${CMAKE_CURRENT_LIST_DIR}/FxnGroupBuilder.cpp ${CMAKE_CURRENT_LIST_DIR}/HisProt.cpp ${CMAKE_CURRENT_LIST_DIR}/InternalCoords.cpp ${CMAKE_CURRENT_LIST_DIR}/Model.cpp + ${CMAKE_CURRENT_LIST_DIR}/StructureEnum.cpp ${CMAKE_CURRENT_LIST_DIR}/StructureRoutines.cpp - ${CMAKE_CURRENT_LIST_DIR}/Sugar.cpp ${CMAKE_CURRENT_LIST_DIR}/SugarBuilder.cpp + ${CMAKE_CURRENT_LIST_DIR}/Sugar.cpp ${CMAKE_CURRENT_LIST_DIR}/SugarLinkAtoms.cpp ${CMAKE_CURRENT_LIST_DIR}/SugarToken.cpp ${CMAKE_CURRENT_LIST_DIR}/Zmatrix.cpp diff --git a/src/Chirality.cpp b/src/Structure/Chirality.cpp similarity index 86% rename from src/Chirality.cpp rename to src/Structure/Chirality.cpp index 90ed5a7c9b..02770ef530 100644 --- a/src/Chirality.cpp +++ b/src/Structure/Chirality.cpp @@ -1,25 +1,12 @@ #include "Chirality.h" -#include "Constants.h" -#include "CpptrajStdio.h" -#include "Frame.h" -#include "Topology.h" -#include "TorsionRoutines.h" +#include "../Constants.h" +#include "../CpptrajStdio.h" +#include "../Frame.h" +#include "../Topology.h" +#include "../TorsionRoutines.h" #include #include // sort -using namespace Cpptraj; - -/** \return string corresponding to ChiralType */ -const char* Chirality::chiralStr(ChiralType ct) { - switch (ct) { - case ERR : return "Error"; - case IS_S : return "S"; - case IS_R : return "R"; - case IS_UNKNOWN_CHIRALITY : return "Unknown"; - } - return 0; -} - /// \return Total priority (i.e. sum of atomic numbers) of atoms bonded to given atom. static int totalPriority(Topology const& topIn, int atnum, int rnum, int depth, int tgtdepth, std::vector& Visited) @@ -89,10 +76,11 @@ class priority_element { * 1-2-3-0 * where 0 is the chiral center. Negative is S, positive is R. */ -Chirality::ChiralType Chirality::DetermineChirality(double& tors, int* AtomIndices, - int atnum, - Topology const& topIn, - Frame const& frameIn, int debugIn) +Cpptraj::Structure::ChiralType + Cpptraj::Structure::DetermineChirality(double& tors, int* AtomIndices, + int atnum, + Topology const& topIn, + Frame const& frameIn, int debugIn) { tors = 0.0; Atom const& atom = topIn[atnum]; @@ -180,9 +168,10 @@ Chirality::ChiralType Chirality::DetermineChirality(double& tors, int* AtomIndic } /** Determine chirality around specified atom. */ -Chirality::ChiralType Chirality::DetermineChirality(int atnum, - Topology const& topIn, - Frame const& frameIn, int debugIn) +Cpptraj::Structure::ChiralType + Cpptraj::Structure::DetermineChirality(int atnum, + Topology const& topIn, + Frame const& frameIn, int debugIn) { double tors; return DetermineChirality(tors, 0, atnum, topIn, frameIn, debugIn); diff --git a/src/Chirality.h b/src/Structure/Chirality.h similarity index 59% rename from src/Chirality.h rename to src/Structure/Chirality.h index 3dd091d85d..e74f6ae764 100644 --- a/src/Chirality.h +++ b/src/Structure/Chirality.h @@ -1,13 +1,11 @@ -#ifndef INC_CHIRALITY_H -#define INC_CHIRALITY_H +#ifndef INC_STRUCTURE_CHIRALITY_H +#define INC_STRUCTURE_CHIRALITY_H +#include "StructureEnum.h" class Topology; class Frame; namespace Cpptraj { -namespace Chirality { +namespace Structure { -enum ChiralType { ERR = 0, IS_S, IS_R, IS_UNKNOWN_CHIRALITY }; -/// \return String corresponding to ChiralType -const char* chiralStr(ChiralType); /// \return Chirality at specified atom, set torsion value ChiralType DetermineChirality(double&, int*, int, Topology const&, Frame const&, int); /// \return Chirality at specified atom diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index 9b67ce3e8c..0f15f6bcab 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -1,10 +1,12 @@ Builder.o : Builder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Builder.h +Chirality.o : Chirality.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Chirality.h StructureEnum.h Disulfide.o : Disulfide.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Disulfide.h ResStatArray.h StructureRoutines.h FunctionalGroup.o : FunctionalGroup.cpp ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.o : FxnGroupBuilder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h StructureRoutines.h Sugar.h SugarToken.h HisProt.o : HisProt.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h HisProt.h StructureRoutines.h InternalCoords.o : InternalCoords.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h InternalCoords.h Model.o : Model.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Model.h +StructureEnum.o : StructureEnum.cpp StructureEnum.h StructureRoutines.o : StructureRoutines.cpp ../Atom.h ../CpptrajStdio.h ../NameType.h ../Residue.h ../SymbolExporting.h StructureRoutines.h Sugar.o : Sugar.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Sugar.h SugarToken.h SugarBuilder.o : SugarBuilder.cpp ../ArgList.h ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../CharMask.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajFile.h ../CpptrajStdio.h ../DistRoutines.h ../FileIO.h ../FileName.h ../Frame.h ../ImageOption.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h LinkAtom.h ResStatArray.h StructureRoutines.h Sugar.h SugarBuilder.h SugarLinkAtoms.h SugarToken.h diff --git a/src/Structure/structurefiles b/src/Structure/structurefiles index d7a7372378..0a0a55cc57 100644 --- a/src/Structure/structurefiles +++ b/src/Structure/structurefiles @@ -1,15 +1,17 @@ # Files for Structure subdirectory. STRUCTURE_SOURCES= \ Builder.cpp \ + Chirality.cpp \ Disulfide.cpp \ FunctionalGroup.cpp \ FxnGroupBuilder.cpp \ HisProt.cpp \ InternalCoords.cpp \ Model.cpp \ + StructureEnum.cpp \ StructureRoutines.cpp \ - Sugar.cpp \ SugarBuilder.cpp \ + Sugar.cpp \ SugarLinkAtoms.cpp \ SugarToken.cpp \ Zmatrix.cpp From 9868c6564c9162b96a591253330fec467a21fbd8 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 09:48:21 -0400 Subject: [PATCH 156/245] Use new chirality --- src/Structure/SugarBuilder.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Structure/SugarBuilder.cpp b/src/Structure/SugarBuilder.cpp index e60368b356..1d805996cb 100644 --- a/src/Structure/SugarBuilder.cpp +++ b/src/Structure/SugarBuilder.cpp @@ -1,4 +1,5 @@ #include "SugarBuilder.h" +#include "Chirality.h" #include "FxnGroupBuilder.h" #include "ResStatArray.h" #include "StructureRoutines.h" @@ -6,7 +7,6 @@ #include "SugarLinkAtoms.h" #include "../ArgList.h" #include "../CharMask.h" // for linkage determination -#include "../Chirality.h" #include "../CpptrajFile.h" #include "../CpptrajStdio.h" #include "../DistRoutines.h" @@ -1113,22 +1113,18 @@ const cdebug = 1; else cdebug = 0; - Cpptraj::Chirality::ChiralType ctypeR = Cpptraj::Chirality:: - DetermineChirality(sugar.HighestStereocenter(), - topIn, frameIn, cdebug); - if (ctypeR == Cpptraj::Chirality::ERR || ctypeR == Cpptraj::Chirality::IS_UNKNOWN_CHIRALITY) { + ChiralType ctypeR = DetermineChirality(sugar.HighestStereocenter(), topIn, frameIn, cdebug); + if (ctypeR == CHIRALITY_ERR || ctypeR == IS_UNKNOWN_CHIRALITY) { mprinterr("Error: Could not determine configuration for furanose.\n"); // TODO warn? return 1; } - if (ctypeR == Cpptraj::Chirality::IS_R) + if (ctypeR == IS_R) stoken.SetChirality(SugarToken::IS_D); else stoken.SetChirality(SugarToken::IS_L); - Cpptraj::Chirality::ChiralType ctypeA = Cpptraj::Chirality:: - DetermineChirality(sugar.AnomericAtom(), - topIn, frameIn, cdebug); - if (ctypeA == Cpptraj::Chirality::ERR || ctypeA == Cpptraj::Chirality::IS_UNKNOWN_CHIRALITY) { + ChiralType ctypeA = DetermineChirality(sugar.AnomericAtom(), topIn, frameIn, cdebug); + if (ctypeA == CHIRALITY_ERR || ctypeA == IS_UNKNOWN_CHIRALITY) { mprinterr("Error: Could not determine chirality around anomeric atom for furanose.\n"); // TODO warn? return 1; } From a281047ef9f5ed930c798c12e48dbb70a394efbc Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 10:02:50 -0400 Subject: [PATCH 157/245] Have Builder use new Chirality and BuildAtom --- src/Structure/BuildAtom.h | 19 ++++++++++++++++--- src/Structure/Builder.cpp | 24 +++++++++++------------- src/Structure/Builder.h | 13 ++++++------- src/Structure/structuredepend | 4 ++-- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/Structure/BuildAtom.h b/src/Structure/BuildAtom.h index 65018bc2b4..7634f6c1fa 100644 --- a/src/Structure/BuildAtom.h +++ b/src/Structure/BuildAtom.h @@ -1,12 +1,25 @@ #ifndef INC_STRUCTURE_BUILDATOM_H #define INC_STRUCTURE_BUILDATOM_H +#include "StructureEnum.h" namespace Cpptraj { namespace Structure { /// Hold information for an atom used when building/modelling new coordinates. class BuildAtom { public: - BuildAtom(); + BuildAtom() : positionKnown_(false), ctype_(IS_UNKNOWN_CHIRALITY) {} + /// Set position status + void SetPositionKnown(bool b) { positionKnown_ = b; } + /// Set chirality + void SetChirality(ChiralType c) { ctype_ = c; } + /// Set size of priority array based on number of bonds + void SetNbonds(int n) { priority_.assign(n, -1); } + /// \return Pointer to priority array + int* PriorityPtr() { return &(priority_[0]); } private: - bool positionKnown_; ///< True if position is "known", i.e. can be used to build. - + bool positionKnown_; ///< True if position is "known", i.e. can be used to build. + ChiralType ctype_; ///< Chirality around atom + std::vector priority_; ///< Indices of bonded atoms, sorted by priority +}; +} +} #endif diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index fdb66acf22..f97c23686a 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -1,4 +1,6 @@ #include "Builder.h" +#include "BuildAtom.h" +#include "Chirality.h" #include "../CpptrajStdio.h" #include "../Topology.h" #include "../Frame.h" @@ -41,22 +43,18 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, Topology const& frag1Top, Frame const& frag1frm, int bondAt0, int bondAt1) { - using namespace Cpptraj::Chirality; int natom0 = frag0Top.Natom(); int newNatom = natom0 + frag1Top.Natom(); + // Reserve space in build atom array (chirality, priority, position status). // The positions of atoms in fragment 0 will be "known" - Barray posKnown( newNatom, false ); + atoms_.assign( newNatom, BuildAtom() ); for (int at = 0; at != natom0; at++) - posKnown[at] = true; + atoms_[at].SetPositionKnown( true ); // Determine what bondAt1 will be in the combined topology. int bondAt1_new = bondAt1 + natom0; - // Reserve space in atom chirality and priority arrays. - atomChirality_.assign( newNatom, IS_UNKNOWN_CHIRALITY ); - atomPriority_.resize( newNatom ); - // Get the chirality of each atom before the bond is added. // This is because when the bond is added the geometry between the // bonded atoms will likely not be correct, so while priority can be @@ -65,11 +63,11 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, // TODO only store for fragment 1? for (int at = 0; at != natom0; ++at) if (frag0Top[at].Nbonds() > 2) - atomChirality_[at] = DetermineChirality(at, frag0Top, frag0frm, debug_); + atoms_[at].SetChirality( DetermineChirality(at, frag0Top, frag0frm, debug_) ); int at1 = 0; for (int at = natom0; at != newNatom; at++, at1++) if (frag1Top[at1].Nbonds() > 2) - atomChirality_[at] = DetermineChirality(at1, frag1Top, frag1frm, debug_); + atoms_[at].SetChirality( DetermineChirality(at1, frag1Top, frag1frm, debug_) ); // Merge fragment 1 topology into fragment 0 frag0Top.AppendTop( frag1Top ); @@ -97,14 +95,14 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, double tors = 0; for (int at = 0; at != natom0; ++at) { if (frag0Top[at].Nbonds() > 2) { - atomPriority_[at].assign(frag0Top[at].Nbonds(), -1); - DetermineChirality(tors, &(atomPriority_[at][0]), at, frag0Top, frag0frm, debug_); + atoms_[at].SetNbonds(frag0Top[at].Nbonds()); + DetermineChirality(tors, atoms_[at].PriorityPtr(), at, frag0Top, frag0frm, debug_); } } for (int at = natom0; at != newNatom; at++) { if (frag0Top[at].Nbonds() > 2) { - atomPriority_[at].assign(frag0Top[at].Nbonds(), -1); - DetermineChirality(tors, &(atomPriority_[at][0]), at, frag0Top, frag0frm, debug_); + atoms_[at].SetNbonds(frag0Top[at].Nbonds()); + DetermineChirality(tors, atoms_[at].PriorityPtr(), at, frag0Top, frag0frm, debug_); } } // Generate a zmatrix for the smaller fragment diff --git a/src/Structure/Builder.h b/src/Structure/Builder.h index 8ae1cadbe4..f8df689a0d 100644 --- a/src/Structure/Builder.h +++ b/src/Structure/Builder.h @@ -1,9 +1,12 @@ #ifndef INC_STRUCTURE_BUILDER_H #define INC_STRUCTURE_BUILDER_H #include -#include "../Chirality.h" +//#incl ude "BuildAtom.h" +class Topology; +class Frame; namespace Cpptraj { namespace Structure { +class BuildAtom; /// Used to attach different topology/frame combos using internal coordinates class Builder { public: @@ -12,18 +15,14 @@ class Builder { /// Combine smaller fragment into larger fragment int Combine(Topology&, Frame&, Topology&, Frame&, int, int); private: - typedef std::vector Carray; - typedef std::vector Iarray; - typedef std::vector Parray; - typedef std::vector Barray; + typedef std::vector AtArray; /// \return heavy atom count static inline int heavy_atom_count(Topology const&); /// Combine fragment1 into fragment 0 int combine01(Topology&, Frame&, Topology const&, Frame const&, int, int); - Carray atomChirality_; ///< Hold chirality for each atom in the combined system. - Parray atomPriority_; ///< Hold bonded atom index priority array for each atom. + AtArray atoms_; ///< Hold chirality, bonded atom index priority, and position status for each atom int debug_; }; } diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index 0f15f6bcab..8c1aa24795 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -1,4 +1,4 @@ -Builder.o : Builder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Builder.h +Builder.o : Builder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h BuildAtom.h Builder.h Chirality.h StructureEnum.h Chirality.o : Chirality.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Chirality.h StructureEnum.h Disulfide.o : Disulfide.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Disulfide.h ResStatArray.h StructureRoutines.h FunctionalGroup.o : FunctionalGroup.cpp ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h @@ -9,7 +9,7 @@ Model.o : Model.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality. StructureEnum.o : StructureEnum.cpp StructureEnum.h StructureRoutines.o : StructureRoutines.cpp ../Atom.h ../CpptrajStdio.h ../NameType.h ../Residue.h ../SymbolExporting.h StructureRoutines.h Sugar.o : Sugar.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Sugar.h SugarToken.h -SugarBuilder.o : SugarBuilder.cpp ../ArgList.h ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../CharMask.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajFile.h ../CpptrajStdio.h ../DistRoutines.h ../FileIO.h ../FileName.h ../Frame.h ../ImageOption.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h LinkAtom.h ResStatArray.h StructureRoutines.h Sugar.h SugarBuilder.h SugarLinkAtoms.h SugarToken.h +SugarBuilder.o : SugarBuilder.cpp ../ArgList.h ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../CharMask.h ../Constants.h ../CoordinateInfo.h ../CpptrajFile.h ../CpptrajStdio.h ../DistRoutines.h ../FileIO.h ../FileName.h ../Frame.h ../ImageOption.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Chirality.h FunctionalGroup.h FxnGroupBuilder.h LinkAtom.h ResStatArray.h StructureEnum.h StructureRoutines.h Sugar.h SugarBuilder.h SugarLinkAtoms.h SugarToken.h SugarLinkAtoms.o : SugarLinkAtoms.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../StringRoutines.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h LinkAtom.h SugarLinkAtoms.h SugarToken.o : SugarToken.cpp ../ArgList.h ../CpptrajStdio.h SugarToken.h Zmatrix.o : Zmatrix.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h InternalCoords.h Model.h Zmatrix.h From 5fbe437299ddbdba655dcf7d97f11b0a1605662d Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 10:05:31 -0400 Subject: [PATCH 158/245] Use new Chirality --- src/Structure/Model.cpp | 6 +++--- src/Structure/Model.h | 4 ++-- src/Structure/structuredepend | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index 7b788fe930..eedbe683fe 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -1,4 +1,5 @@ #include "Model.h" +#include "Chirality.h" #include "../CpptrajStdio.h" #include "../Topology.h" #include "../TorsionRoutines.h" @@ -94,9 +95,8 @@ int Cpptraj::Structure::Model::AssignTheta(double& theta, int ai, int aj, int ak * / \ * i l */ -int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, int al, Topology const& topIn, Frame const& frameIn, std::vector const& atomPositionKnown, std::vector const& atomChirality) +int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, int al, Topology const& topIn, Frame const& frameIn, std::vector const& atomPositionKnown, std::vector const& atomChirality) { - using namespace Cpptraj::Chirality; // Figure out hybridization and chirality of atom j. mprintf("DEBUG: AssignPhi for atom j : %s\n", topIn.AtomMaskName(aj).c_str()); @@ -116,7 +116,7 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in double tors = 0; // FIXME - Only need priority here. ChiralType chirality = DetermineChirality(tors, priority, aj, topIn, frameIn, 1); // FIXME debug - if (chirality == ERR) { + if (chirality == CHIRALITY_ERR) { mprinterr("Error: Problem determining chirality around atom %s\n", topIn.AtomMaskName(aj).c_str()); return 1; } /*else if (chirality == IS_UNKNOWN_CHIRALITY) { diff --git a/src/Structure/Model.h b/src/Structure/Model.h index 7230cd5051..5c49aac8b4 100644 --- a/src/Structure/Model.h +++ b/src/Structure/Model.h @@ -1,7 +1,7 @@ #ifndef INC_STRUCTURE_MODEL_H #define INC_STRUCTURE_MODEL_H #include -#include "../Chirality.h" +#include "StructureEnum.h" class Topology; class Frame; namespace Cpptraj { @@ -9,7 +9,7 @@ namespace Structure { /// Routines to generate model parameters namespace Model { /// Given atoms J K and L, attempt to assign a reasonable value for phi for atom I -int AssignPhi(double&, int, int, int, int, Topology const&, Frame const&, std::vector const&, std::vector const&); +int AssignPhi(double&, int, int, int, int, Topology const&, Frame const&, std::vector const&, std::vector const&); /// Given atoms J and K, attempt to assign a reasonable value for theta for atom I int AssignTheta(double&, int, int, int, Topology const&, Frame const&, std::vector const&); diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index 8c1aa24795..2489247f16 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -5,11 +5,11 @@ FunctionalGroup.o : FunctionalGroup.cpp ../Atom.h ../AtomMap.h ../AtomMask.h ../ FxnGroupBuilder.o : FxnGroupBuilder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h StructureRoutines.h Sugar.h SugarToken.h HisProt.o : HisProt.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h HisProt.h StructureRoutines.h InternalCoords.o : InternalCoords.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h InternalCoords.h -Model.o : Model.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Model.h +Model.o : Model.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Chirality.h Model.h StructureEnum.h StructureEnum.o : StructureEnum.cpp StructureEnum.h StructureRoutines.o : StructureRoutines.cpp ../Atom.h ../CpptrajStdio.h ../NameType.h ../Residue.h ../SymbolExporting.h StructureRoutines.h Sugar.o : Sugar.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Sugar.h SugarToken.h SugarBuilder.o : SugarBuilder.cpp ../ArgList.h ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../CharMask.h ../Constants.h ../CoordinateInfo.h ../CpptrajFile.h ../CpptrajStdio.h ../DistRoutines.h ../FileIO.h ../FileName.h ../Frame.h ../ImageOption.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Chirality.h FunctionalGroup.h FxnGroupBuilder.h LinkAtom.h ResStatArray.h StructureEnum.h StructureRoutines.h Sugar.h SugarBuilder.h SugarLinkAtoms.h SugarToken.h SugarLinkAtoms.o : SugarLinkAtoms.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../StringRoutines.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h LinkAtom.h SugarLinkAtoms.h SugarToken.o : SugarToken.cpp ../ArgList.h ../CpptrajStdio.h SugarToken.h -Zmatrix.o : Zmatrix.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h InternalCoords.h Model.h Zmatrix.h +Zmatrix.o : Zmatrix.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h InternalCoords.h Model.h StructureEnum.h Zmatrix.h From e4e1e6d0cf8130307c1f0c70271dc9b4a7341db7 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 10:07:18 -0400 Subject: [PATCH 159/245] Use new Chirality --- src/Structure/Zmatrix.cpp | 7 ++++--- src/Structure/Zmatrix.h | 4 ++-- src/Structure/structuredepend | 2 +- src/cpptrajdepend | 19 ++++++++++--------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 803b19ddfb..6387fb0209 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -4,6 +4,7 @@ #include // cos #include // std::pair #include "Zmatrix.h" +#include "Chirality.h" #include "Model.h" #include "../Frame.h" #include "../CpptrajStdio.h" @@ -808,14 +809,14 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu */ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topology const& topIn, std::vector const& atomPositionKnown, - std::vector const& atomChirality) + std::vector const& atomChirality) { mprintf("DEBUG: SetFromFrameAroundBond: atA= %s (%i) atB= %s (%i)\n", topIn.AtomMaskName(atA).c_str(), atA+1, topIn.AtomMaskName(atB).c_str(), atB+1); mprintf("DEBUG: Atoms:\n"); for (int at = 0; at != topIn.Natom(); ++at) - mprintf("DEBUG:\t\t%s (%i) %s\n", topIn.AtomMaskName(at).c_str(), (int)atomPositionKnown[at], Cpptraj::Chirality::chiralStr(atomChirality[at])); + mprintf("DEBUG:\t\t%s (%i) %s\n", topIn.AtomMaskName(at).c_str(), (int)atomPositionKnown[at], chiralStr(atomChirality[at])); // Sanity check. A and B must be bonded if (!topIn[atA].IsBondedTo(atB)) { mprinterr("Internal Error: SetFromFrameAroundBond(): Atoms %s and %s are not bonded.\n", @@ -965,7 +966,7 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo int at0 = -1; int at1 = -1; std::vector remainingAtoms; - Cpptraj::Chirality::DetermineChirality(tors, &priority[0], atA, topIn, frameIn, 0); // FIXME debug level + DetermineChirality(tors, &priority[0], atA, topIn, frameIn, 0); // FIXME debug level mprintf("DEBUG: %i bonds to %s\n", AJ1.Nbonds(), topIn.AtomMaskName(atA).c_str()); for (std::vector::const_iterator it = priority.begin(); it != priority.end(); ++it) { if (*it != atB) { diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 6dc6b598ef..5071b00883 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -1,8 +1,8 @@ #ifndef INC_STRUCTURE_ZMATRIX_H #define INC_STRUCTURE_ZMATRIX_H #include "InternalCoords.h" +#include "StructureEnum.h" #include "../Vec3.h" -#include "../Chirality.h" class Frame; class Topology; class Molecule; @@ -38,7 +38,7 @@ class Zmatrix { int SetFromFrame(Frame const&, Topology const&); /// Get internal coordinates around bond in one direction. int SetFromFrameAroundBond(int, int, Frame const&, Topology const&, - std::vector const&, std::vector const&); + std::vector const&, std::vector const&); /// Set Frame from internal coords int SetToFrame(Frame&) const; diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index 2489247f16..6c617f840a 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -12,4 +12,4 @@ Sugar.o : Sugar.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants. SugarBuilder.o : SugarBuilder.cpp ../ArgList.h ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../CharMask.h ../Constants.h ../CoordinateInfo.h ../CpptrajFile.h ../CpptrajStdio.h ../DistRoutines.h ../FileIO.h ../FileName.h ../Frame.h ../ImageOption.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Chirality.h FunctionalGroup.h FxnGroupBuilder.h LinkAtom.h ResStatArray.h StructureEnum.h StructureRoutines.h Sugar.h SugarBuilder.h SugarLinkAtoms.h SugarToken.h SugarLinkAtoms.o : SugarLinkAtoms.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../StringRoutines.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h LinkAtom.h SugarLinkAtoms.h SugarToken.o : SugarToken.cpp ../ArgList.h ../CpptrajStdio.h SugarToken.h -Zmatrix.o : Zmatrix.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Chirality.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h InternalCoords.h Model.h StructureEnum.h Zmatrix.h +Zmatrix.o : Zmatrix.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Chirality.h InternalCoords.h Model.h StructureEnum.h Zmatrix.h diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 326bf3a390..9076e2733c 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -151,7 +151,6 @@ ByteRoutines.o : ByteRoutines.cpp CIFfile.o : CIFfile.cpp ArgList.h Atom.h BufferedLine.h CIFfile.h CpptrajFile.h CpptrajStdio.h FileIO.h FileName.h NameType.h Parallel.h SymbolExporting.h CharMask.o : CharMask.cpp Atom.h CharMask.h CpptrajStdio.h MaskToken.h Molecule.h NameType.h Residue.h Segment.h SymbolExporting.h Unit.h CharmmParamFile.o : CharmmParamFile.cpp ArgList.h AtomType.h BufferedLine.h CharmmParamFile.h Constants.h CpptrajFile.h CpptrajStdio.h FileIO.h FileName.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h StringRoutines.h TypeNameHolder.h -Chirality.o : Chirality.cpp Atom.h AtomMask.h AtomType.h Box.h Chirality.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Cluster/Algorithm.o : Cluster/Algorithm.cpp Cluster/Algorithm.h Cluster/CentroidArray.h Cluster/Cframes.h Cluster/Metric.h Cluster/MetricArray.h Cluster/Node.h CpptrajStdio.h Cluster/Algorithm_DBscan.o : Cluster/Algorithm_DBscan.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Cluster/Algorithm.h Cluster/Algorithm_DBscan.h Cluster/CentroidArray.h Cluster/Cframes.h Cluster/List.h Cluster/Metric.h Cluster/MetricArray.h Cluster/Node.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataSet.h DataSetList.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixDbl.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ProgressBar.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Cluster/Algorithm_DPeaks.o : Cluster/Algorithm_DPeaks.cpp ArgList.h AssociatedData.h Cluster/Algorithm.h Cluster/Algorithm_DPeaks.h Cluster/CentroidArray.h Cluster/Cframes.h Cluster/List.h Cluster/Metric.h Cluster/MetricArray.h Cluster/Node.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_1D.h DataSet_Mesh.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h ProgressBar.h Range.h Spline.h TextFormat.h @@ -204,7 +203,7 @@ DataFileList.o : DataFileList.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h A DataFilter.o : DataFilter.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_integer.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO.o : DataIO.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataSet.h DataSetList.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixDbl.h Dimension.h FileIO.h FileName.h Frame.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 Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_AmberEne.o : DataIO_AmberEne.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberEne.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h -DataIO_AmberPrep.o : DataIO_AmberPrep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h BondSearch.h Box.h BufferedLine.h Chirality.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberPrep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h +DataIO_AmberPrep.o : DataIO_AmberPrep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h BondSearch.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberPrep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/InternalCoords.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CCP4.o : DataIO_CCP4.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ByteRoutines.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CCP4.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridFlt.h Dimension.h FileIO.h FileName.h Frame.h Grid.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmFastRep.o : DataIO_CharmmFastRep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmFastRep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_RemLog.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmOutput.o : DataIO_CharmmOutput.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmOutput.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_double.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h @@ -254,7 +253,7 @@ DataSet_Tensor.o : DataSet_Tensor.cpp AssociatedData.h CpptrajFile.h DataSet.h D DataSet_Topology.o : DataSet_Topology.cpp AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Topology.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ParmFile.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataSet_Vector.o : DataSet_Vector.cpp ArrayIterator.h AssociatedData.h ComplexArray.h Constants.h Corr.h CpptrajFile.h DataSet.h DataSet_1D.h DataSet_Vector.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h PubFFT.h Range.h SymbolExporting.h TextFormat.h Vec3.h DataSet_Vector_Scalar.o : DataSet_Vector_Scalar.cpp AssociatedData.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Vector_Scalar.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h TextFormat.h Vec3.h -DataSet_Zmatrix.o : DataSet_Zmatrix.cpp AssociatedData.h Chirality.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Zmatrix.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h Structure/InternalCoords.h Structure/Zmatrix.h TextFormat.h Vec3.h +DataSet_Zmatrix.o : DataSet_Zmatrix.cpp AssociatedData.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Zmatrix.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h Structure/InternalCoords.h Structure/StructureEnum.h Structure/Zmatrix.h TextFormat.h Vec3.h DataSet_double.o : DataSet_double.cpp AssociatedData.h CpptrajFile.h DataSet.h DataSet_1D.h DataSet_double.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h TextFormat.h DataSet_float.o : DataSet_float.cpp AssociatedData.h CpptrajFile.h DataSet.h DataSet_1D.h DataSet_float.h Dimension.h FileIO.h FileName.h MetaData.h Parallel.h Range.h TextFormat.h DataSet_integer_disk.o : DataSet_integer_disk.cpp AssociatedData.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_1D.h DataSet_integer.h DataSet_integer_disk.h Dimension.h FileIO.h FileName.h File_TempName.h MetaData.h NC_Routines.h Parallel.h Range.h TextFormat.h @@ -304,7 +303,7 @@ Exec_Emin.o : Exec_Emin.cpp Action.h ActionList.h ActionState.h Analysis.h Analy Exec_ExtendedComparison.o : Exec_ExtendedComparison.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_ExtendedComparison.h ExtendedSimilarity.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_Flatten.o : Exec_Flatten.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Flatten.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 ImageOption.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 AtomMask.h AtomType.h BaseIOtype.h Box.h Chirality.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 Segment.h Structure/InternalCoords.h Structure/Model.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 AtomMask.h AtomType.h BaseIOtype.h Box.h Chirality.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 Segment.h Structure/InternalCoords.h Structure/Model.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_HmassRepartition.o : Exec_HmassRepartition.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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 EnsembleIn.h EnsembleOutList.h Exec.h Exec_HmassRepartition.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h Trajin_Single.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h @@ -336,7 +335,7 @@ Exec_Top.o : Exec_Top.cpp Action.h ActionList.h ActionState.h Analysis.h Analysi Exec_Traj.o : Exec_Traj.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_Traj.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_UpdateParameters.o : Exec_UpdateParameters.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_Parameters.h DataSet_Topology.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_UpdateParameters.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_ViewRst.o : Exec_ViewRst.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.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_ViewRst.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h ViewRst.h -Exec_Zmatrix.o : Exec_Zmatrix.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Chirality.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_Zmatrix.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Zmatrix.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 Segment.h Structure/InternalCoords.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h +Exec_Zmatrix.o : Exec_Zmatrix.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_Zmatrix.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Zmatrix.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 Segment.h Structure/InternalCoords.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h ExtendedSimilarity.o : ExtendedSimilarity.cpp AssociatedData.h Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Coords.h Dimension.h ExtendedSimilarity.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Topology.h TypeNameHolder.h Unit.h Vec3.h ExternalFxn.o : ExternalFxn.cpp Random.h FileIO_Bzip2.o : FileIO_Bzip2.cpp CpptrajStdio.h FileIO.h FileIO_Bzip2.h @@ -431,19 +430,21 @@ SpaceGroup.o : SpaceGroup.cpp Matrix_3x3.h Parallel.h SpaceGroup.h Vec3.h Spline.o : Spline.cpp CpptrajStdio.h Spline.h SplineFxnTable.o : SplineFxnTable.cpp Constants.h CpptrajStdio.h Spline.h SplineFxnTable.h StringRoutines.h StringRoutines.o : StringRoutines.cpp CpptrajStdio.h StringRoutines.h -Structure/Builder.o : Structure/Builder.cpp Atom.h AtomMask.h AtomType.h Box.h Chirality.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Builder.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h +Structure/Builder.o : Structure/Builder.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/BuildAtom.h Structure/Builder.h Structure/Chirality.h Structure/StructureEnum.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h +Structure/Chirality.o : Structure/Chirality.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Chirality.h Structure/StructureEnum.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Structure/Disulfide.o : Structure/Disulfide.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Disulfide.h Structure/ResStatArray.h Structure/StructureRoutines.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/FunctionalGroup.o : Structure/FunctionalGroup.cpp Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/FxnGroupBuilder.o : Structure/FxnGroupBuilder.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/HisProt.o : Structure/HisProt.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/HisProt.h Structure/StructureRoutines.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/InternalCoords.o : Structure/InternalCoords.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/InternalCoords.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h -Structure/Model.o : Structure/Model.cpp Atom.h AtomMask.h AtomType.h Box.h Chirality.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Model.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h +Structure/Model.o : Structure/Model.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Chirality.h Structure/Model.h Structure/StructureEnum.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h +Structure/StructureEnum.o : Structure/StructureEnum.cpp Structure/StructureEnum.h Structure/StructureRoutines.o : Structure/StructureRoutines.cpp Atom.h CpptrajStdio.h NameType.h Residue.h Structure/StructureRoutines.h SymbolExporting.h Structure/Sugar.o : Structure/Sugar.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h -Structure/SugarBuilder.o : Structure/SugarBuilder.cpp ArgList.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h CharMask.h Chirality.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DistRoutines.h FileIO.h FileName.h Frame.h ImageOption.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/LinkAtom.h Structure/ResStatArray.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarBuilder.h Structure/SugarLinkAtoms.h Structure/SugarToken.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h +Structure/SugarBuilder.o : Structure/SugarBuilder.cpp ArgList.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DistRoutines.h FileIO.h FileName.h Frame.h ImageOption.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Chirality.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/LinkAtom.h Structure/ResStatArray.h Structure/StructureEnum.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarBuilder.h Structure/SugarLinkAtoms.h Structure/SugarToken.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarLinkAtoms.o : Structure/SugarLinkAtoms.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/LinkAtom.h Structure/SugarLinkAtoms.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarToken.o : Structure/SugarToken.cpp ArgList.h CpptrajStdio.h Structure/SugarToken.h -Structure/Zmatrix.o : Structure/Zmatrix.cpp Atom.h AtomMask.h AtomType.h Box.h Chirality.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/InternalCoords.h Structure/Model.h Structure/Zmatrix.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h +Structure/Zmatrix.o : Structure/Zmatrix.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Chirality.h Structure/InternalCoords.h Structure/Model.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h StructureCheck.o : StructureCheck.cpp Atom.h AtomMask.h AtomType.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h ExclusionArray.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StructureCheck.h SymbolExporting.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h StructureMapper.o : StructureMapper.cpp AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StructureMapper.h SymbolExporting.h TextFormat.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h SymmetricRmsdCalc.o : SymmetricRmsdCalc.cpp ArrayIterator.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h Hungarian.h ImageOption.h MapAtom.h MaskToken.h Matrix.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h SymmetricRmsdCalc.h Topology.h TypeNameHolder.h Unit.h Vec3.h From 1cf3f97f769cc44a303dee21048aef944ee0ad40 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 10:08:19 -0400 Subject: [PATCH 160/245] Use new Chirality --- src/Exec_Graft.cpp | 3 +-- src/cpptrajdepend | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index e9ef301ffb..7966ba7092 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -1,7 +1,7 @@ #include "Exec_Graft.h" #include "CpptrajStdio.h" #include "DataSet_Coords.h" -#include "Chirality.h" +#include "Structure/Chirality.h" #include "Structure/Zmatrix.h" #include "Structure/Model.h" #include // std::copy @@ -284,7 +284,6 @@ const CombinedFrame.SetBox( mol0frm.BoxCrd() ); // Get chirality for each atom before we add the bond - using namespace Cpptraj::Chirality; std::vector atomChirality; atomChirality.reserve( combinedTop.Natom() ); for (int at = 0; at < combinedTop.Natom(); at++) { diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 9076e2733c..d1a586103d 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -303,7 +303,7 @@ Exec_Emin.o : Exec_Emin.cpp Action.h ActionList.h ActionState.h Analysis.h Analy Exec_ExtendedComparison.o : Exec_ExtendedComparison.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_ExtendedComparison.h ExtendedSimilarity.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_Flatten.o : Exec_Flatten.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Flatten.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 ImageOption.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 AtomMask.h AtomType.h BaseIOtype.h Box.h Chirality.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 Segment.h Structure/InternalCoords.h Structure/Model.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h Structure/Chirality.h Structure/InternalCoords.h Structure/Model.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_HmassRepartition.o : Exec_HmassRepartition.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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 EnsembleIn.h EnsembleOutList.h Exec.h Exec_HmassRepartition.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h Trajin_Single.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h From b578874f9595cbeb185d39ccab4848676a271b84 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 10:09:11 -0400 Subject: [PATCH 161/245] Remove reference to old Chirality.cpp --- src/cpptrajfiles | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cpptrajfiles b/src/cpptrajfiles index 7c923792a1..188c6fa74a 100644 --- a/src/cpptrajfiles +++ b/src/cpptrajfiles @@ -153,7 +153,6 @@ COMMON_SOURCES= \ ByteRoutines.cpp \ CharMask.cpp \ CharmmParamFile.cpp \ - Chirality.cpp \ CIFfile.cpp \ ClusterMap.cpp \ Cmd.cpp \ From 43a6eb6ac5b97fbdc335923c3620381792b5c4a9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 10:10:28 -0400 Subject: [PATCH 162/245] Fix enum --- src/Structure/Chirality.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Structure/Chirality.cpp b/src/Structure/Chirality.cpp index 02770ef530..30b3c15f43 100644 --- a/src/Structure/Chirality.cpp +++ b/src/Structure/Chirality.cpp @@ -87,7 +87,7 @@ Cpptraj::Structure::ChiralType if (atom.Nbonds() < 3) { mprinterr("Error: CalcChiralAtomTorsion called for atom %s with less than 3 bonds.\n", topIn.AtomMaskName(atnum).c_str()); - return ERR; + return CHIRALITY_ERR; } // Calculate a priority score for each bonded atom. // First just use the atomic number. From 592a0f7d5670c35f84fff942e175e4aec6d441aa Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 10:23:55 -0400 Subject: [PATCH 163/245] Add clear() routine --- src/Structure/Zmatrix.cpp | 14 ++++++++++++++ src/Structure/Zmatrix.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 6387fb0209..8931aeeb9c 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -29,6 +29,20 @@ Zmatrix::Zmatrix() : seedAt2_(InternalCoords::NO_ATOM) {} +/** Clear the zmatrix. */ +void Zmatrix::clear() { + IC_.clear(); + icseed0_ = InternalCoords::NO_ATOM; + icseed1_ = InternalCoords::NO_ATOM; + icseed2_ = InternalCoords::NO_ATOM; + seed0Pos_ = Vec3(0.0); + seed1Pos_ = Vec3(0.0); + seed2Pos_ = Vec3(0.0); + seedAt0_ = InternalCoords::NO_ATOM; + seedAt1_ = InternalCoords::NO_ATOM; + seedAt2_ = InternalCoords::NO_ATOM; +} + /// Error message for seed already set static inline int seed_err(int iseed) { mprinterr("Internal Error: Internal coord seed %i is already set.\n", iseed); diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 5071b00883..26aca0cad8 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -24,6 +24,8 @@ class Zmatrix { /// \reserve space for # of internal coords TODO zero out seeds? void reserve(unsigned int n) { IC_.reserve( n ); } + /// Clear the Zmatrix + void clear(); /// Add internal coordinate int AddIC(InternalCoords const&); /// Set specified IC From 3e91fe4c163428c5e0343aa3b581f3061a26acc6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 10:57:09 -0400 Subject: [PATCH 164/245] Have Model use BuildAtom --- src/Structure/Model.cpp | 40 ++++++++++++++++++++++------------------ src/Structure/Model.h | 3 ++- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index eedbe683fe..94195d96b9 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -1,5 +1,5 @@ #include "Model.h" -#include "Chirality.h" +#include "BuildAtom.h" #include "../CpptrajStdio.h" #include "../Topology.h" #include "../TorsionRoutines.h" @@ -95,7 +95,10 @@ int Cpptraj::Structure::Model::AssignTheta(double& theta, int ai, int aj, int ak * / \ * i l */ -int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, int al, Topology const& topIn, Frame const& frameIn, std::vector const& atomPositionKnown, std::vector const& atomChirality) +int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, int al, + Topology const& topIn, Frame const& frameIn, + std::vector const& atomPositionKnown, + BuildAtom const& AtomJ) { // Figure out hybridization and chirality of atom j. mprintf("DEBUG: AssignPhi for atom j : %s\n", topIn.AtomMaskName(aj).c_str()); @@ -111,22 +114,23 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in // FIXME aj ak and al should be known // TODO check that atom i actually ends up on the list? - std::vector Priority( AJ.Nbonds() ); - int* priority = static_cast( &Priority[0] ); + //std::vector Priority( AJ.Nbonds() ); + //int* priority = static_cast( &AtomJ_Priority[0] ); + std::vector const& priority = AtomJ.Priority(); double tors = 0; // FIXME - Only need priority here. - ChiralType chirality = DetermineChirality(tors, priority, aj, topIn, frameIn, 1); // FIXME debug - if (chirality == CHIRALITY_ERR) { - mprinterr("Error: Problem determining chirality around atom %s\n", topIn.AtomMaskName(aj).c_str()); - return 1; - } /*else if (chirality == IS_UNKNOWN_CHIRALITY) { - mprintf("DEBUG:\t\tChirality is unknown\n"); - } else if (chirality == IS_S) { - mprintf("DEBUG:\t\tChirality is S\n"); - } else { - mprintf("DEBUG:\t\tChirality is R\n"); - }*/ - mprintf("DEBUG: Original chirality around J %s is %s\n", topIn.AtomMaskName(aj).c_str(), chiralStr(atomChirality[aj])); + //ChiralType chirality = DetermineChirality(tors, priority, aj, topIn, frameIn, 1); // FIXME debug + //if (chirality == CHIRALITY_ERR) { + // mprinterr("Error: Problem determining chirality around atom %s\n", topIn.AtomMaskName(aj).c_str()); + // return 1; + //} /*else if (chirality == IS_UNKNOWN_CHIRALITY) { + // mprintf("DEBUG:\t\tChirality is unknown\n"); + //} else if (chirality == IS_S) { + // mprintf("DEBUG:\t\tChirality is S\n"); + //} else { + // mprintf("DEBUG:\t\tChirality is R\n"); + //}*/ + mprintf("DEBUG: Original chirality around J %s is %s\n", topIn.AtomMaskName(aj).c_str(), chiralStr(AtomJ.Chirality())); mprintf("DEBUG:\t\tPriority around J %s(%i) (tors=%g):", topIn.AtomMaskName(aj).c_str(), (int)atomPositionKnown[aj], tors*Constants::RADDEG); for (int idx = 0; idx < AJ.Nbonds(); idx++) @@ -134,7 +138,7 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in mprintf("\n"); // Determine if chirality is valid bool chirality_is_valid = true; - for (unsigned int idx = 0; idx < Priority.size(); idx++) { + for (unsigned int idx = 0; idx < priority.size(); idx++) { if (atomPositionKnown[priority[idx]] != atomPositionKnown[aj]) { chirality_is_valid = false; break; @@ -178,7 +182,7 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in } else startPhi = knownPhi[knownIdx]; - if (atomChirality[aj] == IS_R) { + if (AtomJ.Chirality() == IS_R) { startPhi = -startPhi; interval = -interval; } diff --git a/src/Structure/Model.h b/src/Structure/Model.h index 5c49aac8b4..5d5a52e379 100644 --- a/src/Structure/Model.h +++ b/src/Structure/Model.h @@ -6,10 +6,11 @@ class Topology; class Frame; namespace Cpptraj { namespace Structure { +class BuildAtom; /// Routines to generate model parameters namespace Model { /// Given atoms J K and L, attempt to assign a reasonable value for phi for atom I -int AssignPhi(double&, int, int, int, int, Topology const&, Frame const&, std::vector const&, std::vector const&); +int AssignPhi(double&, int, int, int, int, Topology const&, Frame const&, std::vector const&, BuildAtom const&); /// Given atoms J and K, attempt to assign a reasonable value for theta for atom I int AssignTheta(double&, int, int, int, Topology const&, Frame const&, std::vector const&); From 8d3578a57bbc53386d63d770ea52d4bf15b4a57a Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 11:04:27 -0400 Subject: [PATCH 165/245] Dont hold position status. Return chirality/priority --- src/Structure/BuildAtom.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Structure/BuildAtom.h b/src/Structure/BuildAtom.h index 7634f6c1fa..9471e25c50 100644 --- a/src/Structure/BuildAtom.h +++ b/src/Structure/BuildAtom.h @@ -6,17 +6,19 @@ namespace Structure { /// Hold information for an atom used when building/modelling new coordinates. class BuildAtom { public: - BuildAtom() : positionKnown_(false), ctype_(IS_UNKNOWN_CHIRALITY) {} - /// Set position status - void SetPositionKnown(bool b) { positionKnown_ = b; } + BuildAtom() : ctype_(IS_UNKNOWN_CHIRALITY) {} /// Set chirality void SetChirality(ChiralType c) { ctype_ = c; } /// Set size of priority array based on number of bonds void SetNbonds(int n) { priority_.assign(n, -1); } /// \return Pointer to priority array int* PriorityPtr() { return &(priority_[0]); } + + /// \return Atom chirality + ChiralType Chirality() const { return ctype_; } + /// \return Priority array + std::vector const& Priority() const { return priority_; } private: - bool positionKnown_; ///< True if position is "known", i.e. can be used to build. ChiralType ctype_; ///< Chirality around atom std::vector priority_; ///< Indices of bonded atoms, sorted by priority }; From 0843363021fb9e204d9404381bafbb211a5fcc8c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 11:05:39 -0400 Subject: [PATCH 166/245] Use BuildAtom. Change function name --- src/Structure/Zmatrix.cpp | 26 +++++++++++++++----------- src/Structure/Zmatrix.h | 5 +++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 8931aeeb9c..5717e22e82 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -4,7 +4,7 @@ #include // cos #include // std::pair #include "Zmatrix.h" -#include "Chirality.h" +#include "BuildAtom.h" #include "Model.h" #include "../Frame.h" #include "../CpptrajStdio.h" @@ -821,14 +821,14 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu * direction of atom A. This means all internal coordinates with A and B * as I and J (should be only 1), as J and K, and as K and L. */ -int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topology const& topIn, - std::vector const& atomPositionKnown, - std::vector const& atomChirality) +int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology const& topIn, + std::vector const& atomPositionKnown, + std::vector const& Atoms) { mprintf("DEBUG: SetFromFrameAroundBond: atA= %s (%i) atB= %s (%i)\n", topIn.AtomMaskName(atA).c_str(), atA+1, topIn.AtomMaskName(atB).c_str(), atB+1); - mprintf("DEBUG: Atoms:\n"); +/* mprintf("DEBUG: Atoms:\n"); for (int at = 0; at != topIn.Natom(); ++at) mprintf("DEBUG:\t\t%s (%i) %s\n", topIn.AtomMaskName(at).c_str(), (int)atomPositionKnown[at], chiralStr(atomChirality[at])); // Sanity check. A and B must be bonded @@ -836,7 +836,7 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo mprinterr("Internal Error: SetFromFrameAroundBond(): Atoms %s and %s are not bonded.\n", topIn.AtomMaskName(atA).c_str(), topIn.AtomMaskName(atB).c_str()); return 1; - } + }*/ IC_.clear(); Barray hasIC( topIn.Natom(), false ); @@ -901,7 +901,9 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo } mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); double newPhi = 0; - if (Cpptraj::Structure::Model::AssignPhi(newPhi, atA, atB, atk0, atl0, topIn, frameIn, atomPositionKnown, atomChirality)) { + if (Cpptraj::Structure::Model::AssignPhi(newPhi, atA, atB, atk0, atl0, topIn, frameIn, + atomPositionKnown, Atoms[atB])) + { mprinterr("Error: phi (i j) assignment failed.\n"); return 1; } @@ -930,7 +932,9 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); // Set phi for I atA atB K newPhi = 0; - if (Cpptraj::Structure::Model::AssignPhi(newPhi, *iat, atA, atB, atk0, topIn, frameIn, atomPositionKnown, atomChirality)) { + if (Cpptraj::Structure::Model::AssignPhi(newPhi, *iat, atA, atB, atk0, topIn, frameIn, + atomPositionKnown, Atoms[atA])) + { mprinterr("Error: phi (j k) assignment failed.\n"); return 1; } @@ -975,12 +979,12 @@ int Zmatrix::SetFromFrameAroundBond(int atA, int atB, Frame const& frameIn, Topo return 1; } else { // 3 or more bonds - double tors; - std::vector priority( AJ1.Nbonds() ); + //double tors; + std::vector const& priority = Atoms[atA].Priority(); //( AJ1.Nbonds() ); int at0 = -1; int at1 = -1; std::vector remainingAtoms; - DetermineChirality(tors, &priority[0], atA, topIn, frameIn, 0); // FIXME debug level + //DetermineChirality(tors, &priority[0], atA, topIn, frameIn, 0); // FIXME debug level mprintf("DEBUG: %i bonds to %s\n", AJ1.Nbonds(), topIn.AtomMaskName(atA).c_str()); for (std::vector::const_iterator it = priority.begin(); it != priority.end(); ++it) { if (*it != atB) { diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 26aca0cad8..8030349da9 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -8,6 +8,7 @@ class Topology; class Molecule; namespace Cpptraj { namespace Structure { +class BuildAtom; /// Hold internal coordinates for a system. class Zmatrix { typedef std::vector ICarray; @@ -39,8 +40,8 @@ class Zmatrix { /// Convert molecule 0 of Frame/Topology to internal coordinates array int SetFromFrame(Frame const&, Topology const&); /// Get internal coordinates around bond in one direction. - int SetFromFrameAroundBond(int, int, Frame const&, Topology const&, - std::vector const&, std::vector const&); + int SetupICsAroundBond(int, int, Frame const&, Topology const&, + std::vector const&, std::vector const&); /// Set Frame from internal coords int SetToFrame(Frame&) const; From 08f8f0d2567f3040dac8884a93c4b3ed181ec8fb Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 11:06:46 -0400 Subject: [PATCH 167/245] Do Zmatrix construction --- src/Structure/Builder.cpp | 34 ++++++++++++++++++++++++++++++++-- src/Structure/Builder.h | 2 ++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index f97c23686a..acef32b939 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -1,9 +1,10 @@ #include "Builder.h" #include "BuildAtom.h" #include "Chirality.h" +#include "Zmatrix.h" #include "../CpptrajStdio.h" -#include "../Topology.h" #include "../Frame.h" +#include "../Topology.h" #include // std::copy using namespace Cpptraj::Structure; @@ -49,8 +50,9 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, // Reserve space in build atom array (chirality, priority, position status). // The positions of atoms in fragment 0 will be "known" atoms_.assign( newNatom, BuildAtom() ); + Barray posKnown( newNatom, false ); for (int at = 0; at != natom0; at++) - atoms_[at].SetPositionKnown( true ); + posKnown[at] = true; // Determine what bondAt1 will be in the combined topology. int bondAt1_new = bondAt1 + natom0; @@ -105,7 +107,35 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, DetermineChirality(tors, atoms_[at].PriorityPtr(), at, frag0Top, frag0frm, debug_); } } + + mprintf("DEBUG: Atoms:\n"); + for (int at = 0; at != frag0Top.Natom(); ++at) { + mprintf("DEBUG:\t\t%s (%i) %s", frag0Top.AtomMaskName(at).c_str(), (int)posKnown[at], + chiralStr(atoms_[at].Chirality())); + if (!atoms_[at].Priority().empty()) { + mprintf(" priority:"); + for (std::vector::const_iterator it = atoms_[at].Priority().begin(); + it != atoms_[at].Priority().end(); ++it) + mprintf(" %s", frag0Top.AtomMaskName(*it).c_str()); + mprintf("\n"); + } + } + // Generate a zmatrix for the smaller fragment + Zmatrix frag1Zmatrix; + frag1Zmatrix.SetDebug( 2 ); // FIXME + if (frag1Zmatrix.SetupICsAroundBond( bondAt0, bondAt1_new, frag0frm, frag0Top, posKnown, atoms_ )) + { + mprinterr("Error: Zmatrix setup for ICs around %s - %s failed.\n", + frag0Top.AtomMaskName(bondAt0).c_str(), + frag0Top.AtomMaskName(bondAt1).c_str()); + return 1; + } + frag1Zmatrix.print( &frag0Top ); + if (frag1Zmatrix.SetToFrame( frag0frm, posKnown )) { + mprinterr("Error: Conversion from fragment 1 Zmatrix to Cartesian coords failed.\n"); + return 1; + } return 0; } diff --git a/src/Structure/Builder.h b/src/Structure/Builder.h index f8df689a0d..ba14a79995 100644 --- a/src/Structure/Builder.h +++ b/src/Structure/Builder.h @@ -7,6 +7,7 @@ class Frame; namespace Cpptraj { namespace Structure { class BuildAtom; +class Zmatrix; /// Used to attach different topology/frame combos using internal coordinates class Builder { public: @@ -16,6 +17,7 @@ class Builder { int Combine(Topology&, Frame&, Topology&, Frame&, int, int); private: typedef std::vector AtArray; + typedef std::vector Barray; /// \return heavy atom count static inline int heavy_atom_count(Topology const&); From 508f19c29971f84a43d5c3618dca26dc6da99599 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 12:03:19 -0400 Subject: [PATCH 168/245] Use new builder class --- src/Exec_Graft.cpp | 38 ++++++++++++++-------- src/Structure/Builder.cpp | 67 ++++++++++++++++++++------------------- src/Structure/Builder.h | 6 ++-- 3 files changed, 61 insertions(+), 50 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 7966ba7092..5f356bce99 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -1,11 +1,9 @@ #include "Exec_Graft.h" #include "CpptrajStdio.h" #include "DataSet_Coords.h" -#include "Structure/Chirality.h" -#include "Structure/Zmatrix.h" -#include "Structure/Model.h" +#include "Structure/Builder.h" #include // std::copy -#include +//#include using namespace Cpptraj::Structure; // Exec_Graft::Help() @@ -238,13 +236,13 @@ const return CpptrajState::ERR; if (mol0crd->Top().SetupIntegerMask(mol0Mask)) return CpptrajState::ERR; - // Update the bond indices for the new topologies - if (UpdateIndices(tgtBondAtoms, mol0Mask, 0)) - return CpptrajState::ERR; - if (UpdateIndices(srcBondAtoms, mol1Mask, mol0Mask.Nselected())) - return CpptrajState::ERR; +// // Update the bond indices for the new topologies +// if (UpdateIndices(tgtBondAtoms, mol0Mask, 0)) +// return CpptrajState::ERR; +// if (UpdateIndices(srcBondAtoms, mol1Mask, mol0Mask.Nselected())) +// return CpptrajState::ERR; - // Modify the target (mol0) topology, update bond atom indices. + // Modify the target (mol0) topology. bool newMol0Top = false; Topology* mol0Top = 0; if (mol0Mask.Nselected() == mol0crd->Top().Natom()) { @@ -254,7 +252,7 @@ const mol0Top = modify_top(mol0crd->Top(), mol0Mask, mol0frm); if (mol0Top == 0) return CpptrajState::ERR; // FIXME need to free mol0Top memory } - // Modify the source (mol1) topology, update bond atom indices. + // Modify the source (mol1) topology. bool newMol1Top = false; Topology* mol1Top = 0; if (mol1Mask.Nselected() == mol1crd->Top().Natom()) { @@ -265,6 +263,18 @@ const if (mol1Top == 0) return CpptrajState::ERR; // FIXME need to free mol1Top memory } + Builder builder; + Topology combinedTop; + Frame CombinedFrame; + if (builder.Combine(combinedTop, CombinedFrame, + *mol0Top, mol0frm, *mol1Top, mol1frm, tgtBondAtoms[0], srcBondAtoms[0])) + { + mprinterr("Error: Fragment combination failed.\n"); + return CpptrajState::ERR; + } + if (outCoords->CoordsSetup(combinedTop, CombinedFrame.CoordsInfo())) + return CpptrajState::ERR; // FIXME free molXTop memory +/* // Combine topologies. Topology combinedTop; combinedTop.SetDebug( State.Debug() ); @@ -309,7 +319,7 @@ const // Track atoms as 'known'. Target atoms are residue 0, Source atoms are in residue 1 typedef std::vector Barray; - //Barray atomPositionKnown;/*( combinedTop.Natom(), false ); + //Barray atomPositionKnown;//( combinedTop.Natom(), false ); //for (int aidx = combinedTop.Res(1).FirstAtom(); aidx != combinedTop.Res(1).LastAtom(); aidx++) // atomPositionKnown[aidx] = true;*/ @@ -321,7 +331,7 @@ const return CpptrajState::ERR; } zmatrix.print(); // DEBUG*/ - // Generate Zmatrix only for ICs involving bonded atoms +/* // Generate Zmatrix only for ICs involving bonded atoms Zmatrix bondZmatrix; // Make atA belong to the smaller fragment. atB fragment will be "known" Barray posKnown( combinedTop.Natom(), false ); @@ -349,7 +359,7 @@ const if (bondZmatrix.SetToFrame( CombinedFrame, posKnown )) { mprinterr("Error: Conversion from bondZmatrix to Cartesian coords failed.\n"); return CpptrajState::ERR; - } + }*/ /* // Map atom j to ICs to change typedef std::map ICmapType; diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index acef32b939..e95dd75887 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -1,5 +1,4 @@ #include "Builder.h" -#include "BuildAtom.h" #include "Chirality.h" #include "Zmatrix.h" #include "../CpptrajStdio.h" @@ -28,21 +27,23 @@ int Builder::heavy_atom_count(Topology const& topIn) { /** Combine two units. The smaller fragment will be merged into * the larger fragment. */ -int Builder::Combine(Topology& frag0Top, Frame& frag0frm, - Topology& frag1Top, Frame& frag1frm, +int Builder::Combine(Topology& CombinedTop, Frame& CombinedFrm, + Topology const& frag0Top, Frame const& frag0frm, + Topology const& frag1Top, Frame const& frag1frm, int bondAt0, int bondAt1) { if (heavy_atom_count(frag0Top) < heavy_atom_count(frag1Top)) { - return combine01(frag1Top, frag1frm, frag0Top, frag0frm, bondAt1, bondAt0); + return combine01(CombinedTop, CombinedFrm, frag1Top, frag1frm, frag0Top, frag0frm, bondAt1, bondAt0); } else { - return combine01(frag0Top, frag0frm, frag1Top, frag1frm, bondAt0, bondAt1); + return combine01(CombinedTop, CombinedFrm, frag0Top, frag0frm, frag1Top, frag1frm, bondAt0, bondAt1); } } /** Combine two units. Fragment 1 will be merged into Fragment 0. */ -int Builder::combine01(Topology& frag0Top, Frame& frag0frm, - Topology const& frag1Top, Frame const& frag1frm, - int bondAt0, int bondAt1) +int Builder::combine01(Topology& CombinedTop, Frame& CombinedFrm, + Topology const& frag0Top, Frame const& frag0frm, + Topology const& frag1Top, Frame const& frag1frm, + int bondAt0, int bondAt1) { int natom0 = frag0Top.Natom(); int newNatom = natom0 + frag1Top.Natom(); @@ -72,22 +73,22 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, atoms_[at].SetChirality( DetermineChirality(at1, frag1Top, frag1frm, debug_) ); // Merge fragment 1 topology into fragment 0 - frag0Top.AppendTop( frag1Top ); + CombinedTop = frag0Top; // TODO use append? + CombinedTop.AppendTop( frag1Top ); // Merge fragment 1 coords into fragment 0 - double* tmpcrd = new double[ frag0frm.size() ]; - unsigned int tmpsize = frag0frm.size(); - std::copy( frag0frm.xAddress(), frag0frm.xAddress()+frag0frm.size(), tmpcrd ); - frag0frm.SetupFrameV( frag0Top.Atoms(), CoordinateInfo(frag0frm.BoxCrd(), false, false, false) ); - std::copy( tmpcrd, tmpcrd+tmpsize, frag0frm.xAddress() ); - std::copy( frag1frm.xAddress(), frag1frm.xAddress()+frag1frm.size(), frag0frm.xAddress()+tmpsize ); + CombinedFrm.SetupFrameV( CombinedTop.Atoms(), CoordinateInfo(frag0frm.BoxCrd(), false, false, false) ); + std::copy( frag0frm.xAddress(), frag0frm.xAddress()+frag0frm.size(), CombinedFrm.xAddress() ); + std::copy( frag1frm.xAddress(), frag1frm.xAddress()+frag1frm.size(), CombinedFrm.xAddress()+frag0frm.size() ); + // Use target box TODO reset the box? + CombinedFrm.SetBox( frag0frm.BoxCrd() ); // Create the bond mprintf("DEBUG: Bond %i %s to %i %s\n", - bondAt0+1, frag0Top.AtomMaskName(bondAt0).c_str(), - bondAt1_new+1, frag0Top.AtomMaskName(bondAt1_new).c_str()); - frag0Top.AddBond( bondAt0, bondAt1_new ); // TODO create pseudo-parameter? + bondAt0+1, CombinedTop.AtomMaskName(bondAt0).c_str(), + bondAt1_new+1, CombinedTop.AtomMaskName(bondAt1_new).c_str()); + CombinedTop.AddBond( bondAt0, bondAt1_new ); // TODO create pseudo-parameter? // Regenerate the molecule info TODO should AddBond do this automatically? - if (frag0Top.DetermineMolecules()) { + if (CombinedTop.DetermineMolecules()) { mprinterr("Error: Could not determine molecule info after combining fragments.\n"); return 1; } @@ -96,27 +97,27 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, // TODO only fragment 1? double tors = 0; for (int at = 0; at != natom0; ++at) { - if (frag0Top[at].Nbonds() > 2) { - atoms_[at].SetNbonds(frag0Top[at].Nbonds()); - DetermineChirality(tors, atoms_[at].PriorityPtr(), at, frag0Top, frag0frm, debug_); + if (CombinedTop[at].Nbonds() > 2) { + atoms_[at].SetNbonds(CombinedTop[at].Nbonds()); + DetermineChirality(tors, atoms_[at].PriorityPtr(), at, CombinedTop, CombinedFrm, debug_); } } for (int at = natom0; at != newNatom; at++) { - if (frag0Top[at].Nbonds() > 2) { - atoms_[at].SetNbonds(frag0Top[at].Nbonds()); - DetermineChirality(tors, atoms_[at].PriorityPtr(), at, frag0Top, frag0frm, debug_); + if (CombinedTop[at].Nbonds() > 2) { + atoms_[at].SetNbonds(CombinedTop[at].Nbonds()); + DetermineChirality(tors, atoms_[at].PriorityPtr(), at, CombinedTop, CombinedFrm, debug_); } } mprintf("DEBUG: Atoms:\n"); - for (int at = 0; at != frag0Top.Natom(); ++at) { - mprintf("DEBUG:\t\t%s (%i) %s", frag0Top.AtomMaskName(at).c_str(), (int)posKnown[at], + for (int at = 0; at != CombinedTop.Natom(); ++at) { + mprintf("DEBUG:\t\t%s (%i) %s", CombinedTop.AtomMaskName(at).c_str(), (int)posKnown[at], chiralStr(atoms_[at].Chirality())); if (!atoms_[at].Priority().empty()) { mprintf(" priority:"); for (std::vector::const_iterator it = atoms_[at].Priority().begin(); it != atoms_[at].Priority().end(); ++it) - mprintf(" %s", frag0Top.AtomMaskName(*it).c_str()); + mprintf(" %s", CombinedTop.AtomMaskName(*it).c_str()); mprintf("\n"); } } @@ -124,15 +125,15 @@ int Builder::combine01(Topology& frag0Top, Frame& frag0frm, // Generate a zmatrix for the smaller fragment Zmatrix frag1Zmatrix; frag1Zmatrix.SetDebug( 2 ); // FIXME - if (frag1Zmatrix.SetupICsAroundBond( bondAt0, bondAt1_new, frag0frm, frag0Top, posKnown, atoms_ )) + if (frag1Zmatrix.SetupICsAroundBond( bondAt0, bondAt1_new, CombinedFrm, CombinedTop, posKnown, atoms_ )) { mprinterr("Error: Zmatrix setup for ICs around %s - %s failed.\n", - frag0Top.AtomMaskName(bondAt0).c_str(), - frag0Top.AtomMaskName(bondAt1).c_str()); + CombinedTop.AtomMaskName(bondAt0).c_str(), + CombinedTop.AtomMaskName(bondAt1_new).c_str()); return 1; } - frag1Zmatrix.print( &frag0Top ); - if (frag1Zmatrix.SetToFrame( frag0frm, posKnown )) { + frag1Zmatrix.print( &CombinedTop ); + if (frag1Zmatrix.SetToFrame( CombinedFrm, posKnown )) { mprinterr("Error: Conversion from fragment 1 Zmatrix to Cartesian coords failed.\n"); return 1; } diff --git a/src/Structure/Builder.h b/src/Structure/Builder.h index ba14a79995..f2e269239e 100644 --- a/src/Structure/Builder.h +++ b/src/Structure/Builder.h @@ -1,7 +1,7 @@ #ifndef INC_STRUCTURE_BUILDER_H #define INC_STRUCTURE_BUILDER_H #include -//#incl ude "BuildAtom.h" +#include "BuildAtom.h" class Topology; class Frame; namespace Cpptraj { @@ -14,7 +14,7 @@ class Builder { /// CONSTRUCTOR Builder(); /// Combine smaller fragment into larger fragment - int Combine(Topology&, Frame&, Topology&, Frame&, int, int); + int Combine(Topology&, Frame&, Topology const&, Frame const&, Topology const&, Frame const&, int, int); private: typedef std::vector AtArray; typedef std::vector Barray; @@ -22,7 +22,7 @@ class Builder { /// \return heavy atom count static inline int heavy_atom_count(Topology const&); /// Combine fragment1 into fragment 0 - int combine01(Topology&, Frame&, Topology const&, Frame const&, int, int); + int combine01(Topology&, Frame&, Topology const&, Frame const&, Topology const&, Frame const&, int, int); AtArray atoms_; ///< Hold chirality, bonded atom index priority, and position status for each atom int debug_; From dfbbb78652a28278250a30f0fade9a18c0156703 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 13:26:53 -0400 Subject: [PATCH 169/245] Fix location of printf newline --- src/Structure/Builder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index e95dd75887..d72d4b7550 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -118,8 +118,8 @@ int Builder::combine01(Topology& CombinedTop, Frame& CombinedFrm, for (std::vector::const_iterator it = atoms_[at].Priority().begin(); it != atoms_[at].Priority().end(); ++it) mprintf(" %s", CombinedTop.AtomMaskName(*it).c_str()); - mprintf("\n"); } + mprintf("\n"); } // Generate a zmatrix for the smaller fragment From f1f2c01f902c5a373191333d18cff80f045caeb2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 13:28:44 -0400 Subject: [PATCH 170/245] Revert to not using Builder class, make sure changes to the Zmatrix and Model functions are working first. --- src/Exec_Graft.cpp | 68 ++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 5f356bce99..a5edd5f24b 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -1,9 +1,12 @@ #include "Exec_Graft.h" #include "CpptrajStdio.h" #include "DataSet_Coords.h" -#include "Structure/Builder.h" +#include "Structure/BuildAtom.h" +#include "Structure/Chirality.h" +#include "Structure/Zmatrix.h" +//#incl ude "Structure/Model.h" #include // std::copy -//#include +#include using namespace Cpptraj::Structure; // Exec_Graft::Help() @@ -236,13 +239,13 @@ const return CpptrajState::ERR; if (mol0crd->Top().SetupIntegerMask(mol0Mask)) return CpptrajState::ERR; -// // Update the bond indices for the new topologies -// if (UpdateIndices(tgtBondAtoms, mol0Mask, 0)) -// return CpptrajState::ERR; -// if (UpdateIndices(srcBondAtoms, mol1Mask, mol0Mask.Nselected())) -// return CpptrajState::ERR; + // Update the bond indices for the new topologies + if (UpdateIndices(tgtBondAtoms, mol0Mask, 0)) + return CpptrajState::ERR; + if (UpdateIndices(srcBondAtoms, mol1Mask, mol0Mask.Nselected())) + return CpptrajState::ERR; - // Modify the target (mol0) topology. + // Modify the target (mol0) topology, update bond atom indices. bool newMol0Top = false; Topology* mol0Top = 0; if (mol0Mask.Nselected() == mol0crd->Top().Natom()) { @@ -252,7 +255,7 @@ const mol0Top = modify_top(mol0crd->Top(), mol0Mask, mol0frm); if (mol0Top == 0) return CpptrajState::ERR; // FIXME need to free mol0Top memory } - // Modify the source (mol1) topology. + // Modify the source (mol1) topology, update bond atom indices. bool newMol1Top = false; Topology* mol1Top = 0; if (mol1Mask.Nselected() == mol1crd->Top().Natom()) { @@ -263,18 +266,6 @@ const if (mol1Top == 0) return CpptrajState::ERR; // FIXME need to free mol1Top memory } - Builder builder; - Topology combinedTop; - Frame CombinedFrame; - if (builder.Combine(combinedTop, CombinedFrame, - *mol0Top, mol0frm, *mol1Top, mol1frm, tgtBondAtoms[0], srcBondAtoms[0])) - { - mprinterr("Error: Fragment combination failed.\n"); - return CpptrajState::ERR; - } - if (outCoords->CoordsSetup(combinedTop, CombinedFrame.CoordsInfo())) - return CpptrajState::ERR; // FIXME free molXTop memory -/* // Combine topologies. Topology combinedTop; combinedTop.SetDebug( State.Debug() ); @@ -294,6 +285,16 @@ const CombinedFrame.SetBox( mol0frm.BoxCrd() ); // Get chirality for each atom before we add the bond + std::vector atomChirality( combinedTop.Natom() ); + for (int at = 0; at < mol0Top->Natom(); at++) + if (combinedTop[at].Nbonds() > 2) + atomChirality[at].SetChirality( DetermineChirality(at, combinedTop, CombinedFrame, 0) ); + for (int at = mol0Top->Natom(); at < combinedTop.Natom(); at++) + if (combinedTop[at].Nbonds() > 2) + atomChirality[at].SetChirality( DetermineChirality(at, combinedTop, CombinedFrame, 0) ); + for (int at = 0; at < combinedTop.Natom(); at++) + mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(at).c_str(), chiralStr(atomChirality[at].Chirality())); +/* std::vector atomChirality; atomChirality.reserve( combinedTop.Natom() ); for (int at = 0; at < combinedTop.Natom(); at++) { @@ -302,7 +303,7 @@ const else atomChirality.push_back( IS_UNKNOWN_CHIRALITY ); mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(at).c_str(), chiralStr(atomChirality.back())); - } + }*/ // Create bonds for (unsigned int idx = 0; idx != tgtBondAtoms.size(); idx++) { @@ -314,12 +315,27 @@ const // Regenerate the molecule info FIXME should Topology just do this? if (combinedTop.DetermineMolecules()) return CpptrajState::ERR; + // Determine priorities + double tors; + for (int at = 0; at < mol0Top->Natom(); at++) { + if (combinedTop[at].Nbonds() > 2) { + atomChirality[at].SetNbonds(combinedTop[at].Nbonds()); + DetermineChirality(tors, atomChirality[at].PriorityPtr(), at, combinedTop, CombinedFrame, 0); + } + } + for (int at = mol0Top->Natom(); at < combinedTop.Natom(); at++) { + if (combinedTop[at].Nbonds() > 2) { + atomChirality[at].SetNbonds(combinedTop[at].Nbonds()); + DetermineChirality(tors, atomChirality[at].PriorityPtr(), at, combinedTop, CombinedFrame, 0); + } + } + // Add to output COORDS set if (outCoords->CoordsSetup(combinedTop, outInfo)) return CpptrajState::ERR; // FIXME free molXTop memory // Track atoms as 'known'. Target atoms are residue 0, Source atoms are in residue 1 typedef std::vector Barray; - //Barray atomPositionKnown;//( combinedTop.Natom(), false ); + //Barray atomPositionKnown;/*( combinedTop.Natom(), false ); //for (int aidx = combinedTop.Res(1).FirstAtom(); aidx != combinedTop.Res(1).LastAtom(); aidx++) // atomPositionKnown[aidx] = true;*/ @@ -331,7 +347,7 @@ const return CpptrajState::ERR; } zmatrix.print(); // DEBUG*/ -/* // Generate Zmatrix only for ICs involving bonded atoms + // Generate Zmatrix only for ICs involving bonded atoms Zmatrix bondZmatrix; // Make atA belong to the smaller fragment. atB fragment will be "known" Barray posKnown( combinedTop.Natom(), false ); @@ -349,7 +365,7 @@ const posKnown[at] = true; } bondZmatrix.SetDebug( 2 ); // FIXME - if (bondZmatrix.SetFromFrameAroundBond(atA, atB, CombinedFrame, combinedTop, posKnown, atomChirality)) { + if (bondZmatrix.SetupICsAroundBond(atA, atB, CombinedFrame, combinedTop, posKnown, atomChirality)) { mprinterr("Error: Zmatrix setup for ICs around %s and %s failed.\n", combinedTop.AtomMaskName(atA).c_str(), combinedTop.AtomMaskName(atB).c_str()); @@ -359,7 +375,7 @@ const if (bondZmatrix.SetToFrame( CombinedFrame, posKnown )) { mprinterr("Error: Conversion from bondZmatrix to Cartesian coords failed.\n"); return CpptrajState::ERR; - }*/ + } /* // Map atom j to ICs to change typedef std::map ICmapType; From 7f1d0b396c3b450afee11a5493bd5112ea2e0768 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 13:34:32 -0400 Subject: [PATCH 171/245] Remove unused code/includes --- src/Exec_Graft.cpp | 1 - src/Structure/Model.cpp | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index a5edd5f24b..67c3be3bc1 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -6,7 +6,6 @@ #include "Structure/Zmatrix.h" //#incl ude "Structure/Model.h" #include // std::copy -#include using namespace Cpptraj::Structure; // Exec_Graft::Help() diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index 94195d96b9..3ca4b50b21 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -137,14 +137,14 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in mprintf(" %s(%i)", topIn.AtomMaskName(priority[idx]).c_str(), (int)atomPositionKnown[priority[idx]]); mprintf("\n"); // Determine if chirality is valid - bool chirality_is_valid = true; +/* bool chirality_is_valid = true; for (unsigned int idx = 0; idx < priority.size(); idx++) { if (atomPositionKnown[priority[idx]] != atomPositionKnown[aj]) { chirality_is_valid = false; break; } } - mprintf("DEBUG:\t\tChirality is valid: %i\n", (int)chirality_is_valid); + mprintf("DEBUG:\t\tChirality is valid: %i\n", (int)chirality_is_valid);*/ // Fill in what values we can for known atoms std::vector knownPhi( AJ.Nbonds() ); @@ -199,6 +199,7 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in currentPhi += interval; } } + // Reverse direction currentPhi = startPhi - interval; for (int idx = knownIdx - 1; idx > -1; idx--) { int atnum = priority[idx]; From 30c5ded22ee08e7ea07a99448a23da9e55e0bf34 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 19:40:57 -0400 Subject: [PATCH 172/245] Add file containing Structure enums --- src/Structure/StructureEnum.cpp | 12 ++++++++++++ src/Structure/StructureEnum.h | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/Structure/StructureEnum.cpp create mode 100644 src/Structure/StructureEnum.h diff --git a/src/Structure/StructureEnum.cpp b/src/Structure/StructureEnum.cpp new file mode 100644 index 0000000000..1ef86d24f8 --- /dev/null +++ b/src/Structure/StructureEnum.cpp @@ -0,0 +1,12 @@ +#include "StructureEnum.h" + +/** \return string corresponding to ChiralType */ +const char* Cpptraj::Structure::chiralStr(ChiralType ct) { + switch (ct) { + case CHIRALITY_ERR : return "Error"; + case IS_S : return "S"; + case IS_R : return "R"; + case IS_UNKNOWN_CHIRALITY : return "Unknown"; + } + return 0; +} diff --git a/src/Structure/StructureEnum.h b/src/Structure/StructureEnum.h new file mode 100644 index 0000000000..311767921a --- /dev/null +++ b/src/Structure/StructureEnum.h @@ -0,0 +1,12 @@ +#ifndef INC_STRUCTURE_STRUCTUREENUM_H +#define INC_STRUCTURE_STRUCTUREENUM_H +namespace Cpptraj { +namespace Structure { + +enum ChiralType { CHIRALITY_ERR = 0, IS_S, IS_R, IS_UNKNOWN_CHIRALITY }; +/// \return String corresponding to ChiralType +const char* chiralStr(ChiralType); + +} +} +#endif From d8b9dae17755149dd39284e4dff555072bc9a446 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 23 Oct 2023 19:45:53 -0400 Subject: [PATCH 173/245] Just pass in chiral info for the atoms we need --- src/Exec_Graft.cpp | 2 +- src/Structure/Builder.cpp | 2 +- src/Structure/Zmatrix.cpp | 8 ++++---- src/Structure/Zmatrix.h | 2 +- src/Structure/structuredepend | 6 +++--- src/cpptrajdepend | 8 ++++---- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 67c3be3bc1..2b70c8f955 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -364,7 +364,7 @@ const posKnown[at] = true; } bondZmatrix.SetDebug( 2 ); // FIXME - if (bondZmatrix.SetupICsAroundBond(atA, atB, CombinedFrame, combinedTop, posKnown, atomChirality)) { + if (bondZmatrix.SetupICsAroundBond(atA, atB, CombinedFrame, combinedTop, posKnown, atomChirality[atA], atomChirality[atB])) { mprinterr("Error: Zmatrix setup for ICs around %s and %s failed.\n", combinedTop.AtomMaskName(atA).c_str(), combinedTop.AtomMaskName(atB).c_str()); diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index d72d4b7550..a4d8a5379f 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -125,7 +125,7 @@ int Builder::combine01(Topology& CombinedTop, Frame& CombinedFrm, // Generate a zmatrix for the smaller fragment Zmatrix frag1Zmatrix; frag1Zmatrix.SetDebug( 2 ); // FIXME - if (frag1Zmatrix.SetupICsAroundBond( bondAt0, bondAt1_new, CombinedFrm, CombinedTop, posKnown, atoms_ )) + if (frag1Zmatrix.SetupICsAroundBond( bondAt0, bondAt1_new, CombinedFrm, CombinedTop, posKnown, atoms_[bondAt0], atoms_[bondAt1_new] )) { mprinterr("Error: Zmatrix setup for ICs around %s - %s failed.\n", CombinedTop.AtomMaskName(bondAt0).c_str(), diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 5717e22e82..3a421ae760 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -823,7 +823,7 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnu */ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology const& topIn, std::vector const& atomPositionKnown, - std::vector const& Atoms) + BuildAtom const& AtomA, BuildAtom const& AtomB) { mprintf("DEBUG: SetFromFrameAroundBond: atA= %s (%i) atB= %s (%i)\n", topIn.AtomMaskName(atA).c_str(), atA+1, @@ -902,7 +902,7 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); double newPhi = 0; if (Cpptraj::Structure::Model::AssignPhi(newPhi, atA, atB, atk0, atl0, topIn, frameIn, - atomPositionKnown, Atoms[atB])) + atomPositionKnown, AtomB)) { mprinterr("Error: phi (i j) assignment failed.\n"); return 1; @@ -933,7 +933,7 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology // Set phi for I atA atB K newPhi = 0; if (Cpptraj::Structure::Model::AssignPhi(newPhi, *iat, atA, atB, atk0, topIn, frameIn, - atomPositionKnown, Atoms[atA])) + atomPositionKnown, AtomA)) { mprinterr("Error: phi (j k) assignment failed.\n"); return 1; @@ -980,7 +980,7 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology } else { // 3 or more bonds //double tors; - std::vector const& priority = Atoms[atA].Priority(); //( AJ1.Nbonds() ); + std::vector const& priority = AtomA.Priority(); //( AJ1.Nbonds() ); int at0 = -1; int at1 = -1; std::vector remainingAtoms; diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 8030349da9..64fec8306b 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -41,7 +41,7 @@ class Zmatrix { int SetFromFrame(Frame const&, Topology const&); /// Get internal coordinates around bond in one direction. int SetupICsAroundBond(int, int, Frame const&, Topology const&, - std::vector const&, std::vector const&); + std::vector const&, BuildAtom const&, BuildAtom const&); /// Set Frame from internal coords int SetToFrame(Frame&) const; diff --git a/src/Structure/structuredepend b/src/Structure/structuredepend index 6c617f840a..786f57a3d6 100644 --- a/src/Structure/structuredepend +++ b/src/Structure/structuredepend @@ -1,15 +1,15 @@ -Builder.o : Builder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h BuildAtom.h Builder.h Chirality.h StructureEnum.h +Builder.o : Builder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h BuildAtom.h Builder.h Chirality.h InternalCoords.h StructureEnum.h Zmatrix.h Chirality.o : Chirality.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Chirality.h StructureEnum.h Disulfide.o : Disulfide.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Disulfide.h ResStatArray.h StructureRoutines.h FunctionalGroup.o : FunctionalGroup.cpp ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.o : FxnGroupBuilder.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h FunctionalGroup.h FxnGroupBuilder.h StructureRoutines.h Sugar.h SugarToken.h HisProt.o : HisProt.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h HisProt.h StructureRoutines.h InternalCoords.o : InternalCoords.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h InternalCoords.h -Model.o : Model.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Chirality.h Model.h StructureEnum.h +Model.o : Model.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h BuildAtom.h Model.h StructureEnum.h StructureEnum.o : StructureEnum.cpp StructureEnum.h StructureRoutines.o : StructureRoutines.cpp ../Atom.h ../CpptrajStdio.h ../NameType.h ../Residue.h ../SymbolExporting.h StructureRoutines.h Sugar.o : Sugar.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Sugar.h SugarToken.h SugarBuilder.o : SugarBuilder.cpp ../ArgList.h ../Atom.h ../AtomMap.h ../AtomMask.h ../AtomType.h ../Box.h ../CharMask.h ../Constants.h ../CoordinateInfo.h ../CpptrajFile.h ../CpptrajStdio.h ../DistRoutines.h ../FileIO.h ../FileName.h ../Frame.h ../ImageOption.h ../MapAtom.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Chirality.h FunctionalGroup.h FxnGroupBuilder.h LinkAtom.h ResStatArray.h StructureEnum.h StructureRoutines.h Sugar.h SugarBuilder.h SugarLinkAtoms.h SugarToken.h SugarLinkAtoms.o : SugarLinkAtoms.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../FileName.h ../Frame.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../StringRoutines.h ../SymbolExporting.h ../Topology.h ../TypeNameHolder.h ../Unit.h ../Vec3.h LinkAtom.h SugarLinkAtoms.h SugarToken.o : SugarToken.cpp ../ArgList.h ../CpptrajStdio.h SugarToken.h -Zmatrix.o : Zmatrix.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h Chirality.h InternalCoords.h Model.h StructureEnum.h Zmatrix.h +Zmatrix.o : Zmatrix.cpp ../Atom.h ../AtomMask.h ../AtomType.h ../Box.h ../Constants.h ../CoordinateInfo.h ../CpptrajStdio.h ../DistRoutines.h ../FileName.h ../Frame.h ../ImageOption.h ../MaskToken.h ../Matrix_3x3.h ../Molecule.h ../NameType.h ../Parallel.h ../ParameterHolders.h ../ParameterSet.h ../ParameterTypes.h ../Range.h ../ReplicaDimArray.h ../Residue.h ../Segment.h ../SymbolExporting.h ../Topology.h ../TorsionRoutines.h ../TypeNameHolder.h ../Unit.h ../Vec3.h BuildAtom.h InternalCoords.h Model.h StructureEnum.h Zmatrix.h diff --git a/src/cpptrajdepend b/src/cpptrajdepend index d1a586103d..baed3536cd 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -303,7 +303,7 @@ Exec_Emin.o : Exec_Emin.cpp Action.h ActionList.h ActionState.h Analysis.h Analy Exec_ExtendedComparison.o : Exec_ExtendedComparison.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_ExtendedComparison.h ExtendedSimilarity.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_Flatten.o : Exec_Flatten.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Flatten.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 ImageOption.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h Structure/Chirality.h Structure/InternalCoords.h Structure/Model.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h Structure/BuildAtom.h Structure/Chirality.h Structure/InternalCoords.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_HmassRepartition.o : Exec_HmassRepartition.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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 EnsembleIn.h EnsembleOutList.h Exec.h Exec_HmassRepartition.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h Trajin_Single.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h @@ -430,21 +430,21 @@ SpaceGroup.o : SpaceGroup.cpp Matrix_3x3.h Parallel.h SpaceGroup.h Vec3.h Spline.o : Spline.cpp CpptrajStdio.h Spline.h SplineFxnTable.o : SplineFxnTable.cpp Constants.h CpptrajStdio.h Spline.h SplineFxnTable.h StringRoutines.h StringRoutines.o : StringRoutines.cpp CpptrajStdio.h StringRoutines.h -Structure/Builder.o : Structure/Builder.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/BuildAtom.h Structure/Builder.h Structure/Chirality.h Structure/StructureEnum.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h +Structure/Builder.o : Structure/Builder.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/BuildAtom.h Structure/Builder.h Structure/Chirality.h Structure/InternalCoords.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/Chirality.o : Structure/Chirality.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Chirality.h Structure/StructureEnum.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Structure/Disulfide.o : Structure/Disulfide.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Disulfide.h Structure/ResStatArray.h Structure/StructureRoutines.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/FunctionalGroup.o : Structure/FunctionalGroup.cpp Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/FxnGroupBuilder.o : Structure/FxnGroupBuilder.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/HisProt.o : Structure/HisProt.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/HisProt.h Structure/StructureRoutines.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/InternalCoords.o : Structure/InternalCoords.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/InternalCoords.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h -Structure/Model.o : Structure/Model.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Chirality.h Structure/Model.h Structure/StructureEnum.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h +Structure/Model.o : Structure/Model.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/BuildAtom.h Structure/Model.h Structure/StructureEnum.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Structure/StructureEnum.o : Structure/StructureEnum.cpp Structure/StructureEnum.h Structure/StructureRoutines.o : Structure/StructureRoutines.cpp Atom.h CpptrajStdio.h NameType.h Residue.h Structure/StructureRoutines.h SymbolExporting.h Structure/Sugar.o : Structure/Sugar.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Sugar.h Structure/SugarToken.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarBuilder.o : Structure/SugarBuilder.cpp ArgList.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DistRoutines.h FileIO.h FileName.h Frame.h ImageOption.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Chirality.h Structure/FunctionalGroup.h Structure/FxnGroupBuilder.h Structure/LinkAtom.h Structure/ResStatArray.h Structure/StructureEnum.h Structure/StructureRoutines.h Structure/Sugar.h Structure/SugarBuilder.h Structure/SugarLinkAtoms.h Structure/SugarToken.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarLinkAtoms.o : Structure/SugarLinkAtoms.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/LinkAtom.h Structure/SugarLinkAtoms.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h Structure/SugarToken.o : Structure/SugarToken.cpp ArgList.h CpptrajStdio.h Structure/SugarToken.h -Structure/Zmatrix.o : Structure/Zmatrix.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/Chirality.h Structure/InternalCoords.h Structure/Model.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h +Structure/Zmatrix.o : Structure/Zmatrix.cpp Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h Structure/BuildAtom.h Structure/InternalCoords.h Structure/Model.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h StructureCheck.o : StructureCheck.cpp Atom.h AtomMask.h AtomType.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h ExclusionArray.h FileName.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StructureCheck.h SymbolExporting.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h StructureMapper.o : StructureMapper.cpp AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h StructureMapper.h SymbolExporting.h TextFormat.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h SymmetricRmsdCalc.o : SymmetricRmsdCalc.cpp ArrayIterator.h Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h DistRoutines.h FileName.h Frame.h Hungarian.h ImageOption.h MapAtom.h MaskToken.h Matrix.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h SymmetricRmsdCalc.h Topology.h TypeNameHolder.h Unit.h Vec3.h From cb41b76407473ddfda179b19795742bf43f3b04a Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 24 Oct 2023 09:09:35 -0400 Subject: [PATCH 174/245] Only get chirality and priorities for the 2 bonded atoms --- src/Exec_Graft.cpp | 61 +++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 2b70c8f955..a888979c82 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -283,16 +283,40 @@ const // Use target box TODO reset the box? CombinedFrame.SetBox( mol0frm.BoxCrd() ); + // Make atA belong to the smaller fragment. atB fragment will be "known" + typedef std::vector Barray; + Barray posKnown( combinedTop.Natom(), false ); + int atA, atB; + // NOTE: mol0 is tgt. mol1 is src. + if (heavy_atom_count(*mol0Top) < heavy_atom_count(*mol1Top)) { + atA = tgtBondAtoms[0]; + atB = srcBondAtoms[0]; + for (int at = mol0Top->Natom(); at != combinedTop.Natom(); at++) + posKnown[at] = true; + } else { + atA = srcBondAtoms[0]; + atB = tgtBondAtoms[0]; + for (int at = 0; at != mol0Top->Natom(); at++) + posKnown[at] = true; + } + // Get chirality for each atom before we add the bond - std::vector atomChirality( combinedTop.Natom() ); - for (int at = 0; at < mol0Top->Natom(); at++) + BuildAtom AtomA; + if (combinedTop[atA].Nbonds() > 2) + AtomA.SetChirality( DetermineChirality(atA, combinedTop, CombinedFrame, 0) ); + mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(atA).c_str(), chiralStr(AtomA.Chirality())); + BuildAtom AtomB; + if (combinedTop[atB].Nbonds() > 2) + AtomB.SetChirality( DetermineChirality(atB, combinedTop, CombinedFrame, 0) ); + mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(atB).c_str(), chiralStr(AtomB.Chirality())); +/* for (int at = 0; at < mol0Top->Natom(); at++) if (combinedTop[at].Nbonds() > 2) atomChirality[at].SetChirality( DetermineChirality(at, combinedTop, CombinedFrame, 0) ); for (int at = mol0Top->Natom(); at < combinedTop.Natom(); at++) if (combinedTop[at].Nbonds() > 2) atomChirality[at].SetChirality( DetermineChirality(at, combinedTop, CombinedFrame, 0) ); for (int at = 0; at < combinedTop.Natom(); at++) - mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(at).c_str(), chiralStr(atomChirality[at].Chirality())); + mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(at).c_str(), chiralStr(atomChirality[at].Chirality()));*/ /* std::vector atomChirality; atomChirality.reserve( combinedTop.Natom() ); @@ -316,7 +340,15 @@ const // Determine priorities double tors; - for (int at = 0; at < mol0Top->Natom(); at++) { + if (combinedTop[atA].Nbonds() > 2) { + AtomA.SetNbonds(combinedTop[atA].Nbonds()); + DetermineChirality(tors, AtomA.PriorityPtr(), atA, combinedTop, CombinedFrame, 0); + } + if (combinedTop[atB].Nbonds() > 2) { + AtomB.SetNbonds(combinedTop[atB].Nbonds()); + DetermineChirality(tors, AtomB.PriorityPtr(), atB, combinedTop, CombinedFrame, 0); + } +/* for (int at = 0; at < mol0Top->Natom(); at++) { if (combinedTop[at].Nbonds() > 2) { atomChirality[at].SetNbonds(combinedTop[at].Nbonds()); DetermineChirality(tors, atomChirality[at].PriorityPtr(), at, combinedTop, CombinedFrame, 0); @@ -327,13 +359,12 @@ const atomChirality[at].SetNbonds(combinedTop[at].Nbonds()); DetermineChirality(tors, atomChirality[at].PriorityPtr(), at, combinedTop, CombinedFrame, 0); } - } + }*/ // Add to output COORDS set if (outCoords->CoordsSetup(combinedTop, outInfo)) return CpptrajState::ERR; // FIXME free molXTop memory // Track atoms as 'known'. Target atoms are residue 0, Source atoms are in residue 1 - typedef std::vector Barray; //Barray atomPositionKnown;/*( combinedTop.Natom(), false ); //for (int aidx = combinedTop.Res(1).FirstAtom(); aidx != combinedTop.Res(1).LastAtom(); aidx++) // atomPositionKnown[aidx] = true;*/ @@ -348,23 +379,9 @@ const zmatrix.print(); // DEBUG*/ // Generate Zmatrix only for ICs involving bonded atoms Zmatrix bondZmatrix; - // Make atA belong to the smaller fragment. atB fragment will be "known" - Barray posKnown( combinedTop.Natom(), false ); - int atA, atB; - // NOTE: mol0 is tgt. mol1 is src. - if (heavy_atom_count(*mol0Top) < heavy_atom_count(*mol1Top)) { - atA = tgtBondAtoms[0]; - atB = srcBondAtoms[0]; - for (int at = mol0Top->Natom(); at != combinedTop.Natom(); at++) - posKnown[at] = true; - } else { - atA = srcBondAtoms[0]; - atB = tgtBondAtoms[0]; - for (int at = 0; at != mol0Top->Natom(); at++) - posKnown[at] = true; - } + bondZmatrix.SetDebug( 2 ); // FIXME - if (bondZmatrix.SetupICsAroundBond(atA, atB, CombinedFrame, combinedTop, posKnown, atomChirality[atA], atomChirality[atB])) { + if (bondZmatrix.SetupICsAroundBond(atA, atB, CombinedFrame, combinedTop, posKnown, AtomA, AtomB)) { mprinterr("Error: Zmatrix setup for ICs around %s and %s failed.\n", combinedTop.AtomMaskName(atA).c_str(), combinedTop.AtomMaskName(atB).c_str()); From c989bee2b084f005e312bf182ddf819dbbb2c5d4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 24 Oct 2023 09:22:00 -0400 Subject: [PATCH 175/245] Put heavy atom count function into Topology --- src/Exec_Graft.cpp | 13 +------------ src/Topology.cpp | 11 +++++++++++ src/Topology.h | 2 ++ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index a888979c82..edfd1ee3ba 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -187,17 +187,6 @@ class ICholder { ICtype ictype_; ///< Type of reset (IJ=all, JK=theta,phi, KL=phi) }; -/// \return Heavy atom count -int heavy_atom_count(Topology const& topIn) { - int hac = 0; - for (int i = 0; i != topIn.Natom(); i++) { - if (topIn[i].Element() != Atom::HYDROGEN && - topIn[i].Element() != Atom::EXTRAPT) - hac++; - } - return hac; -} - /** Graft using internal coordinates to build the final structure. */ Exec::RetType Exec_Graft::graft_ic(CpptrajState& State, ArgList& argIn) const @@ -288,7 +277,7 @@ const Barray posKnown( combinedTop.Natom(), false ); int atA, atB; // NOTE: mol0 is tgt. mol1 is src. - if (heavy_atom_count(*mol0Top) < heavy_atom_count(*mol1Top)) { + if (mol0Top->HeavyAtomCount() < mol1Top->HeavyAtomCount()) { atA = tgtBondAtoms[0]; atB = srcBondAtoms[0]; for (int at = mol0Top->Natom(); at != combinedTop.Natom(); at++) diff --git a/src/Topology.cpp b/src/Topology.cpp index f22765506a..fe35eea5c2 100644 --- a/src/Topology.cpp +++ b/src/Topology.cpp @@ -38,6 +38,17 @@ const char *Topology::c_str() const { return parmName_.c_str(); } +/** \return count of heavy atoms (ignore hydrogen/extra points). */ +unsigned int Topology::HeavyAtomCount() const { + unsigned int hac = 0; + for (atom_iterator at = begin(); at != end(); ++at) { + if (at->Element() != Atom::HYDROGEN && + at->Element() != Atom::EXTRAPT) + hac++; + } + return hac; +} + /** Reset all PDB-related info. * NOTE: This routine is used by AmbPDB. */ diff --git a/src/Topology.h b/src/Topology.h index 7f0e67ca6e..cc670fad38 100644 --- a/src/Topology.h +++ b/src/Topology.h @@ -47,6 +47,8 @@ class Topology { const Atom &operator[](int idx) const { return atoms_[idx]; } std::vector const& Atoms() const { return atoms_; } Atom& SetAtom(int idx) { return atoms_[idx]; } + /// \return Count of "heavy" atoms (non-hydrogen, non-extra point) + unsigned int HeavyAtomCount() const; // ----- Amber Extra Info -------------------- std::vector const& TreeChainClassification() const { return tree_; } std::vector const& JoinArray() const { return ijoin_; } From 5d7c7793433ed8fad7353334250d986331deaa67 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 24 Oct 2023 09:42:04 -0400 Subject: [PATCH 176/245] Make the routine in builder the same as what is in graft --- src/Structure/Builder.cpp | 165 ++++++++++++++------------------------ src/Structure/Builder.h | 14 +--- 2 files changed, 63 insertions(+), 116 deletions(-) diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index a4d8a5379f..111cfbb6be 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -1,4 +1,5 @@ #include "Builder.h" +#include "BuildAtom.h" #include "Chirality.h" #include "Zmatrix.h" #include "../CpptrajStdio.h" @@ -13,128 +14,84 @@ Builder::Builder() : debug_(0) {} -/** \return Heavy atom count */ -int Builder::heavy_atom_count(Topology const& topIn) { - int hac = 0; - for (int i = 0; i != topIn.Natom(); i++) { - if (topIn[i].Element() != Atom::HYDROGEN && - topIn[i].Element() != Atom::EXTRAPT) - hac++; - } - return hac; -} - -/** Combine two units. The smaller fragment will be merged into - * the larger fragment. - */ -int Builder::Combine(Topology& CombinedTop, Frame& CombinedFrm, - Topology const& frag0Top, Frame const& frag0frm, +/** Combine two units. Fragment 1 will be merged into Fragment 0 and bonded. */ +int Builder::Combine(Topology& frag0Top, Frame& frag0frm, Topology const& frag1Top, Frame const& frag1frm, int bondAt0, int bondAt1) -{ - if (heavy_atom_count(frag0Top) < heavy_atom_count(frag1Top)) { - return combine01(CombinedTop, CombinedFrm, frag1Top, frag1frm, frag0Top, frag0frm, bondAt1, bondAt0); - } else { - return combine01(CombinedTop, CombinedFrm, frag0Top, frag0frm, frag1Top, frag1frm, bondAt0, bondAt1); - } -} - -/** Combine two units. Fragment 1 will be merged into Fragment 0. */ -int Builder::combine01(Topology& CombinedTop, Frame& CombinedFrm, - Topology const& frag0Top, Frame const& frag0frm, - Topology const& frag1Top, Frame const& frag1frm, - int bondAt0, int bondAt1) { int natom0 = frag0Top.Natom(); int newNatom = natom0 + frag1Top.Natom(); - // Reserve space in build atom array (chirality, priority, position status). - // The positions of atoms in fragment 0 will be "known" - atoms_.assign( newNatom, BuildAtom() ); + // Determine which "direction" we will be combining the fragments. + // Make atA belong to the smaller fragment. atB fragment will be "known". + // Ensure atB index is what it will be after fragments are combined. Barray posKnown( newNatom, false ); - for (int at = 0; at != natom0; at++) - posKnown[at] = true; - - // Determine what bondAt1 will be in the combined topology. - int bondAt1_new = bondAt1 + natom0; + int atA, atB; + if (frag0Top.HeavyAtomCount() < frag1Top.HeavyAtomCount()) { + // Fragment 1 is larger + atA = bondAt0; + atB = bondAt1 + natom0; + for (int at = frag0Top.Natom(); at != newNatom; at++) + posKnown[at] = true; + } else { + // Fragment 0 is larger or equal + atA = bondAt1 + natom0; + atB = bondAt0; + for (int at = 0; at != natom0; at++) + posKnown[at] = true; + } - // Get the chirality of each atom before the bond is added. - // This is because when the bond is added the geometry between the - // bonded atoms will likely not be correct, so while priority can be - // determined, the actual chirality can not. - // TODO store priorities as well? - // TODO only store for fragment 1? - for (int at = 0; at != natom0; ++at) - if (frag0Top[at].Nbonds() > 2) - atoms_[at].SetChirality( DetermineChirality(at, frag0Top, frag0frm, debug_) ); - int at1 = 0; - for (int at = natom0; at != newNatom; at++, at1++) - if (frag1Top[at1].Nbonds() > 2) - atoms_[at].SetChirality( DetermineChirality(at1, frag1Top, frag1frm, debug_) ); + // Combine fragment1 into fragment 0 topology + Topology& combinedTop = frag0Top; + combinedTop.AppendTop( frag1Top ); + // Combined fragment1 into fragment 0 coords. + // Need to save the original coords in frame0 since SetupFrameV does not preserve. + double* tmpcrd0 = new double[natom0*3]; + std::copy( frag0frm.xAddress(), frag0frm.xAddress()+frag0frm.size(), tmpcrd0 ); + frag0frm.SetupFrameV( combinedTop.Atoms(), CoordinateInfo(frag0frm.BoxCrd(), false, false, false)); + std::copy( tmpcrd0, tmpcrd0+natom0*3, frag0frm.xAddress() ); + std::copy( frag1frm.xAddress(), frag1frm.xAddress()+frag1frm.size(), frag0frm.xAddress()+natom0*3 ); + Frame& CombinedFrame = frag0frm; - // Merge fragment 1 topology into fragment 0 - CombinedTop = frag0Top; // TODO use append? - CombinedTop.AppendTop( frag1Top ); - // Merge fragment 1 coords into fragment 0 - CombinedFrm.SetupFrameV( CombinedTop.Atoms(), CoordinateInfo(frag0frm.BoxCrd(), false, false, false) ); - std::copy( frag0frm.xAddress(), frag0frm.xAddress()+frag0frm.size(), CombinedFrm.xAddress() ); - std::copy( frag1frm.xAddress(), frag1frm.xAddress()+frag1frm.size(), CombinedFrm.xAddress()+frag0frm.size() ); - // Use target box TODO reset the box? - CombinedFrm.SetBox( frag0frm.BoxCrd() ); + // Get the chirality around each atom before the bond is added. + BuildAtom AtomA; + if (combinedTop[atA].Nbonds() > 2) + AtomA.SetChirality( DetermineChirality(atA, combinedTop, CombinedFrame, 0) ); + mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(atA).c_str(), chiralStr(AtomA.Chirality())); + BuildAtom AtomB; + if (combinedTop[atB].Nbonds() > 2) + AtomB.SetChirality( DetermineChirality(atB, combinedTop, CombinedFrame, 0) ); + mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(atB).c_str(), chiralStr(AtomB.Chirality())); // Create the bond - mprintf("DEBUG: Bond %i %s to %i %s\n", - bondAt0+1, CombinedTop.AtomMaskName(bondAt0).c_str(), - bondAt1_new+1, CombinedTop.AtomMaskName(bondAt1_new).c_str()); - CombinedTop.AddBond( bondAt0, bondAt1_new ); // TODO create pseudo-parameter? - // Regenerate the molecule info TODO should AddBond do this automatically? - if (CombinedTop.DetermineMolecules()) { - mprinterr("Error: Could not determine molecule info after combining fragments.\n"); - return 1; - } + combinedTop.AddBond( atA, atB ); // TODO pseudo-parameter? + // // Regenerate the molecule info FIXME should Topology just do this? + if (combinedTop.DetermineMolecules()) return 1; - // Store priorities around each atom. - // TODO only fragment 1? - double tors = 0; - for (int at = 0; at != natom0; ++at) { - if (CombinedTop[at].Nbonds() > 2) { - atoms_[at].SetNbonds(CombinedTop[at].Nbonds()); - DetermineChirality(tors, atoms_[at].PriorityPtr(), at, CombinedTop, CombinedFrm, debug_); - } + // Determine priorities + double tors; + if (combinedTop[atA].Nbonds() > 2) { + AtomA.SetNbonds(combinedTop[atA].Nbonds()); + DetermineChirality(tors, AtomA.PriorityPtr(), atA, combinedTop, CombinedFrame, 0); } - for (int at = natom0; at != newNatom; at++) { - if (CombinedTop[at].Nbonds() > 2) { - atoms_[at].SetNbonds(CombinedTop[at].Nbonds()); - DetermineChirality(tors, atoms_[at].PriorityPtr(), at, CombinedTop, CombinedFrm, debug_); - } + if (combinedTop[atB].Nbonds() > 2) { + AtomB.SetNbonds(combinedTop[atB].Nbonds()); + DetermineChirality(tors, AtomB.PriorityPtr(), atB, combinedTop, CombinedFrame, 0); } - mprintf("DEBUG: Atoms:\n"); - for (int at = 0; at != CombinedTop.Natom(); ++at) { - mprintf("DEBUG:\t\t%s (%i) %s", CombinedTop.AtomMaskName(at).c_str(), (int)posKnown[at], - chiralStr(atoms_[at].Chirality())); - if (!atoms_[at].Priority().empty()) { - mprintf(" priority:"); - for (std::vector::const_iterator it = atoms_[at].Priority().begin(); - it != atoms_[at].Priority().end(); ++it) - mprintf(" %s", CombinedTop.AtomMaskName(*it).c_str()); - } - mprintf("\n"); - } + // Generate Zmatrix only for ICs involving bonded atoms + Zmatrix bondZmatrix; - // Generate a zmatrix for the smaller fragment - Zmatrix frag1Zmatrix; - frag1Zmatrix.SetDebug( 2 ); // FIXME - if (frag1Zmatrix.SetupICsAroundBond( bondAt0, bondAt1_new, CombinedFrm, CombinedTop, posKnown, atoms_[bondAt0], atoms_[bondAt1_new] )) - { - mprinterr("Error: Zmatrix setup for ICs around %s - %s failed.\n", - CombinedTop.AtomMaskName(bondAt0).c_str(), - CombinedTop.AtomMaskName(bondAt1_new).c_str()); + bondZmatrix.SetDebug( 2 ); // FIXME + if (bondZmatrix.SetupICsAroundBond(atA, atB, CombinedFrame, combinedTop, posKnown, AtomA, AtomB)) { + mprinterr("Error: Zmatrix setup for ICs around %s and %s failed.\n", + combinedTop.AtomMaskName(atA).c_str(), + combinedTop.AtomMaskName(atB).c_str()); return 1; } - frag1Zmatrix.print( &CombinedTop ); - if (frag1Zmatrix.SetToFrame( CombinedFrm, posKnown )) { - mprinterr("Error: Conversion from fragment 1 Zmatrix to Cartesian coords failed.\n"); + bondZmatrix.print(&combinedTop); + if (bondZmatrix.SetToFrame( CombinedFrame, posKnown )) { + mprinterr("Error: Conversion from bondZmatrix to Cartesian coords failed.\n"); return 1; } diff --git a/src/Structure/Builder.h b/src/Structure/Builder.h index f2e269239e..05f2d243e2 100644 --- a/src/Structure/Builder.h +++ b/src/Structure/Builder.h @@ -1,30 +1,20 @@ #ifndef INC_STRUCTURE_BUILDER_H #define INC_STRUCTURE_BUILDER_H #include -#include "BuildAtom.h" class Topology; class Frame; namespace Cpptraj { namespace Structure { -class BuildAtom; -class Zmatrix; /// Used to attach different topology/frame combos using internal coordinates class Builder { public: /// CONSTRUCTOR Builder(); - /// Combine smaller fragment into larger fragment - int Combine(Topology&, Frame&, Topology const&, Frame const&, Topology const&, Frame const&, int, int); + /// Combine second fragment into first fragment and bond + int Combine(Topology&, Frame&, Topology const&, Frame const&, int, int); private: - typedef std::vector AtArray; typedef std::vector Barray; - /// \return heavy atom count - static inline int heavy_atom_count(Topology const&); - /// Combine fragment1 into fragment 0 - int combine01(Topology&, Frame&, Topology const&, Frame const&, Topology const&, Frame const&, int, int); - - AtArray atoms_; ///< Hold chirality, bonded atom index priority, and position status for each atom int debug_; }; } From 769dd2bcff2f36bec3bfc05ec246732789453bbe Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 24 Oct 2023 10:13:14 -0400 Subject: [PATCH 177/245] Print the atoms being bonded --- src/Structure/Builder.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index 111cfbb6be..2da945447c 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -64,6 +64,7 @@ int Builder::Combine(Topology& frag0Top, Frame& frag0frm, mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(atB).c_str(), chiralStr(AtomB.Chirality())); // Create the bond + mprintf("DEBUG: Bonding atom %s to %s\n", combinedTop.AtomMaskName(atA).c_str(), combinedTop.AtomMaskName(atB).c_str()); combinedTop.AddBond( atA, atB ); // TODO pseudo-parameter? // // Regenerate the molecule info FIXME should Topology just do this? if (combinedTop.DetermineMolecules()) return 1; From 1f74789564f34208904f055552c0f66ffd335ef8 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 24 Oct 2023 10:13:41 -0400 Subject: [PATCH 178/245] Builder is now working! --- src/Exec_Graft.cpp | 112 +++++++++++++++++++++++++-------------------- src/Exec_Graft.h | 2 +- src/cpptrajdepend | 2 +- 3 files changed, 64 insertions(+), 52 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index edfd1ee3ba..84310c0e6b 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -1,9 +1,10 @@ #include "Exec_Graft.h" #include "CpptrajStdio.h" #include "DataSet_Coords.h" -#include "Structure/BuildAtom.h" -#include "Structure/Chirality.h" -#include "Structure/Zmatrix.h" +#include "Structure/Builder.h" +//#incl ude "Structure/BuildAtom.h" +//#incl ude "Structure/Chirality.h" +//#incl ude "Structure/Zmatrix.h" //#incl ude "Structure/Model.h" #include // std::copy @@ -93,42 +94,6 @@ Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) return graft_rms(State, argIn); } -/** Get atoms to bond , from keyword(s). */ -int Exec_Graft::get_bond_atoms(ArgList& argIn, Iarray& tgtBondAtoms, Iarray& srcBondAtoms, - Topology const& tgtTop, Topology const& srcTop) -{ - tgtBondAtoms.clear(); - srcBondAtoms.clear(); - std::string 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 1; - } - AtomMask tb, sb; - if (tb.SetMaskString(bndarg[0])) return 1; - if (sb.SetMaskString(bndarg[1])) return 1; - if (tgtTop.SetupIntegerMask(tb)) return 1; - if (srcTop.SetupIntegerMask(sb)) return 1; - if (tb.Nselected() != 1) { - mprinterr("Error: 'bond' target mask does not select only 1 atom.\n"); - return 1; - } - if (sb.Nselected() != 1) { - mprinterr("Error: 'bond' source mask does not select only 1 atom.\n"); - return 1; - } - 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"); - } - return 0; -} - /** Get COORDS set. */ DataSet_Coords* Exec_Graft::get_crd(ArgList& argIn, DataSetList const& DSL, const char* key, const char* desc, Frame& srcFrame, const char* frameKey) @@ -187,6 +152,23 @@ class ICholder { ICtype ictype_; ///< Type of reset (IJ=all, JK=theta,phi, KL=phi) }; +/** Select bond atom index. */ +int Exec_Graft::select_bond_idx(std::string const& bond0maskstr, Topology const& mol0Top) { + // Select bond atom indices + AtomMask bondmask0; + if (bondmask0.SetMaskString( bond0maskstr )) return -1; + if (mol0Top.SetupIntegerMask( bondmask0 )) return -1; + if (bondmask0.None()) { + mprinterr("Error: Bond mask '%s' selects no atoms in topology '%s'\n", bondmask0.MaskString(), mol0Top.c_str()); + return -1; + } + if (bondmask0.Nselected() > 1) { + mprinterr("Error: Bond mask '%s' selects more than 1 atom in topology '%s'\n", bondmask0.MaskString(), mol0Top.c_str()); + return -1; + } + return bondmask0[0]; +} + /** Graft using internal coordinates to build the final structure. */ Exec::RetType Exec_Graft::graft_ic(CpptrajState& State, ArgList& argIn) const @@ -211,10 +193,20 @@ const return CpptrajState::ERR; } - // Get atoms to bond - Iarray tgtBondAtoms, srcBondAtoms; - if (get_bond_atoms(argIn, tgtBondAtoms, srcBondAtoms, mol0crd->Top(), mol1crd->Top())) + // Get atoms to bond + std::string bondargstr = argIn.GetStringKey("bond"); + if (bondargstr.empty()) { + mprinterr("Error: No 'bond' keyword specified.\n"); + return CpptrajState::ERR; + } + ArgList bondarg( bondargstr, "," ); + if (bondarg.Nargs() != 2) { + mprinterr("Error: Expected 2 comma-separated masks for 'bond' keyword, got %i\n", bondarg.Nargs()); return CpptrajState::ERR; + } + std::string const& tgtbondmask = bondarg[0]; + std::string const& srcbondmask = bondarg[1]; + // Get atoms to keep from source. AtomMask mol1Mask; if (mol1Mask.SetMaskString( argIn.GetStringKey("srcmask") )) @@ -228,10 +220,10 @@ const if (mol0crd->Top().SetupIntegerMask(mol0Mask)) return CpptrajState::ERR; // Update the bond indices for the new topologies - if (UpdateIndices(tgtBondAtoms, mol0Mask, 0)) + /*if (UpdateIndices(tgtBondAtoms, mol0Mask, 0)) return CpptrajState::ERR; if (UpdateIndices(srcBondAtoms, mol1Mask, mol0Mask.Nselected())) - return CpptrajState::ERR; + return CpptrajState::ERR;*/ // Modify the target (mol0) topology, update bond atom indices. bool newMol0Top = false; @@ -254,11 +246,31 @@ const if (mol1Top == 0) return CpptrajState::ERR; // FIXME need to free mol1Top memory } + // Select bond atom indices + int bondat0 = select_bond_idx(tgtbondmask, *mol0Top); + if (bondat0 < 0) { + mprinterr("Error: Could not select target bond atom '%s'\n", tgtbondmask.c_str()); + return CpptrajState::ERR; + } + int bondat1 = select_bond_idx(srcbondmask, *mol1Top); + if (bondat1 < 0) { + mprinterr("Error: Could not select source bond atom '%s'\n", srcbondmask.c_str()); + return CpptrajState::ERR; + } + // Combine topologies. Topology combinedTop; combinedTop.SetDebug( State.Debug() ); combinedTop.SetParmName( outCoords->Meta().Name(), FileName() ); combinedTop.AppendTop( *mol0Top ); + + Frame CombinedFrame = mol0frm; + Builder builder; + if (builder.Combine( combinedTop, CombinedFrame, *mol1Top, mol1frm, bondat0, bondat1 )) { + mprinterr("Error: Fragment combine failed.\n"); + return CpptrajState::ERR; + } +/* combinedTop.AppendTop( *mol1Top ); // Only coords+box for now. @@ -297,7 +309,7 @@ const BuildAtom AtomB; if (combinedTop[atB].Nbonds() > 2) AtomB.SetChirality( DetermineChirality(atB, combinedTop, CombinedFrame, 0) ); - mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(atB).c_str(), chiralStr(AtomB.Chirality())); + mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(atB).c_str(), chiralStr(AtomB.Chirality()));*/ /* for (int at = 0; at < mol0Top->Natom(); at++) if (combinedTop[at].Nbonds() > 2) atomChirality[at].SetChirality( DetermineChirality(at, combinedTop, CombinedFrame, 0) ); @@ -318,7 +330,7 @@ const }*/ // Create bonds - for (unsigned int idx = 0; idx != tgtBondAtoms.size(); idx++) { +/* for (unsigned int idx = 0; idx != tgtBondAtoms.size(); idx++) { mprintf("DEBUG: Bond %i %s to %i %s\n", tgtBondAtoms[idx]+1, combinedTop.AtomMaskName(tgtBondAtoms[idx]).c_str(), srcBondAtoms[idx]+1, combinedTop.AtomMaskName(srcBondAtoms[idx]).c_str()); @@ -336,7 +348,7 @@ const if (combinedTop[atB].Nbonds() > 2) { AtomB.SetNbonds(combinedTop[atB].Nbonds()); DetermineChirality(tors, AtomB.PriorityPtr(), atB, combinedTop, CombinedFrame, 0); - } + }*/ /* for (int at = 0; at < mol0Top->Natom(); at++) { if (combinedTop[at].Nbonds() > 2) { atomChirality[at].SetNbonds(combinedTop[at].Nbonds()); @@ -351,7 +363,7 @@ const }*/ // Add to output COORDS set - if (outCoords->CoordsSetup(combinedTop, outInfo)) return CpptrajState::ERR; // FIXME free molXTop memory + if (outCoords->CoordsSetup(combinedTop, CombinedFrame.CoordsInfo())) return CpptrajState::ERR; // FIXME free molXTop memory // Track atoms as 'known'. Target atoms are residue 0, Source atoms are in residue 1 //Barray atomPositionKnown;/*( combinedTop.Natom(), false ); @@ -367,7 +379,7 @@ const } zmatrix.print(); // DEBUG*/ // Generate Zmatrix only for ICs involving bonded atoms - Zmatrix bondZmatrix; +/* Zmatrix bondZmatrix; bondZmatrix.SetDebug( 2 ); // FIXME if (bondZmatrix.SetupICsAroundBond(atA, atB, CombinedFrame, combinedTop, posKnown, AtomA, AtomB)) { @@ -380,7 +392,7 @@ const if (bondZmatrix.SetToFrame( CombinedFrame, posKnown )) { mprinterr("Error: Conversion from bondZmatrix to Cartesian coords failed.\n"); return CpptrajState::ERR; - } + }*/ /* // Map atom j to ICs to change typedef std::map ICmapType; diff --git a/src/Exec_Graft.h b/src/Exec_Graft.h index e6612a9778..0d92711d7f 100644 --- a/src/Exec_Graft.h +++ b/src/Exec_Graft.h @@ -11,7 +11,7 @@ class Exec_Graft : public Exec { private: typedef std::vector Iarray; - static int get_bond_atoms(ArgList&, Iarray&, Iarray&, Topology const&, Topology const&); + static int select_bond_idx(std::string const&, Topology const&); static Topology* modify_top(Topology const&, AtomMask const&, Frame&); diff --git a/src/cpptrajdepend b/src/cpptrajdepend index baed3536cd..d5f8388c9c 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -303,7 +303,7 @@ Exec_Emin.o : Exec_Emin.cpp Action.h ActionList.h ActionState.h Analysis.h Analy Exec_ExtendedComparison.o : Exec_ExtendedComparison.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_ExtendedComparison.h ExtendedSimilarity.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_Flatten.o : Exec_Flatten.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Flatten.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 ImageOption.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h Structure/BuildAtom.h Structure/Chirality.h Structure/InternalCoords.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h Structure/Builder.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_HmassRepartition.o : Exec_HmassRepartition.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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 EnsembleIn.h EnsembleOutList.h Exec.h Exec_HmassRepartition.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h Trajin_Single.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h From bb520aefcd53ec144caa3091d1a230741be2e7ac Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 24 Oct 2023 11:22:45 -0400 Subject: [PATCH 179/245] Create routine explicitly for setting atom priority --- src/Structure/BuildAtom.h | 6 ++++-- src/Structure/Builder.cpp | 9 ++++----- src/Structure/Chirality.cpp | 11 +++++++++++ src/Structure/Chirality.h | 4 +++- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Structure/BuildAtom.h b/src/Structure/BuildAtom.h index 9471e25c50..1515d2ce9f 100644 --- a/src/Structure/BuildAtom.h +++ b/src/Structure/BuildAtom.h @@ -10,9 +10,11 @@ class BuildAtom { /// Set chirality void SetChirality(ChiralType c) { ctype_ = c; } /// Set size of priority array based on number of bonds - void SetNbonds(int n) { priority_.assign(n, -1); } + //void SetNbonds(int n) { priority_.assign(n, -1); } /// \return Pointer to priority array - int* PriorityPtr() { return &(priority_[0]); } + //int* PriorityPtr() { return &(priority_[0]); } + /// Used to modify the priority array + std::vector& ModifyPriority() { return priority_; } /// \return Atom chirality ChiralType Chirality() const { return ctype_; } diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index 2da945447c..83c1ca4063 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -70,14 +70,13 @@ int Builder::Combine(Topology& frag0Top, Frame& frag0frm, if (combinedTop.DetermineMolecules()) return 1; // Determine priorities - double tors; if (combinedTop[atA].Nbonds() > 2) { - AtomA.SetNbonds(combinedTop[atA].Nbonds()); - DetermineChirality(tors, AtomA.PriorityPtr(), atA, combinedTop, CombinedFrame, 0); + //AtomA.SetNbonds(combinedTop[atA].Nbonds()); + SetPriority(AtomA.ModifyPriority(), atA, combinedTop, CombinedFrame, 0); } if (combinedTop[atB].Nbonds() > 2) { - AtomB.SetNbonds(combinedTop[atB].Nbonds()); - DetermineChirality(tors, AtomB.PriorityPtr(), atB, combinedTop, CombinedFrame, 0); + //AtomB.SetNbonds(combinedTop[atB].Nbonds()); + SetPriority(AtomB.ModifyPriority(), atB, combinedTop, CombinedFrame, 0); } // Generate Zmatrix only for ICs involving bonded atoms diff --git a/src/Structure/Chirality.cpp b/src/Structure/Chirality.cpp index 30b3c15f43..c7da6d0b62 100644 --- a/src/Structure/Chirality.cpp +++ b/src/Structure/Chirality.cpp @@ -176,3 +176,14 @@ Cpptraj::Structure::ChiralType double tors; return DetermineChirality(tors, 0, atnum, topIn, frameIn, debugIn); } + +/** Set priority around a specified atom. */ +Cpptraj::Structure::ChiralType + Cpptraj::Structure::SetPriority(std::vector& priority, + int atnum, Topology const& topIn, + Frame const& frameIn, int debugIn) +{ + priority.resize( topIn[atnum].Nbonds() ); + double tors; + return DetermineChirality(tors, &priority[0], atnum, topIn, frameIn, debugIn); +} diff --git a/src/Structure/Chirality.h b/src/Structure/Chirality.h index e74f6ae764..e895352409 100644 --- a/src/Structure/Chirality.h +++ b/src/Structure/Chirality.h @@ -1,5 +1,6 @@ #ifndef INC_STRUCTURE_CHIRALITY_H #define INC_STRUCTURE_CHIRALITY_H +#include #include "StructureEnum.h" class Topology; class Frame; @@ -10,7 +11,8 @@ namespace Structure { ChiralType DetermineChirality(double&, int*, int, Topology const&, Frame const&, int); /// \return Chirality at specified atom ChiralType DetermineChirality(int, Topology const&, Frame const&, int); - +/// \return Chirality at specified atom, set priority +ChiralType SetPriority(std::vector&, int, Topology const&, Frame const&, int); } } #endif From b37cd30d5e95f7b645e458fc62947ac26d931fdd Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 24 Oct 2023 11:28:18 -0400 Subject: [PATCH 180/245] Get rid of old code --- src/Exec_Graft.cpp | 287 +-------------------------------------------- 1 file changed, 1 insertion(+), 286 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 84310c0e6b..759aba6440 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -2,10 +2,6 @@ #include "CpptrajStdio.h" #include "DataSet_Coords.h" #include "Structure/Builder.h" -//#incl ude "Structure/BuildAtom.h" -//#incl ude "Structure/Chirality.h" -//#incl ude "Structure/Zmatrix.h" -//#incl ude "Structure/Model.h" #include // std::copy using namespace Cpptraj::Structure; @@ -137,21 +133,6 @@ Topology* Exec_Graft::modify_top(Topology const& topIn, AtomMask const& mask, Fr return srcTopPtr; } -/// Hold IC that needs to be reset -class ICholder { - public: - typedef std::vector Uarray; - enum ICtype { IJ = 0, JK, KL, NO_IC_TYPE }; - - ICholder(unsigned int i, ICtype t) : icidxs_(1, i), ictype_(t) {} - void AddIdx(unsigned int i) { icidxs_.push_back(i); } - Uarray const& Idxs() const { return icidxs_; } - ICtype Type() const { return ictype_; } - private: - Uarray icidxs_; ///< Indices of ICs in zmatrix - ICtype ictype_; ///< Type of reset (IJ=all, JK=theta,phi, KL=phi) -}; - /** Select bond atom index. */ int Exec_Graft::select_bond_idx(std::string const& bond0maskstr, Topology const& mol0Top) { // Select bond atom indices @@ -219,11 +200,6 @@ const return CpptrajState::ERR; if (mol0crd->Top().SetupIntegerMask(mol0Mask)) return CpptrajState::ERR; - // Update the bond indices for the new topologies - /*if (UpdateIndices(tgtBondAtoms, mol0Mask, 0)) - return CpptrajState::ERR; - if (UpdateIndices(srcBondAtoms, mol1Mask, mol0Mask.Nselected())) - return CpptrajState::ERR;*/ // Modify the target (mol0) topology, update bond atom indices. bool newMol0Top = false; @@ -270,271 +246,10 @@ const mprinterr("Error: Fragment combine failed.\n"); return CpptrajState::ERR; } -/* - combinedTop.AppendTop( *mol1Top ); - - // Only coords+box for now. - CoordinateInfo outInfo(mol0frm.BoxCrd(), false, false, false); - - // Combine coords. - Frame CombinedFrame; // = outCoords->AllocateFrame(); - CombinedFrame.SetupFrameV( combinedTop.Atoms(), outInfo ); - std::copy(mol0frm.xAddress(), mol0frm.xAddress()+mol0frm.size(), CombinedFrame.xAddress()); - std::copy(mol1frm.xAddress(), mol1frm.xAddress()+mol1frm.size(), CombinedFrame.xAddress()+mol0frm.size()); - // Use target box TODO reset the box? - CombinedFrame.SetBox( mol0frm.BoxCrd() ); - - // Make atA belong to the smaller fragment. atB fragment will be "known" - typedef std::vector Barray; - Barray posKnown( combinedTop.Natom(), false ); - int atA, atB; - // NOTE: mol0 is tgt. mol1 is src. - if (mol0Top->HeavyAtomCount() < mol1Top->HeavyAtomCount()) { - atA = tgtBondAtoms[0]; - atB = srcBondAtoms[0]; - for (int at = mol0Top->Natom(); at != combinedTop.Natom(); at++) - posKnown[at] = true; - } else { - atA = srcBondAtoms[0]; - atB = tgtBondAtoms[0]; - for (int at = 0; at != mol0Top->Natom(); at++) - posKnown[at] = true; - } - - // Get chirality for each atom before we add the bond - BuildAtom AtomA; - if (combinedTop[atA].Nbonds() > 2) - AtomA.SetChirality( DetermineChirality(atA, combinedTop, CombinedFrame, 0) ); - mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(atA).c_str(), chiralStr(AtomA.Chirality())); - BuildAtom AtomB; - if (combinedTop[atB].Nbonds() > 2) - AtomB.SetChirality( DetermineChirality(atB, combinedTop, CombinedFrame, 0) ); - mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(atB).c_str(), chiralStr(AtomB.Chirality()));*/ -/* for (int at = 0; at < mol0Top->Natom(); at++) - if (combinedTop[at].Nbonds() > 2) - atomChirality[at].SetChirality( DetermineChirality(at, combinedTop, CombinedFrame, 0) ); - for (int at = mol0Top->Natom(); at < combinedTop.Natom(); at++) - if (combinedTop[at].Nbonds() > 2) - atomChirality[at].SetChirality( DetermineChirality(at, combinedTop, CombinedFrame, 0) ); - for (int at = 0; at < combinedTop.Natom(); at++) - mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(at).c_str(), chiralStr(atomChirality[at].Chirality()));*/ -/* - std::vector atomChirality; - atomChirality.reserve( combinedTop.Natom() ); - for (int at = 0; at < combinedTop.Natom(); at++) { - if (combinedTop[at].Nbonds() > 2) - atomChirality.push_back( DetermineChirality(at, combinedTop, CombinedFrame, 0) ); - else - atomChirality.push_back( IS_UNKNOWN_CHIRALITY ); - mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(at).c_str(), chiralStr(atomChirality.back())); - }*/ - - // Create bonds -/* for (unsigned int idx = 0; idx != tgtBondAtoms.size(); idx++) { - mprintf("DEBUG: Bond %i %s to %i %s\n", - tgtBondAtoms[idx]+1, combinedTop.AtomMaskName(tgtBondAtoms[idx]).c_str(), - srcBondAtoms[idx]+1, combinedTop.AtomMaskName(srcBondAtoms[idx]).c_str()); - combinedTop.AddBond( tgtBondAtoms[idx], srcBondAtoms[idx] ); - } - // Regenerate the molecule info FIXME should Topology just do this? - if (combinedTop.DetermineMolecules()) return CpptrajState::ERR; - - // Determine priorities - double tors; - if (combinedTop[atA].Nbonds() > 2) { - AtomA.SetNbonds(combinedTop[atA].Nbonds()); - DetermineChirality(tors, AtomA.PriorityPtr(), atA, combinedTop, CombinedFrame, 0); - } - if (combinedTop[atB].Nbonds() > 2) { - AtomB.SetNbonds(combinedTop[atB].Nbonds()); - DetermineChirality(tors, AtomB.PriorityPtr(), atB, combinedTop, CombinedFrame, 0); - }*/ -/* for (int at = 0; at < mol0Top->Natom(); at++) { - if (combinedTop[at].Nbonds() > 2) { - atomChirality[at].SetNbonds(combinedTop[at].Nbonds()); - DetermineChirality(tors, atomChirality[at].PriorityPtr(), at, combinedTop, CombinedFrame, 0); - } - } - for (int at = mol0Top->Natom(); at < combinedTop.Natom(); at++) { - if (combinedTop[at].Nbonds() > 2) { - atomChirality[at].SetNbonds(combinedTop[at].Nbonds()); - DetermineChirality(tors, atomChirality[at].PriorityPtr(), at, combinedTop, CombinedFrame, 0); - } - }*/ - // Add to output COORDS set + // Add topology to output COORDS set if (outCoords->CoordsSetup(combinedTop, CombinedFrame.CoordsInfo())) return CpptrajState::ERR; // FIXME free molXTop memory - // Track atoms as 'known'. Target atoms are residue 0, Source atoms are in residue 1 - //Barray atomPositionKnown;/*( combinedTop.Natom(), false ); - //for (int aidx = combinedTop.Res(1).FirstAtom(); aidx != combinedTop.Res(1).LastAtom(); aidx++) - // atomPositionKnown[aidx] = true;*/ - - // Generate Z matrix FIXME ensure mol 0 is the one we are interested in -/* Zmatrix zmatrix; - zmatrix.SetDebug( 2 ); // FIXME - if (zmatrix.SetFromFrame(CombinedFrame, combinedTop)) { - mprinterr("Error: Zmatrix setup failed.\n"); - return CpptrajState::ERR; - } - zmatrix.print(); // DEBUG*/ - // Generate Zmatrix only for ICs involving bonded atoms -/* Zmatrix bondZmatrix; - - bondZmatrix.SetDebug( 2 ); // FIXME - if (bondZmatrix.SetupICsAroundBond(atA, atB, CombinedFrame, combinedTop, posKnown, AtomA, AtomB)) { - mprinterr("Error: Zmatrix setup for ICs around %s and %s failed.\n", - combinedTop.AtomMaskName(atA).c_str(), - combinedTop.AtomMaskName(atB).c_str()); - return CpptrajState::ERR; - } - bondZmatrix.print(&combinedTop); - if (bondZmatrix.SetToFrame( CombinedFrame, posKnown )) { - mprinterr("Error: Conversion from bondZmatrix to Cartesian coords failed.\n"); - return CpptrajState::ERR; - }*/ -/* - // Map atom j to ICs to change - typedef std::map ICmapType; - typedef std::pair ICpairType; - ICmapType ICsToChange; - // Update ICs corresponding to added bonds - for (unsigned int idx = 0; idx != tgtBondAtoms.size(); idx++) { - int a0 = tgtBondAtoms[idx]; - int a1 = srcBondAtoms[idx]; - // Loop over ICs - for (unsigned int icidx = 0; icidx < zmatrix.N_IC(); icidx++) { - InternalCoords const& oic = zmatrix[icidx]; - ICholder::ICtype ictype = ICholder::NO_IC_TYPE; - if ( (oic.AtI() == a0 && oic.AtJ() == a1) || - (oic.AtI() == a1 && oic.AtJ() == a0) ) - { - if (!atomPositionKnown.empty()) { - mprinterr("Internal Error: i j IC is not first one encountered.\n"); - return CpptrajState::ERR; - } - // Declare atoms in residue with j k l atoms as 'known' - if ( combinedTop[oic.AtJ()].ResNum() != combinedTop[oic.AtK()].ResNum() || - combinedTop[oic.AtJ()].ResNum() != combinedTop[oic.AtL()].ResNum() ) - { - mprinterr("Internal Error: j k l atoms not part of same residue for i j IC.\n"); - return CpptrajState::ERR; - } - int jresnum = combinedTop[oic.AtJ()].ResNum(); - atomPositionKnown.assign( combinedTop.Natom(), false ); - for (int aidx = combinedTop.Res(jresnum).FirstAtom(); aidx != combinedTop.Res(jresnum).LastAtom(); aidx++) - atomPositionKnown[aidx] = true; - // Set dist, theta, phi - mprintf("DEBUG: Found IC for bond %i %i (i j)", a0+1, a1+1); - oic.printIC(combinedTop); - ictype = ICholder::IJ; - double newDist = Atom::GetBondLength( combinedTop[oic.AtI()].Element(), combinedTop[oic.AtJ()].Element() ); - mprintf("DEBUG:\t\tnewDist= %g\n", newDist); - double newTheta = 0; - if (Cpptraj::Structure::Model::AssignTheta(newTheta, oic.AtI(), oic.AtJ(), oic.AtK(), combinedTop, CombinedFrame, atomPositionKnown)) { - mprinterr("Error: theta assignment failed.\n"); - return CpptrajState::ERR; - } - mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); - double newPhi = 0; - if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown, atomChirality)) { - mprinterr("Error: phi assignment failed.\n"); - return CpptrajState::ERR; - } - mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); - // TODO be smarter about these values - InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), newDist, newTheta*Constants::RADDEG, newPhi*Constants::RADDEG ); - zmatrix.SetIC( icidx, newIc ); - // Update frame - //Vec3 posI = Zmatrix::AtomIposition( newIc, CombinedFrame ); - //CombinedFrame.SetXYZ( newIc.AtI(), posI ); - //atomPositionKnown[newIc.AtI()] = true; - } else if ( (oic.AtJ() == a0 && oic.AtK() == a1) || - (oic.AtJ() == a1 && oic.AtK() == a0) ) - { - // Set theta, phi - mprintf("DEBUG: Found IC for bond %i %i (j k)", a0+1, a1+1); - oic.printIC(combinedTop); - ictype = ICholder::JK; - double newTheta = 0; - if (Cpptraj::Structure::Model::AssignTheta(newTheta, oic.AtI(), oic.AtJ(), oic.AtK(), combinedTop, CombinedFrame, atomPositionKnown)) { - mprinterr("Error: theta assignment failed.\n"); - return CpptrajState::ERR; - } - mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); - double newPhi = 0; - if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown, atomChirality)) { - mprinterr("Error: phi assignment failed.\n"); - return CpptrajState::ERR; - } - mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); // FIXME Internal coords should be radians - InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), oic.Dist(), newTheta*Constants::RADDEG, newPhi*Constants::RADDEG ); - zmatrix.SetIC( icidx, newIc ); - // Update frame - //Vec3 posI = Zmatrix::AtomIposition( newIc, CombinedFrame ); - //CombinedFrame.SetXYZ( newIc.AtI(), posI ); - //atomPositionKnown[newIc.AtI()] = true; - } else if ( (oic.AtK() == a0 && oic.AtL() == a1) || - (oic.AtK() == a1 && oic.AtL() == a0) ) - { - // Set phi - mprintf("DEBUG: Found IC for bond %i %i (k l)", a0+1, a1+1); - oic.printIC(combinedTop); - ictype = ICholder::KL; - double newPhi = 0; - if (Cpptraj::Structure::Model::AssignPhi(newPhi, oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), combinedTop, CombinedFrame, atomPositionKnown, atomChirality)) { - mprinterr("Error: phi assignment failed.\n"); - return CpptrajState::ERR; - } - mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); - InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), oic.Dist(), oic.Theta(), newPhi*Constants::RADDEG ); - zmatrix.SetIC( icidx, newIc ); - // Update frame - //Vec3 posI = Zmatrix::AtomIposition( newIc, CombinedFrame ); - //CombinedFrame.SetXYZ( newIc.AtI(), posI ); - //atomPositionKnown[newIc.AtI()] = true; - } - if (ictype != ICholder::NO_IC_TYPE) { - ICmapType::iterator it = ICsToChange.lower_bound( oic.AtJ() ); - if (it == ICsToChange.end() || it->first != oic.AtJ()) - ICsToChange.insert( ICpairType(oic.AtJ(), ICholder(icidx, ictype)) ); - else - it->second.AddIdx( icidx ); - } - } // END loop over ICs - } // END loop over bonds - // Loop over ICs to change - for (ICmapType::const_iterator it = ICsToChange.begin(); it != ICsToChange.end(); ++it) { - mprintf("DEBUG: IC atomj= %i :\n", it->first+1); - // FIXME. Probably going to have to fix this if atom j is a chiral center - //double phi = -180.0; - //double interval = 360.0 / it->second.Idxs().size(); - for (ICholder::Uarray::const_iterator jt = it->second.Idxs().begin(); - jt != it->second.Idxs().end(); ++jt) - { - InternalCoords const& oic = zmatrix[*jt]; - mprintf("DEBUG:\t\t"); - oic.printIC(combinedTop); - *double dist = oic.Dist(); - double theta = oic.Theta(); - double phi = oic.Phi(); - if (it->second.Type() == ICholder::IJ) { - dist = Atom::GetBondLength( combinedTop[oic.AtI()].Element(), combinedTop[oic.AtJ()].Element() ); - theta = 120.0; - phi = 180.0; - } //else if (it->second.Type() == ICholder::JK) { - //theta = 120.0; - //} - InternalCoords newIc( oic.AtI(), oic.AtJ(), oic.AtK(), oic.AtL(), dist, theta, phi ); - zmatrix.SetIC( *jt, newIc ); - //phi += interval;* - } - } - if (zmatrix.SetToFrame( CombinedFrame )) { - mprinterr("Error: Conversion from Zmatrix to Cartesian coords failed.\n"); - return CpptrajState::ERR; - }*/ - // Add frame to the output data set outCoords->AddFrame( CombinedFrame ); From d25be0c2a4921ec31c00d2c4285432168570bd20 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 24 Oct 2023 15:31:12 -0400 Subject: [PATCH 181/245] Fix memory leak --- src/Structure/Builder.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index 83c1ca4063..1b1ebcbce8 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -52,6 +52,7 @@ int Builder::Combine(Topology& frag0Top, Frame& frag0frm, std::copy( tmpcrd0, tmpcrd0+natom0*3, frag0frm.xAddress() ); std::copy( frag1frm.xAddress(), frag1frm.xAddress()+frag1frm.size(), frag0frm.xAddress()+natom0*3 ); Frame& CombinedFrame = frag0frm; + delete[] tmpcrd0; // Get the chirality around each atom before the bond is added. BuildAtom AtomA; From 6e7bb07790dc4bcac9c7d068413286abbef8c7ba Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 24 Oct 2023 15:37:56 -0400 Subject: [PATCH 182/245] Refactor graft so rms fit and IC have a common base to work from --- src/Exec_Graft.cpp | 498 +++++++++++++++++++-------------------------- src/Exec_Graft.h | 22 +- 2 files changed, 220 insertions(+), 300 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 759aba6440..a58fe2fe5d 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -5,41 +5,19 @@ #include // std::copy using namespace Cpptraj::Structure; -// Exec_Graft::Help() -void Exec_Graft::Help() const -{ - mprintf("\tsrc [srcframe <#>] [srcfitmask ] [srcmask ]\n" - "\t[srccharge \n" - "\ttgt [tgtframe <#>] [tgtfitmask ] [tgtmask ]\n" - "\t[tgtcharge \n" - "\tname [bond , ...]\n" - " Graft coordinates from source to coordinates in target.\n"); -} -/** 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) - { - // 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; +/** CONSTRUCTOR */ +Exec_Graft::Exec_Graft() : + Exec(COORDS), + debug_(0), + newMol0Top_(0), + newMol1Top_(0) +{} + +/** DESTRUCTOR */ +Exec_Graft::~Exec_Graft() { + if (newMol0Top_ != 0) delete newMol0Top_; + if (newMol1Top_ != 0) delete newMol1Top_; } /** Redistribute charge on atoms in topology to match a target charge. */ @@ -81,15 +59,6 @@ int Exec_Graft::redistribute_charge(Topology& topIn, double charge) { return 0; } -// Exec_Graft::Execute() -Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) -{ - if (argIn.hasKey("ic")) - return graft_ic(State,argIn); - else - return graft_rms(State, argIn); -} - /** Get COORDS set. */ DataSet_Coords* Exec_Graft::get_crd(ArgList& argIn, DataSetList const& DSL, const char* key, const char* desc, Frame& srcFrame, const char* frameKey) @@ -109,8 +78,7 @@ DataSet_Coords* Exec_Graft::get_crd(ArgList& argIn, DataSetList const& DSL, return srcCoords; } -/** Modify given topology and frame by specified mask. Ensure the bonding - * atom will be present in the stripped topology. +/** Modify given topology and frame by specified mask. * \return topology modified by mask. */ Topology* Exec_Graft::modify_top(Topology const& topIn, AtomMask const& mask, Frame& srcFrame) @@ -150,18 +118,32 @@ int Exec_Graft::select_bond_idx(std::string const& bond0maskstr, Topology const& return bondmask0[0]; } -/** Graft using internal coordinates to build the final structure. */ -Exec::RetType Exec_Graft::graft_ic(CpptrajState& State, ArgList& argIn) -const +// Exec_Graft::Help() +void Exec_Graft::Help() const +{ + mprintf("\tsrc [srcframe <#>] [srcfitmask ] [srcmask ]\n" + "\t[srccharge \n" + "\ttgt [tgtframe <#>] [tgtfitmask ] [tgtmask ]\n" + "\t[tgtcharge \n" + "\tname [bond , ...]\n" + " Graft coordinates from source to coordinates in target.\n"); +} + +// Exec_Graft::Execute() +Exec::RetType Exec_Graft::Execute(CpptrajState& State, ArgList& argIn) { - // Source (fragment) + debug_ = State.Debug(); + bool use_ic = argIn.hasKey("ic"); + + // Source (1, fragment) Frame mol1frm; DataSet_Coords* mol1crd = get_crd(argIn, State.DSL(), "src", "Source COORDS", mol1frm, "srcframe"); if (mol1crd == 0) return CpptrajState::ERR; - // Target (base) + // Target (0, base) Frame mol0frm; DataSet_Coords* mol0crd = get_crd(argIn, State.DSL(), "tgt", "Target COORDS", mol0frm, "tgtframe"); if (mol0crd == 0) return CpptrajState::ERR; + // Create output coords std::string kw = argIn.GetStringKey("name"); if (kw.empty()) { @@ -175,18 +157,19 @@ const } // Get atoms to bond + Sarray bond0ArgStrings; + Sarray bond1ArgStrings; std::string bondargstr = argIn.GetStringKey("bond"); - if (bondargstr.empty()) { - mprinterr("Error: No 'bond' keyword specified.\n"); - return CpptrajState::ERR; - } - ArgList bondarg( bondargstr, "," ); - if (bondarg.Nargs() != 2) { - mprinterr("Error: Expected 2 comma-separated masks for 'bond' keyword, got %i\n", bondarg.Nargs()); - return CpptrajState::ERR; + while (!bondargstr.empty()) { + ArgList bondarg( bondargstr, "," ); + if (bondarg.Nargs() != 2) { + mprinterr("Error: Expected 2 comma-separated masks for 'bond' keyword, got %i\n", bondarg.Nargs()); + return CpptrajState::ERR; + } + bond0ArgStrings.push_back(bondarg[0]); + bond1ArgStrings.push_back(bondarg[1]); + bondargstr = argIn.GetStringKey("bond"); } - std::string const& tgtbondmask = bondarg[0]; - std::string const& srcbondmask = bondarg[1]; // Get atoms to keep from source. AtomMask mol1Mask; @@ -201,195 +184,56 @@ const if (mol0crd->Top().SetupIntegerMask(mol0Mask)) return CpptrajState::ERR; - // Modify the target (mol0) topology, update bond atom indices. - bool newMol0Top = false; - Topology* mol0Top = 0; - if (mol0Mask.Nselected() == mol0crd->Top().Natom()) { - mol0Top = mol0crd->TopPtr(); - } else { - newMol0Top = true; - mol0Top = modify_top(mol0crd->Top(), mol0Mask, mol0frm); - if (mol0Top == 0) return CpptrajState::ERR; // FIXME need to free mol0Top memory - } - // Modify the source (mol1) topology, update bond atom indices. - bool newMol1Top = false; - Topology* mol1Top = 0; - if (mol1Mask.Nselected() == mol1crd->Top().Natom()) { - mol1Top = mol1crd->TopPtr(); - } else { - newMol1Top = true; - mol1Top = modify_top(mol1crd->Top(), mol1Mask, mol1frm); - if (mol1Top == 0) return CpptrajState::ERR; // FIXME need to free mol1Top memory - } - - // Select bond atom indices - int bondat0 = select_bond_idx(tgtbondmask, *mol0Top); - if (bondat0 < 0) { - mprinterr("Error: Could not select target bond atom '%s'\n", tgtbondmask.c_str()); - return CpptrajState::ERR; - } - int bondat1 = select_bond_idx(srcbondmask, *mol1Top); - if (bondat1 < 0) { - mprinterr("Error: Could not select source bond atom '%s'\n", srcbondmask.c_str()); - return CpptrajState::ERR; - } - - // Combine topologies. - Topology combinedTop; - combinedTop.SetDebug( State.Debug() ); - combinedTop.SetParmName( outCoords->Meta().Name(), FileName() ); - combinedTop.AppendTop( *mol0Top ); - - Frame CombinedFrame = mol0frm; - Builder builder; - if (builder.Combine( combinedTop, CombinedFrame, *mol1Top, mol1frm, bondat0, bondat1 )) { - mprinterr("Error: Fragment combine failed.\n"); - return CpptrajState::ERR; - } - - // Add topology to output COORDS set - if (outCoords->CoordsSetup(combinedTop, CombinedFrame.CoordsInfo())) return CpptrajState::ERR; // FIXME free molXTop memory - - // Add frame to the output data set - outCoords->AddFrame( CombinedFrame ); - - if (newMol0Top) delete mol0Top; - if (newMol1Top) delete mol1Top; - - return CpptrajState::OK; -} - -/** Graft with RMS-fitting. */ -Exec::RetType Exec_Graft::graft_rms(CpptrajState& State, ArgList& argIn) -const -{ - // 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; - } - Frame srcFrame = srcCoords->AllocateFrame(); - srcCoords->GetFrame(argIn.getKeyInt("srcframe", 1)-1, srcFrame); + // Determine if charges will be redistributed bool hasSrcCharge = argIn.Contains("srccharge"); double srccharge = argIn.getKeyDouble("srccharge", 0); - // 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; - } - Frame tgtFrame = tgtCoords->AllocateFrame(); - tgtCoords->GetFrame(argIn.getKeyInt("tgtframe", 1)-1, tgtFrame); bool hasTgtCharge = argIn.Contains("tgtcharge"); double tgtcharge = argIn.getKeyDouble("tgtcharge", 0); - // 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") )) - 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 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"); - } - // 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("\tUpdated bond indices:\n"); - for (unsigned int ii = 0; ii != tgtBondAtoms.size(); 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; - 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; + if (!use_ic) { // TODO allow with IC? + std::string srcfitstr = argIn.GetStringKey("srcfitmask"); + std::string tgtfitstr = argIn.GetStringKey("tgtfitmask"); + 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 (mol1crd->Top().SetupIntegerMask(srcFitMask)) + return CpptrajState::ERR; + if (mol0crd->Top().SetupIntegerMask(tgtFitMask)) + return CpptrajState::ERR; + } } - + // Info - mprintf("\tSource coords : %s\n", srcCoords->legend()); - mprintf("\tTarget coords : %s\n", tgtCoords->legend()); + mprintf("\tSource coords : %s\n", mol1crd->legend()); + mprintf("\tTarget coords : %s\n", mol0crd->legend()); mprintf("\tOutput coords : %s\n", outCoords->legend()); mprintf("\tSource mask :"); - srcMask.BriefMaskInfo(); + mol1Mask.BriefMaskInfo(); mprintf("\n"); mprintf("\tTarget mask :"); - tgtMask.BriefMaskInfo(); + mol0Mask.BriefMaskInfo(); mprintf("\n"); - if (hasSrcCharge && (srcMask.Nselected() != srcCoords->Top().Natom())) + if (!bond0ArgStrings.empty()) { + mprintf("\tBonds will be created between:\n"); + for (unsigned int idx = 0; idx != bond0ArgStrings.size(); idx++) + mprintf("\t\tAtoms %s and %s\n", bond0ArgStrings[idx].c_str(), bond1ArgStrings[idx].c_str()); + } + if (hasSrcCharge && (mol1Mask.Nselected() != mol1crd->Top().Natom())) mprintf("\tAdjusting source charge to %g\n", srccharge); - if (hasTgtCharge && (tgtMask.Nselected() != tgtCoords->Top().Natom())) + if (hasTgtCharge && (mol0Mask.Nselected() != mol0crd->Top().Natom())) mprintf("\tAdjusting target charge to %g\n", tgtcharge); if (doRmsFit) { mprintf( "\tSource fit mask :"); @@ -403,93 +247,161 @@ const } // Source gets RMS fit to target (reference) Frame srcFitFrame; - srcFitFrame.SetupFrameFromMask(srcFitMask, srcCoords->Top().Atoms()); - srcFitFrame.SetCoordinates(srcFrame, srcFitMask); + srcFitFrame.SetupFrameFromMask(srcFitMask, mol1crd->Top().Atoms()); + srcFitFrame.SetCoordinates(mol1frm, srcFitMask); Frame tgtFitFrame; - tgtFitFrame.SetupFrameFromMask(tgtFitMask, tgtCoords->Top().Atoms()); - tgtFitFrame.SetCoordinates(tgtFrame, tgtFitMask); + tgtFitFrame.SetupFrameFromMask(tgtFitMask, mol0crd->Top().Atoms()); + tgtFitFrame.SetCoordinates(mol0frm, 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 ); + mol1frm.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; + // Modify the target (mol0) topology + if (newMol0Top_ != 0) delete newMol0Top_; + newMol0Top_ = 0; + Topology* mol0Top = 0; + if (mol0Mask.Nselected() == mol0crd->Top().Natom()) { + mol0Top = mol0crd->TopPtr(); + } else { + mol0Top = modify_top(mol0crd->Top(), mol0Mask, mol0frm); + newMol0Top_ = mol0Top; + if (mol0Top == 0) return CpptrajState::ERR; + // Modify charges if needed + if (hasTgtCharge) { + if (redistribute_charge(*mol0Top, tgtcharge)) { + mprinterr("Error: Redistribute tgt charge failed.\n"); + return CpptrajState::ERR; + } } - srcFrmPtr = new Frame(); - srcFrmPtr->SetupFrameV(srcTopPtr->Atoms(), srcCoords->CoordsInfo()); - srcFrmPtr->SetFrame(srcFrame, srcMask); + } + // Modify the source (mol1) topology + if (newMol1Top_ != 0) delete newMol1Top_; + newMol1Top_ = 0; + Topology* mol1Top = 0; + if (mol1Mask.Nselected() == mol1crd->Top().Natom()) { + mol1Top = mol1crd->TopPtr(); + } else { + mol1Top = modify_top(mol1crd->Top(), mol1Mask, mol1frm); + newMol1Top_ = mol1Top; + if (mol1Top == 0) return CpptrajState::ERR; // Modify charges if needed if (hasSrcCharge) { - if (redistribute_charge(*srcTopPtr, srccharge)) { + if (redistribute_charge(*mol1Top, srccharge)) { mprinterr("Error: Redistribute src charge failed.\n"); return CpptrajState::ERR; } } } - // 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"); + if (use_ic) { + if (graft_ic( outCoords, *mol0Top, mol0frm, *mol1Top, mol1frm, bond0ArgStrings, bond1ArgStrings)) return CpptrajState::ERR; - } - tgtFrmPtr = new Frame(); - tgtFrmPtr->SetupFrameV(tgtTopPtr->Atoms(), tgtCoords->CoordsInfo()); - tgtFrmPtr->SetFrame(tgtFrame, tgtMask); - // Modify charges if needed - if (hasTgtCharge) { - if (redistribute_charge(*tgtTopPtr, tgtcharge)) { - mprinterr("Error: Redistribute tgt charge failed.\n"); - return CpptrajState::ERR; - } - } + } else { + if (graft_rms( outCoords, *mol0Top, mol0frm, *mol1Top, mol1frm, bond0ArgStrings, bond1ArgStrings)) + return CpptrajState::ERR; + } + return CpptrajState::OK; +} + + +/** Graft using internal coordinates to build the final structure. */ +int Exec_Graft::graft_ic(DataSet_Coords* outCoords, + Topology const& mol0Top, Frame const& mol0frm, + Topology const& mol1Top, Frame const& mol1frm, + Sarray const& bond0Atoms, Sarray const& bond1Atoms) +const +{ + // Get bonding atom masks + if (bond0Atoms.size() != 1 || bond1Atoms.size() != 1) { + mprinterr("Error: Graft with internal coordinates only works with 1 bond.\n"); + return 1; + } + std::string const& tgtbondmask = bond0Atoms[0]; + std::string const& srcbondmask = bond1Atoms[0]; + + // Select bond atom indices + int bondat0 = select_bond_idx(tgtbondmask, mol0Top); + if (bondat0 < 0) { + mprinterr("Error: Could not select target bond atom '%s'\n", tgtbondmask.c_str()); + return 1; + } + int bondat1 = select_bond_idx(srcbondmask, mol1Top); + if (bondat1 < 0) { + mprinterr("Error: Could not select source bond atom '%s'\n", srcbondmask.c_str()); + return 1; + } + + // Combine topologies. + Topology combinedTop; + combinedTop.SetDebug( debug_ ); + combinedTop.SetParmName( outCoords->Meta().Name(), FileName() ); + combinedTop.AppendTop( mol0Top ); + combinedTop.SetParmBox( mol0frm.BoxCrd() ); + combinedTop.Brief("Grafted parm:"); + + Frame CombinedFrame = mol0frm; + Builder builder; + if (builder.Combine( combinedTop, CombinedFrame, mol1Top, mol1frm, bondat0, bondat1 )) { + mprinterr("Error: Fragment combine failed.\n"); + return 1; } + // Add topology to output COORDS set + if (outCoords->CoordsSetup(combinedTop, CombinedFrame.CoordsInfo())) return 1; + + // Add frame to the output data set + outCoords->AddFrame( CombinedFrame ); + + return 0; +} + +/** Graft with RMS-fitting. */ +int Exec_Graft::graft_rms(DataSet_Coords* outCoords, + Topology const& mol0Top, Frame const& mol0frm, + Topology const& mol1Top, Frame const& mol1frm, + Sarray const& bond0Atoms, Sarray const& bond1Atoms) +const +{ // Combine topologies. Use target box info. Topology combinedTop; - combinedTop.SetDebug( State.Debug() ); + combinedTop.SetDebug( debug_ ); combinedTop.SetParmName( outCoords->Meta().Name(), FileName() ); - combinedTop.AppendTop( *tgtTopPtr ); - combinedTop.AppendTop( *srcTopPtr ); + combinedTop.AppendTop( mol0Top ); + combinedTop.AppendTop( mol1Top ); + // Add any bonds - for (unsigned int ii = 0; ii != tgtBondAtoms.size(); ii++) - combinedTop.AddBond( tgtBondAtoms[ii], srcBondAtoms[ii] ); + for (unsigned int ii = 0; ii != bond0Atoms.size(); ii++) { + int bondat0 = select_bond_idx(bond0Atoms[ii], mol0Top); + if (bondat0 < 0) { + mprinterr("Error: Could not select target bond atom '%s'\n", bond0Atoms[ii].c_str()); + return 1; + } + int bondat1 = select_bond_idx(bond1Atoms[ii], mol1Top); + if (bondat1 < 0) { + mprinterr("Error: Could not select source bond atom '%s'\n", bond1Atoms[ii].c_str()); + return 1; + } + combinedTop.AddBond( bondat0, bondat1 + mol0Top.Natom() ); + } // Regenerate the molecule info FIXME should Topology just do this? - if (combinedTop.DetermineMolecules()) return CpptrajState::ERR; - combinedTop.SetParmBox( tgtFrmPtr->BoxCrd() ); + if (combinedTop.DetermineMolecules()) return 1; + combinedTop.SetParmBox( mol0frm.BoxCrd() ); combinedTop.Brief("Grafted parm:"); - - // Output coords. // Only coords+box for now. - CoordinateInfo outInfo(tgtFrmPtr->BoxCrd(), false, false, false); - if (outCoords->CoordsSetup(combinedTop, outInfo)) return CpptrajState::ERR; + CoordinateInfo outInfo(mol0frm.BoxCrd(), false, false, false); + if (outCoords->CoordsSetup(combinedTop, outInfo)) return 1; + + // Combine coords. Frame CombinedFrame = outCoords->AllocateFrame(); - 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 ); + std::copy(mol0frm.xAddress(), mol0frm.xAddress()+mol0frm.size(), CombinedFrame.xAddress()); + std::copy(mol1frm.xAddress(), mol1frm.xAddress()+mol1frm.size(), CombinedFrame.xAddress()+mol0frm.size()); + CombinedFrame.SetBox( mol0frm.BoxCrd() ); - // Free memory if needed - if (srcTopPtr != srcCoords->TopPtr()) { - delete srcTopPtr; - delete srcFrmPtr; - } - if (tgtTopPtr != tgtCoords->TopPtr()) { - delete tgtTopPtr; - delete tgtFrmPtr; - } + // Add to topology + outCoords->AddFrame( CombinedFrame ); - return CpptrajState::OK; + return 0; } diff --git a/src/Exec_Graft.h b/src/Exec_Graft.h index 0d92711d7f..1df79f08b3 100644 --- a/src/Exec_Graft.h +++ b/src/Exec_Graft.h @@ -4,21 +4,29 @@ /// Graft part of one COORDS to another COORDS class Exec_Graft : public Exec { public: - Exec_Graft() : Exec(COORDS) {} + Exec_Graft(); + ~Exec_Graft(); void Help() const; DispatchObject* Alloc() const { return (DispatchObject*)new Exec_Graft(); } RetType Execute(CpptrajState&, ArgList&); private: typedef std::vector Iarray; - + typedef std::vector Sarray; + /// Select bond index from expression in given topology static int select_bond_idx(std::string const&, Topology const&); - + /// Redistribute charge in given topology to match given target + static int redistribute_charge(Topology&, double); + /// Modify topology and frame according to mask expression static Topology* modify_top(Topology const&, AtomMask const&, Frame&); - + /// Get COORDS data set static DataSet_Coords* get_crd(ArgList&, DataSetList const&, const char*, const char*, Frame&, const char*); + /// Graft using internal coordinates + int graft_ic(DataSet_Coords*, Topology const&, Frame const&, Topology const&, Frame const&, Sarray const&, Sarray const&) const; + /// Graft assuming structures have been rms fit + int graft_rms(DataSet_Coords*, Topology const&, Frame const&, Topology const&, Frame const&, Sarray const&, Sarray const&) const; - RetType graft_ic(CpptrajState&, ArgList&) const; - RetType graft_rms(CpptrajState&, ArgList&) const; - static int redistribute_charge(Topology&, double); + int debug_; + Topology* newMol0Top_; ///< Hold target topology if modified. + Topology* newMol1Top_; ///< Hold source topology if modified. }; #endif From 69184adeac1f53c1d8542dad7b3d72ec9e4ff245 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 24 Oct 2023 19:38:45 -0400 Subject: [PATCH 183/245] For debug, Print nbonds and element name for each atom when modeling theta --- src/Structure/Model.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index 3ca4b50b21..aef3576311 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -16,7 +16,9 @@ int Cpptraj::Structure::Model::AssignTheta(double& theta, int ai, int aj, int ak enum HybridizationType { SP = 0, SP2, SP3, UNKNOWN_HYBRIDIZATION }; Atom const& AJ = topIn[aj]; - mprintf("DEBUG:\t\tNbonds: %i\n", AJ.Nbonds()); + mprintf("DEBUG:\t\tI %s Nbonds: %i\n", topIn[ai].ElementName(), topIn[ai].Nbonds()); + mprintf("DEBUG:\t\tJ %s Nbonds: %i\n", AJ.ElementName(), AJ.Nbonds()); + mprintf("DEBUG:\t\tK %s Nbonds: %i\n", topIn[ak].ElementName(), topIn[ak].Nbonds()); // Sanity check if (AJ.Nbonds() < 2) { mprinterr("Internal Error: AssignTheta() called for atom J %s with fewer than 2 bonds.\n", topIn.AtomMaskName(aj).c_str()); From 9d51edd0c22f0588826998e524ccf42b9dc3773c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 25 Oct 2023 09:41:49 -0400 Subject: [PATCH 184/245] Start amber off file reader --- src/DataFile.cpp | 4 ++ src/DataFile.h | 2 +- src/DataIO_AmberLib.cpp | 87 +++++++++++++++++++++++++++++++++++++++++ src/DataIO_AmberLib.h | 17 ++++++++ src/cpptrajdepend | 3 +- src/cpptrajfiles | 1 + 6 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 src/DataIO_AmberLib.cpp create mode 100644 src/DataIO_AmberLib.h diff --git a/src/DataFile.cpp b/src/DataFile.cpp index 5fd034d5f9..b215286b34 100644 --- a/src/DataFile.cpp +++ b/src/DataFile.cpp @@ -33,6 +33,7 @@ #include "DataIO_AmberEne.h" #include "DataIO_Numpy.h" #include "DataIO_AmberPrep.h" +#include "DataIO_AmberLib.h" // CONSTRUCTOR DataFile::DataFile() : @@ -87,6 +88,7 @@ const FileTypes::AllocToken DataFile::DF_AllocArray[] = { { "Amber Energy File", 0, 0, DataIO_AmberEne::Alloc}, { "Numpy array", 0, 0, DataIO_Numpy::Alloc}, { "Amber Prep File", DataIO_AmberPrep::ReadHelp, 0, DataIO_AmberPrep::Alloc}, + { "Amber OFF File", 0, 0, DataIO_AmberLib::Alloc}, { "Unknown Data file", 0, 0, 0 } }; @@ -114,6 +116,8 @@ const FileTypes::KeyToken DataFile::DF_KeyArray[] = { { AMBERENE, "amberene", ".ene" }, { NUMPY, "numpy", ".npy" }, { AMBERPREP, "prepin", ".prepin" }, + { AMBERLIB, "off", ".off" }, + { AMBERLIB, "off", ".lib" }, { UNKNOWN_DATA, 0, 0 } }; diff --git a/src/DataFile.h b/src/DataFile.h index 378cf552ff..f5f6b0b92a 100644 --- a/src/DataFile.h +++ b/src/DataFile.h @@ -18,7 +18,7 @@ class DataFile { DATAFILE=0, XMGRACE, GNUPLOT, XPLOR, OPENDX, REMLOG, MDOUT, EVECS, VECTRAJ, XVG, CCP4, CHARMMREPD, CHARMMFASTREP, CHARMMOUT, CPOUT, CHARMMRTFPRM, CMATRIX_BINARY, CMATRIX_NETCDF, PEAKS, - NETCDFDATA, AMBERENE, NUMPY, AMBERPREP, + NETCDFDATA, AMBERENE, NUMPY, AMBERPREP, AMBERLIB, UNKNOWN_DATA }; DataFile(); diff --git a/src/DataIO_AmberLib.cpp b/src/DataIO_AmberLib.cpp new file mode 100644 index 0000000000..063eebc25c --- /dev/null +++ b/src/DataIO_AmberLib.cpp @@ -0,0 +1,87 @@ +#include "DataIO_AmberLib.h" +#include "CpptrajStdio.h" +#include "BufferedLine.h" + +/// CONSTRUCTOR +DataIO_AmberLib::DataIO_AmberLib() +{ + +} + +// DataIO_AmberLib::ID_DataFormat() +bool DataIO_AmberLib::ID_DataFormat(CpptrajFile& infile) +{ + if (infile.OpenFile()) return false; + std::string line = infile.GetLine(); + infile.CloseFile(); + bool isLib = (line == "!!index array str"); + + return isLib; +} + +// DataIO_AmberLib::ReadHelp() +void DataIO_AmberLib::ReadHelp() +{ + +} + +// DataIO_AmberLib::processReadArgs() +int DataIO_AmberLib::processReadArgs(ArgList& argIn) +{ + + return 0; +} + +// DataIO_AmberLib::ReadData() +int DataIO_AmberLib::ReadData(FileName const& fname, DataSetList& dsl, std::string const& dsname) +{ + BufferedLine infile; + if (infile.OpenFileRead( fname )) { + mprinterr("Error: Could not open Amber lib file '%s' for reading.\n", fname.full()); + return 1; + } + + // Read first line + std::string line = infile.GetLine(); + if (line != "!!index array str") { + mprinterr("Error: Expected first line to be '!!index array str', got '%s'\n", line.c_str()); + return 1; + } + typedef std::vector Sarray; + Sarray UnitNames; + // Read units + line = infile.GetLine(); + while (!line.empty() && line[0] != '!') + { + UnitNames.push_back( line ); + line = infile.GetLine(); + } + mprintf("DEBUG: Units:"); + for (Sarray::const_iterator it = UnitNames.begin(); it != UnitNames.end(); ++it) + mprintf(" %s", it->c_str()); + mprintf("\n"); + + // Now should be at first unit + + return 0; +} + +// DataIO_AmberLib::WriteHelp() +void DataIO_AmberLib::WriteHelp() +{ + +} + +// DataIO_AmberLib::processWriteArgs() +int DataIO_AmberLib::processWriteArgs(ArgList& argIn) +{ + + return 0; +} + +// DataIO_AmberLib::WriteData() +int DataIO_AmberLib::WriteData(FileName const& fname, DataSetList const& dsl) +{ + + return 1; +} diff --git a/src/DataIO_AmberLib.h b/src/DataIO_AmberLib.h new file mode 100644 index 0000000000..decf20c604 --- /dev/null +++ b/src/DataIO_AmberLib.h @@ -0,0 +1,17 @@ +#ifndef INC_DATAIO_AMBERLIB_H +#define INC_DATAIO_AMBERLIB_H +#include "DataIO.h" +/// +class DataIO_AmberLib : public DataIO { + public: + DataIO_AmberLib(); + static void ReadHelp(); + static void WriteHelp(); + static BaseIOtype* Alloc() { return (BaseIOtype*)new DataIO_AmberLib(); } + int processReadArgs(ArgList&); + int ReadData(FileName const&, DataSetList&, std::string const&); + int processWriteArgs(ArgList&); + int WriteData(FileName const&, DataSetList const&); + bool ID_DataFormat(CpptrajFile&); +}; +#endif diff --git a/src/cpptrajdepend b/src/cpptrajdepend index d5f8388c9c..09a47d122a 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -198,11 +198,12 @@ CpptrajFile.o : CpptrajFile.cpp CpptrajFile.h CpptrajStdio.h FileIO.h FileIO_Bzi CpptrajState.o : CpptrajState.cpp Action.h ActionList.h ActionState.h Action_CreateCrd.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h CompactFrameArray.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_REF.h DataSet_Coords_TRJ.h DataSet_Topology.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleNavigator.h EnsembleOutList.h FileIO.h FileName.h FileTypes.h Frame.h FrameArray.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ProgressBar.h Random.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajFrameIndex.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h CpptrajStdio.o : CpptrajStdio.cpp Parallel.h CurveFit.o : CurveFit.cpp CurveFit.h -DataFile.o : DataFile.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Cluster/Cframes.h Cluster/Cmatrix_NC.h Constants.h CoordinateInfo.h Cph.h CpptrajFile.h CpptrajStdio.h DataFile.h DataIO.h DataIO_AmberEne.h DataIO_AmberPrep.h DataIO_CCP4.h DataIO_CharmmFastRep.h DataIO_CharmmOutput.h DataIO_CharmmRepLog.h DataIO_CharmmRtfPrm.h DataIO_Cmatrix_Binary.h DataIO_Cmatrix_NC.h DataIO_Cpout.h DataIO_Evecs.h DataIO_Gnuplot.h DataIO_Grace.h DataIO_Mdout.h DataIO_NetCDF.h DataIO_Numpy.h DataIO_OpenDx.h DataIO_Peaks.h DataIO_RemLog.h DataIO_Std.h DataIO_VecTraj.h DataIO_XVG.h DataIO_Xplor.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_PairwiseCache.h DataSet_PairwiseCache_MEM.h DataSet_RemLog.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.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 Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajectoryFile.h TypeNameHolder.h Unit.h Vec3.h +DataFile.o : DataFile.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Cluster/Cframes.h Cluster/Cmatrix_NC.h Constants.h CoordinateInfo.h Cph.h CpptrajFile.h CpptrajStdio.h DataFile.h DataIO.h DataIO_AmberEne.h DataIO_AmberLib.h DataIO_AmberPrep.h DataIO_CCP4.h DataIO_CharmmFastRep.h DataIO_CharmmOutput.h DataIO_CharmmRepLog.h DataIO_CharmmRtfPrm.h DataIO_Cmatrix_Binary.h DataIO_Cmatrix_NC.h DataIO_Cpout.h DataIO_Evecs.h DataIO_Gnuplot.h DataIO_Grace.h DataIO_Mdout.h DataIO_NetCDF.h DataIO_Numpy.h DataIO_OpenDx.h DataIO_Peaks.h DataIO_RemLog.h DataIO_Std.h DataIO_VecTraj.h DataIO_XVG.h DataIO_Xplor.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_PairwiseCache.h DataSet_PairwiseCache_MEM.h DataSet_RemLog.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.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 Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajectoryFile.h TypeNameHolder.h Unit.h Vec3.h DataFileList.o : DataFileList.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h PDBfile.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataFilter.o : DataFilter.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_integer.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO.o : DataIO.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataSet.h DataSetList.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixDbl.h Dimension.h FileIO.h FileName.h Frame.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 Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_AmberEne.o : DataIO_AmberEne.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberEne.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h +DataIO_AmberLib.o : DataIO_AmberLib.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberLib.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_AmberPrep.o : DataIO_AmberPrep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h BondSearch.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberPrep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/InternalCoords.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CCP4.o : DataIO_CCP4.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ByteRoutines.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CCP4.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridFlt.h Dimension.h FileIO.h FileName.h Frame.h Grid.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmFastRep.o : DataIO_CharmmFastRep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmFastRep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_RemLog.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h diff --git a/src/cpptrajfiles b/src/cpptrajfiles index 188c6fa74a..0f26ad421b 100644 --- a/src/cpptrajfiles +++ b/src/cpptrajfiles @@ -174,6 +174,7 @@ COMMON_SOURCES= \ DataFilter.cpp \ DataIO.cpp \ DataIO_AmberEne.cpp \ + DataIO_AmberLib.cpp \ DataIO_AmberPrep.cpp \ DataIO_CCP4.cpp \ DataIO_CharmmFastRep.cpp \ From a310d4a03c28b30c145f01d96654b56995688956 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 25 Oct 2023 10:35:52 -0400 Subject: [PATCH 185/245] Ensure we can read all the sections. Skip unknown ones --- src/DataIO_AmberLib.cpp | 97 ++++++++++++++++++++++++++++++++++++++--- src/DataIO_AmberLib.h | 13 ++++++ 2 files changed, 105 insertions(+), 5 deletions(-) diff --git a/src/DataIO_AmberLib.cpp b/src/DataIO_AmberLib.cpp index 063eebc25c..a257662b87 100644 --- a/src/DataIO_AmberLib.cpp +++ b/src/DataIO_AmberLib.cpp @@ -53,19 +53,106 @@ int DataIO_AmberLib::ReadData(FileName const& fname, DataSetList& dsl, std::stri line = infile.GetLine(); while (!line.empty() && line[0] != '!') { - UnitNames.push_back( line ); + // Using ArgList here is a hacky way to get rid of the quotes + ArgList tmparg(line); + UnitNames.push_back( tmparg[0] ); line = infile.GetLine(); } - mprintf("DEBUG: Units:"); + // Now should be at first unit + mprintf("DEBUG: Units:\n"); for (Sarray::const_iterator it = UnitNames.begin(); it != UnitNames.end(); ++it) - mprintf(" %s", it->c_str()); - mprintf("\n"); + { + mprintf("DEBUG: Reading unit %s\n", it->c_str()); + std::string entryColumn = "!entry." + *it + ".unit.atoms"; + ArgList tmparg( line ); + if (tmparg.Nargs() < 1 || tmparg[0] != entryColumn) { + mprinterr("Error: Expected '%s', got '%s'\n", entryColumn.c_str(), line.c_str()); + return 1; + } + read_unit( infile, line, *it ); + } - // Now should be at first unit return 0; } +/** Strings corresponding to SectionType */ +const char* DataIO_AmberLib::sectionStr_[] = { + "atoms", "atomspertinfo", "boundbox", "childsequence", "connect", + "connectivity", "hierarchy", "name", "positions", "residueconnect", + "residues", "solventcap", "velocities", 0 }; + +/** \return Section type from entry line. */ +DataIO_AmberLib::SectionType DataIO_AmberLib::id_section(std::string const& line, + std::string const& unitName) +{ + std::string entry = "!entry." + unitName + ".unit."; + for (int idx = 0; idx < (int)UNKNOWN_SECTION; idx++) { + std::string sectionName = entry + std::string(sectionStr_[idx]); + std::size_t found = line.find_first_of(" "); + if (found == std::string::npos) { + mprinterr("Error: Malformed entry line: %s\n", line.c_str()); + break; + } + if (line.compare(0, found, sectionName) == 0) + return (SectionType)idx; + } + return UNKNOWN_SECTION; +} + +/** Read a unit from OFF file. It is expected that the next line from + * infile is the first entry in the unit.atoms table. + */ +int DataIO_AmberLib::read_unit(BufferedLine& infile, std::string& Line, + std::string const& unitName) +const +{ + // Format: "Atom name" "Type" "Type index (unused)" "resnum" "flags" "sequence" "element" "charge" + char aname[16]; + char atype[16]; + int typex; + int resx; + int flags; + int seq; + int elt; + double charge; + + SectionType currentSection = id_section( Line, unitName ); + if (currentSection == UNKNOWN_SECTION) { + mprinterr("Error: Could not ID first section: %s\n", Line.c_str()); + return 1; + } + mprintf("DEBUG: First section is %s\n", sectionStr_[currentSection]); + bool readUnit = true; + while (readUnit) { + const char* lineptr = infile.Line(); + if (lineptr == 0) { + readUnit = false; + break; + } + Line.assign(lineptr); + if (!Line.empty()) { + mprintf("DEBUG: Line: %s\n", Line.c_str()); + //ArgList cols( Line, " \t\n" ); + if (Line[0] == '!') { + // See if we are at another unit + ArgList tmparg( Line, ". " ); + if (tmparg[2] == "unit" && tmparg[3] == "atoms" && tmparg[4] == "table") { + readUnit = false; + break; + } + currentSection = id_section( Line, unitName ); + if (currentSection == UNKNOWN_SECTION) { + mprintf("Warning: Could not ID section: %s\n", Line.c_str()); + } else + mprintf("DEBUG: Section is %s\n", sectionStr_[currentSection]); + } + } + } + + return 0; +} + // DataIO_AmberLib::WriteHelp() void DataIO_AmberLib::WriteHelp() { diff --git a/src/DataIO_AmberLib.h b/src/DataIO_AmberLib.h index decf20c604..ada120dfe6 100644 --- a/src/DataIO_AmberLib.h +++ b/src/DataIO_AmberLib.h @@ -1,6 +1,7 @@ #ifndef INC_DATAIO_AMBERLIB_H #define INC_DATAIO_AMBERLIB_H #include "DataIO.h" +class BufferedLine; /// class DataIO_AmberLib : public DataIO { public: @@ -13,5 +14,17 @@ class DataIO_AmberLib : public DataIO { int processWriteArgs(ArgList&); int WriteData(FileName const&, DataSetList const&); bool ID_DataFormat(CpptrajFile&); + private: + // Keep in sync with sectionStr_ + enum SectionType { ATOMTABLE = 0, PERTINFO, BOUNDBOX, CHILDSEQUENCE, CONNECT, + CONNECTIVITY, HIERARCHY, UNITNAME, POSITIONS, RESCONNECT, + RESIDUES, SOLVENTCAP, VELOCITIES, UNKNOWN_SECTION }; + /// Strings corresponding to section type + static const char* sectionStr_[]; + + /// ID OFF section from line + static inline SectionType id_section(std::string const&, std::string const&); + /// Read unit from OFF file + int read_unit(BufferedLine&, std::string&, std::string const&) const; }; #endif From f03e704d09daa88cca5d4d0e11c4f9e44468abab Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 25 Oct 2023 11:08:26 -0400 Subject: [PATCH 186/245] Add ability to set mass from element --- src/Atom.cpp | 5 +++++ src/Atom.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/Atom.cpp b/src/Atom.cpp index bb4b7e1199..15f8500181 100644 --- a/src/Atom.cpp +++ b/src/Atom.cpp @@ -136,6 +136,11 @@ void Atom::DetermineElement(int atomicnum) { SetElementFromName(); } +/** Set atomic mass from current element */ +void Atom::SetMassFromElement() { + mass_ = AtomicElementMass_[ element_ ]; +} + // CONSTRUCTOR Atom::Atom(NameType const& aname, double charge, double mass, NameType const& atype) : charge_(charge), polar_(0.0), mass_(mass), gb_radius_(0.0), gb_screen_(0.0), diff --git a/src/Atom.h b/src/Atom.h index e5b94a2a3f..ddc79dad78 100644 --- a/src/Atom.h +++ b/src/Atom.h @@ -97,6 +97,8 @@ class Atom { double ParseRadius() const; /// Determine element from given atomic number. Use mass/name if number < 1. void DetermineElement(int); + /// Set atomic mass from current element + void SetMassFromElement(); protected: static const size_t NUMELEMENTS_ = 77; private: From 12fd7ede8feda45e719d18399ac28703a0acd798 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 25 Oct 2023 11:08:43 -0400 Subject: [PATCH 187/245] Read atoms and connectivity --- src/DataIO_AmberLib.cpp | 64 +++++++++++++++++++++++++++++++++++------ src/DataIO_AmberLib.h | 3 ++ 2 files changed, 59 insertions(+), 8 deletions(-) diff --git a/src/DataIO_AmberLib.cpp b/src/DataIO_AmberLib.cpp index a257662b87..d1705b738c 100644 --- a/src/DataIO_AmberLib.cpp +++ b/src/DataIO_AmberLib.cpp @@ -69,7 +69,10 @@ int DataIO_AmberLib::ReadData(FileName const& fname, DataSetList& dsl, std::stri mprinterr("Error: Expected '%s', got '%s'\n", entryColumn.c_str(), line.c_str()); return 1; } - read_unit( infile, line, *it ); + if (read_unit( infile, line, *it )) { + mprinterr("Error: Reading unit '%s'\n", it->c_str()); + return 1; + } } @@ -100,13 +103,7 @@ DataIO_AmberLib::SectionType DataIO_AmberLib::id_section(std::string const& line return UNKNOWN_SECTION; } -/** Read a unit from OFF file. It is expected that the next line from - * infile is the first entry in the unit.atoms table. - */ -int DataIO_AmberLib::read_unit(BufferedLine& infile, std::string& Line, - std::string const& unitName) -const -{ +int DataIO_AmberLib::read_atoms(Topology& topOut, std::string const& line, std::string const& unitName) { // Format: "Atom name" "Type" "Type index (unused)" "resnum" "flags" "sequence" "element" "charge" char aname[16]; char atype[16]; @@ -116,6 +113,46 @@ const int seq; int elt; double charge; + + if (sscanf(line.c_str(), "%s %s %i %i %i %i %i %lf", + aname, atype, &typex, &resx, &flags, &seq, &elt, &charge) != 8) + { + mprinterr("Error: Expected 8 columns for atoms table line: %s\n", line.c_str()); + return 1; + } + // Sanity check + if (seq-1 != topOut.Natom()) { + mprinterr("Error: For unit %s expected sequence %i, got %i\n", unitName.c_str(), topOut.Natom()+1, seq); + return 1; + } + Atom atm; + atm.SetName( NameType(aname) ); + atm.SetTypeName( NameType(atype) ); + atm.DetermineElement( elt ); + atm.SetMassFromElement(); + atm.SetCharge( charge ); + Residue res( unitName, resx, ' ', ' ' ); + topOut.AddTopAtom( atm, res ); + return 0; +} + +int DataIO_AmberLib::read_bonds(Topology& topOut, std::string const& line) { + int at0, at1, flags; + if (sscanf(line.c_str(), "%i %i %i", &at0, &at1, &flags) != 3) { + mprinterr("Error: Expected 3 columns for connectivity line: %s\n", line.c_str()); + return 1; + } + topOut.AddBond( at0-1, at1-1 ); + return 0; +} + +/** Read a unit from OFF file. It is expected that the next line from + * infile is the first entry in the unit.atoms table. + */ +int DataIO_AmberLib::read_unit(BufferedLine& infile, std::string& Line, + std::string const& unitName) +const +{ SectionType currentSection = id_section( Line, unitName ); if (currentSection == UNKNOWN_SECTION) { @@ -123,6 +160,11 @@ const return 1; } mprintf("DEBUG: First section is %s\n", sectionStr_[currentSection]); + + Topology top; + top.SetParmName( unitName, FileName() ); + Frame frm; + bool readUnit = true; while (readUnit) { const char* lineptr = infile.Line(); @@ -146,9 +188,15 @@ const mprintf("Warning: Could not ID section: %s\n", Line.c_str()); } else mprintf("DEBUG: Section is %s\n", sectionStr_[currentSection]); + } else if (currentSection == ATOMTABLE) { + if (read_atoms(top, Line, unitName)) return 1; + } else if (currentSection == CONNECTIVITY) { + if (read_bonds(top, Line)) return 1; } } } + top.CommonSetup(); + top.Summary(); return 0; } diff --git a/src/DataIO_AmberLib.h b/src/DataIO_AmberLib.h index ada120dfe6..ad552616ba 100644 --- a/src/DataIO_AmberLib.h +++ b/src/DataIO_AmberLib.h @@ -26,5 +26,8 @@ class DataIO_AmberLib : public DataIO { static inline SectionType id_section(std::string const&, std::string const&); /// Read unit from OFF file int read_unit(BufferedLine&, std::string&, std::string const&) const; + + static int read_atoms(Topology&, std::string const&, std::string const&); + static int read_bonds(Topology&, std::string const&); }; #endif From eefa7584ae6676be1a0ebac78b0a6650093e835c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 25 Oct 2023 11:40:19 -0400 Subject: [PATCH 188/245] Read positions, create COORDS data set for units --- src/DataIO_AmberLib.cpp | 45 +++++++++++++++++++++++++++++++++++++---- src/DataIO_AmberLib.h | 3 ++- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/DataIO_AmberLib.cpp b/src/DataIO_AmberLib.cpp index d1705b738c..f45fdd9261 100644 --- a/src/DataIO_AmberLib.cpp +++ b/src/DataIO_AmberLib.cpp @@ -69,7 +69,12 @@ int DataIO_AmberLib::ReadData(FileName const& fname, DataSetList& dsl, std::stri mprinterr("Error: Expected '%s', got '%s'\n", entryColumn.c_str(), line.c_str()); return 1; } - if (read_unit( infile, line, *it )) { + DataSet_Coords* ds = (DataSet_Coords*)dsl.AddSet( DataSet::COORDS, MetaData(dsname, *it) ); + if (ds == 0) { + mprinterr("Error: Could not create data set for unit %s\n", it->c_str()); + return 1; + } + if (read_unit( ds, infile, line, *it )) { mprinterr("Error: Reading unit '%s'\n", it->c_str()); return 1; } @@ -103,6 +108,14 @@ DataIO_AmberLib::SectionType DataIO_AmberLib::id_section(std::string const& line return UNKNOWN_SECTION; } +static inline std::string noquotes(const char* ptrIn) { + std::string out; + for (const char* ptr = ptrIn; *ptr != '\0'; ++ptr) + if (*ptr != '"') + out += *ptr; + return out; +} + int DataIO_AmberLib::read_atoms(Topology& topOut, std::string const& line, std::string const& unitName) { // Format: "Atom name" "Type" "Type index (unused)" "resnum" "flags" "sequence" "element" "charge" char aname[16]; @@ -126,8 +139,8 @@ int DataIO_AmberLib::read_atoms(Topology& topOut, std::string const& line, std:: return 1; } Atom atm; - atm.SetName( NameType(aname) ); - atm.SetTypeName( NameType(atype) ); + atm.SetName( NameType(noquotes(aname)) ); + atm.SetTypeName( NameType(noquotes(atype)) ); atm.DetermineElement( elt ); atm.SetMassFromElement(); atm.SetCharge( charge ); @@ -136,6 +149,19 @@ int DataIO_AmberLib::read_atoms(Topology& topOut, std::string const& line, std:: return 0; } +int DataIO_AmberLib::read_positions(std::vector& positions, std::string const& line) +{ + double x, y, z; + mprintf("DEBUG Positions %s\n", line.c_str()); + if (sscanf(line.c_str(), "%lf %lf %lf", &x, &y, &z) != 3) { + mprinterr("Error: Expected 3 columns for positions line: %s\n", line.c_str()); + return 1; + } + mprintf("DEBUG: %g %g %g\n", x, y, z); + positions.push_back( Vec3(x, y, z) ); + return 0; +} + int DataIO_AmberLib::read_bonds(Topology& topOut, std::string const& line) { int at0, at1, flags; if (sscanf(line.c_str(), "%i %i %i", &at0, &at1, &flags) != 3) { @@ -149,7 +175,8 @@ int DataIO_AmberLib::read_bonds(Topology& topOut, std::string const& line) { /** Read a unit from OFF file. It is expected that the next line from * infile is the first entry in the unit.atoms table. */ -int DataIO_AmberLib::read_unit(BufferedLine& infile, std::string& Line, +int DataIO_AmberLib::read_unit(DataSet_Coords* crd, + BufferedLine& infile, std::string& Line, std::string const& unitName) const { @@ -163,6 +190,7 @@ const Topology top; top.SetParmName( unitName, FileName() ); + std::vector positions; Frame frm; bool readUnit = true; @@ -192,11 +220,20 @@ const if (read_atoms(top, Line, unitName)) return 1; } else if (currentSection == CONNECTIVITY) { if (read_bonds(top, Line)) return 1; + } else if (currentSection == POSITIONS) { + if (read_positions(positions, Line)) return 1; } } } top.CommonSetup(); top.Summary(); + frm.SetupFrameV( top.Atoms(), CoordinateInfo() ); + frm.ClearAtoms(); + for (std::vector::const_iterator it = positions.begin(); it != positions.end(); ++it) + frm.AddVec3( *it ); + + crd->CoordsSetup(top, frm.CoordsInfo()); + crd->AddFrame( frm ); return 0; } diff --git a/src/DataIO_AmberLib.h b/src/DataIO_AmberLib.h index ad552616ba..1f1b5aadd2 100644 --- a/src/DataIO_AmberLib.h +++ b/src/DataIO_AmberLib.h @@ -25,9 +25,10 @@ class DataIO_AmberLib : public DataIO { /// ID OFF section from line static inline SectionType id_section(std::string const&, std::string const&); /// Read unit from OFF file - int read_unit(BufferedLine&, std::string&, std::string const&) const; + int read_unit(DataSet_Coords*, BufferedLine&, std::string&, std::string const&) const; static int read_atoms(Topology&, std::string const&, std::string const&); static int read_bonds(Topology&, std::string const&); + static int read_positions(std::vector&, std::string const&); }; #endif From 7585b69104c4b428d05102db2261b15db2501765 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 26 Oct 2023 15:28:57 -0400 Subject: [PATCH 189/245] When assigning a phi and need to guess initial phi, make branch with a depth of 1 cis to try to avoid clashes. --- src/Structure/Model.cpp | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index aef3576311..d885081352 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -91,6 +91,31 @@ int Cpptraj::Structure::Model::AssignTheta(double& theta, int ai, int aj, int ak return 0; } +/// Recursive function to return depth from an atom along bonds +static int atom_depth(int& depth, + int at, Topology const& topIn, std::vector& visited, int maxdepth) +{ + if (depth == maxdepth) return 0; + depth++; + visited[at] = true; + int depthFromHere = 1; + for (Atom::bond_iterator bat = topIn[at].bondbegin(); bat != topIn[at].bondend(); ++bat) + { + if (!visited[*bat]) + depthFromHere += atom_depth( depth, *bat, topIn, visited, maxdepth ); + } + return depthFromHere; +} + +static inline double wrap360(double phi) { + if (phi > Constants::PI) + return phi - Constants::TWOPI; + else if (phi < -Constants::PI) + return phi + Constants::TWOPI; + else + return phi; +} + /** Attempt to assign a reasonable value for phi internal coordinate for atom i * given that atoms j k and l have known positions. * j - k @@ -167,6 +192,28 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in } } + // If we have to assign an initial phi, make trans the longer branch + if (knownIdx == -1) { + std::vector visited = atomPositionKnown; + // TODO: Ensure bonded atoms are not yet visited? + visited[aj] = true; + visited[ak] = true; + std::vector depth( AJ.Nbonds() ); + for (int idx = 0; idx < AJ.Nbonds(); idx++) { + int atnum = priority[idx]; + if (atnum != ak) { + int currentDepth = 0; + depth[idx] = atom_depth(currentDepth, atnum, topIn, visited, 10); + mprintf("DEBUG:\t\tAJ %s depth from %s is %i\n", + topIn.AtomMaskName(aj).c_str(), topIn.AtomMaskName(atnum).c_str(), depth[idx]); + if (knownIdx == -1 && depth[idx] == 1) { + knownIdx = idx; + knownPhi[idx] = 0; + } + } + } + } + // The interval will be 360 / (number of bonds - 1) double interval = Constants::TWOPI / (AJ.Nbonds() - 1); @@ -199,6 +246,7 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in if (atnum == ai) phi = currentPhi; mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); currentPhi += interval; + currentPhi = wrap360(currentPhi); } } // Reverse direction @@ -209,6 +257,7 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in if (atnum == ai) phi = currentPhi; mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); currentPhi -= interval; + currentPhi = wrap360(currentPhi); } } From 5854d7368cde8f1520ee9f61059f16215f647701 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 26 Oct 2023 15:31:08 -0400 Subject: [PATCH 190/245] Allow depth of 2 to be cis as well --- src/Structure/Model.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index d885081352..7acfab2ec3 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -206,7 +206,7 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in depth[idx] = atom_depth(currentDepth, atnum, topIn, visited, 10); mprintf("DEBUG:\t\tAJ %s depth from %s is %i\n", topIn.AtomMaskName(aj).c_str(), topIn.AtomMaskName(atnum).c_str(), depth[idx]); - if (knownIdx == -1 && depth[idx] == 1) { + if (knownIdx == -1 && depth[idx] < 3) { knownIdx = idx; knownPhi[idx] = 0; } From 40c1961e3af5fbc048fee13677d742da2b21f16a Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 26 Oct 2023 15:51:17 -0400 Subject: [PATCH 191/245] Update tests --- test/Test_Graft/IC.Final.graft.mol2.save | 16 ++++++------ test/Test_Graft/IC.Nucleotide.pdb.save | 32 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/test/Test_Graft/IC.Final.graft.mol2.save b/test/Test_Graft/IC.Final.graft.mol2.save index ea8fa731b2..e4af61be0c 100644 --- a/test/Test_Graft/IC.Final.graft.mol2.save +++ b/test/Test_Graft/IC.Final.graft.mol2.save @@ -6,15 +6,15 @@ USER_CHARGES @ATOM - 1 N 4.8738 2.7240 0.6904 N 1 TYR -0.415700 - 2 H 4.2210 3.3937 0.3091 H 1 TYR 0.271900 - 3 CA 5.5211 1.8009 -0.2198 CX 1 TYR -0.001400 - 4 HA 6.6012 1.9392 -0.1712 H1 1 TYR 0.087600 + 1 N 5.0262 1.0605 2.4857 N 1 TYR -0.415700 + 2 H 4.3432 1.6530 2.9356 H 1 TYR 0.271900 + 3 CA 5.5045 1.4387 1.1713 CX 1 TYR -0.001400 + 4 HA 6.5833 1.5906 1.2064 H1 1 TYR 0.087600 5 CB 5.1981 0.3552 0.1428 CT 1 TYR -0.015200 - 6 HB2 5.5459 0.1487 1.1550 HC 1 TYR 0.029500 - 7 HB3 5.6984 -0.3147 -0.5565 HC 1 TYR 0.029500 - 8 C 5.0649 2.0340 -1.6530 C 1 TYR 0.597300 - 9 O 4.2484 2.9152 -1.9122 O 1 TYR -0.567900 + 6 HB2 5.6866 -0.5735 0.4378 HC 1 TYR 0.029500 + 7 HB3 5.5697 0.6663 -0.8336 HC 1 TYR 0.029500 + 8 C 4.8470 2.7276 0.6990 C 1 TYR 0.597300 + 9 O 4.0264 3.3055 1.4083 O 1 TYR -0.567900 10 C2 3.6760 0.1340 0.0670 CA 2 PRY 0.033204 11 C3 3.1370 -1.1220 0.3590 CA 2 PRY -0.149016 12 H4 3.7940 -1.9290 0.6360 HA 2 PRY 0.153372 diff --git a/test/Test_Graft/IC.Nucleotide.pdb.save b/test/Test_Graft/IC.Nucleotide.pdb.save index 633e3e4fa8..59b95bddc8 100644 --- a/test/Test_Graft/IC.Nucleotide.pdb.save +++ b/test/Test_Graft/IC.Nucleotide.pdb.save @@ -12,22 +12,22 @@ ATOM 11 C2 DA 1 5.285 -2.520 5.935 1.00 0.00 C ATOM 12 H2 DA 1 5.498 -2.482 6.993 1.00 0.00 H ATOM 13 N3 DA 1 5.073 -1.309 5.456 1.00 0.00 N ATOM 14 C4 DA 1 4.806 -1.356 4.133 1.00 0.00 C -ATOM 15 C5' DA 1 2.648 1.767 5.965 1.00 0.00 C -ATOM 16 H5' DA 1 3.340 1.199 6.588 1.00 0.00 H -ATOM 17 H5'' DA 1 2.100 2.476 6.586 1.00 0.00 H -ATOM 18 C4' DA 1 3.435 2.528 4.911 1.00 0.00 C -ATOM 19 H4' DA 1 3.859 3.430 5.353 1.00 0.00 H -ATOM 20 O4' DA 1 4.595 1.732 4.521 1.00 0.00 O +ATOM 15 C5' DA 1 1.109 1.452 3.145 1.00 0.00 C +ATOM 16 H5' DA 1 0.981 0.812 4.017 1.00 0.00 H +ATOM 17 H5'' DA 1 0.230 2.087 3.028 1.00 0.00 H +ATOM 18 C4' DA 1 2.335 2.328 3.343 1.00 0.00 C +ATOM 19 H4' DA 1 2.082 3.168 3.988 1.00 0.00 H +ATOM 20 O4' DA 1 3.334 1.576 4.098 1.00 0.00 O ATOM 21 C1' DA 1 4.385 1.163 3.237 1.00 0.00 C -ATOM 22 H1' DA 1 5.115 1.568 2.538 1.00 0.00 H -ATOM 23 C3' DA 1 2.698 2.797 3.597 1.00 0.00 C -ATOM 24 H3' DA 1 1.629 2.885 3.790 1.00 0.00 H -ATOM 25 C2' DA 1 2.974 1.502 2.753 1.00 0.00 C -ATOM 26 H2' DA 1 2.040 1.006 2.489 1.00 0.00 H -ATOM 27 O3' DA 1 3.160 3.896 2.824 1.00 0.00 O -ATOM 28 P DA 1 0.884 0.051 6.465 0.00 0.00 P -ATOM 29 O1P DA 1 0.522 1.032 7.498 0.00 0.00 O -ATOM 30 O2P DA 1 -0.065 -0.845 5.788 0.00 0.00 O -ATOM 31 O5' DA 1 1.734 0.873 5.326 0.00 0.00 O +ATOM 22 H1' DA 1 5.314 1.643 3.542 1.00 0.00 H +ATOM 23 C3' DA 1 3.063 2.753 2.066 1.00 0.00 C +ATOM 24 H3' DA 1 2.348 2.823 1.246 1.00 0.00 H +ATOM 25 C2' DA 1 4.053 1.564 1.798 1.00 0.00 C +ATOM 26 H2' DA 1 3.856 1.107 0.829 1.00 0.00 H +ATOM 27 O3' DA 1 3.851 3.932 2.147 1.00 0.00 O +ATOM 28 P DA 1 -0.042 -0.302 1.764 0.00 0.00 P +ATOM 29 O1P DA 1 -1.186 0.613 1.641 0.00 0.00 O +ATOM 30 O2P DA 1 0.290 -1.365 0.804 0.00 0.00 O +ATOM 31 O5' DA 1 1.283 0.644 1.978 0.00 0.00 O TER 32 DA 1 END From 7e4c7d0e9f94c311d802d5e0b43b54998012d5e6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 26 Oct 2023 16:40:05 -0400 Subject: [PATCH 192/245] Add Ainfo routine --- src/AssociatedData.cpp | 4 ++++ src/AssociatedData.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/AssociatedData.cpp b/src/AssociatedData.cpp index 80f791d13d..064a7be245 100644 --- a/src/AssociatedData.cpp +++ b/src/AssociatedData.cpp @@ -26,3 +26,7 @@ int AssociatedData_NOE::NOE_Args(ArgList& argIn) { } return 0; } + +void AssociatedData_NOE::Ainfo() const { + mprintf("(NOE %g < %g < %g)", l_bound_, rexp_, u_bound_); +} diff --git a/src/AssociatedData.h b/src/AssociatedData.h index 615e9dcc96..f8c68c7020 100644 --- a/src/AssociatedData.h +++ b/src/AssociatedData.h @@ -9,6 +9,7 @@ class AssociatedData { AssociatedData(AssociatedType t) : type_(t) {} AssociatedType Type() { return type_; } virtual AssociatedData* Copy() const = 0; + virtual void Ainfo() const = 0; private: AssociatedType type_; }; @@ -26,6 +27,7 @@ class AssociatedData_NOE : public AssociatedData { double NOE_rexp() const { return rexp_; } AssociatedData* Copy() const { return new AssociatedData_NOE(*this); } + void Ainfo() const; private: double l_bound_; ///< Lower bound double u_bound_; ///< Upper bound From 34a14bcef0b939c44b6a9f02a1894703aeb7315f Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 26 Oct 2023 16:48:20 -0400 Subject: [PATCH 193/245] Split AssociatedData file into separate classes --- src/Action_Distance.cpp | 1 + src/Action_NMRrst.cpp | 1 + src/Analysis_Statistics.cpp | 1 + src/AssociatedData.h | 21 ---------------- ...ociatedData.cpp => AssociatedData_NOE.cpp} | 2 +- src/AssociatedData_NOE.h | 24 +++++++++++++++++++ src/DataSet_Topology.h | 1 + src/Exec_DataSetCmd.cpp | 1 + src/cpptrajdepend | 10 ++++---- src/cpptrajfiles | 2 +- 10 files changed, 36 insertions(+), 28 deletions(-) rename src/{AssociatedData.cpp => AssociatedData_NOE.cpp} (96%) create mode 100644 src/AssociatedData_NOE.h diff --git a/src/Action_Distance.cpp b/src/Action_Distance.cpp index 83d0303f14..7e848cca63 100644 --- a/src/Action_Distance.cpp +++ b/src/Action_Distance.cpp @@ -1,6 +1,7 @@ #include "Action_Distance.h" #include "CpptrajStdio.h" #include "DistRoutines.h" +#include "AssociatedData_NOE.h" // CONSTRUCTOR Action_Distance::Action_Distance() : diff --git a/src/Action_NMRrst.cpp b/src/Action_NMRrst.cpp index 5f33fc0912..868077390a 100644 --- a/src/Action_NMRrst.cpp +++ b/src/Action_NMRrst.cpp @@ -10,6 +10,7 @@ #include "ViewRst.h" #include "BufferedLine.h" #include "DistRoutines.h" +#include "AssociatedData_NOE.h" // CONSTRUCTOR Action_NMRrst::Action_NMRrst() : diff --git a/src/Analysis_Statistics.cpp b/src/Analysis_Statistics.cpp index 672a50ffbc..2fbd0666b8 100644 --- a/src/Analysis_Statistics.cpp +++ b/src/Analysis_Statistics.cpp @@ -1,6 +1,7 @@ #include // sqrt #include "Analysis_Statistics.h" #include "CpptrajStdio.h" +#include "AssociatedData_NOE.h" // CONSTRUCTOR Analysis_Statistics::Analysis_Statistics() : diff --git a/src/AssociatedData.h b/src/AssociatedData.h index f8c68c7020..9453fbcc19 100644 --- a/src/AssociatedData.h +++ b/src/AssociatedData.h @@ -1,6 +1,5 @@ #ifndef INC_ASSOCIATEDDATA_H #define INC_ASSOCIATEDDATA_H -class ArgList; class AssociatedData { public: /// Destructor. Virtual since this class is inherited. @@ -13,24 +12,4 @@ class AssociatedData { private: AssociatedType type_; }; - -/// For Analysis_Statistics DISTANCE NOE -class AssociatedData_NOE : public AssociatedData { - public: - AssociatedData_NOE() : AssociatedData(NOE), l_bound_(0.0), u_bound_(0.0), rexp_(-1.0) {} - AssociatedData_NOE(double l, double u, double r) : - AssociatedData(NOE), l_bound_(l), u_bound_(u), rexp_(r) {} - static const char* HelpText; - int NOE_Args(ArgList&); - double NOE_bound() const { return l_bound_; } - double NOE_boundH() const { return u_bound_; } - double NOE_rexp() const { return rexp_; } - - AssociatedData* Copy() const { return new AssociatedData_NOE(*this); } - void Ainfo() const; - private: - double l_bound_; ///< Lower bound - double u_bound_; ///< Upper bound - double rexp_; ///< Expected distance -}; #endif diff --git a/src/AssociatedData.cpp b/src/AssociatedData_NOE.cpp similarity index 96% rename from src/AssociatedData.cpp rename to src/AssociatedData_NOE.cpp index 064a7be245..85040a2e96 100644 --- a/src/AssociatedData.cpp +++ b/src/AssociatedData_NOE.cpp @@ -1,4 +1,4 @@ -#include "AssociatedData.h" +#include "AssociatedData_NOE.h" #include "CpptrajStdio.h" #include "ArgList.h" diff --git a/src/AssociatedData_NOE.h b/src/AssociatedData_NOE.h new file mode 100644 index 0000000000..bcc3d1db91 --- /dev/null +++ b/src/AssociatedData_NOE.h @@ -0,0 +1,24 @@ +#ifndef INC_ASSOCIATEDDATA_NOE_H +#define INC_ASSOCIATEDDATA_NOE_H +#include "AssociatedData.h" +class ArgList; +/// For Analysis_Statistics DISTANCE NOE +class AssociatedData_NOE : public AssociatedData { + public: + AssociatedData_NOE() : AssociatedData(NOE), l_bound_(0.0), u_bound_(0.0), rexp_(-1.0) {} + AssociatedData_NOE(double l, double u, double r) : + AssociatedData(NOE), l_bound_(l), u_bound_(u), rexp_(r) {} + static const char* HelpText; + int NOE_Args(ArgList&); + double NOE_bound() const { return l_bound_; } + double NOE_boundH() const { return u_bound_; } + double NOE_rexp() const { return rexp_; } + + AssociatedData* Copy() const { return new AssociatedData_NOE(*this); } + void Ainfo() const; + private: + double l_bound_; ///< Lower bound + double u_bound_; ///< Upper bound + double rexp_; ///< Expected distance +}; +#endif diff --git a/src/DataSet_Topology.h b/src/DataSet_Topology.h index 331c25233c..e9328469c4 100644 --- a/src/DataSet_Topology.h +++ b/src/DataSet_Topology.h @@ -2,6 +2,7 @@ #define INC_DATASET_TOPOLOGY #include "DataSet.h" #include "Topology.h" +class ArgList; /// Hold Topology data class DataSet_Topology : public DataSet { public: diff --git a/src/Exec_DataSetCmd.cpp b/src/Exec_DataSetCmd.cpp index 28d559b36b..3f503ddc72 100644 --- a/src/Exec_DataSetCmd.cpp +++ b/src/Exec_DataSetCmd.cpp @@ -8,6 +8,7 @@ #include "DataSet_Mesh.h" #include "DataSet_Mat3x3.h" #include "StringRoutines.h" +#include "AssociatedData_NOE.h" // Exec_DataSetCmd::Help() void Exec_DataSetCmd::Help() const { diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 09a47d122a..9f652fb96b 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -29,7 +29,7 @@ Action_Dihedral.o : Action_Dihedral.cpp Action.h ActionState.h Action_Dihedral.h Action_DihedralRMS.o : Action_DihedralRMS.cpp Action.h ActionState.h Action_DihedralRMS.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h 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 ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceAction.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Action_Dipole.o : Action_Dipole.cpp Action.h ActionState.h Action_Dipole.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_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 ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Action_DistRmsd.o : Action_DistRmsd.cpp Action.h ActionState.h Action_DistRmsd.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceAction.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h -Action_Distance.o : Action_Distance.cpp Action.h ActionState.h Action_Distance.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h +Action_Distance.o : Action_Distance.cpp Action.h ActionState.h Action_Distance.h ArgList.h AssociatedData.h AssociatedData_NOE.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Action_Energy.o : Action_Energy.cpp Action.h ActionState.h Action_Energy.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h CharMask.h Constants.h Constraints.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h Energy.h EnergyArray.h Ewald.h EwaldOptions.h Ewald_ParticleMesh.h Ewald_Regular.h ExclusionArray.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MdOpts.h MetaData.h Molecule.h NameType.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h PotentialFunction.h PotentialTerm.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SplineFxnTable.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h helpme_standalone.h Action_Esander.o : Action_Esander.cpp Action.h ActionState.h Action_Esander.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h Energy_Sander.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Action_FilterByData.o : Action_FilterByData.cpp Action.h ActionState.h Action_FilterByData.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h @@ -55,7 +55,7 @@ Action_MultiDihedral.o : Action_MultiDihedral.cpp Action.h ActionState.h Action_ Action_MultiPucker.o : Action_MultiPucker.cpp Action.h ActionState.h Action_MultiPucker.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Pucker.h Pucker_PuckerMask.h Pucker_PuckerSearch.h Pucker_PuckerToken.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TypeNameHolder.h Unit.h Vec3.h Action_MultiVector.o : Action_MultiVector.cpp Action.h ActionState.h Action_MultiVector.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ComplexArray.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_Vector.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Action_NAstruct.o : Action_NAstruct.cpp Action.h ActionFrameCounter.h ActionState.h Action_NAstruct.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h AxisType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_float.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OutputTrajCommon.h PDBfile.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ParmFile.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajectoryFile.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h -Action_NMRrst.o : Action_NMRrst.cpp Action.h ActionState.h Action_NMRrst.h ArgList.h AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_double.h DataSet_float.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImageOption.h MapAtom.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h ViewRst.h +Action_NMRrst.o : Action_NMRrst.cpp Action.h ActionState.h Action_NMRrst.h ArgList.h AssociatedData.h AssociatedData_NOE.h Atom.h AtomMap.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h CharMask.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_double.h DataSet_float.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImageOption.h MapAtom.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h ViewRst.h Action_NativeContacts.o : Action_NativeContacts.cpp Action.h ActionState.h Action_NativeContacts.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixDbl.h DataSet_integer.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImageOption.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h PDBfile.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Action_OrderParameter.o : Action_OrderParameter.cpp Action.h ActionState.h Action_OrderParameter.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImageOption.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Action_Outtraj.o : Action_Outtraj.cpp Action.h ActionFrameCounter.h ActionState.h Action_Outtraj.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OutputTrajCommon.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajectoryFile.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h @@ -129,7 +129,7 @@ Analysis_RunningAvg.o : Analysis_RunningAvg.cpp ActionState.h Analysis.h Analysi Analysis_Slope.o : Analysis_Slope.cpp ActionState.h Analysis.h AnalysisState.h Analysis_Slope.h ArgList.h Array1D.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_Mesh.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h Spline.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Analysis_Spline.o : Analysis_Spline.cpp ActionState.h Analysis.h AnalysisState.h Analysis_Spline.h ArgList.h Array1D.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_Mesh.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h Spline.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Analysis_State.o : Analysis_State.cpp ActionState.h Analysis.h AnalysisState.h Analysis_State.h ArgList.h Array1D.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_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 ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h -Analysis_Statistics.o : Analysis_Statistics.cpp ActionState.h Analysis.h AnalysisState.h Analysis_Statistics.h ArgList.h Array1D.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_float.h DataSet_integer.h DataSet_string.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h +Analysis_Statistics.o : Analysis_Statistics.cpp ActionState.h Analysis.h AnalysisState.h Analysis_Statistics.h ArgList.h Array1D.h AssociatedData.h AssociatedData_NOE.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_float.h DataSet_integer.h DataSet_string.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Analysis_TI.o : Analysis_TI.cpp ActionState.h Analysis.h AnalysisState.h Analysis_TI.h ArgList.h Array1D.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_Mesh.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Random.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h Spline.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Analysis_TICA.o : Analysis_TICA.cpp ActionState.h Analysis.h AnalysisState.h Analysis_TICA.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h Analysis_Timecorr.o : Analysis_Timecorr.cpp ActionState.h Analysis.h AnalysisState.h Analysis_Timecorr.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ComplexArray.h Constants.h CoordinateInfo.h Corr.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_Vector.h DataSet_double.h Dimension.h DispatchObject.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h PubFFT.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h @@ -137,7 +137,7 @@ Analysis_VectorMath.o : Analysis_VectorMath.cpp ActionState.h Analysis.h Analysi Analysis_Wavelet.o : Analysis_Wavelet.cpp ActionFrameCounter.h ActionState.h Analysis.h AnalysisState.h Analysis_Wavelet.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ClusterMap.h ComplexArray.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixFlt.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImageOption.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OutputTrajCommon.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ParmFile.h ProgressBar.h ProgressTimer.h PubFFT.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajectoryFile.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h ArgList.o : ArgList.cpp ArgList.h CpptrajStdio.h StringRoutines.h Array1D.o : Array1D.cpp ArgList.h Array1D.h AssociatedData.h Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h -AssociatedData.o : AssociatedData.cpp ArgList.h AssociatedData.h CpptrajStdio.h +AssociatedData_NOE.o : AssociatedData_NOE.cpp ArgList.h AssociatedData.h AssociatedData_NOE.h CpptrajStdio.h Atom.o : Atom.cpp Atom.h CpptrajStdio.h NameType.h SymbolExporting.h AtomMap.o : AtomMap.cpp Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h AtomMask.o : AtomMask.cpp Atom.h AtomMask.h CpptrajStdio.h MaskToken.h Molecule.h NameType.h Residue.h Segment.h SymbolExporting.h Unit.h @@ -299,7 +299,7 @@ Exec_CrdTransform.o : Exec_CrdTransform.cpp Action.h ActionList.h ActionState.h Exec_CreateSet.o : Exec_CreateSet.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_CreateSet.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 RPNcalc.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_DataFile.o : Exec_DataFile.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_DataFile.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 Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_DataFilter.o : Exec_DataFilter.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_DataFilter.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 ProgressBar.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h -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 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_Mat3x3.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 Segment.h Spline.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h +Exec_DataSetCmd.o : Exec_DataSetCmd.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h ArrayIterator.h AssociatedData.h AssociatedData_NOE.h Atom.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_Mat3x3.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 Segment.h Spline.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 AtomMask.h AtomType.h BaseIOtype.h Box.h CharMask.h Constants.h Constraints.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 MdOpts.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_ExtendedComparison.o : Exec_ExtendedComparison.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_ExtendedComparison.h ExtendedSimilarity.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_Flatten.o : Exec_Flatten.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Flatten.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h diff --git a/src/cpptrajfiles b/src/cpptrajfiles index 0f26ad421b..5575d3df2d 100644 --- a/src/cpptrajfiles +++ b/src/cpptrajfiles @@ -140,7 +140,7 @@ COMMON_SOURCES= \ Analysis_Wavelet.cpp \ ArgList.cpp \ Array1D.cpp \ - AssociatedData.cpp \ + AssociatedData_NOE.cpp \ Atom.cpp \ AtomMap.cpp \ AtomMask.cpp \ From 8c89bd2b15c0558f2718cbdf9db10ea0c54e338e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 26 Oct 2023 19:32:07 -0400 Subject: [PATCH 194/245] Start adding connect atoms as associated data --- src/AssociatedData.h | 2 +- src/AssociatedData_Connect.cpp | 7 +++++++ src/AssociatedData_Connect.h | 19 +++++++++++++++++++ src/DataIO_AmberLib.cpp | 17 +++++++++++++++++ src/DataIO_AmberLib.h | 2 ++ src/cpptrajdepend | 3 ++- src/cpptrajfiles | 1 + 7 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 src/AssociatedData_Connect.cpp create mode 100644 src/AssociatedData_Connect.h diff --git a/src/AssociatedData.h b/src/AssociatedData.h index 9453fbcc19..b626518f41 100644 --- a/src/AssociatedData.h +++ b/src/AssociatedData.h @@ -4,7 +4,7 @@ class AssociatedData { public: /// Destructor. Virtual since this class is inherited. virtual ~AssociatedData() {} - enum AssociatedType { NOE = 0 }; + enum AssociatedType { NOE = 0, CONNECT }; AssociatedData(AssociatedType t) : type_(t) {} AssociatedType Type() { return type_; } virtual AssociatedData* Copy() const = 0; diff --git a/src/AssociatedData_Connect.cpp b/src/AssociatedData_Connect.cpp new file mode 100644 index 0000000000..dde3daf6bd --- /dev/null +++ b/src/AssociatedData_Connect.cpp @@ -0,0 +1,7 @@ +#include "AssociatedData_Connect.h" + +const char* AssociatedData_Connect::HelpText = ""; + +void AssociatedData_Connect::Ainfo() const { + return; +} diff --git a/src/AssociatedData_Connect.h b/src/AssociatedData_Connect.h new file mode 100644 index 0000000000..a1d062b2da --- /dev/null +++ b/src/AssociatedData_Connect.h @@ -0,0 +1,19 @@ +#ifndef INC_ASSOCIATEDDATA_CONNECT_H +#define INC_ASSOCIATEDDATA_CONNECT_H +#include +#include "AssociatedData.h" +/// For holding unit connect atoms (COORDS data sets) +class AssociatedData_Connect : public AssociatedData { + public: + AssociatedData_Connect() : AssociatedData(CONNECT) {} + static const char* HelpText; + + void AddConnectAtom(int at) { connect_.push_back( at ); } + + AssociatedData* Copy() const { return new AssociatedData_Connect(*this); } + void Ainfo() const; + private: + typedef std::vector Iarray; + Iarray connect_; +}; +#endif diff --git a/src/DataIO_AmberLib.cpp b/src/DataIO_AmberLib.cpp index f45fdd9261..710b38fa6d 100644 --- a/src/DataIO_AmberLib.cpp +++ b/src/DataIO_AmberLib.cpp @@ -1,6 +1,7 @@ #include "DataIO_AmberLib.h" #include "CpptrajStdio.h" #include "BufferedLine.h" +#include "AssociatedData_Connect.h" /// CONSTRUCTOR DataIO_AmberLib::DataIO_AmberLib() @@ -172,6 +173,22 @@ int DataIO_AmberLib::read_bonds(Topology& topOut, std::string const& line) { return 0; } +int DataIO_AmberLib::read_connect(AssociatedData_Connect& ConnectAtoms, std::string const& line) { + int connectAtom = -1; + if (sscanf(line.c_str(), "%i", &connectAtom) != 1) { + mprinterr("Error: Expected 1 column for connect line: %s\n", line.c_str()); + return 1; + } + // Amber lib atoms start from 1 + if (connectAtom < 1) { + mprinterr("Error: Atom index < 1 in connect line: %s\n", line.c_str()); + return 1; + } + ConnectAtoms.AddConnectAtom( connectAtom-1 ); + return 0; +} + + /** Read a unit from OFF file. It is expected that the next line from * infile is the first entry in the unit.atoms table. */ diff --git a/src/DataIO_AmberLib.h b/src/DataIO_AmberLib.h index 1f1b5aadd2..9f8952fa37 100644 --- a/src/DataIO_AmberLib.h +++ b/src/DataIO_AmberLib.h @@ -2,6 +2,7 @@ #define INC_DATAIO_AMBERLIB_H #include "DataIO.h" class BufferedLine; +class AssociatedData_Connect; /// class DataIO_AmberLib : public DataIO { public: @@ -30,5 +31,6 @@ class DataIO_AmberLib : public DataIO { static int read_atoms(Topology&, std::string const&, std::string const&); static int read_bonds(Topology&, std::string const&); static int read_positions(std::vector&, std::string const&); + static int read_connect(AssociatedData_Connect&, std::string const&); }; #endif diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 9f652fb96b..5a70cbd8be 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -137,6 +137,7 @@ Analysis_VectorMath.o : Analysis_VectorMath.cpp ActionState.h Analysis.h Analysi Analysis_Wavelet.o : Analysis_Wavelet.cpp ActionFrameCounter.h ActionState.h Analysis.h AnalysisState.h Analysis_Wavelet.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ClusterMap.h ComplexArray.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixFlt.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImageOption.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OutputTrajCommon.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ParmFile.h ProgressBar.h ProgressTimer.h PubFFT.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajectoryFile.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h ArgList.o : ArgList.cpp ArgList.h CpptrajStdio.h StringRoutines.h Array1D.o : Array1D.cpp ArgList.h Array1D.h AssociatedData.h Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h +AssociatedData_Connect.o : AssociatedData_Connect.cpp AssociatedData.h AssociatedData_Connect.h AssociatedData_NOE.o : AssociatedData_NOE.cpp ArgList.h AssociatedData.h AssociatedData_NOE.h CpptrajStdio.h Atom.o : Atom.cpp Atom.h CpptrajStdio.h NameType.h SymbolExporting.h AtomMap.o : AtomMap.cpp Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h @@ -203,7 +204,7 @@ DataFileList.o : DataFileList.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h A DataFilter.o : DataFilter.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_integer.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO.o : DataIO.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataSet.h DataSetList.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixDbl.h Dimension.h FileIO.h FileName.h Frame.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 Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_AmberEne.o : DataIO_AmberEne.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberEne.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h -DataIO_AmberLib.o : DataIO_AmberLib.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberLib.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h +DataIO_AmberLib.o : DataIO_AmberLib.cpp ArgList.h AssociatedData.h AssociatedData_Connect.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberLib.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_AmberPrep.o : DataIO_AmberPrep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h BondSearch.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_AmberPrep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h Structure/InternalCoords.h Structure/StructureEnum.h Structure/Zmatrix.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CCP4.o : DataIO_CCP4.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ByteRoutines.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CCP4.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridFlt.h Dimension.h FileIO.h FileName.h Frame.h Grid.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h DataIO_CharmmFastRep.o : DataIO_CharmmFastRep.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_CharmmFastRep.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_RemLog.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h diff --git a/src/cpptrajfiles b/src/cpptrajfiles index 5575d3df2d..b6095972cc 100644 --- a/src/cpptrajfiles +++ b/src/cpptrajfiles @@ -140,6 +140,7 @@ COMMON_SOURCES= \ Analysis_Wavelet.cpp \ ArgList.cpp \ Array1D.cpp \ + AssociatedData_Connect.cpp \ AssociatedData_NOE.cpp \ Atom.cpp \ AtomMap.cpp \ From a5b1e8751398dda0b08419b79ffab3ff212b7bb2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 26 Oct 2023 19:34:55 -0400 Subject: [PATCH 195/245] Fill out Ainfo function --- src/AssociatedData_Connect.cpp | 7 +++++++ src/cpptrajdepend | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/AssociatedData_Connect.cpp b/src/AssociatedData_Connect.cpp index dde3daf6bd..22f0bfc23a 100644 --- a/src/AssociatedData_Connect.cpp +++ b/src/AssociatedData_Connect.cpp @@ -1,7 +1,14 @@ #include "AssociatedData_Connect.h" +#include "CpptrajStdio.h" const char* AssociatedData_Connect::HelpText = ""; void AssociatedData_Connect::Ainfo() const { + if (!connect_.empty()) { + mprintf(" (Connect Atoms:"); + for (Iarray::const_iterator it = connect_.begin(); it != connect_.end(); ++it) + mprintf(" %i", *it + 1); + mprintf("\n"); + } return; } diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 5a70cbd8be..ec6864933d 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -137,7 +137,7 @@ Analysis_VectorMath.o : Analysis_VectorMath.cpp ActionState.h Analysis.h Analysi Analysis_Wavelet.o : Analysis_Wavelet.cpp ActionFrameCounter.h ActionState.h Analysis.h AnalysisState.h Analysis_Wavelet.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ClusterMap.h ComplexArray.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixFlt.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImageOption.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OutputTrajCommon.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ParmFile.h ProgressBar.h ProgressTimer.h PubFFT.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajectoryFile.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h ArgList.o : ArgList.cpp ArgList.h CpptrajStdio.h StringRoutines.h Array1D.o : Array1D.cpp ArgList.h Array1D.h AssociatedData.h Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h -AssociatedData_Connect.o : AssociatedData_Connect.cpp AssociatedData.h AssociatedData_Connect.h +AssociatedData_Connect.o : AssociatedData_Connect.cpp AssociatedData.h AssociatedData_Connect.h CpptrajStdio.h AssociatedData_NOE.o : AssociatedData_NOE.cpp ArgList.h AssociatedData.h AssociatedData_NOE.h CpptrajStdio.h Atom.o : Atom.cpp Atom.h CpptrajStdio.h NameType.h SymbolExporting.h AtomMap.o : AtomMap.cpp Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h From fde5a7eecb3692b0b6ce36f18ef53039389ddc47 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 26 Oct 2023 19:38:14 -0400 Subject: [PATCH 196/245] Read the connect atoms --- src/AssociatedData_Connect.cpp | 2 +- src/DataIO_AmberLib.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/AssociatedData_Connect.cpp b/src/AssociatedData_Connect.cpp index 22f0bfc23a..5d18b71a98 100644 --- a/src/AssociatedData_Connect.cpp +++ b/src/AssociatedData_Connect.cpp @@ -8,7 +8,7 @@ void AssociatedData_Connect::Ainfo() const { mprintf(" (Connect Atoms:"); for (Iarray::const_iterator it = connect_.begin(); it != connect_.end(); ++it) mprintf(" %i", *it + 1); - mprintf("\n"); + mprintf(")"); } return; } diff --git a/src/DataIO_AmberLib.cpp b/src/DataIO_AmberLib.cpp index 710b38fa6d..a215d15526 100644 --- a/src/DataIO_AmberLib.cpp +++ b/src/DataIO_AmberLib.cpp @@ -197,7 +197,7 @@ int DataIO_AmberLib::read_unit(DataSet_Coords* crd, std::string const& unitName) const { - + AssociatedData_Connect ConnectAtoms; SectionType currentSection = id_section( Line, unitName ); if (currentSection == UNKNOWN_SECTION) { mprinterr("Error: Could not ID first section: %s\n", Line.c_str()); @@ -239,6 +239,8 @@ const if (read_bonds(top, Line)) return 1; } else if (currentSection == POSITIONS) { if (read_positions(positions, Line)) return 1; + } else if (currentSection == CONNECT) { + if (read_connect(ConnectAtoms, Line)) return 1; } } } @@ -251,6 +253,8 @@ const crd->CoordsSetup(top, frm.CoordsInfo()); crd->AddFrame( frm ); + ConnectAtoms.Ainfo(); + mprintf("\n"); return 0; } From 84dbafac0217bf113071883937dbf3847ebe05d4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 26 Oct 2023 20:21:04 -0400 Subject: [PATCH 197/245] Associate the connect data --- src/DataIO_AmberLib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DataIO_AmberLib.cpp b/src/DataIO_AmberLib.cpp index a215d15526..343269a6ed 100644 --- a/src/DataIO_AmberLib.cpp +++ b/src/DataIO_AmberLib.cpp @@ -253,6 +253,7 @@ const crd->CoordsSetup(top, frm.CoordsInfo()); crd->AddFrame( frm ); + crd->AssociateData( &ConnectAtoms ); ConnectAtoms.Ainfo(); mprintf("\n"); From 808590edff7c1ed68ef9f3a902f59da6584ed348 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 08:43:44 -0400 Subject: [PATCH 198/245] Start sequence command --- src/Exec_Sequence.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++ src/Exec_Sequence.h | 14 +++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/Exec_Sequence.cpp create mode 100644 src/Exec_Sequence.h diff --git a/src/Exec_Sequence.cpp b/src/Exec_Sequence.cpp new file mode 100644 index 0000000000..5f6ba7f5d6 --- /dev/null +++ b/src/Exec_Sequence.cpp @@ -0,0 +1,47 @@ +#include "Exec_Sequence.h" +#include "CpptrajStdio.h" + +// Exec_Sequence::Help() +void Exec_Sequence::Help() const +{ + +} + +// Exec_Sequence::Execute() +Exec::RetType Exec_Sequence::Execute(CpptrajState& State, ArgList& argIn) +{ + // Args + Sarray LibSetNames; + std::string libsetname = argIn.GetStringKey("libset"); + while (!libsetname.empty()) { + LibSetNames.push_back( libsetname ); + libsetname = argIn.GetStringKey("libset"); + } + + // Get the actual sequence from remaining args. + Sarray main_sequence; + ArgList remaining = argIn.RemainingArgs(); + std::string unit = remaining.GetStringNext(); + while (!unit.empty()) { + main_sequence.push_back( unit ); + unit = remaining.GetStringNext(); + } + if (main_sequence.empty()) { + mprinterr("Error: No units specified.\n"); + return CpptrajState::ERR; + } + + // Info + if (!LibSetNames.empty()) { + mprintf("\tLibrary set names:"); + for (Sarray::const_iterator it = LibSetNames.begin(); it != LibSetNames.end(); ++it) + mprintf(" %s", it->c_str()); + mprintf("\n"); + } + mprintf("\tMain sequence:"); + for (Sarray::const_iterator it = main_sequence.begin(); it != main_sequence.end(); ++it) + mprintf(" %s", it->c_str()); + mprintf("\n"); + + return CpptrajState::OK; +} diff --git a/src/Exec_Sequence.h b/src/Exec_Sequence.h new file mode 100644 index 0000000000..2c3c6cfe9a --- /dev/null +++ b/src/Exec_Sequence.h @@ -0,0 +1,14 @@ +#ifndef INC_EXEC_SEQUENCE_H +#define INC_EXEC_SEQUENCE_H +#include "Exec.h" +/// Create a molecule from 2 or more units +class Exec_Sequence : public Exec { + public: + Exec_Sequence() : Exec(GENERAL) {} + void Help() const; + DispatchObject* Alloc() const { return (DispatchObject*)new Exec_Sequence(); } + RetType Execute(CpptrajState&, ArgList&); + private: + typedef std::vector Sarray; +}; +#endif From 60b5580decad84bed751399f8405f3c5d27449e0 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 08:46:54 -0400 Subject: [PATCH 199/245] Add output set --- src/Exec_Sequence.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Exec_Sequence.cpp b/src/Exec_Sequence.cpp index 5f6ba7f5d6..7d29528be8 100644 --- a/src/Exec_Sequence.cpp +++ b/src/Exec_Sequence.cpp @@ -17,6 +17,16 @@ Exec::RetType Exec_Sequence::Execute(CpptrajState& State, ArgList& argIn) LibSetNames.push_back( libsetname ); libsetname = argIn.GetStringKey("libset"); } + std::string dsname = argIn.GetStringKey("name"); + if (dsname.empty()) { + mprinterr("Error: No output set name specified with 'name'\n"); + return CpptrajState::ERR; + } + DataSet_Coords* OUT = (DataSet_Coords*)State.DSL().AddSet(DataSet::COORDS, MetaData(dsname)); + if (OUT == 0) { + mprinterr("Error: Could not create output COORDS set named '%s'\n", dsname.c_str()); + return CpptrajState::ERR; + } // Get the actual sequence from remaining args. Sarray main_sequence; @@ -42,6 +52,7 @@ Exec::RetType Exec_Sequence::Execute(CpptrajState& State, ArgList& argIn) for (Sarray::const_iterator it = main_sequence.begin(); it != main_sequence.end(); ++it) mprintf(" %s", it->c_str()); mprintf("\n"); + mprintf("\tOutput set name : %s\n", OUT->legend()); return CpptrajState::OK; } From dc76e8dbfc98654293d84c753ddd1fad8689cf98 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 08:59:30 -0400 Subject: [PATCH 200/245] Search for units --- src/Exec_Sequence.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++ src/Exec_Sequence.h | 3 +++ 2 files changed, 54 insertions(+) diff --git a/src/Exec_Sequence.cpp b/src/Exec_Sequence.cpp index 7d29528be8..cfa9e47592 100644 --- a/src/Exec_Sequence.cpp +++ b/src/Exec_Sequence.cpp @@ -7,6 +7,57 @@ void Exec_Sequence::Help() const } +/** Generate and build the specified sequence. */ +int Exec_Sequence::generate_sequence(DataSet_Coords* OUT, + DataSetList const& DSL, + Sarray const& main_sequence, + Sarray const& LibSetNames) +const +{ + // First, get all units in order. + typedef std::vector Uarray; + Uarray Units; + Units.reserve( main_sequence.size() ); + + for (Sarray::const_iterator it = main_sequence.begin(); it != main_sequence.end(); ++it) + { + DataSet_Coords* unit = 0; + if (LibSetNames.empty()) { + // Look for name + unit = (DataSet_Coords*)DSL.FindSetOfGroup( *it, DataSet::COORDINATES ); + } else { + // Look for name[aspect] + DataSet* ds = 0; + for (Sarray::const_iterator name = LibSetNames.begin(); name != LibSetNames.end(); ++name) + { + MetaData meta(*name, *it); + ds = DSL.CheckForSet( meta ); + if (ds != 0) break; + } + if (ds != 0) { + if (ds->Group() != DataSet::COORDINATES) { + mprinterr("Error: Set '%s' is not of type Coordinates.\n", ds->legend()); + return 1; + } + unit = (DataSet_Coords*)ds; + } + } + if (unit == 0) { + mprinterr("Error: Unit '%s' not found.\n", it->c_str()); + return 1; + } + // Needs to have connect associated data + AssociatedData* ad = unit->GetAssociatedData(AssociatedData::CONNECT); + if (ad == 0) { + mprinterr("Error: Unit '%s' does not have CONNECT data.\n"); + return 1; + } + Units.push_back( unit ); + } // END loop over sequence + mprintf("\tFound %zu units.\n", Units.size()); + return 0; +} + // Exec_Sequence::Execute() Exec::RetType Exec_Sequence::Execute(CpptrajState& State, ArgList& argIn) { diff --git a/src/Exec_Sequence.h b/src/Exec_Sequence.h index 2c3c6cfe9a..e73c07258d 100644 --- a/src/Exec_Sequence.h +++ b/src/Exec_Sequence.h @@ -10,5 +10,8 @@ class Exec_Sequence : public Exec { RetType Execute(CpptrajState&, ArgList&); private: typedef std::vector Sarray; + + int generate_sequence(DataSet_Coords*, DataSetList const&, + Sarray const&, Sarray const&) const; }; #endif From 833f26530848eab39a7fc4cc50c8305cc8a26033 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 09:03:50 -0400 Subject: [PATCH 201/245] Enable the sequence command for testing --- src/Command.cpp | 2 ++ src/Exec_Sequence.cpp | 15 +++++++++------ src/Exec_Sequence.h | 4 ++-- src/cpptrajdepend | 3 ++- src/cpptrajfiles | 1 + 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Command.cpp b/src/Command.cpp index 0f92b4588b..e098f8c9bd 100644 --- a/src/Command.cpp +++ b/src/Command.cpp @@ -57,6 +57,7 @@ #include "Exec_CrdTransform.h" #include "Exec_ExtendedComparison.h" #include "Exec_Zmatrix.h" +#include "Exec_Sequence.h" // ----- TRAJECTORY ------------------------------------------------------------ #include "Exec_Traj.h" // ----- TOPOLOGY -------------------------------------------------------------- @@ -280,6 +281,7 @@ void Command::Init() { Command::AddCmd( new Exec_PermuteDihedrals(), Cmd::EXE, 1, "permutedihedrals" ); Command::AddCmd( new Exec_PrepareForLeap(), Cmd::EXE, 1, "prepareforleap" ); Command::AddCmd( new Exec_RotateDihedral(), Cmd::EXE, 1, "rotatedihedral" ); + Command::AddCmd( new Exec_Sequence(), Cmd::EXE, 1, "sequence" ); Command::AddCmd( new Exec_SplitCoords(), Cmd::EXE, 1, "splitcoords" ); Command::AddCmd( new Exec_Zmatrix(), Cmd::EXE, 1, "zmatrix" ); // TRAJECTORY diff --git a/src/Exec_Sequence.cpp b/src/Exec_Sequence.cpp index cfa9e47592..c69f12eddd 100644 --- a/src/Exec_Sequence.cpp +++ b/src/Exec_Sequence.cpp @@ -1,12 +1,6 @@ #include "Exec_Sequence.h" #include "CpptrajStdio.h" -// Exec_Sequence::Help() -void Exec_Sequence::Help() const -{ - -} - /** Generate and build the specified sequence. */ int Exec_Sequence::generate_sequence(DataSet_Coords* OUT, DataSetList const& DSL, @@ -58,6 +52,15 @@ const return 0; } +// Exec_Sequence::Help() +void Exec_Sequence::Help() const +{ + mprintf("\tname ...\n" + "\t[{libset } ...]\n" + " Create a molecule from a sequence of units.\n"); +} + + // Exec_Sequence::Execute() Exec::RetType Exec_Sequence::Execute(CpptrajState& State, ArgList& argIn) { diff --git a/src/Exec_Sequence.h b/src/Exec_Sequence.h index e73c07258d..d9f4d27ee2 100644 --- a/src/Exec_Sequence.h +++ b/src/Exec_Sequence.h @@ -1,10 +1,10 @@ #ifndef INC_EXEC_SEQUENCE_H #define INC_EXEC_SEQUENCE_H #include "Exec.h" -/// Create a molecule from 2 or more units +/// Create a molecule from a sequence of units class Exec_Sequence : public Exec { public: - Exec_Sequence() : Exec(GENERAL) {} + Exec_Sequence() : Exec(COORDS) {} void Help() const; DispatchObject* Alloc() const { return (DispatchObject*)new Exec_Sequence(); } RetType Execute(CpptrajState&, ArgList&); diff --git a/src/cpptrajdepend b/src/cpptrajdepend index ec6864933d..3411d7910f 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -186,7 +186,7 @@ ClusterMap.o : ClusterMap.cpp AssociatedData.h ClusterMap.h Constants.h CpptrajF Cmd.o : Cmd.cpp Cmd.h DispatchObject.h CmdInput.o : CmdInput.cpp CmdInput.h StringRoutines.h CmdList.o : CmdList.cpp Cmd.h CmdList.h DispatchObject.h -Command.o : Command.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h ActionTopWriter.h Action_Align.h Action_Angle.h Action_AreaPerMol.h Action_AtomMap.h Action_AtomicCorr.h Action_AtomicFluct.h Action_AutoImage.h Action_Average.h Action_AvgBox.h Action_Bounds.h Action_Box.h Action_Center.h Action_Channel.h Action_CheckChirality.h Action_CheckStructure.h Action_Closest.h Action_ClusterDihedral.h Action_Contacts.h Action_CreateCrd.h Action_CreateReservoir.h Action_DNAionTracker.h Action_DSSP.h Action_Density.h Action_Diffusion.h Action_Dihedral.h Action_DihedralRMS.h Action_Dipole.h Action_DistRmsd.h Action_Distance.h Action_Energy.h Action_Esander.h Action_FilterByData.h Action_FixAtomOrder.h Action_FixImagedBonds.h Action_GIST.h Action_Grid.h Action_GridFreeEnergy.h Action_HydrogenBond.h Action_Image.h Action_InfraredSpectrum.h Action_Jcoupling.h Action_Keep.h Action_LESsplit.h Action_LIE.h Action_LipidOrder.h Action_MakeStructure.h Action_Mask.h Action_Matrix.h Action_MinImage.h Action_Molsurf.h Action_MultiDihedral.h Action_MultiPucker.h Action_MultiVector.h Action_NAstruct.h Action_NMRrst.h Action_NativeContacts.h Action_OrderParameter.h Action_Outtraj.h Action_PairDist.h Action_Pairwise.h Action_Principal.h Action_Projection.h Action_Pucker.h Action_Radgyr.h Action_Radial.h Action_RandomizeIons.h Action_Remap.h Action_ReplicateCell.h Action_Rmsd.h Action_Rotate.h Action_RunningAvg.h Action_STFC_Diffusion.h Action_Scale.h Action_SetVelocity.h Action_Spam.h Action_Strip.h Action_Surf.h Action_SymmetricRmsd.h Action_Temperature.h Action_Time.h Action_ToroidalDiffusion.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_CalcDiffusion.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_TICA.h Analysis_Timecorr.h Analysis_VectorMath.h Analysis_Wavelet.h ArgList.h Array1D.h ArrayIterator.h AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h AxisType.h BaseIOtype.h Box.h BoxArgs.h BufferedLine.h CharMask.h Cluster/Algorithm.h Cluster/BestReps.h Cluster/CentroidArray.h Cluster/Cframes.h Cluster/Control.h Cluster/DrawGraph.h Cluster/List.h Cluster/Metric.h Cluster/MetricArray.h Cluster/Node.h Cluster/Sieve.h Cluster/Silhouette.h ClusterMap.h Cmd.h CmdInput.h CmdList.h Command.h CompactFrameArray.h ComplexArray.h Constants.h Constraints.h ControlBlock.h ControlBlock_For.h CoordinateInfo.h Corr.h Cph.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_REF.h DataSet_GridFlt.h DataSet_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 DiffusionResults.h DihedralSearch.h Dimension.h DispatchObject.h Energy.h Energy_Sander.h EnsembleIn.h EnsembleOutList.h Ewald.h EwaldOptions.h Ewald_ParticleMesh.h ExclusionArray.h Exec.h Exec_AddMissingRes.h Exec_Analyze.h Exec_Calc.h Exec_CatCrd.h Exec_Change.h Exec_ClusterMap.h Exec_CombineCoords.h Exec_Commands.h Exec_CompareClusters.h Exec_CompareEnergy.h Exec_CompareTop.h Exec_CrdAction.h Exec_CrdOut.h Exec_CrdTransform.h Exec_CreateSet.h Exec_DataFile.h Exec_DataFilter.h Exec_DataSetCmd.h Exec_Emin.h Exec_ExtendedComparison.h Exec_Flatten.h Exec_GenerateAmberRst.h Exec_Graft.h Exec_Help.h Exec_HmassRepartition.h Exec_LoadCrd.h Exec_LoadTraj.h Exec_ParallelAnalysis.h Exec_ParmBox.h Exec_ParmSolvent.h Exec_ParmStrip.h Exec_ParmWrite.h Exec_ParseTiming.h Exec_PermuteDihedrals.h Exec_Precision.h Exec_PrepareForLeap.h Exec_PrintData.h Exec_Random.h Exec_ReadData.h Exec_ReadEnsembleData.h Exec_ReadInput.h Exec_RotateDihedral.h Exec_RunAnalysis.h Exec_ScaleDihedralK.h Exec_SequenceAlign.h Exec_Set.h Exec_Show.h Exec_SortEnsembleData.h Exec_SplitCoords.h Exec_System.h Exec_Top.h Exec_Traj.h Exec_UpdateParameters.h Exec_ViewRst.h Exec_Zmatrix.h ExtendedSimilarity.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h GIST_PME.h Grid.h GridAction.h GridBin.h HistBin.h Hungarian.h ImageOption.h ImageTypes.h InputTrajCommon.h MapAtom.h MaskArray.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NC_Routines.h NameType.h NetcdfFile.h OnlineVarT.h OutputTrajCommon.h PDBfile.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h PubFFT.h Pucker.h Pucker_PuckerMask.h Pucker_PuckerSearch.h Pucker_PuckerToken.h RPNcalc.h Random.h Range.h ReferenceAction.h ReferenceFrame.h RemdReservoirNC.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h Spline.h SplineFxnTable.h StructureCheck.h SymbolExporting.h SymmetricRmsdCalc.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h cuda_kernels/GistCudaSetup.cuh helpme_standalone.h molsurf.h +Command.o : Command.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h ActionTopWriter.h Action_Align.h Action_Angle.h Action_AreaPerMol.h Action_AtomMap.h Action_AtomicCorr.h Action_AtomicFluct.h Action_AutoImage.h Action_Average.h Action_AvgBox.h Action_Bounds.h Action_Box.h Action_Center.h Action_Channel.h Action_CheckChirality.h Action_CheckStructure.h Action_Closest.h Action_ClusterDihedral.h Action_Contacts.h Action_CreateCrd.h Action_CreateReservoir.h Action_DNAionTracker.h Action_DSSP.h Action_Density.h Action_Diffusion.h Action_Dihedral.h Action_DihedralRMS.h Action_Dipole.h Action_DistRmsd.h Action_Distance.h Action_Energy.h Action_Esander.h Action_FilterByData.h Action_FixAtomOrder.h Action_FixImagedBonds.h Action_GIST.h Action_Grid.h Action_GridFreeEnergy.h Action_HydrogenBond.h Action_Image.h Action_InfraredSpectrum.h Action_Jcoupling.h Action_Keep.h Action_LESsplit.h Action_LIE.h Action_LipidOrder.h Action_MakeStructure.h Action_Mask.h Action_Matrix.h Action_MinImage.h Action_Molsurf.h Action_MultiDihedral.h Action_MultiPucker.h Action_MultiVector.h Action_NAstruct.h Action_NMRrst.h Action_NativeContacts.h Action_OrderParameter.h Action_Outtraj.h Action_PairDist.h Action_Pairwise.h Action_Principal.h Action_Projection.h Action_Pucker.h Action_Radgyr.h Action_Radial.h Action_RandomizeIons.h Action_Remap.h Action_ReplicateCell.h Action_Rmsd.h Action_Rotate.h Action_RunningAvg.h Action_STFC_Diffusion.h Action_Scale.h Action_SetVelocity.h Action_Spam.h Action_Strip.h Action_Surf.h Action_SymmetricRmsd.h Action_Temperature.h Action_Time.h Action_ToroidalDiffusion.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_CalcDiffusion.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_TICA.h Analysis_Timecorr.h Analysis_VectorMath.h Analysis_Wavelet.h ArgList.h Array1D.h ArrayIterator.h AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h AxisType.h BaseIOtype.h Box.h BoxArgs.h BufferedLine.h CharMask.h Cluster/Algorithm.h Cluster/BestReps.h Cluster/CentroidArray.h Cluster/Cframes.h Cluster/Control.h Cluster/DrawGraph.h Cluster/List.h Cluster/Metric.h Cluster/MetricArray.h Cluster/Node.h Cluster/Sieve.h Cluster/Silhouette.h ClusterMap.h Cmd.h CmdInput.h CmdList.h Command.h CompactFrameArray.h ComplexArray.h Constants.h Constraints.h ControlBlock.h ControlBlock_For.h CoordinateInfo.h Corr.h Cph.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_REF.h DataSet_GridFlt.h DataSet_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 DiffusionResults.h DihedralSearch.h Dimension.h DispatchObject.h Energy.h Energy_Sander.h EnsembleIn.h EnsembleOutList.h Ewald.h EwaldOptions.h Ewald_ParticleMesh.h ExclusionArray.h Exec.h Exec_AddMissingRes.h Exec_Analyze.h Exec_Calc.h Exec_CatCrd.h Exec_Change.h Exec_ClusterMap.h Exec_CombineCoords.h Exec_Commands.h Exec_CompareClusters.h Exec_CompareEnergy.h Exec_CompareTop.h Exec_CrdAction.h Exec_CrdOut.h Exec_CrdTransform.h Exec_CreateSet.h Exec_DataFile.h Exec_DataFilter.h Exec_DataSetCmd.h Exec_Emin.h Exec_ExtendedComparison.h Exec_Flatten.h Exec_GenerateAmberRst.h Exec_Graft.h Exec_Help.h Exec_HmassRepartition.h Exec_LoadCrd.h Exec_LoadTraj.h Exec_ParallelAnalysis.h Exec_ParmBox.h Exec_ParmSolvent.h Exec_ParmStrip.h Exec_ParmWrite.h Exec_ParseTiming.h Exec_PermuteDihedrals.h Exec_Precision.h Exec_PrepareForLeap.h Exec_PrintData.h Exec_Random.h Exec_ReadData.h Exec_ReadEnsembleData.h Exec_ReadInput.h Exec_RotateDihedral.h Exec_RunAnalysis.h Exec_ScaleDihedralK.h Exec_Sequence.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 Exec_Zmatrix.h ExtendedSimilarity.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h GIST_PME.h Grid.h GridAction.h GridBin.h HistBin.h Hungarian.h ImageOption.h ImageTypes.h InputTrajCommon.h MapAtom.h MaskArray.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NC_Routines.h NameType.h NetcdfFile.h OnlineVarT.h OutputTrajCommon.h PDBfile.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h PubFFT.h Pucker.h Pucker_PuckerMask.h Pucker_PuckerSearch.h Pucker_PuckerToken.h RPNcalc.h Random.h Range.h ReferenceAction.h ReferenceFrame.h RemdReservoirNC.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h Spline.h SplineFxnTable.h StructureCheck.h SymbolExporting.h SymmetricRmsdCalc.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h cuda_kernels/GistCudaSetup.cuh helpme_standalone.h molsurf.h CompactFrameArray.o : CompactFrameArray.cpp Box.h CompactFrameArray.h CoordinateInfo.h CpptrajStdio.h Matrix_3x3.h Parallel.h ReplicaDimArray.h Vec3.h ComplexArray.o : ComplexArray.cpp ArrayIterator.h ComplexArray.h Constraints.o : Constraints.cpp ArgList.h Atom.h AtomMask.h AtomType.h Box.h CharMask.h Constants.h Constraints.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h @@ -327,6 +327,7 @@ Exec_ReadInput.o : Exec_ReadInput.cpp Action.h ActionList.h ActionState.h Analys Exec_RotateDihedral.o : Exec_RotateDihedral.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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 DihedralSearch.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_RotateDihedral.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_RunAnalysis.o : Exec_RunAnalysis.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_RunAnalysis.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_ScaleDihedralK.o : Exec_ScaleDihedralK.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_ScaleDihedralK.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h +Exec_Sequence.o : Exec_Sequence.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_Sequence.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_SequenceAlign.o : Exec_SequenceAlign.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.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_SequenceAlign.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OutputTrajCommon.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h Exec_Set.o : Exec_Set.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_StringVar.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Set.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 Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_Show.o : Exec_Show.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_StringVar.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Show.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h diff --git a/src/cpptrajfiles b/src/cpptrajfiles index b6095972cc..2d534859fb 100644 --- a/src/cpptrajfiles +++ b/src/cpptrajfiles @@ -298,6 +298,7 @@ COMMON_SOURCES= \ Exec_RunAnalysis.cpp \ Exec_ScaleDihedralK.cpp \ Exec_Set.cpp \ + Exec_Sequence.cpp \ Exec_SequenceAlign.cpp \ Exec_Show.cpp \ Exec_SortEnsembleData.cpp \ From 5292da125f607acbb6834339a39ff10580a8d91b Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 09:24:37 -0400 Subject: [PATCH 202/245] Set up bonding atoms --- src/AssociatedData_Connect.h | 4 ++- src/Exec_Sequence.cpp | 61 ++++++++++++++++++++++++++++++++++++ src/Exec_Sequence.h | 4 ++- 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/src/AssociatedData_Connect.h b/src/AssociatedData_Connect.h index a1d062b2da..72d6036c9d 100644 --- a/src/AssociatedData_Connect.h +++ b/src/AssociatedData_Connect.h @@ -4,16 +4,18 @@ #include "AssociatedData.h" /// For holding unit connect atoms (COORDS data sets) class AssociatedData_Connect : public AssociatedData { + typedef std::vector Iarray; public: AssociatedData_Connect() : AssociatedData(CONNECT) {} static const char* HelpText; void AddConnectAtom(int at) { connect_.push_back( at ); } + unsigned int NconnectAtoms() const { return connect_.size(); } + Iarray const& Connect() const { return connect_; } AssociatedData* Copy() const { return new AssociatedData_Connect(*this); } void Ainfo() const; private: - typedef std::vector Iarray; Iarray connect_; }; #endif diff --git a/src/Exec_Sequence.cpp b/src/Exec_Sequence.cpp index c69f12eddd..8f17e572e4 100644 --- a/src/Exec_Sequence.cpp +++ b/src/Exec_Sequence.cpp @@ -1,5 +1,7 @@ #include "Exec_Sequence.h" #include "CpptrajStdio.h" +#include "AssociatedData_Connect.h" +#include "Structure/Builder.h" /** Generate and build the specified sequence. */ int Exec_Sequence::generate_sequence(DataSet_Coords* OUT, @@ -12,6 +14,11 @@ const typedef std::vector Uarray; Uarray Units; Units.reserve( main_sequence.size() ); + typedef std::vector Iarray; + Iarray bondat0, bondat1; + bondat0.reserve( Units.size() ); + bondat1.reserve( Units.size() ); + int total_natom = 0; for (Sarray::const_iterator it = main_sequence.begin(); it != main_sequence.end(); ++it) { @@ -40,15 +47,62 @@ const mprinterr("Error: Unit '%s' not found.\n", it->c_str()); return 1; } + if (unit->Size() < 1) { + mprinterr("Error: Unit '%s' is empty.\n", unit->legend()); + return 1; + } + if (unit->Size() > 1) { + mprintf("Warning: Unit '%s' has more than 1 frame. Only using first frame.\n", unit->legend()); + } // Needs to have connect associated data AssociatedData* ad = unit->GetAssociatedData(AssociatedData::CONNECT); if (ad == 0) { mprinterr("Error: Unit '%s' does not have CONNECT data.\n"); return 1; } + AssociatedData_Connect const& C = static_cast( *ad ); + if (C.NconnectAtoms() < 2) { + mprinterr("Error: Not enough connect atoms in unit '%s'\n", unit->legend()); + return 1; + } + // Set up connectivity. The HEAD atom of this unit will connect to the + // TAIL atom of the previous unit. + if (Units.empty()) { + bondat0.push_back( C.Connect()[0] ); + bondat1.push_back( C.Connect()[1] ); + } else { + bondat0.push_back( bondat1.back() ); + bondat1.push_back( C.Connect()[0] + total_natom ); + } Units.push_back( unit ); + total_natom += unit->Top().Natom(); } // END loop over sequence mprintf("\tFound %zu units.\n", Units.size()); + if (Units.empty()) { + mprinterr("Error: No units.\n"); + return 1; + } + if (Units.size() > 1) { + for (unsigned int idx = 1; idx < Units.size(); idx++) + mprintf("\tConnect %s atom %i to %s atom %i\n", + Units[idx-1]->legend(), bondat0[idx]+1, + Units[idx]->legend(), bondat1[idx]+1); + } + + Topology combinedTop; + combinedTop.SetDebug( debug_ ); + combinedTop.SetParmName( OUT->Meta().Name(), FileName() ); + combinedTop.AppendTop( Units.front()->Top() ); + //combinedTop.SetParmBox( Units // TODO + combinedTop.Brief("Sequence topology:"); + + Frame CombinedFrame = Units.front()->AllocateFrame(); + Units.front()->GetFrame(0, CombinedFrame); + + + using namespace Cpptraj::Structure; + Builder builder; + return 0; } @@ -64,6 +118,7 @@ void Exec_Sequence::Help() const // Exec_Sequence::Execute() Exec::RetType Exec_Sequence::Execute(CpptrajState& State, ArgList& argIn) { + debug_ = State.Debug(); // Args Sarray LibSetNames; std::string libsetname = argIn.GetStringKey("libset"); @@ -108,5 +163,11 @@ Exec::RetType Exec_Sequence::Execute(CpptrajState& State, ArgList& argIn) mprintf("\n"); mprintf("\tOutput set name : %s\n", OUT->legend()); + // Execute + if (generate_sequence(OUT, State.DSL(), main_sequence, LibSetNames)) { + mprinterr("Error: Could not generate sequence.\n"); + return CpptrajState::ERR; + } + return CpptrajState::OK; } diff --git a/src/Exec_Sequence.h b/src/Exec_Sequence.h index d9f4d27ee2..148cf4e1af 100644 --- a/src/Exec_Sequence.h +++ b/src/Exec_Sequence.h @@ -4,7 +4,7 @@ /// Create a molecule from a sequence of units class Exec_Sequence : public Exec { public: - Exec_Sequence() : Exec(COORDS) {} + Exec_Sequence() : Exec(COORDS), debug_(0) {} void Help() const; DispatchObject* Alloc() const { return (DispatchObject*)new Exec_Sequence(); } RetType Execute(CpptrajState&, ArgList&); @@ -13,5 +13,7 @@ class Exec_Sequence : public Exec { int generate_sequence(DataSet_Coords*, DataSetList const&, Sarray const&, Sarray const&) const; + + int debug_; }; #endif From 1f772ee119615f669b2f5067ce23dc52f0ba4182 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 09:36:38 -0400 Subject: [PATCH 203/245] Fix use of connect atoms --- src/Exec_Sequence.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Exec_Sequence.cpp b/src/Exec_Sequence.cpp index 8f17e572e4..07a124cf5e 100644 --- a/src/Exec_Sequence.cpp +++ b/src/Exec_Sequence.cpp @@ -15,9 +15,9 @@ const Uarray Units; Units.reserve( main_sequence.size() ); typedef std::vector Iarray; - Iarray bondat0, bondat1; - bondat0.reserve( Units.size() ); - bondat1.reserve( Units.size() ); + Iarray connectAt0, connectAt1; + connectAt0.reserve( Units.size() ); + connectAt1.reserve( Units.size() ); int total_natom = 0; for (Sarray::const_iterator it = main_sequence.begin(); it != main_sequence.end(); ++it) @@ -65,15 +65,9 @@ const mprinterr("Error: Not enough connect atoms in unit '%s'\n", unit->legend()); return 1; } - // Set up connectivity. The HEAD atom of this unit will connect to the - // TAIL atom of the previous unit. - if (Units.empty()) { - bondat0.push_back( C.Connect()[0] ); - bondat1.push_back( C.Connect()[1] ); - } else { - bondat0.push_back( bondat1.back() ); - bondat1.push_back( C.Connect()[0] + total_natom ); - } + // Update connect atom indices based on their position in the sequence. + connectAt0.push_back( C.Connect()[0] + total_natom ); + connectAt1.push_back( C.Connect()[1] + total_natom ); Units.push_back( unit ); total_natom += unit->Top().Natom(); } // END loop over sequence @@ -82,11 +76,13 @@ const mprinterr("Error: No units.\n"); return 1; } + for (unsigned int idx = 0; idx < Units.size(); idx++) + mprintf("\tUnit %s HEAD %i TAIL %i\n", Units[idx]->legend(), connectAt0[idx]+1, connectAt1[idx]+1); if (Units.size() > 1) { for (unsigned int idx = 1; idx < Units.size(); idx++) mprintf("\tConnect %s atom %i to %s atom %i\n", - Units[idx-1]->legend(), bondat0[idx]+1, - Units[idx]->legend(), bondat1[idx]+1); + Units[idx-1]->legend(), connectAt1[idx-1]+1, + Units[idx]->legend(), connectAt0[idx] +1); } Topology combinedTop; From 9ec233c2224b012a3c09fb20ea7e2f3ad1e673a0 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 09:49:37 -0400 Subject: [PATCH 204/245] Update connect 1 indices, not connect 0 indices. Do the combining into final unit. --- src/Exec_Sequence.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/Exec_Sequence.cpp b/src/Exec_Sequence.cpp index 07a124cf5e..ad302bc3c1 100644 --- a/src/Exec_Sequence.cpp +++ b/src/Exec_Sequence.cpp @@ -65,8 +65,9 @@ const mprinterr("Error: Not enough connect atoms in unit '%s'\n", unit->legend()); return 1; } - // Update connect atom indices based on their position in the sequence. - connectAt0.push_back( C.Connect()[0] + total_natom ); + // Update connect atom 1 indices based on their position in the sequence. + // Do not update connect atom 0 indices since they will not yet be connected. + connectAt0.push_back( C.Connect()[0] ); connectAt1.push_back( C.Connect()[1] + total_natom ); Units.push_back( unit ); total_natom += unit->Top().Natom(); @@ -78,12 +79,6 @@ const } for (unsigned int idx = 0; idx < Units.size(); idx++) mprintf("\tUnit %s HEAD %i TAIL %i\n", Units[idx]->legend(), connectAt0[idx]+1, connectAt1[idx]+1); - if (Units.size() > 1) { - for (unsigned int idx = 1; idx < Units.size(); idx++) - mprintf("\tConnect %s atom %i to %s atom %i\n", - Units[idx-1]->legend(), connectAt1[idx-1]+1, - Units[idx]->legend(), connectAt0[idx] +1); - } Topology combinedTop; combinedTop.SetDebug( debug_ ); @@ -98,7 +93,23 @@ const using namespace Cpptraj::Structure; Builder builder; - + for (unsigned int idx = 1; idx < Units.size(); idx++) { + mprintf("\tConnect %s atom %i to %s atom %i\n", + Units[idx-1]->legend(), connectAt1[idx-1]+1, + Units[idx]->legend(), connectAt0[idx] +1); + Frame mol1frm = Units[idx]->AllocateFrame(); + Units[idx]->GetFrame(0, mol1frm); + if (builder.Combine( combinedTop, CombinedFrame, Units[idx]->Top(), mol1frm, + connectAt1[idx-1], connectAt0[idx] )) { + mprinterr("Error: Sequence combine between units %u %s and %u %s failed.\n", + idx, Units[idx-1]->legend(), idx+1, Units[idx]->legend()); + return 1; + } + } + + OUT->CoordsSetup(combinedTop, CombinedFrame.CoordsInfo()); + OUT->AddFrame( CombinedFrame ); + return 0; } From 79699ae8ed2af01cbe701bef13fc3f8ef40e921a Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 13:27:39 -0400 Subject: [PATCH 205/245] Hide some debug info --- src/DataIO_AmberLib.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/DataIO_AmberLib.cpp b/src/DataIO_AmberLib.cpp index 343269a6ed..78988fe3e6 100644 --- a/src/DataIO_AmberLib.cpp +++ b/src/DataIO_AmberLib.cpp @@ -60,10 +60,10 @@ int DataIO_AmberLib::ReadData(FileName const& fname, DataSetList& dsl, std::stri line = infile.GetLine(); } // Now should be at first unit - mprintf("DEBUG: Units:\n"); + if (debug_ > 0) mprintf("DEBUG: Units:\n"); for (Sarray::const_iterator it = UnitNames.begin(); it != UnitNames.end(); ++it) { - mprintf("DEBUG: Reading unit %s\n", it->c_str()); + if (debug_ > 0) mprintf("DEBUG: Reading unit %s\n", it->c_str()); std::string entryColumn = "!entry." + *it + ".unit.atoms"; ArgList tmparg( line ); if (tmparg.Nargs() < 1 || tmparg[0] != entryColumn) { @@ -80,7 +80,7 @@ int DataIO_AmberLib::ReadData(FileName const& fname, DataSetList& dsl, std::stri return 1; } } - + mprintf("\tRead %zu units from Amber OFF file.\n", UnitNames.size()); return 0; } @@ -109,6 +109,7 @@ DataIO_AmberLib::SectionType DataIO_AmberLib::id_section(std::string const& line return UNKNOWN_SECTION; } +/// Remove quotes from string static inline std::string noquotes(const char* ptrIn) { std::string out; for (const char* ptr = ptrIn; *ptr != '\0'; ++ptr) @@ -117,6 +118,7 @@ static inline std::string noquotes(const char* ptrIn) { return out; } +/** Read atoms line */ int DataIO_AmberLib::read_atoms(Topology& topOut, std::string const& line, std::string const& unitName) { // Format: "Atom name" "Type" "Type index (unused)" "resnum" "flags" "sequence" "element" "charge" char aname[16]; @@ -150,19 +152,19 @@ int DataIO_AmberLib::read_atoms(Topology& topOut, std::string const& line, std:: return 0; } +/** Read positions line. */ int DataIO_AmberLib::read_positions(std::vector& positions, std::string const& line) { double x, y, z; - mprintf("DEBUG Positions %s\n", line.c_str()); if (sscanf(line.c_str(), "%lf %lf %lf", &x, &y, &z) != 3) { mprinterr("Error: Expected 3 columns for positions line: %s\n", line.c_str()); return 1; } - mprintf("DEBUG: %g %g %g\n", x, y, z); positions.push_back( Vec3(x, y, z) ); return 0; } +/** Read bonds line */ int DataIO_AmberLib::read_bonds(Topology& topOut, std::string const& line) { int at0, at1, flags; if (sscanf(line.c_str(), "%i %i %i", &at0, &at1, &flags) != 3) { @@ -173,6 +175,7 @@ int DataIO_AmberLib::read_bonds(Topology& topOut, std::string const& line) { return 0; } +/** Read connections line */ int DataIO_AmberLib::read_connect(AssociatedData_Connect& ConnectAtoms, std::string const& line) { int connectAtom = -1; if (sscanf(line.c_str(), "%i", &connectAtom) != 1) { @@ -188,7 +191,6 @@ int DataIO_AmberLib::read_connect(AssociatedData_Connect& ConnectAtoms, std::str return 0; } - /** Read a unit from OFF file. It is expected that the next line from * infile is the first entry in the unit.atoms table. */ @@ -203,7 +205,7 @@ const mprinterr("Error: Could not ID first section: %s\n", Line.c_str()); return 1; } - mprintf("DEBUG: First section is %s\n", sectionStr_[currentSection]); + if (debug_ > 1) mprintf("DEBUG: First section is %s\n", sectionStr_[currentSection]); Topology top; top.SetParmName( unitName, FileName() ); @@ -219,7 +221,7 @@ const } Line.assign(lineptr); if (!Line.empty()) { - mprintf("DEBUG: Line: %s\n", Line.c_str()); + if (debug_ > 2) mprintf("DEBUG: Line: %s\n", Line.c_str()); //ArgList cols( Line, " \t\n" ); if (Line[0] == '!') { // See if we are at another unit @@ -231,8 +233,9 @@ const currentSection = id_section( Line, unitName ); if (currentSection == UNKNOWN_SECTION) { mprintf("Warning: Could not ID section: %s\n", Line.c_str()); - } else - mprintf("DEBUG: Section is %s\n", sectionStr_[currentSection]); + } else { + if (debug_ > 1) mprintf("DEBUG: Section is %s\n", sectionStr_[currentSection]); + } } else if (currentSection == ATOMTABLE) { if (read_atoms(top, Line, unitName)) return 1; } else if (currentSection == CONNECTIVITY) { @@ -245,7 +248,7 @@ const } } top.CommonSetup(); - top.Summary(); + if (debug_ > 1) top.Summary(); frm.SetupFrameV( top.Atoms(), CoordinateInfo() ); frm.ClearAtoms(); for (std::vector::const_iterator it = positions.begin(); it != positions.end(); ++it) @@ -254,7 +257,7 @@ const crd->CoordsSetup(top, frm.CoordsInfo()); crd->AddFrame( frm ); crd->AssociateData( &ConnectAtoms ); - ConnectAtoms.Ainfo(); + if (debug_ > 1) ConnectAtoms.Ainfo(); mprintf("\n"); return 0; From d2c05b6c3c5d203aa8707b81d525540a55fe7d3f Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 13:40:34 -0400 Subject: [PATCH 206/245] Remove old code --- src/Structure/Zmatrix.cpp | 340 +------------------------------------- src/Structure/Zmatrix.h | 2 - 2 files changed, 3 insertions(+), 339 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 3a421ae760..77d4151267 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -77,6 +77,7 @@ int Zmatrix::AddIC(InternalCoords const& ic) { return 0; } +/** Set IC at specified position. */ // TODO check if seed? void Zmatrix::SetIC(unsigned int idx, InternalCoords const& ic) { IC_[idx] = ic; } @@ -119,116 +120,6 @@ void Zmatrix::print(Topology* topIn) const { } } -// ------------------------------------- -/// For bonded atoms, hold atom index, atom number, and # bonds. -/** Used to determine atom priority when looking for torsions to - * base ICs off of. - */ -/*class AtnumNbonds { - public: - /// CONSTRUCTOR - AtnumNbonds() : idx_(-1), priority_(-1), nbonds_(-1) {} - /// CONSTRUCTOR - AtnumNbonds(int idx, Atom const& atm) : - idx_(idx), priority_(mainChainPriority(atm)), nbonds_(atm.Nbonds()) {} - /// Sort by priority, # bonds, atom index - bool operator<(const AtnumNbonds& rhs) const { - if (idx_ < 0) return false; - if (priority_ == rhs.priority_) { - if (nbonds_ == rhs.nbonds_) { - return (idx_ < rhs.idx_); - } else { - return (nbonds_ < rhs.nbonds_); - } - } else { - return (priority_ < rhs.priority_); - } - } - int Idx() const { return idx_; } - int Priority() const { return priority_; } - int Nbonds() const { return nbonds_; } - private: - /// Set priority based on how likely this is to be a main chain atom. - static int mainChainPriority(Atom const& atm) { - switch(atm.Element()) { - case Atom::CARBON : return 0; // highest priority - case Atom::NITROGEN : - case Atom::BORON : - case Atom::PHOSPHORUS : return 1; - case Atom::OXYGEN : - case Atom::SULFUR : return 2; - // These atoms form only 1 bond and have lowest priority - case Atom::HYDROGEN : - case Atom::FLUORINE : - case Atom::CHLORINE : - case Atom::BROMINE : - case Atom::LITHIUM : return 4; - default : return 3; // 1 bond priority - 1 - } - return 5; // should never get here - } - - int idx_; ///< Atom index - int priority_; ///< Likelyhood of begin a main chain atom (0 most likely) - int nbonds_; ///< Number of bonded atoms -}; - -/// Get bonded atom priorities -static std::set getBondedAtomPriorities(int seed0, Topology const& topIn, int ignoreIdx0, int ignoreIdx1) { - std::set bondedAtoms; - for (Atom::bond_iterator bat = topIn[seed0].bondbegin(); - bat != topIn[seed0].bondend(); ++bat) - { - if (*bat != ignoreIdx0 && *bat != ignoreIdx1) - bondedAtoms.insert( AtnumNbonds(*bat, topIn[*bat]) ); - } - for (std::set::const_iterator it = bondedAtoms.begin(); it != bondedAtoms.end(); ++it) - mprintf("DEBUG: Atom %s bonded atom %s idx=%i priority= %i nbonds=%i\n", - topIn.AtomMaskName(seed0).c_str(), - topIn.AtomMaskName(it->Idx()).c_str(), - it->Idx(), it->Priority(), it->Nbonds()); - return bondedAtoms; -} - -/// \return Index of atom at front of the set (highest priority). -static inline int FrontIdx(std::set const& in) { - std::set::const_iterator it = in.begin(); - return it->Idx(); -} - -/// \return Index of first atom that isSet (has coords), or atom at front of the set (highest priority). -static inline int FirstOrFrontIdx(std::set const& in, std::vector const& isSet) -{ - if (in.empty()) return -1; - int firstIdx = FrontIdx( in ); - int firstSetIdx = -1; - if (in.size() == 1) - firstSetIdx = firstIdx; - else { - for (std::set::const_iterator it = in.begin(); - it != in.end(); ++it) - { - if (isSet[it->Idx()]) { - firstSetIdx = it->Idx(); - break; - } - } - } - mprintf("DEBUG: First idx= %i First set idx= %i\n", firstIdx, firstSetIdx); - if (firstSetIdx > -1) - return firstSetIdx; - return firstIdx; -}*/ -// ------------------------------------- - -/** \return True if all IC seeds are set. */ -/*bool Zmatrix::HasICSeeds() const { - bool has_ic_seed = (icseed0_ != InternalCoords::NO_ATOM && - icseed1_ != InternalCoords::NO_ATOM && - icseed2_ != InternalCoords::NO_ATOM ); - return has_ic_seed; -}*/ - /** \return True if all Cartesian seeds are set. */ bool Zmatrix::HasCartSeeds() const { bool has_cart_seed = (seedAt0_ != InternalCoords::NO_ATOM && @@ -380,76 +271,7 @@ int Zmatrix::autoSetSeeds_simple(Frame const& frameIn, Topology const& topIn, Mo return 0; } -/** Given a first seed, automatically determine remaining 2 seeds. - * Set all seed indices and positions. - */ -/* -int Zmatrix::autoSetSeeds(Frame const& frameIn, Topology const& topIn, unsigned int maxnatom, int firstSeed) -{ - int at0 = firstSeed; - if (maxnatom < 2) { - seedAt0_ = at0; - seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); - return 0; - } - // Choose second seed atom as bonded atom with lowest index. Prefer heavy - // atoms and atoms with more than 1 bond. - std::set bondedTo0 = getBondedAtomPriorities(at0, topIn, -1, -1); - if (bondedTo0.empty()) { - mprinterr("Internal Error: Zmatrix::SetFromFrame(): could not get second seed atom.\n"); - return 1; - } - int at1 = FrontIdx( bondedTo0 ); - if (maxnatom < 3) { - seedAt1_ = at1; - seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); - return 0; - } - // The third seed atom will either be bonded to seed 0 or seed 1. - AtnumNbonds potential2From0, potential2From1; - std::set bondedTo1 = getBondedAtomPriorities(at1, topIn, at0, -1); - if (!bondedTo1.empty()) { - std::set::const_iterator it = bondedTo1.begin(); - potential2From1 = *it; - } - if (bondedTo0.size() >= 2) { - std::set::const_iterator it = bondedTo0.begin(); - ++it; - potential2From0 = *it; - } - if (potential2From0 < potential2From1) { - mprintf("DEBUG: 2 - 0 - 1\n"); - seedAt0_ = potential2From0.Idx(); - seedAt1_ = at0; - seedAt2_ = at1; - // D0 D1 D2 A2 - //addIc(at2, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); - // D1 D2 A2 A0 - //addIc(at0, at2, DUMMY2, DUMMY1, frameIn.XYZ(at0), frameIn.XYZ(at2), seed2Pos_.Dptr(), seed1Pos_.Dptr()); - // D2 A2 A0 A1 - //addIc(at1, at0, at2, DUMMY2, frameIn.XYZ(at1), frameIn.XYZ(at0), frameIn.XYZ(at2), seed2Pos_.Dptr()); - } else { - mprintf("DEBUG: 0 - 1 - 2\n"); - seedAt0_ = at0; - seedAt1_ = at1; - seedAt2_ = potential2From1.Idx(); - // D0 D1 D2 A0 - //addIc(at0, DUMMY2, DUMMY1, DUMMY0, frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr(), seed0Pos_.Dptr()); - // D1 D2 A0 A1 - //addIc(at1, at0, DUMMY2, DUMMY1, frameIn.XYZ(at1), frameIn.XYZ(at0), seed2Pos_.Dptr(), seed1Pos_.Dptr()); - // D2 A0 A1 A2 - //addIc(at2, at1, at0, DUMMY2, frameIn.XYZ(at2), frameIn.XYZ(at1), frameIn.XYZ(at0), seed2Pos_.Dptr()); - } - mprintf("DEBUG: Seed atoms: %s - %s - %s\n", - topIn.AtomMaskName(seedAt0_).c_str(), - topIn.AtomMaskName(seedAt1_).c_str(), - topIn.AtomMaskName(seedAt2_).c_str()); - seed0Pos_ = Vec3(frameIn.XYZ(seedAt0_)); - seed1Pos_ = Vec3(frameIn.XYZ(seedAt1_)); - seed2Pos_ = Vec3(frameIn.XYZ(seedAt2_)); - return 0; -}*/ - +/// For DEBUG, print integer array static inline void printIarray(std::vector const& arr, const char* desc, Topology const& topIn) { mprintf("DEBUG:\t\t%s:", desc); for (std::vector::const_iterator it = arr.begin(); it != arr.end(); ++it) @@ -705,114 +527,6 @@ int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn) { int Zmatrix::SetFromFrame(Frame const& frameIn, Topology const& topIn, int molnum) { return SetFromFrame_Trace(frameIn, topIn, molnum); -/* - if (molnum < 0) { - mprinterr("Internal Error: Zmatrix::SetFromFrame(): Negative molecule index.\n"); - return 1; - } - if (topIn.Nmol() < 1) { - mprinterr("Internal Error: Zmatrix::SetFromFrame(): No molecules.\n"); - return 1; - } - IC_.clear(); - Molecule const& currentMol = topIn.Mol(molnum); - // Flatten the molecule array - Iarray atomIndices; - atomIndices.reserve( currentMol.NumAtoms() ); - for (Unit::const_iterator seg = currentMol.MolUnit().segBegin(); - seg != currentMol.MolUnit().segEnd(); ++seg) - for (int idx = seg->Begin(); idx != seg->End(); ++idx) - atomIndices.push_back( idx ); - unsigned int maxnatom = atomIndices.size(); - - // Keep track of which atoms are associated with an internal coordinate - Barray hasIC( topIn.Natom(), false ); - unsigned int nHasIC = 0; - - // See if we need to assign seed atoms - if (!HasCartSeeds()) { - // First seed atom will just be first atom TODO lowest index heavy atom? - if (autoSetSeeds(frameIn, topIn, maxnatom, atomIndices.front())) { - mprinterr("Error: Could not automatically determine seed atoms.\n"); - return 1; - } - - } else { - // Seed atoms already set - mprintf("DEBUG: Cartesian Seed indices: %s %s %s\n", - topIn.AtomMaskName(seedAt0_).c_str(), - topIn.AtomMaskName(seedAt1_).c_str(), - topIn.AtomMaskName(seedAt2_).c_str()); - } - // If there are less than 4 atoms we are done - if (maxnatom < 4) return 0; - // Seeds are already done - MARK(seedAt0_, hasIC, nHasIC); - MARK(seedAt1_, hasIC, nHasIC); - MARK(seedAt2_, hasIC, nHasIC); - // Do the remaining atoms. - // Find the lowest unset atom. - unsigned int lowestUnsetIdx = 0; - for (; lowestUnsetIdx < maxnatom; ++lowestUnsetIdx) - if (!hasIC[atomIndices[lowestUnsetIdx]]) break; - mprintf("DEBUG: Lowest unset atom %i at index %u\n", atomIndices[lowestUnsetIdx]+1, lowestUnsetIdx); - - // Loop over remaining atoms - while (nHasIC < maxnatom) { - // Find the next atom that is not yet set. - unsigned int idx = lowestUnsetIdx; - bool findNextAtom = true; - int ai = -1; - int aj = -1; - int ak = -1; - int al = -1; - while (findNextAtom) { - while (idx < maxnatom && hasIC[atomIndices[idx]]) idx++; - if (idx >= maxnatom) { - mprinterr("Error: Could not find next atom to set.\n"); - return 1; - } - ai = atomIndices[idx]; - mprintf("DEBUG:\tAttempting to set atom i %i\n", ai+1); - // Determine j k and l indices. Prefer atoms that have already been set. - std::set bondedAtomsI = getBondedAtomPriorities(ai, topIn, -1, -1); - aj = FirstOrFrontIdx( bondedAtomsI, hasIC ); - mprintf("DEBUG:\t\tAtom j = %i\n", aj+1); - std::set bondedAtomsJ = getBondedAtomPriorities(aj, topIn, ai, -1); // TODO reuse bondedAtomsI? - ak = FirstOrFrontIdx( bondedAtomsJ, hasIC ); - mprintf("DEBUG:\t\tAtom k = %i\n", ak+1); - // FIXME check for cycle here? - std::set bondedAtomsK = getBondedAtomPriorities(ak, topIn, aj, ai); // TODO reuse bondedAtomsI? - al = FirstOrFrontIdx( bondedAtomsK, hasIC ); - mprintf("DEBUG:\t\tAtom l = %i\n", al+1); - if (aj < 0 || ak < 0 || al < 0) { - //mprinterr("Internal Error: Could not find torsion for atom %i %s\n", ai+1, topIn.AtomMaskName(ai).c_str()); - //return 1; - mprintf("Warning: Could not find torsion for atom %i %s\n", ai+1, topIn.AtomMaskName(ai).c_str()); - mprintf("Warning: Creating pseudo torsion using seed atoms.\n"); - aj = seedAt2_; - ak = seedAt1_; - al = seedAt0_; - // TODO mark such torsions as problematic in InternalCoords? - } - // All 3 of the connecting atoms must be set - if (hasIC[aj] && hasIC[ak] && hasIC[al]) { - findNextAtom = false; - } else - idx++; - } // END loop over findNextAtom - // Create IC for i j k l - addIc(ai, aj, ak, al, frameIn.XYZ(ai), frameIn.XYZ(aj), frameIn.XYZ(ak), frameIn.XYZ(al)); - MARK(ai, hasIC, nHasIC); - - // Next lowest unset atom - for (; lowestUnsetIdx < maxnatom; ++lowestUnsetIdx) - if (!hasIC[atomIndices[lowestUnsetIdx]]) break; - - //break; //DEBUG - } // END loop over remaining atoms - - return 0;*/ } /** Given two bonded atoms A and B, where B has a depth of at least 2 @@ -828,15 +542,6 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology mprintf("DEBUG: SetFromFrameAroundBond: atA= %s (%i) atB= %s (%i)\n", topIn.AtomMaskName(atA).c_str(), atA+1, topIn.AtomMaskName(atB).c_str(), atB+1); -/* mprintf("DEBUG: Atoms:\n"); - for (int at = 0; at != topIn.Natom(); ++at) - mprintf("DEBUG:\t\t%s (%i) %s\n", topIn.AtomMaskName(at).c_str(), (int)atomPositionKnown[at], chiralStr(atomChirality[at])); - // Sanity check. A and B must be bonded - if (!topIn[atA].IsBondedTo(atB)) { - mprinterr("Internal Error: SetFromFrameAroundBond(): Atoms %s and %s are not bonded.\n", - topIn.AtomMaskName(atA).c_str(), topIn.AtomMaskName(atB).c_str()); - return 1; - }*/ IC_.clear(); Barray hasIC( topIn.Natom(), false ); @@ -979,12 +684,10 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology return 1; } else { // 3 or more bonds - //double tors; - std::vector const& priority = AtomA.Priority(); //( AJ1.Nbonds() ); + std::vector const& priority = AtomA.Priority(); int at0 = -1; int at1 = -1; std::vector remainingAtoms; - //DetermineChirality(tors, &priority[0], atA, topIn, frameIn, 0); // FIXME debug level mprintf("DEBUG: %i bonds to %s\n", AJ1.Nbonds(), topIn.AtomMaskName(atA).c_str()); for (std::vector::const_iterator it = priority.begin(); it != priority.end(); ++it) { if (*it != atB) { @@ -1011,12 +714,6 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology } } - // Add the rest - //for (unsigned int idx = 0; idx < ToTrace.size(); idx += 3) { - // if (traceMol(ToTrace[idx], ToTrace[idx+1], ToTrace[idx+2], frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) - // return 1; - // } - return 0; } @@ -1166,37 +863,6 @@ int Zmatrix::SetToFrame(Frame& frameOut, Barray& hasPosition) const { InternalCoords const& ic = IC_[idx]; Vec3 posI = AtomIposition(ic, frameOut); -/* - double rdist = ic.Dist(); - double theta = ic.Theta(); - double phi = ic.Phi(); - - double sinTheta = sin(theta * Constants::DEGRAD); - double cosTheta = cos(theta * Constants::DEGRAD); - double sinPhi = sin(phi * Constants::DEGRAD); - double cosPhi = cos(phi * Constants::DEGRAD); - - // NOTE: Want -x - Vec3 xyz( -(rdist * cosTheta), - rdist * cosPhi * sinTheta, - rdist * sinPhi * sinTheta ); - - Vec3 posL = Vec3( frameOut.XYZ( ic.AtL()) ); - Vec3 posK = Vec3( frameOut.XYZ( ic.AtK()) ); - Vec3 posJ = Vec3( frameOut.XYZ( ic.AtJ()) ); - - Vec3 LK = posK - posL; - Vec3 KJ = posJ - posK; - KJ.Normalize(); - Vec3 Norm = LK.Cross(KJ); - Norm.Normalize(); - Vec3 NxKJ = Norm.Cross(KJ); - - Matrix_3x3 Rot( KJ[0], NxKJ[0], Norm[0], - KJ[1], NxKJ[1], Norm[1], - KJ[2], NxKJ[2], Norm[2] ); - - Vec3 posI = (Rot * xyz) + posJ;*/ frameOut.SetXYZ( ic.AtI(), posI ); hasPosition[ ic.AtI() ] = true; diff --git a/src/Structure/Zmatrix.h b/src/Structure/Zmatrix.h index 64fec8306b..d778e34145 100644 --- a/src/Structure/Zmatrix.h +++ b/src/Structure/Zmatrix.h @@ -69,8 +69,6 @@ class Zmatrix { typedef std::vector Iarray; /// Simple version of auto set seeds based on connectivity only int autoSetSeeds_simple(Frame const&, Topology const&, Molecule const&); - /// Automatically set seeds -// int autoSetSeeds(Frame const&, Topology const&, unsigned int, int); /// Calculate and add an internal coordinate given indices and Cartesian coords. void addIc(int,int,int,int,const double*,const double*,const double*,const double*); /// Add internal coordiantes by tracing a molecule From 092b9dd25ccbc0a26630e5511434d5834f15a702 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 13:53:06 -0400 Subject: [PATCH 207/245] Hide debug info --- src/Structure/Builder.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index 1b1ebcbce8..f09672c871 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -54,18 +54,26 @@ int Builder::Combine(Topology& frag0Top, Frame& frag0frm, Frame& CombinedFrame = frag0frm; delete[] tmpcrd0; + int chiralityDebug; + if (debug_ < 1) + chiralityDebug = 0; + else + chiralityDebug = debug_ - 1; // Get the chirality around each atom before the bond is added. BuildAtom AtomA; if (combinedTop[atA].Nbonds() > 2) - AtomA.SetChirality( DetermineChirality(atA, combinedTop, CombinedFrame, 0) ); - mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(atA).c_str(), chiralStr(AtomA.Chirality())); + AtomA.SetChirality( DetermineChirality(atA, combinedTop, CombinedFrame, chiralityDebug) ); + if (debug_ > 0) + mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(atA).c_str(), chiralStr(AtomA.Chirality())); BuildAtom AtomB; if (combinedTop[atB].Nbonds() > 2) - AtomB.SetChirality( DetermineChirality(atB, combinedTop, CombinedFrame, 0) ); - mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(atB).c_str(), chiralStr(AtomB.Chirality())); + AtomB.SetChirality( DetermineChirality(atB, combinedTop, CombinedFrame, chiralityDebug) ); + if (debug_ > 0) + mprintf("DEBUG:\tAtom %4s chirality %6s\n", combinedTop.AtomMaskName(atB).c_str(), chiralStr(AtomB.Chirality())); // Create the bond - mprintf("DEBUG: Bonding atom %s to %s\n", combinedTop.AtomMaskName(atA).c_str(), combinedTop.AtomMaskName(atB).c_str()); + if (debug_ > 0) + mprintf("DEBUG: Bonding atom %s to %s\n", combinedTop.AtomMaskName(atA).c_str(), combinedTop.AtomMaskName(atB).c_str()); combinedTop.AddBond( atA, atB ); // TODO pseudo-parameter? // // Regenerate the molecule info FIXME should Topology just do this? if (combinedTop.DetermineMolecules()) return 1; @@ -73,17 +81,17 @@ int Builder::Combine(Topology& frag0Top, Frame& frag0frm, // Determine priorities if (combinedTop[atA].Nbonds() > 2) { //AtomA.SetNbonds(combinedTop[atA].Nbonds()); - SetPriority(AtomA.ModifyPriority(), atA, combinedTop, CombinedFrame, 0); + SetPriority(AtomA.ModifyPriority(), atA, combinedTop, CombinedFrame, chiralityDebug); } if (combinedTop[atB].Nbonds() > 2) { //AtomB.SetNbonds(combinedTop[atB].Nbonds()); - SetPriority(AtomB.ModifyPriority(), atB, combinedTop, CombinedFrame, 0); + SetPriority(AtomB.ModifyPriority(), atB, combinedTop, CombinedFrame, chiralityDebug); } // Generate Zmatrix only for ICs involving bonded atoms Zmatrix bondZmatrix; - bondZmatrix.SetDebug( 2 ); // FIXME + bondZmatrix.SetDebug( debug_ ); if (bondZmatrix.SetupICsAroundBond(atA, atB, CombinedFrame, combinedTop, posKnown, AtomA, AtomB)) { mprinterr("Error: Zmatrix setup for ICs around %s and %s failed.\n", combinedTop.AtomMaskName(atA).c_str(), From 4882b9980d7489a0d7bee7afe62311c00c1b8ba7 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 13:53:12 -0400 Subject: [PATCH 208/245] Start hiding debug info --- src/Structure/Zmatrix.cpp | 77 +++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 77d4151267..c607022cb9 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -331,7 +331,7 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, // Create ICs for 1 bond atoms for (Iarray::const_iterator atI = OneBondAtoms.begin(); atI != OneBondAtoms.end(); ++atI) { addIc(*atI, atJ, atK, atL, frameIn.XYZ(*atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); - mprintf("DEBUG: Added (1 atom) "); + if (debug_ > 1) mprintf("DEBUG: Added (1 atom) "); IC_.back().printIC(topIn); MARK(*atI, hasIC, nHasIC); } @@ -356,7 +356,7 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, } if (!hasIC[p.ai_]) { addIc(p.ai_, p.aj_, p.ak_, p.al_, frameIn.XYZ(p.ai_), frameIn.XYZ(p.aj_), frameIn.XYZ(p.ak_), frameIn.XYZ(p.al_)); - mprintf("DEBUG: Added (stack) "); + if (debug_ > 1) mprintf("DEBUG: Added (stack) "); IC_.back().printIC(topIn); Branches.pop(); MARK(p.ai_, hasIC, nHasIC); @@ -367,7 +367,7 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, has_next = true; break; } else { - mprintf("DEBUG:\t\t%s already has an IC.\n", topIn.AtomMaskName(p.ai_).c_str()); + if (debug_ > 1) mprintf("DEBUG:\t\t%s already has an IC.\n", topIn.AtomMaskName(p.ai_).c_str()); std::vector indices = AtomI_indices(p.ai_); // FIXME check empty or size > 1 IC_[indices.front()].printIC( topIn ); @@ -375,7 +375,7 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, } } // END while branches remain on stack if (!has_next) { - mprintf("DEBUG:\t\tNothing left on the stack.\n"); + if (debug_ > 1) mprintf("DEBUG:\t\tNothing left on the stack.\n"); break; } } else { @@ -390,7 +390,7 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, // Add lowest index as IC if (!hasIC[atI]) { addIc(atI, atJ, atK, atL, frameIn.XYZ(atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); - mprintf("DEBUG: Added (next) "); + if (debug_ > 1) mprintf("DEBUG: Added (next) "); IC_.back().printIC(topIn); MARK(atI, hasIC, nHasIC); } @@ -400,11 +400,13 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, maxStack = std::max(maxStack, (unsigned int)Branches.size()); if (debug_ > 1) { PHI const& p = Branches.top(); - mprintf("DEBUG:\t\tPlaced on stack: %s - %s - %s - %s (%zu)\n", - topIn.AtomMaskName(p.ai_).c_str(), - topIn.AtomMaskName(p.aj_).c_str(), - topIn.AtomMaskName(p.ak_).c_str(), - topIn.AtomMaskName(p.al_).c_str(), Branches.size()); + if (debug_ > 1) { + mprintf("DEBUG:\t\tPlaced on stack: %s - %s - %s - %s (%zu)\n", + topIn.AtomMaskName(p.ai_).c_str(), + topIn.AtomMaskName(p.aj_).c_str(), + topIn.AtomMaskName(p.ak_).c_str(), + topIn.AtomMaskName(p.al_).c_str(), Branches.size()); + } } } // Designate lowest index as next @@ -539,9 +541,10 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology std::vector const& atomPositionKnown, BuildAtom const& AtomA, BuildAtom const& AtomB) { - mprintf("DEBUG: SetFromFrameAroundBond: atA= %s (%i) atB= %s (%i)\n", - topIn.AtomMaskName(atA).c_str(), atA+1, - topIn.AtomMaskName(atB).c_str(), atB+1); + if (debug_ > 0) + mprintf("DEBUG: SetupICsAroundBond: atA= %s (%i) atB= %s (%i)\n", + topIn.AtomMaskName(atA).c_str(), atA+1, + topIn.AtomMaskName(atB).c_str(), atB+1); IC_.clear(); Barray hasIC( topIn.Natom(), false ); @@ -572,10 +575,12 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology } } } - for (std::vector::const_iterator it = KLpairs.begin(); - it != KLpairs.end(); ++it) - mprintf("DEBUG:\t\tKL pair %s - %s\n", topIn.AtomMaskName(it->first).c_str(), - topIn.AtomMaskName(it->second).c_str()); + if (debug_ > 0) { + for (std::vector::const_iterator it = KLpairs.begin(); + it != KLpairs.end(); ++it) + mprintf("DEBUG:\t\tKL pair %s - %s\n", topIn.AtomMaskName(it->first).c_str(), + topIn.AtomMaskName(it->second).c_str()); + } if (KLpairs.empty()) { mprinterr("Error: SetFromFrameAroundBond(): Could not find an atom pair bonded to atom %s\n", topIn.AtomMaskName(atB).c_str()); @@ -593,18 +598,20 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology } int atk0 = KLpairs[maxIdx].first; int atl0 = KLpairs[maxIdx].second; - mprintf("DEBUG: Chosen KL pair: %s - %s\n",topIn.AtomMaskName(atk0).c_str(), - topIn.AtomMaskName(atl0).c_str()); + if (debug_ > 0) + mprintf("DEBUG: Chosen KL pair: %s - %s\n",topIn.AtomMaskName(atk0).c_str(), + topIn.AtomMaskName(atl0).c_str()); // ---- I J: Set dist, theta, phi for atA atB K L internal coord --- - mprintf("DEBUG: IC (i j) %i - %i - %i - %i\n", atA+1, atB+1, atk0+1, atl0+1); + if (debug_ > 0) + mprintf("DEBUG: IC (i j) %i - %i - %i - %i\n", atA+1, atB+1, atk0+1, atl0+1); double newDist = Atom::GetBondLength( topIn[atA].Element(), topIn[atB].Element() ); - mprintf("DEBUG:\t\tnewDist= %g\n", newDist); + if (debug_ > 0) mprintf("DEBUG:\t\tnewDist= %g\n", newDist); double newTheta = 0; if (Cpptraj::Structure::Model::AssignTheta(newTheta, atA, atB, atk0, topIn, frameIn, atomPositionKnown)) { mprinterr("Error: theta (i j) assignment failed.\n"); return 1; } - mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); + if (debug_ > 0) mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); double newPhi = 0; if (Cpptraj::Structure::Model::AssignPhi(newPhi, atA, atB, atk0, atl0, topIn, frameIn, atomPositionKnown, AtomB)) @@ -612,10 +619,12 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology mprinterr("Error: phi (i j) assignment failed.\n"); return 1; } - mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); + if (debug_ > 0) mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); IC_.push_back(InternalCoords( atA, atB, atk0, atl0, newDist, newTheta*Constants::RADDEG, newPhi*Constants::RADDEG )); - mprintf("DEBUG: MODEL I J IC: "); - IC_.back().printIC(topIn); + if (debug_ > 0) { + mprintf("DEBUG: MODEL I J IC: "); + IC_.back().printIC(topIn); + } MARK( atA, hasIC, nHasIC ); // ----- J K: Set up ICs for X atA atB K --------------------------- Atom const& AJ1 = topIn[atA]; @@ -634,7 +643,8 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology mprinterr("Error: theta (j k) assignment failed.\n"); return 1; } - mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); + if (debug_ > 0) + mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); // Set phi for I atA atB K newPhi = 0; if (Cpptraj::Structure::Model::AssignPhi(newPhi, *iat, atA, atB, atk0, topIn, frameIn, @@ -643,10 +653,13 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology mprinterr("Error: phi (j k) assignment failed.\n"); return 1; } - mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); + if (debug_ > 0) + mprintf("DEBUG:\t\tnewPhi = %g\n", newPhi*Constants::RADDEG); IC_.push_back(InternalCoords( *iat, atA, atB, atk0, newDist, newTheta*Constants::RADDEG, newPhi*Constants::RADDEG )); - mprintf("DEBUG: MODEL J K IC: "); - IC_.back().printIC(topIn); + if (debug_ > 0) { + mprintf("DEBUG: MODEL J K IC: "); + IC_.back().printIC(topIn); + } MARK( *iat, hasIC, nHasIC ); // ----- K L: Set up ICs for X iat atA atB --------------------- /*Atom const& AJ2 = topIn[*iat]; @@ -679,7 +692,7 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology // Handle remaining atoms. if (AJ1.Nbonds() > 1) { if (AJ1.Nbonds() == 2) { - mprintf("DEBUG: 2 bonds to %s.\n", topIn.AtomMaskName(atA).c_str()); + if (debug_ > 0) mprintf("DEBUG: 2 bonds to %s.\n", topIn.AtomMaskName(atA).c_str()); if (traceMol(atB, atA, ati, frameIn, topIn, topIn.Natom(), nHasIC, hasIC)) return 1; } else { @@ -688,10 +701,10 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology int at0 = -1; int at1 = -1; std::vector remainingAtoms; - mprintf("DEBUG: %i bonds to %s\n", AJ1.Nbonds(), topIn.AtomMaskName(atA).c_str()); + if (debug_ > 0) mprintf("DEBUG: %i bonds to %s\n", AJ1.Nbonds(), topIn.AtomMaskName(atA).c_str()); for (std::vector::const_iterator it = priority.begin(); it != priority.end(); ++it) { if (*it != atB) { - mprintf("DEBUG:\t\t%s\n", topIn.AtomMaskName(*it).c_str()); + if (debug_ > 0) mprintf("DEBUG:\t\t%s\n", topIn.AtomMaskName(*it).c_str()); if (at0 == -1) at0 = *it; else if (at1 == -1) From 0705dce69fe4e15d6a92145d5b529f5a9eae7c52 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 14:11:10 -0400 Subject: [PATCH 209/245] Add debug arg --- src/Structure/Model.cpp | 88 ++++++++++++++++------------------------- src/Structure/Model.h | 4 +- 2 files changed, 37 insertions(+), 55 deletions(-) diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index 7acfab2ec3..c2c99bf6b1 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -8,17 +8,20 @@ /** Attempt to assign a reasonable value for theta internal coordinate for * atom i given that atoms j and k have known positions. */ -int Cpptraj::Structure::Model::AssignTheta(double& theta, int ai, int aj, int ak, Topology const& topIn, Frame const& frameIn, std::vector const& atomPositionKnown) +int Cpptraj::Structure::Model::AssignTheta(double& theta, int ai, int aj, int ak, Topology const& topIn, Frame const& frameIn, std::vector const& atomPositionKnown, int debug) { // Figure out hybridization and chirality of atom j. - mprintf("DEBUG: AssignTheta for atom j : %s\n", topIn.AtomMaskName(aj).c_str()); + if (debug > 0) + mprintf("DEBUG: AssignTheta for atom j : %s\n", topIn.AtomMaskName(aj).c_str()); enum HybridizationType { SP = 0, SP2, SP3, UNKNOWN_HYBRIDIZATION }; Atom const& AJ = topIn[aj]; - mprintf("DEBUG:\t\tI %s Nbonds: %i\n", topIn[ai].ElementName(), topIn[ai].Nbonds()); - mprintf("DEBUG:\t\tJ %s Nbonds: %i\n", AJ.ElementName(), AJ.Nbonds()); - mprintf("DEBUG:\t\tK %s Nbonds: %i\n", topIn[ak].ElementName(), topIn[ak].Nbonds()); + if (debug > 0) { + mprintf("DEBUG:\t\tI %s Nbonds: %i\n", topIn[ai].ElementName(), topIn[ai].Nbonds()); + mprintf("DEBUG:\t\tJ %s Nbonds: %i\n", AJ.ElementName(), AJ.Nbonds()); + mprintf("DEBUG:\t\tK %s Nbonds: %i\n", topIn[ak].ElementName(), topIn[ak].Nbonds()); + } // Sanity check if (AJ.Nbonds() < 2) { mprinterr("Internal Error: AssignTheta() called for atom J %s with fewer than 2 bonds.\n", topIn.AtomMaskName(aj).c_str()); @@ -125,53 +128,32 @@ static inline double wrap360(double phi) { int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, int al, Topology const& topIn, Frame const& frameIn, std::vector const& atomPositionKnown, - BuildAtom const& AtomJ) + BuildAtom const& AtomJ, int debug) { // Figure out hybridization and chirality of atom j. - mprintf("DEBUG: AssignPhi for atom j : %s\n", topIn.AtomMaskName(aj).c_str()); + if (debug > 0) + mprintf("DEBUG: AssignPhi for atom j : %s\n", topIn.AtomMaskName(aj).c_str()); Atom const& AJ = topIn[aj]; - mprintf("DEBUG:\t\tNbonds: %i\n", AJ.Nbonds()); + if (debug > 0) mprintf("DEBUG:\t\tNbonds: %i\n", AJ.Nbonds()); // If atom J only has 2 bonds, ai-aj-ak-al is the only possibility. if (AJ.Nbonds() < 3) { - mprintf("DEBUG:\t\tFewer than 3 bonds. Setting phi to -180.\n"); + if (debug > 0) + mprintf("DEBUG:\t\tFewer than 3 bonds. Setting phi to -180.\n"); phi = -180 * Constants::DEGRAD; return 0; } - // FIXME aj ak and al should be known // TODO check that atom i actually ends up on the list? - //std::vector Priority( AJ.Nbonds() ); - //int* priority = static_cast( &AtomJ_Priority[0] ); std::vector const& priority = AtomJ.Priority(); - double tors = 0; - // FIXME - Only need priority here. - //ChiralType chirality = DetermineChirality(tors, priority, aj, topIn, frameIn, 1); // FIXME debug - //if (chirality == CHIRALITY_ERR) { - // mprinterr("Error: Problem determining chirality around atom %s\n", topIn.AtomMaskName(aj).c_str()); - // return 1; - //} /*else if (chirality == IS_UNKNOWN_CHIRALITY) { - // mprintf("DEBUG:\t\tChirality is unknown\n"); - //} else if (chirality == IS_S) { - // mprintf("DEBUG:\t\tChirality is S\n"); - //} else { - // mprintf("DEBUG:\t\tChirality is R\n"); - //}*/ - mprintf("DEBUG: Original chirality around J %s is %s\n", topIn.AtomMaskName(aj).c_str(), chiralStr(AtomJ.Chirality())); - mprintf("DEBUG:\t\tPriority around J %s(%i) (tors=%g):", - topIn.AtomMaskName(aj).c_str(), (int)atomPositionKnown[aj], tors*Constants::RADDEG); - for (int idx = 0; idx < AJ.Nbonds(); idx++) - mprintf(" %s(%i)", topIn.AtomMaskName(priority[idx]).c_str(), (int)atomPositionKnown[priority[idx]]); - mprintf("\n"); - // Determine if chirality is valid -/* bool chirality_is_valid = true; - for (unsigned int idx = 0; idx < priority.size(); idx++) { - if (atomPositionKnown[priority[idx]] != atomPositionKnown[aj]) { - chirality_is_valid = false; - break; - } + if (debug > 0) { + mprintf("DEBUG: Original chirality around J %s is %s\n", topIn.AtomMaskName(aj).c_str(), chiralStr(AtomJ.Chirality())); + mprintf("DEBUG:\t\tPriority around J %s(%i):", + topIn.AtomMaskName(aj).c_str(), (int)atomPositionKnown[aj]); + for (int idx = 0; idx < AJ.Nbonds(); idx++) + mprintf(" %s(%i)", topIn.AtomMaskName(priority[idx]).c_str(), (int)atomPositionKnown[priority[idx]]); + mprintf("\n"); } - mprintf("DEBUG:\t\tChirality is valid: %i\n", (int)chirality_is_valid);*/ // Fill in what values we can for known atoms std::vector knownPhi( AJ.Nbonds() ); @@ -187,7 +169,8 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in frameIn.XYZ(aj), frameIn.XYZ(ak), frameIn.XYZ(al)); - mprintf("DEBUG:\t\tKnown phi for %s = %g\n", topIn.AtomMaskName(atnum).c_str(), knownPhi[idx]*Constants::RADDEG); + if (debug > 0) + mprintf("DEBUG:\t\tKnown phi for %s = %g\n", topIn.AtomMaskName(atnum).c_str(), knownPhi[idx]*Constants::RADDEG); if (knownIdx == -1) knownIdx = idx; // FIXME handle more than 1 known } } @@ -204,8 +187,9 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in if (atnum != ak) { int currentDepth = 0; depth[idx] = atom_depth(currentDepth, atnum, topIn, visited, 10); - mprintf("DEBUG:\t\tAJ %s depth from %s is %i\n", - topIn.AtomMaskName(aj).c_str(), topIn.AtomMaskName(atnum).c_str(), depth[idx]); + if (debug > 0) + mprintf("DEBUG:\t\tAJ %s depth from %s is %i\n", + topIn.AtomMaskName(aj).c_str(), topIn.AtomMaskName(atnum).c_str(), depth[idx]); if (knownIdx == -1 && depth[idx] < 3) { knownIdx = idx; knownPhi[idx] = 0; @@ -220,13 +204,7 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in double startPhi; if (knownIdx == -1) { startPhi = -180*Constants::DEGRAD; - // If all atom statuses match the chirality is valid. Have R start -180. - //if (chirality_is_valid) - //{ - // if (chirality == IS_R) // FIXME just always start -180? - // startPhi = -180*Constants::DEGRAD; - //} - mprintf("DEBUG:\t\tNo known phi. Setting to %g.\n", startPhi*Constants::RADDEG); + if (debug > 0) mprintf("DEBUG:\t\tNo known phi. Setting to %g.\n", startPhi*Constants::RADDEG); knownIdx = 0; } else startPhi = knownPhi[knownIdx]; @@ -235,8 +213,10 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in startPhi = -startPhi; interval = -interval; } - mprintf("DEBUG:\t\tStart phi is %g degrees\n", startPhi*Constants::RADDEG); - mprintf("DEBUG:\t\tInterval is %g degrees\n", interval * Constants::RADDEG); + if (debug > 0) { + mprintf("DEBUG:\t\tStart phi is %g degrees\n", startPhi*Constants::RADDEG); + mprintf("DEBUG:\t\tInterval is %g degrees\n", interval * Constants::RADDEG); + } // Forward direction double currentPhi = startPhi; @@ -244,7 +224,8 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in int atnum = priority[idx]; if (atnum != ak) { if (atnum == ai) phi = currentPhi; - mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); + if (debug > 0) + mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); currentPhi += interval; currentPhi = wrap360(currentPhi); } @@ -255,7 +236,8 @@ int Cpptraj::Structure::Model::AssignPhi(double& phi, int ai, int aj, int ak, in int atnum = priority[idx]; if (atnum != ak) { if (atnum == ai) phi = currentPhi; - mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); + if (debug > 0) + mprintf("DEBUG:\t\t\t%s phi= %g\n", topIn.AtomMaskName(atnum).c_str(), currentPhi*Constants::RADDEG); currentPhi -= interval; currentPhi = wrap360(currentPhi); } diff --git a/src/Structure/Model.h b/src/Structure/Model.h index 5d5a52e379..240e64875e 100644 --- a/src/Structure/Model.h +++ b/src/Structure/Model.h @@ -10,9 +10,9 @@ class BuildAtom; /// Routines to generate model parameters namespace Model { /// Given atoms J K and L, attempt to assign a reasonable value for phi for atom I -int AssignPhi(double&, int, int, int, int, Topology const&, Frame const&, std::vector const&, BuildAtom const&); +int AssignPhi(double&, int, int, int, int, Topology const&, Frame const&, std::vector const&, BuildAtom const&, int); /// Given atoms J and K, attempt to assign a reasonable value for theta for atom I -int AssignTheta(double&, int, int, int, Topology const&, Frame const&, std::vector const&); +int AssignTheta(double&, int, int, int, Topology const&, Frame const&, std::vector const&, int); } // END namespace Model } // END namespace Structure From d194551e9b3bf85973db2bd4af02ba8ec6320256 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 14:13:06 -0400 Subject: [PATCH 210/245] Use model debug level --- src/Structure/Zmatrix.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index c607022cb9..8521a18792 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -598,23 +598,26 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology } int atk0 = KLpairs[maxIdx].first; int atl0 = KLpairs[maxIdx].second; - if (debug_ > 0) + int modelDebug = 0; + if (debug_ > 0) { mprintf("DEBUG: Chosen KL pair: %s - %s\n",topIn.AtomMaskName(atk0).c_str(), topIn.AtomMaskName(atl0).c_str()); + modelDebug = debug_ - 1; + } // ---- I J: Set dist, theta, phi for atA atB K L internal coord --- if (debug_ > 0) mprintf("DEBUG: IC (i j) %i - %i - %i - %i\n", atA+1, atB+1, atk0+1, atl0+1); double newDist = Atom::GetBondLength( topIn[atA].Element(), topIn[atB].Element() ); if (debug_ > 0) mprintf("DEBUG:\t\tnewDist= %g\n", newDist); double newTheta = 0; - if (Cpptraj::Structure::Model::AssignTheta(newTheta, atA, atB, atk0, topIn, frameIn, atomPositionKnown)) { + if (Cpptraj::Structure::Model::AssignTheta(newTheta, atA, atB, atk0, topIn, frameIn, atomPositionKnown, modelDebug)) { mprinterr("Error: theta (i j) assignment failed.\n"); return 1; } if (debug_ > 0) mprintf("DEBUG:\t\tnewTheta = %g\n", newTheta*Constants::RADDEG); double newPhi = 0; if (Cpptraj::Structure::Model::AssignPhi(newPhi, atA, atB, atk0, atl0, topIn, frameIn, - atomPositionKnown, AtomB)) + atomPositionKnown, AtomB, modelDebug)) { mprinterr("Error: phi (i j) assignment failed.\n"); return 1; @@ -639,7 +642,7 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology newDist = sqrt( DIST2_NoImage(frameIn.XYZ(*iat), frameIn.XYZ(atA)) ); // Set theta for I atA atB newTheta = 0; - if (Cpptraj::Structure::Model::AssignTheta(newTheta, *iat, atA, atB, topIn, frameIn, atomPositionKnown)) { + if (Cpptraj::Structure::Model::AssignTheta(newTheta, *iat, atA, atB, topIn, frameIn, atomPositionKnown, modelDebug)) { mprinterr("Error: theta (j k) assignment failed.\n"); return 1; } @@ -648,7 +651,7 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology // Set phi for I atA atB K newPhi = 0; if (Cpptraj::Structure::Model::AssignPhi(newPhi, *iat, atA, atB, atk0, topIn, frameIn, - atomPositionKnown, AtomA)) + atomPositionKnown, AtomA, modelDebug)) { mprinterr("Error: phi (j k) assignment failed.\n"); return 1; From 8f4b690b6a2004273224d49ada21ecde14fc2acd Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 14:35:33 -0400 Subject: [PATCH 211/245] Hide some debug --- src/Exec_Graft.cpp | 1 + src/Structure/Builder.cpp | 3 ++- src/Structure/Builder.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index a58fe2fe5d..17603dac68 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -344,6 +344,7 @@ const Frame CombinedFrame = mol0frm; Builder builder; + builder.SetDebug( debug_ ); if (builder.Combine( combinedTop, CombinedFrame, mol1Top, mol1frm, bondat0, bondat1 )) { mprinterr("Error: Fragment combine failed.\n"); return 1; diff --git a/src/Structure/Builder.cpp b/src/Structure/Builder.cpp index f09672c871..4b09556d77 100644 --- a/src/Structure/Builder.cpp +++ b/src/Structure/Builder.cpp @@ -98,7 +98,8 @@ int Builder::Combine(Topology& frag0Top, Frame& frag0frm, combinedTop.AtomMaskName(atB).c_str()); return 1; } - bondZmatrix.print(&combinedTop); + if (debug_ > 0) + bondZmatrix.print(&combinedTop); if (bondZmatrix.SetToFrame( CombinedFrame, posKnown )) { mprinterr("Error: Conversion from bondZmatrix to Cartesian coords failed.\n"); return 1; diff --git a/src/Structure/Builder.h b/src/Structure/Builder.h index 05f2d243e2..86087d0bec 100644 --- a/src/Structure/Builder.h +++ b/src/Structure/Builder.h @@ -12,6 +12,8 @@ class Builder { Builder(); /// Combine second fragment into first fragment and bond int Combine(Topology&, Frame&, Topology const&, Frame const&, int, int); + /// Set debug + void SetDebug(int d) { debug_ = d; } private: typedef std::vector Barray; From ff8d9ef63be89f2f20570ebaba2973bc0adac23d Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 14:44:28 -0400 Subject: [PATCH 212/245] Hide more debug. Put printing of ICs behind debug checks --- src/Exec_Graft.cpp | 3 ++- src/Structure/Zmatrix.cpp | 30 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 17603dac68..ba8a288a5a 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -340,7 +340,8 @@ const combinedTop.SetParmName( outCoords->Meta().Name(), FileName() ); combinedTop.AppendTop( mol0Top ); combinedTop.SetParmBox( mol0frm.BoxCrd() ); - combinedTop.Brief("Grafted parm:"); + if (debug_ > 0) + combinedTop.Brief("Grafted parm:"); Frame CombinedFrame = mol0frm; Builder builder; diff --git a/src/Structure/Zmatrix.cpp b/src/Structure/Zmatrix.cpp index 8521a18792..538564c2b9 100644 --- a/src/Structure/Zmatrix.cpp +++ b/src/Structure/Zmatrix.cpp @@ -331,8 +331,10 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, // Create ICs for 1 bond atoms for (Iarray::const_iterator atI = OneBondAtoms.begin(); atI != OneBondAtoms.end(); ++atI) { addIc(*atI, atJ, atK, atL, frameIn.XYZ(*atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); - if (debug_ > 1) mprintf("DEBUG: Added (1 atom) "); - IC_.back().printIC(topIn); + if (debug_ > 1) { + mprintf("DEBUG: Added (1 atom) "); + IC_.back().printIC(topIn); + } MARK(*atI, hasIC, nHasIC); } // If nothing else, check the stack @@ -356,8 +358,10 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, } if (!hasIC[p.ai_]) { addIc(p.ai_, p.aj_, p.ak_, p.al_, frameIn.XYZ(p.ai_), frameIn.XYZ(p.aj_), frameIn.XYZ(p.ak_), frameIn.XYZ(p.al_)); - if (debug_ > 1) mprintf("DEBUG: Added (stack) "); - IC_.back().printIC(topIn); + if (debug_ > 1) { + mprintf("DEBUG: Added (stack) "); + IC_.back().printIC(topIn); + } Branches.pop(); MARK(p.ai_, hasIC, nHasIC); // Designate branch as next. @@ -367,10 +371,12 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, has_next = true; break; } else { - if (debug_ > 1) mprintf("DEBUG:\t\t%s already has an IC.\n", topIn.AtomMaskName(p.ai_).c_str()); - std::vector indices = AtomI_indices(p.ai_); - // FIXME check empty or size > 1 - IC_[indices.front()].printIC( topIn ); + if (debug_ > 1) { + mprintf("DEBUG:\t\t%s already has an IC.\n", topIn.AtomMaskName(p.ai_).c_str()); + std::vector indices = AtomI_indices(p.ai_); + // TODO check empty or size > 1 + IC_[indices.front()].printIC( topIn ); + } Branches.pop(); } } // END while branches remain on stack @@ -390,8 +396,10 @@ int Zmatrix::traceMol(int atL0, int atK0, int atJ0, // Add lowest index as IC if (!hasIC[atI]) { addIc(atI, atJ, atK, atL, frameIn.XYZ(atI), frameIn.XYZ(atJ), frameIn.XYZ(atK), frameIn.XYZ(atL)); - if (debug_ > 1) mprintf("DEBUG: Added (next) "); - IC_.back().printIC(topIn); + if (debug_ > 1) { + mprintf("DEBUG: Added (next) "); + IC_.back().printIC(topIn); + } MARK(atI, hasIC, nHasIC); } // Place all above lowest index on the stack. @@ -729,7 +737,7 @@ int Zmatrix::SetupICsAroundBond(int atA, int atB, Frame const& frameIn, Topology } } } - + return 0; } From 1e3a4ef6e64df347ad47676c6e78814eef0910c6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 14:46:15 -0400 Subject: [PATCH 213/245] Add comment --- src/Exec_Graft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index ba8a288a5a..88bc55188e 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -386,7 +386,7 @@ const mprinterr("Error: Could not select source bond atom '%s'\n", bond1Atoms[ii].c_str()); return 1; } - combinedTop.AddBond( bondat0, bondat1 + mol0Top.Natom() ); + combinedTop.AddBond( bondat0, bondat1 + mol0Top.Natom() ); // TODO pseudo-parameter? } // Regenerate the molecule info FIXME should Topology just do this? if (combinedTop.DetermineMolecules()) return 1; From 4bc957dad82c21615077271c9b0fd55c09dc8a14 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 14:56:06 -0400 Subject: [PATCH 214/245] Add OFF read test --- test/Test_ReadOFF/Lib.mol2.save | 34 +++++++++++++++++++++++++++++++++ test/Test_ReadOFF/RunTest.sh | 18 +++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 test/Test_ReadOFF/Lib.mol2.save create mode 100755 test/Test_ReadOFF/RunTest.sh diff --git a/test/Test_ReadOFF/Lib.mol2.save b/test/Test_ReadOFF/Lib.mol2.save new file mode 100644 index 0000000000..3729da3f97 --- /dev/null +++ b/test/Test_ReadOFF/Lib.mol2.save @@ -0,0 +1,34 @@ +@MOLECULE +Cpptraj Generated mol2 file. + 12 11 1 0 0 +SMALL +USER_CHARGES + + +@ATOM + 1 N 0.0540 -0.2256 0.0153 N 1 CNALA -0.570310 + 2 H -0.4149 0.5139 0.5357 H 1 CNALA 0.364710 + 3 CA 1.5127 -0.0215 0.0706 CX 1 CNALA 0.118030 + 4 HA 1.9976 -0.8599 -0.4376 H1 1 CNALA 0.105630 + 5 CB 1.8871 1.2873 -0.6522 CT 1 CNALA -0.214290 + 6 HB1 1.5308 1.2705 -1.6848 HC 1 CNALA 0.081710 + 7 HB2 1.4452 2.1491 -0.1463 HC 1 CNALA 0.081710 + 8 HB3 2.9715 1.4185 -0.6703 HC 1 CNALA 0.081710 + 9 C 2.0167 -0.0042 1.5042 C 1 CNALA 0.597740 + 10 O 1.3510 0.3674 2.4498 O 1 CNALA -0.533510 + 11 OXT 3.2954 -0.2516 1.6078 OH 1 CNALA -0.566290 + 12 HXT 3.6319 -0.4443 0.7168 HO 1 CNALA 0.453160 +@BOND + 1 1 3 1 + 2 3 5 1 + 3 3 9 1 + 4 9 10 1 + 5 9 11 1 + 6 1 2 1 + 7 3 4 1 + 8 5 6 1 + 9 5 7 1 + 10 5 8 1 + 11 11 12 1 +@SUBSTRUCTURE + 1 CNALA 1 **** 0 **** **** diff --git a/test/Test_ReadOFF/RunTest.sh b/test/Test_ReadOFF/RunTest.sh new file mode 100755 index 0000000000..db36da31aa --- /dev/null +++ b/test/Test_ReadOFF/RunTest.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +. ../MasterTest.sh + +CleanFiles cpptraj.in Lib.mol2 + +INPUT='-i cpptraj.in' + +cat > cpptraj.in < Date: Fri, 27 Oct 2023 15:00:06 -0400 Subject: [PATCH 215/245] Enable test --- test/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index 21f1de9a5b..8786704402 100644 --- a/test/Makefile +++ b/test/Makefile @@ -530,6 +530,9 @@ test.readprep: test.zmatrix: @-cd Test_Zmatrix && ./RunTest.sh $(OPT) +test.readoff: + @-cd Test_ReadOFF && ./RunTest.sh $(OPT) + # Every test target should go here. COMPLETETESTS=test.general \ test.strip \ @@ -697,7 +700,8 @@ COMPLETETESTS=test.general \ test.calcdiffusion \ test.parsetiming \ test.readprep \ - test.zmatrix + test.zmatrix \ + test.readoff test.all: $(MAKE) test.complete summary From d5f848eee4c862a5216973c954191daecae6344b Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 15:00:13 -0400 Subject: [PATCH 216/245] Make blank connect a warning, happens with terminii --- src/DataIO_AmberLib.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/DataIO_AmberLib.cpp b/src/DataIO_AmberLib.cpp index 78988fe3e6..8088f022ea 100644 --- a/src/DataIO_AmberLib.cpp +++ b/src/DataIO_AmberLib.cpp @@ -184,8 +184,7 @@ int DataIO_AmberLib::read_connect(AssociatedData_Connect& ConnectAtoms, std::str } // Amber lib atoms start from 1 if (connectAtom < 1) { - mprinterr("Error: Atom index < 1 in connect line: %s\n", line.c_str()); - return 1; + mprintf("Warning: Atom index < 1 in connect line: %s\n", line.c_str()); } ConnectAtoms.AddConnectAtom( connectAtom-1 ); return 0; From 13c3408de177d46f201761f8d4e72a389642e58c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Fri, 27 Oct 2023 15:14:58 -0400 Subject: [PATCH 217/245] Protect against bad connect atoms --- src/Exec_Sequence.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Exec_Sequence.cpp b/src/Exec_Sequence.cpp index ad302bc3c1..9feedb2435 100644 --- a/src/Exec_Sequence.cpp +++ b/src/Exec_Sequence.cpp @@ -99,6 +99,13 @@ const Units[idx]->legend(), connectAt0[idx] +1); Frame mol1frm = Units[idx]->AllocateFrame(); Units[idx]->GetFrame(0, mol1frm); + int bondat0 = connectAt1[idx-1]; + int bondat1 = connectAt0[idx]; + if (bondat0 < 0 || bondat1 < 0) { + mprinterr("Error: Invalid connect atom(s) between %s atom %i to %s atom %i\n", + Units[idx-1]->legend(), bondat0+1, Units[idx]->legend(), bondat1+1); + return 1; + } if (builder.Combine( combinedTop, CombinedFrame, Units[idx]->Top(), mol1frm, connectAt1[idx-1], connectAt0[idx] )) { mprinterr("Error: Sequence combine between units %u %s and %u %s failed.\n", From 5303a4fb5226d4af1d154019d626c0f2ab752829 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 31 Oct 2023 09:40:22 -0400 Subject: [PATCH 218/245] Add destructor to free memory --- src/PotentialFunction.cpp | 6 ++++++ src/PotentialFunction.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/PotentialFunction.cpp b/src/PotentialFunction.cpp index acb1ff5e9b..5d2e66a2d4 100644 --- a/src/PotentialFunction.cpp +++ b/src/PotentialFunction.cpp @@ -9,6 +9,12 @@ #include "PotentialTerm_Angle.h" #include "PotentialTerm_Dihedral.h" +/** DESTRUCTOR */ +PotentialFunction::~PotentialFunction() { + for (Parray::iterator it = terms_.begin(); it != terms_.end(); ++it) + delete *it; +} + /** Add a term to the potential function. */ int PotentialFunction::AddTerm(PotentialTerm::Type typeIn, MdOpts const& opts) { PotentialTerm* term = 0; diff --git a/src/PotentialFunction.h b/src/PotentialFunction.h index 57b406e909..f187a85229 100644 --- a/src/PotentialFunction.h +++ b/src/PotentialFunction.h @@ -12,7 +12,10 @@ class MdOpts; /// Hold terms for additive potential. class PotentialFunction { public: + /// CONSTRUCTOR PotentialFunction() : current_(0), deg_of_freedom_(0) {} + /// DESTRUCTOR + ~PotentialFunction(); /// Add term to function with given options int AddTerm(PotentialTerm::Type, MdOpts const&); /// Add term to function with default options From a049d33623cf3700a4f88a6cc973ce440f56765a Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 09:12:26 -0400 Subject: [PATCH 219/245] Add help text --- src/Exec_Zmatrix.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Exec_Zmatrix.cpp b/src/Exec_Zmatrix.cpp index e27a72fdb6..c10450f60d 100644 --- a/src/Exec_Zmatrix.cpp +++ b/src/Exec_Zmatrix.cpp @@ -5,12 +5,6 @@ using namespace Cpptraj::Structure; -// Exec_Zmatrix::Help() -void Exec_Zmatrix::Help() const -{ - -} - /** Get Zmatrix for specified molecule at specified frame number. */ int Exec_Zmatrix::getZmatrix(DataSet_Coords* CRD, int molnum, int frmidx, std::string const& dsname, DataFile* outfile, CpptrajState& State) @@ -110,6 +104,18 @@ const return 0; } +// Exec_Zmatrix::Help() +void Exec_Zmatrix::Help() const +{ + mprintf("\t [name ]\n" + "\t{ zset [parm |parmindex <#>] |\n" + "\t [molnum ] [frame ] [out ] }\n" + " If 'zset' is specified, apply Z-matrix to specified COORDS set; + " output is a new COORDS set.\n" + " Otherwise calculate Zmatrix for specified molecule/frame of\n" + " specified COORDS set; output is a Z-matrix set.\n"); +} + // Exec_Zmatrix::Execute() Exec::RetType Exec_Zmatrix::Execute(CpptrajState& State, ArgList& argIn) { From 2cd73280eb21d0a5f30a0592932eea4f63f7063e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 09:28:36 -0400 Subject: [PATCH 220/245] Fix processing of arguments depending on zmatrix mode --- src/Exec_Zmatrix.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Exec_Zmatrix.cpp b/src/Exec_Zmatrix.cpp index c10450f60d..16b643c408 100644 --- a/src/Exec_Zmatrix.cpp +++ b/src/Exec_Zmatrix.cpp @@ -110,7 +110,8 @@ void Exec_Zmatrix::Help() const mprintf("\t [name ]\n" "\t{ zset [parm |parmindex <#>] |\n" "\t [molnum ] [frame ] [out ] }\n" - " If 'zset' is specified, apply Z-matrix to specified COORDS set; + " If 'zset' is specified, use Z-matrix to generate coordinates using\n" + " a specified topology or topology from specified COORDS set;\n" " output is a new COORDS set.\n" " Otherwise calculate Zmatrix for specified molecule/frame of\n" " specified COORDS set; output is a Z-matrix set.\n"); @@ -120,15 +121,22 @@ void Exec_Zmatrix::Help() const Exec::RetType Exec_Zmatrix::Execute(CpptrajState& State, ArgList& argIn) { debug_ = State.Debug(); - int molnum = argIn.getKeyInt("molnum", 1) - 1; - int frmidx = argIn.getKeyInt("frame", 1) - 1; std::string dsname = argIn.GetStringKey("name"); - DataFile* outfile = State.DFL().AddDataFile( argIn.GetStringKey("out"), argIn ); // TODO not if zset - std::string zsetname = argIn.GetStringKey("zset"); + int molnum = -1; + int frmidx = -1; + DataFile* outfile = 0; Topology* topIn = 0; - if (argIn.Contains("parm") || argIn.Contains("parmindex")) - topIn = (Topology*)State.DSL().GetTopology(argIn); + if (zsetname.empty()) { + // Calculating Z-matrix + molnum = argIn.getKeyInt("molnum", 1) - 1; + frmidx = argIn.getKeyInt("frame", 1) - 1; + outfile = State.DFL().AddDataFile( argIn.GetStringKey("out"), argIn ); + } else { + // Applying Zmatrix + if (argIn.Contains("parm") || argIn.Contains("parmindex")) + topIn = (Topology*)State.DSL().GetTopology(argIn); + } // Get COORDS set name std::string setname = argIn.GetStringNext(); // ----- No more args below here ----- From 038aa2f24b91d471c28e0a1420a4da0dc5379831 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 09:31:04 -0400 Subject: [PATCH 221/245] Add zmatrix manual entry --- doc/cpptraj.lyx | 145 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 3 deletions(-) diff --git a/doc/cpptraj.lyx b/doc/cpptraj.lyx index b1c11b0368..dd68dc8651 100644 --- a/doc/cpptraj.lyx +++ b/doc/cpptraj.lyx @@ -6253,7 +6253,7 @@ The following COORDS data set commands are available: \begin_layout Standard \align center \begin_inset Tabular - + @@ -6585,7 +6585,7 @@ Rotate specified dihedral to specified value or by given increment. - + \begin_inset Text \begin_layout Plain Layout @@ -6594,13 +6594,34 @@ splitcoords \end_inset - + \begin_inset Text \begin_layout Plain Layout Split molecules in a COORDS set into a trajectory. \end_layout +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +zmatrix +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Apply Z-matrix to a COORDS set or calculate Z-matrix for a molecule/frame + in a COORDS set. +\end_layout + \end_inset @@ -8887,6 +8908,124 @@ Set0 splitcoords Set0 name Set0Split \end_layout +\begin_layout Subsection +zmatrix +\end_layout + +\begin_layout LyX-Code +zmatrix [name ] +\end_layout + +\begin_layout LyX-Code + { zset [parm |parmindex <#>] | +\end_layout + +\begin_layout LyX-Code + [molnum ] [frame ] [out ] } +\end_layout + +\begin_deeper +\begin_layout Description + COORDS set to calculate Z-matrix from or use as topology for applied + Z-matrix. +\end_layout + +\begin_layout Description +[name +\begin_inset space ~ +\end_inset + +] Name of output COORDS set (if 'zset') or output Z-matrix set. +\end_layout + +\begin_layout Description +zset +\begin_inset space ~ +\end_inset + + Name of Z-matrix set to use to generate coordinates. +\end_layout + +\begin_deeper +\begin_layout Description +parm +\begin_inset space ~ +\end_inset + + Use specified topology name as topology for generated coordinates. +\end_layout + +\begin_layout Description +parmindex +\begin_inset space ~ +\end_inset + +<#> Use topology index as topology for generated coordinates. +\end_layout + +\end_deeper +\begin_layout Description +[molnum +\begin_inset space ~ +\end_inset + +] Calculate Z-matrix from specified molecule (default first molecule). +\end_layout + +\begin_layout Description +[frame +\begin_inset space ~ +\end_inset + +] Calculate Z-matrix from specified molecule in specified frame + (default first frame). +\end_layout + +\begin_layout Description +[out +\begin_inset space ~ +\end_inset + +] File to write calculated Z-matrix to. +\end_layout + +\end_deeper +\begin_layout Standard +Command for working with Z-matrices. + If 'zset' is specified, generate coordinates from the specified Z-matrix + data set and topology. + Otherwise, calculate a Z-matrix for a single molecule from the specified + frame of given COORDS data set. +\end_layout + \begin_layout Section General Commands \end_layout From 232593a4cb39e0a6c7b60dc83e957e18c7534b40 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 09:34:06 -0400 Subject: [PATCH 222/245] Add test lib file --- test/Test_ReadOFF/aminocn15ipq_10.0.lib | 105 ++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 test/Test_ReadOFF/aminocn15ipq_10.0.lib diff --git a/test/Test_ReadOFF/aminocn15ipq_10.0.lib b/test/Test_ReadOFF/aminocn15ipq_10.0.lib new file mode 100644 index 0000000000..194c80dee1 --- /dev/null +++ b/test/Test_ReadOFF/aminocn15ipq_10.0.lib @@ -0,0 +1,105 @@ +!!index array str + "CNALA" +!entry.CNALA.unit.atoms table str name str type int typex int resx int flags int seq int elmnt dbl chg + "N" "N" 0 1 131072 1 7 -0.57031 + "H" "H" 0 1 131072 2 1 0.36471 + "CA" "CX" 0 1 131072 3 6 0.11803 + "HA" "H1" 0 1 131072 4 1 0.10563 + "CB" "CT" 0 1 131072 5 6 -0.21429 + "HB1" "HC" 0 1 131072 6 1 0.08171 + "HB2" "HC" 0 1 131072 7 1 0.08171 + "HB3" "HC" 0 1 131072 8 1 0.08171 + "C" "C" 0 1 131072 9 6 0.59774 + "O" "O" 0 1 131072 10 8 -0.53351 + "OXT" "OH" 0 1 131072 11 8 -0.56629 + "HXT" "HO" 0 1 131072 12 1 0.45316 +!entry.CNALA.unit.atomspertinfo table str pname str ptype int ptypex int pelmnt dbl pchg + "N" "N" 0 -1 0.0 + "H" "H" 0 -1 0.0 + "CA" "CX" 0 -1 0.0 + "HA" "H1" 0 -1 0.0 + "CB" "CT" 0 -1 0.0 + "HB1" "HC" 0 -1 0.0 + "HB2" "HC" 0 -1 0.0 + "HB3" "HC" 0 -1 0.0 + "C" "C" 0 -1 0.0 + "O" "O" 0 -1 0.0 + "OXT" "OH" 0 -1 0.0 + "HXT" "HO" 0 -1 0.0 +!entry.CNALA.unit.boundbox array dbl + -1.000000 + 0.0 + 0.0 + 0.0 + 0.0 +!entry.CNALA.unit.childsequence single int + 2 +!entry.CNALA.unit.connect array int + 1 + 0 +!entry.CNALA.unit.connectivity table int atom1x int atom2x int flags + 1 2 1 + 1 3 1 + 3 4 1 + 3 5 1 + 3 9 1 + 5 6 1 + 5 7 1 + 5 8 1 + 9 10 1 + 9 11 1 + 11 12 1 +!entry.CNALA.unit.hierarchy table str abovetype int abovex str belowtype int belowx + "U" 0 "R" 1 + "R" 1 "A" 1 + "R" 1 "A" 2 + "R" 1 "A" 3 + "R" 1 "A" 4 + "R" 1 "A" 5 + "R" 1 "A" 6 + "R" 1 "A" 7 + "R" 1 "A" 8 + "R" 1 "A" 9 + "R" 1 "A" 10 + "R" 1 "A" 11 + "R" 1 "A" 12 +!entry.CNALA.unit.name single str + "CNALA" +!entry.CNALA.unit.positions table dbl x dbl y dbl z + 0.054000 -0.225600 0.015300 + -0.414900 0.513900 0.535700 + 1.512700 -0.021500 0.070600 + 1.997600 -0.859900 -0.437600 + 1.887100 1.287300 -0.652200 + 1.530800 1.270500 -1.684800 + 1.445200 2.149100 -0.146300 + 2.971500 1.418500 -0.670300 + 2.016700 -0.004200 1.504200 + 1.351000 0.367400 2.449800 + 3.295400 -0.251600 1.607800 + 3.631900 -0.444300 0.716800 +!entry.CNALA.unit.residueconnect table int c1x int c2x int c3x int c4x int c5x int c6x + 1 0 0 0 0 0 +!entry.CNALA.unit.residues table str name int seq int childseq int startatomx str restype int imagingx + "CNALA" 1 13 1 "p" 0 +!entry.CNALA.unit.residuesPdbSequenceNumber array int + 0 +!entry.CNALA.unit.solventcap array dbl + -1.000000 + 0.0 + 0.0 + 0.0 + 0.0 +!entry.CNALA.unit.velocities table dbl x dbl y dbl z + 0.0 0.0 0.0 + 0.0 0.0 0.0 + 0.0 0.0 0.0 + 0.0 0.0 0.0 + 0.0 0.0 0.0 + 0.0 0.0 0.0 + 0.0 0.0 0.0 + 0.0 0.0 0.0 + 0.0 0.0 0.0 + 0.0 0.0 0.0 + 0.0 0.0 0.0 + 0.0 0.0 0.0 From 123b45c512fa763d3367c64744eb6e5a12a6d310 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 09:41:32 -0400 Subject: [PATCH 223/245] Start sequence test --- test/Test_Sequence/RunTest.sh | 20 ++++ test/Test_Sequence/cph_nucleic_caps.lib | 119 ++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100755 test/Test_Sequence/RunTest.sh create mode 100644 test/Test_Sequence/cph_nucleic_caps.lib diff --git a/test/Test_Sequence/RunTest.sh b/test/Test_Sequence/RunTest.sh new file mode 100755 index 0000000000..20813c5df0 --- /dev/null +++ b/test/Test_Sequence/RunTest.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +. ../MasterTest.sh + +TESTNAME='Sequence tests' + +CleanFiles cpptraj.in Mol.mol2 + +INPUT='-i cpptraj.in' + +cat > cpptraj.in < Date: Wed, 1 Nov 2023 09:47:56 -0400 Subject: [PATCH 224/245] Try to check for SP2 nitrogens with 3 bonds (partial double bond character) --- src/Structure/Model.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Structure/Model.cpp b/src/Structure/Model.cpp index c2c99bf6b1..affbf21f06 100644 --- a/src/Structure/Model.cpp +++ b/src/Structure/Model.cpp @@ -41,7 +41,18 @@ int Cpptraj::Structure::Model::AssignTheta(double& theta, int ai, int aj, int ak case Atom::NITROGEN : switch (AJ.Nbonds()) { case 2 : hybrid = SP2; break; - case 3 : hybrid = SP3; break; + case 3 : + // Check for potential SP2. If only 1 of the bonded atoms is + // hydrogen, assume SP2. TODO actually check for aromaticity. + int n_hydrogens = 0; + for (Atom::bond_iterator bat = AJ.bondbegin(); bat != AJ.bondend(); ++bat) + if (topIn[*bat].Element() == Atom::HYDROGEN) + n_hydrogens++; + if (n_hydrogens == 1) + hybrid = SP2; + else + hybrid = SP3; + break; } break; case Atom::OXYGEN : From 8f54647e9daebfe365fd164ca1a1a3e89acf613c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 09:48:45 -0400 Subject: [PATCH 225/245] Add test save --- test/Test_Sequence/Mol.mol2.save | 45 ++++++++++++++++++++++++++++++++ test/Test_Sequence/RunTest.sh | 1 + 2 files changed, 46 insertions(+) create mode 100644 test/Test_Sequence/Mol.mol2.save diff --git a/test/Test_Sequence/Mol.mol2.save b/test/Test_Sequence/Mol.mol2.save new file mode 100644 index 0000000000..d15e8643b6 --- /dev/null +++ b/test/Test_Sequence/Mol.mol2.save @@ -0,0 +1,45 @@ +@MOLECULE +Cpptraj Generated mol2 file. + 17 16 2 0 0 +SMALL +USER_CHARGES + + +@ATOM + 1 C1 -1.8623 -1.2984 -0.5952 CT 1 MOC 1.387300 + 2 H2 -2.2353 -2.1775 -1.1026 H1 1 MOC -0.288000 + 3 H3 -2.2811 -0.4130 -1.0709 H1 1 MOC -0.288000 + 4 H4 -2.1956 -1.3220 0.4412 H1 1 MOC -0.288000 + 5 O5 -0.4741 -1.3169 -0.6848 OS 1 MOC -0.523200 + 6 N 0.0540 -0.2256 0.0153 N 2 CNALA -0.570310 + 7 H -0.4149 0.5139 0.5357 H 2 CNALA 0.364710 + 8 CA 1.5127 -0.0215 0.0706 CX 2 CNALA 0.118030 + 9 HA 1.9976 -0.8599 -0.4376 H1 2 CNALA 0.105630 + 10 CB 1.8871 1.2873 -0.6522 CT 2 CNALA -0.214290 + 11 HB1 1.5308 1.2705 -1.6848 HC 2 CNALA 0.081710 + 12 HB2 1.4452 2.1491 -0.1463 HC 2 CNALA 0.081710 + 13 HB3 2.9715 1.4185 -0.6703 HC 2 CNALA 0.081710 + 14 C 2.0167 -0.0042 1.5042 C 2 CNALA 0.597740 + 15 O 1.3510 0.3674 2.4498 O 2 CNALA -0.533510 + 16 OXT 3.2954 -0.2516 1.6078 OH 2 CNALA -0.566290 + 17 HXT 3.6319 -0.4443 0.7168 HO 2 CNALA 0.453160 +@BOND + 1 1 5 1 + 2 6 8 1 + 3 8 10 1 + 4 8 14 1 + 5 14 15 1 + 6 14 16 1 + 7 5 6 1 + 8 1 2 1 + 9 1 3 1 + 10 1 4 1 + 11 6 7 1 + 12 8 9 1 + 13 10 11 1 + 14 10 12 1 + 15 10 13 1 + 16 16 17 1 +@SUBSTRUCTURE + 1 MOC 1 **** 0 **** **** + 2 CNALA 6 **** 0 **** **** diff --git a/test/Test_Sequence/RunTest.sh b/test/Test_Sequence/RunTest.sh index 20813c5df0..41058e626b 100755 --- a/test/Test_Sequence/RunTest.sh +++ b/test/Test_Sequence/RunTest.sh @@ -16,5 +16,6 @@ sequence CAPS[MOC] A15[CNALA] name Mol crdout Mol Mol.mol2 EOF RunCpptraj "$TESTNAME" +DoTest Mol.mol2.save Mol.mol2 EndTest From 36a3baa3feec9cd542f323176816df4ea867b49f Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 09:50:16 -0400 Subject: [PATCH 226/245] Enable sequence test --- test/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index 8786704402..483b3486a7 100644 --- a/test/Makefile +++ b/test/Makefile @@ -533,6 +533,9 @@ test.zmatrix: test.readoff: @-cd Test_ReadOFF && ./RunTest.sh $(OPT) +test.sequence: + @-cd Test_Sequence && ./RunTest.sh $(OPT) + # Every test target should go here. COMPLETETESTS=test.general \ test.strip \ @@ -701,7 +704,8 @@ COMPLETETESTS=test.general \ test.parsetiming \ test.readprep \ test.zmatrix \ - test.readoff + test.readoff \ + test.sequence test.all: $(MAKE) test.complete summary From 089cbd3cbdef9d3acd0c5b71cbaf8add53bb14c4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 09:55:49 -0400 Subject: [PATCH 227/245] Test libset keyword --- test/Test_Sequence/RunTest.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/Test_Sequence/RunTest.sh b/test/Test_Sequence/RunTest.sh index 41058e626b..147a49ad72 100755 --- a/test/Test_Sequence/RunTest.sh +++ b/test/Test_Sequence/RunTest.sh @@ -14,8 +14,12 @@ readdata cph_nucleic_caps.lib name CAPS list sequence CAPS[MOC] A15[CNALA] name Mol crdout Mol Mol.mol2 + +sequence libset A15 libset CAPS MOC CNALA name Mol2 +crdout Mol2 Mol2.mol2 EOF RunCpptraj "$TESTNAME" DoTest Mol.mol2.save Mol.mol2 +DoTest Mol.mol2.save Mol2.mol2 EndTest From 2cadda1295518a62368c023a38cefc411d1215e3 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 10:03:07 -0400 Subject: [PATCH 228/245] Update depends --- src/cpptrajdepend | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 3411d7910f..de28b9369a 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -327,7 +327,7 @@ Exec_ReadInput.o : Exec_ReadInput.cpp Action.h ActionList.h ActionState.h Analys Exec_RotateDihedral.o : Exec_RotateDihedral.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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 DihedralSearch.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_RotateDihedral.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_RunAnalysis.o : Exec_RunAnalysis.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_RunAnalysis.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_ScaleDihedralK.o : Exec_ScaleDihedralK.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_ScaleDihedralK.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h -Exec_Sequence.o : Exec_Sequence.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_Sequence.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h +Exec_Sequence.o : Exec_Sequence.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h AssociatedData_Connect.h Atom.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_Sequence.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 Segment.h Structure/Builder.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_SequenceAlign.o : Exec_SequenceAlign.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.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_SequenceAlign.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OutputTrajCommon.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h Exec_Set.o : Exec_Set.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_StringVar.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Set.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 Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_Show.o : Exec_Show.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_StringVar.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Show.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h From 400eede4dcadb2087d43a39f514b38916b8f431d Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 10:07:02 -0400 Subject: [PATCH 229/245] Add stub for arg process function --- src/AssociatedData_Connect.cpp | 4 ++++ src/AssociatedData_Connect.h | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/AssociatedData_Connect.cpp b/src/AssociatedData_Connect.cpp index 5d18b71a98..387339a2f4 100644 --- a/src/AssociatedData_Connect.cpp +++ b/src/AssociatedData_Connect.cpp @@ -3,6 +3,10 @@ const char* AssociatedData_Connect::HelpText = ""; +int AssociatedData_Connect::ProcessAdataArgs(ArgList&) { + return 0; +} + void AssociatedData_Connect::Ainfo() const { if (!connect_.empty()) { mprintf(" (Connect Atoms:"); diff --git a/src/AssociatedData_Connect.h b/src/AssociatedData_Connect.h index 72d6036c9d..4c24a34422 100644 --- a/src/AssociatedData_Connect.h +++ b/src/AssociatedData_Connect.h @@ -6,15 +6,18 @@ class AssociatedData_Connect : public AssociatedData { typedef std::vector Iarray; public: + /// Empty CONSTRUCTOR AssociatedData_Connect() : AssociatedData(CONNECT) {} + // ----- Inherited functions ------- static const char* HelpText; - + int ProcessAdataArgs(ArgList&); + AssociatedData* Copy() const { return new AssociatedData_Connect(*this); } + void Ainfo() const; + // --------------------------------- void AddConnectAtom(int at) { connect_.push_back( at ); } unsigned int NconnectAtoms() const { return connect_.size(); } Iarray const& Connect() const { return connect_; } - AssociatedData* Copy() const { return new AssociatedData_Connect(*this); } - void Ainfo() const; private: Iarray connect_; }; From b0d315d2bb2f2fc8e45239c7370aa85999aabccf Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 10:08:50 -0400 Subject: [PATCH 230/245] Make arg processing function virtual --- src/Action_Distance.cpp | 2 +- src/AssociatedData.h | 8 ++++++++ src/AssociatedData_NOE.cpp | 2 +- src/AssociatedData_NOE.h | 11 +++++++---- src/Exec_DataSetCmd.cpp | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Action_Distance.cpp b/src/Action_Distance.cpp index 7e848cca63..054497d20a 100644 --- a/src/Action_Distance.cpp +++ b/src/Action_Distance.cpp @@ -36,7 +36,7 @@ Action::RetType Action_Distance::Init(ArgList& actionArgs, ActionInit& init, int std::string stypename = actionArgs.GetStringKey("type"); if ( stypename == "noe" ) { stype = MetaData::NOE; - if (noe.NOE_Args( actionArgs )) return Action::ERR; + if (noe.ProcessAdataArgs( actionArgs )) return Action::ERR; } // Determine mode. ReferenceFrame refFrm = init.DSL().GetReferenceFrame( actionArgs ); diff --git a/src/AssociatedData.h b/src/AssociatedData.h index b626518f41..f37af22d7c 100644 --- a/src/AssociatedData.h +++ b/src/AssociatedData.h @@ -1,14 +1,22 @@ #ifndef INC_ASSOCIATEDDATA_H #define INC_ASSOCIATEDDATA_H +class ArgList; class AssociatedData { public: /// Destructor. Virtual since this class is inherited. virtual ~AssociatedData() {} + /// Associated data types enum AssociatedType { NOE = 0, CONNECT }; + /// CONSTRUCTOR - take associated data type AssociatedData(AssociatedType t) : type_(t) {} + /// \return Associated data type AssociatedType Type() { return type_; } + /// \return A copy of the associated data virtual AssociatedData* Copy() const = 0; + /// Print associated data info to stdout virtual void Ainfo() const = 0; + /// Process arguments for associated data + virtual int ProcessAdataArgs(ArgList&) = 0; private: AssociatedType type_; }; diff --git a/src/AssociatedData_NOE.cpp b/src/AssociatedData_NOE.cpp index 85040a2e96..912e20b0fe 100644 --- a/src/AssociatedData_NOE.cpp +++ b/src/AssociatedData_NOE.cpp @@ -5,7 +5,7 @@ const char* AssociatedData_NOE::HelpText = "[bound bound ] [rexp ] [noe_strong] [noe_medium] [noe_weak]"; -int AssociatedData_NOE::NOE_Args(ArgList& argIn) { +int AssociatedData_NOE::ProcessAdataArgs(ArgList& argIn) { l_bound_ = argIn.getKeyDouble("bound", 0.0); u_bound_ = argIn.getKeyDouble("bound", 0.0); rexp_ = argIn.getKeyDouble("rexp", -1.0); diff --git a/src/AssociatedData_NOE.h b/src/AssociatedData_NOE.h index bcc3d1db91..8da077db90 100644 --- a/src/AssociatedData_NOE.h +++ b/src/AssociatedData_NOE.h @@ -5,17 +5,20 @@ class ArgList; /// For Analysis_Statistics DISTANCE NOE class AssociatedData_NOE : public AssociatedData { public: + /// Empty CONSTRUCTOR AssociatedData_NOE() : AssociatedData(NOE), l_bound_(0.0), u_bound_(0.0), rexp_(-1.0) {} + /// CONSTRUCTOR - take lower/upper bounds and expected distance AssociatedData_NOE(double l, double u, double r) : AssociatedData(NOE), l_bound_(l), u_bound_(u), rexp_(r) {} + // ----- Inherited functions ------- static const char* HelpText; - int NOE_Args(ArgList&); + int ProcessAdataArgs(ArgList&); + AssociatedData* Copy() const { return new AssociatedData_NOE(*this); } + void Ainfo() const; + // --------------------------------- double NOE_bound() const { return l_bound_; } double NOE_boundH() const { return u_bound_; } double NOE_rexp() const { return rexp_; } - - AssociatedData* Copy() const { return new AssociatedData_NOE(*this); } - void Ainfo() const; private: double l_bound_; ///< Lower bound double u_bound_; ///< Upper bound diff --git a/src/Exec_DataSetCmd.cpp b/src/Exec_DataSetCmd.cpp index 3f503ddc72..0edbe71706 100644 --- a/src/Exec_DataSetCmd.cpp +++ b/src/Exec_DataSetCmd.cpp @@ -884,7 +884,7 @@ Exec::RetType Exec_DataSetCmd::ChangeModeType(CpptrajState const& State, ArgList // Additional options for type 'noe' AssociatedData_NOE noeData; if (dtype == MetaData::NOE) { - if (noeData.NOE_Args(argIn)) + if (noeData.ProcessAdataArgs(argIn)) return CpptrajState::ERR; } if (dmode != MetaData::UNKNOWN_MODE) From da9c3fa4f9ac75edd139fb3e7929aa4f186e9312 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 10:12:50 -0400 Subject: [PATCH 231/245] Create arg routine for connect associated data --- src/AssociatedData_Connect.cpp | 14 +++++++++++++- src/cpptrajdepend | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/AssociatedData_Connect.cpp b/src/AssociatedData_Connect.cpp index 387339a2f4..1a0b51cb31 100644 --- a/src/AssociatedData_Connect.cpp +++ b/src/AssociatedData_Connect.cpp @@ -1,9 +1,21 @@ #include "AssociatedData_Connect.h" #include "CpptrajStdio.h" +#include "ArgList.h" const char* AssociatedData_Connect::HelpText = ""; -int AssociatedData_Connect::ProcessAdataArgs(ArgList&) { +int AssociatedData_Connect::ProcessAdataArgs(ArgList& argIn) { + // Expect user atom args to start from 1 + int head = argIn.getKeyInt("head", 0) - 1; + int tail = argIn.getKeyInt("tail", 0) - 1; + if (head < 0) head = -1; + if (tail < 0) tail = -1; + if (head == -1 && tail == -1) { + mprinterr("Error: Either at least 'head' or 'tail' must be specified.\n"); + return 1; + } + connect_.push_back( head ); + connect_.push_back( tail ); return 0; } diff --git a/src/cpptrajdepend b/src/cpptrajdepend index de28b9369a..60bccdfbf2 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -137,7 +137,7 @@ Analysis_VectorMath.o : Analysis_VectorMath.cpp ActionState.h Analysis.h Analysi Analysis_Wavelet.o : Analysis_Wavelet.cpp ActionFrameCounter.h ActionState.h Analysis.h AnalysisState.h Analysis_Wavelet.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ClusterMap.h ComplexArray.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixFlt.h Dimension.h DispatchObject.h DistRoutines.h FileIO.h FileName.h FileTypes.h Frame.h ImageOption.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OutputTrajCommon.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ParmFile.h ProgressBar.h ProgressTimer.h PubFFT.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajectoryFile.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h ArgList.o : ArgList.cpp ArgList.h CpptrajStdio.h StringRoutines.h Array1D.o : Array1D.cpp ArgList.h Array1D.h AssociatedData.h Atom.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h -AssociatedData_Connect.o : AssociatedData_Connect.cpp AssociatedData.h AssociatedData_Connect.h CpptrajStdio.h +AssociatedData_Connect.o : AssociatedData_Connect.cpp ArgList.h AssociatedData.h AssociatedData_Connect.h CpptrajStdio.h AssociatedData_NOE.o : AssociatedData_NOE.cpp ArgList.h AssociatedData.h AssociatedData_NOE.h CpptrajStdio.h Atom.o : Atom.cpp Atom.h CpptrajStdio.h NameType.h SymbolExporting.h AtomMap.o : AtomMap.cpp Atom.h AtomMap.h AtomMask.h AtomType.h Box.h Constants.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MapAtom.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h From 5b61646d3ea0d32bc120b1bce82929145679bddb Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 10:30:05 -0400 Subject: [PATCH 232/245] Add help text --- src/AssociatedData_Connect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AssociatedData_Connect.cpp b/src/AssociatedData_Connect.cpp index 1a0b51cb31..1a774154d1 100644 --- a/src/AssociatedData_Connect.cpp +++ b/src/AssociatedData_Connect.cpp @@ -2,7 +2,7 @@ #include "CpptrajStdio.h" #include "ArgList.h" -const char* AssociatedData_Connect::HelpText = ""; +const char* AssociatedData_Connect::HelpText = "[head ] [tail ]"; int AssociatedData_Connect::ProcessAdataArgs(ArgList& argIn) { // Expect user atom args to start from 1 From 6141c0fb07d09e5a6a94182a23c8a4bfa048e641 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 10:30:14 -0400 Subject: [PATCH 233/245] Make const pointer --- src/DataSet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataSet.h b/src/DataSet.h index b20d6f8cb8..f619652f4d 100644 --- a/src/DataSet.h +++ b/src/DataSet.h @@ -85,7 +85,7 @@ class DataSet { # endif // ----------------------------------------------------- /// Associate additional data with this set. - void AssociateData(AssociatedData* a) { associatedData_.push_back( a->Copy() ); } + void AssociateData(AssociatedData const* a) { associatedData_.push_back( a->Copy() ); } /// Set DataSet MetaData int SetMeta(MetaData const&); /// Set DataSet ensemble number. From 080d4b0a91601a308c96b34ea0e96208970df6ed Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 10:30:28 -0400 Subject: [PATCH 234/245] Start connect data set command --- src/Exec_DataSetCmd.cpp | 49 +++++++++++++++++++++++++++++++++++++++++ src/Exec_DataSetCmd.h | 1 + 2 files changed, 50 insertions(+) diff --git a/src/Exec_DataSetCmd.cpp b/src/Exec_DataSetCmd.cpp index 0edbe71706..90bd113646 100644 --- a/src/Exec_DataSetCmd.cpp +++ b/src/Exec_DataSetCmd.cpp @@ -9,6 +9,7 @@ #include "DataSet_Mat3x3.h" #include "StringRoutines.h" #include "AssociatedData_NOE.h" +#include "AssociatedData_Connect.h" // Exec_DataSetCmd::Help() void Exec_DataSetCmd::Help() const { @@ -297,6 +298,54 @@ Exec::RetType Exec_DataSetCmd::ModifyPoints(CpptrajState& State, ArgList& argIn, return CpptrajState::OK; } +// Exec_DataSetCmd::SetConnect() +Exec::RetType Exec_DataSetCmd::SetConnect(CpptrajState& State, ArgList& argIn) { + // Keywords + AssociatedData_Connect connect; + if (connect.ProcessAdataArgs(argIn)) { + mprinterr("Error: Could not process 'connect' keywords.\n"); + return CpptrajState::ERR; + } + mprintf("\t"); + connect.Ainfo(); + mprintf("\n"); + // Get Data set(s) + typedef std::vector DCarray; + DCarray inputSets; + std::string crdsetarg = argIn.GetStringNext(); + if (crdsetarg.empty()) + mprintf("Warning: No data set arguments specified.\n"); + while (!crdsetarg.empty()) { + DataSetList dsl1 = State.DSL().GetMultipleSets( crdsetarg ); + for (DataSetList::const_iterator it = dsl1.begin(); it != dsl1.end(); ++it) + { + if ( (*it)->Group() != DataSet::COORDINATES ) { + mprintf("Warning: 'connect' only works with COORDS sets; '%s' is not COORDS.\n", (*it)->legend()); + } else { + inputSets.push_back( static_cast( *it ) ); + } + } + crdsetarg = argIn.GetStringNext(); + } + if (inputSets.empty()) { + mprinterr("Error: 'connect': No data sets selected.\n"); + return CpptrajState::ERR; + } + mprintf("\t%zu sets.\n", inputSets.size()); + for (DCarray::const_iterator it = inputSets.begin(); it != inputSets.end(); ++it) { + // Check for existing associated data + AssociatedData_Connect* ad = (AssociatedData_Connect*)(*it)->GetAssociatedData(AssociatedData::CONNECT); + if (ad == 0) { + (*it)->AssociateData( &connect ); + } else { + mprintf("Warning: Overwriting associated data in '%s'.\n", (*it)->legend()); + *ad = connect; + } + } + + return CpptrajState::OK; +} + // Exec_DataSetCmd::VectorCoord() Exec::RetType Exec_DataSetCmd::VectorCoord(CpptrajState& State, ArgList& argIn) { // Keywords diff --git a/src/Exec_DataSetCmd.h b/src/Exec_DataSetCmd.h index d9f17149f1..5a72d97644 100644 --- a/src/Exec_DataSetCmd.h +++ b/src/Exec_DataSetCmd.h @@ -21,6 +21,7 @@ class Exec_DataSetCmd : public Exec { static void Help_ModifyPoints(); RetType ModifyPoints(CpptrajState&, ArgList&, bool); + RetType SetConnect(CpptrajState&, ArgList&); RetType VectorCoord(CpptrajState&, ArgList&); RetType ChangeOutputFormat(CpptrajState const&, ArgList&); RetType Remove(CpptrajState&, ArgList&); From d89eff6de46f501b7df0a8359f22d705ba661ca7 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 10:38:47 -0400 Subject: [PATCH 235/245] Start connect data set command --- src/Exec_DataSetCmd.cpp | 7 ++++++- src/cpptrajdepend | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Exec_DataSetCmd.cpp b/src/Exec_DataSetCmd.cpp index 90bd113646..6c8b76906c 100644 --- a/src/Exec_DataSetCmd.cpp +++ b/src/Exec_DataSetCmd.cpp @@ -14,7 +14,7 @@ // Exec_DataSetCmd::Help() void Exec_DataSetCmd::Help() const { mprintf("\t{legend|makexy|vectorcoord|cat|make2d|droppoints|keeppoints|remove|\n" - "\t dim|outformat|invert|shift|mode|type} \n"); + "\t connect|dim|outformat|invert|shift|mode|type} \n"); mprintf(" Type 'help dataset ' for detailed subcommand help.\n"); } @@ -58,6 +58,8 @@ void Exec_DataSetCmd::Help(ArgList& argIn) const { Help_InvertSets(); } else if (argIn.hasKey("shift")) { Help_Shift(); + } else if (argIn.hasKey("connect")) { + mprintf(" connect %s\n", AssociatedData_Connect::HelpText); } else if (argIn.hasKey("mode")) { mprintf(" [mode ] [type ] [ ...]\n"); mprintf(" : "); @@ -98,6 +100,9 @@ Exec::RetType Exec_DataSetCmd::Execute(CpptrajState& State, ArgList& argIn) { } else if (argIn.hasKey("make2d")) { // Create 2D matrix from 1D set err = Make2D(State, argIn); // --------------------------------------------- + } else if (argIn.hasKey("connect")) { // Add connection atoms to COORDS set + err = SetConnect(State, argIn); + // --------------------------------------------- } else if (argIn.hasKey("vectorcoord")) { // Extract vector X/Y/Z coord as new set err = VectorCoord(State, argIn); // --------------------------------------------- diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 60bccdfbf2..e379d7ca83 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -300,7 +300,7 @@ Exec_CrdTransform.o : Exec_CrdTransform.cpp Action.h ActionList.h ActionState.h Exec_CreateSet.o : Exec_CreateSet.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_CreateSet.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 RPNcalc.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_DataFile.o : Exec_DataFile.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_DataFile.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 Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_DataFilter.o : Exec_DataFilter.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_DataFilter.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 ProgressBar.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h -Exec_DataSetCmd.o : Exec_DataSetCmd.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h ArrayIterator.h AssociatedData.h AssociatedData_NOE.h Atom.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_Mat3x3.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 Segment.h Spline.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h +Exec_DataSetCmd.o : Exec_DataSetCmd.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h ArrayIterator.h AssociatedData.h AssociatedData_Connect.h AssociatedData_NOE.h Atom.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_Mat3x3.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 Segment.h Spline.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.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 AtomMask.h AtomType.h BaseIOtype.h Box.h CharMask.h Constants.h Constraints.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 MdOpts.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_ExtendedComparison.o : Exec_ExtendedComparison.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_ExtendedComparison.h ExtendedSimilarity.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 Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h Exec_Flatten.o : Exec_Flatten.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.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_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Flatten.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h From 68d9bcfbbbb5789453f1cc18a9c1301ebe1ff3dc Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 11:02:17 -0400 Subject: [PATCH 236/245] Fix printf statement --- src/Exec_Sequence.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Exec_Sequence.cpp b/src/Exec_Sequence.cpp index 9feedb2435..63a69b2bf1 100644 --- a/src/Exec_Sequence.cpp +++ b/src/Exec_Sequence.cpp @@ -57,7 +57,7 @@ const // Needs to have connect associated data AssociatedData* ad = unit->GetAssociatedData(AssociatedData::CONNECT); if (ad == 0) { - mprinterr("Error: Unit '%s' does not have CONNECT data.\n"); + mprinterr("Error: Unit '%s' does not have CONNECT data.\n", unit->legend()); return 1; } AssociatedData_Connect const& C = static_cast( *ad ); From 726974b732a8ee19bd992d10647785c761ccc036 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 12:42:15 -0400 Subject: [PATCH 237/245] Test setting head/tail atoms --- test/Test_Sequence/RunTest.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/test/Test_Sequence/RunTest.sh b/test/Test_Sequence/RunTest.sh index 147a49ad72..c19383a9da 100755 --- a/test/Test_Sequence/RunTest.sh +++ b/test/Test_Sequence/RunTest.sh @@ -4,7 +4,7 @@ TESTNAME='Sequence tests' -CleanFiles cpptraj.in Mol.mol2 +CleanFiles cpptraj.in Mol.mol2 Mol2.mol2 MOC.mol2 CNALA.mol2 Mol3.mol2 INPUT='-i cpptraj.in' @@ -17,9 +17,26 @@ crdout Mol Mol.mol2 sequence libset A15 libset CAPS MOC CNALA name Mol2 crdout Mol2 Mol2.mol2 + +crdout CAPS[MOC] MOC.mol2 +crdout A15[CNALA] CNALA.mol2 EOF -RunCpptraj "$TESTNAME" +RunCpptraj "$TESTNAME, library files" DoTest Mol.mol2.save Mol.mol2 DoTest Mol.mol2.save Mol2.mol2 +# NOTE: Depends on mol2 generation of previous test +cat > cpptraj.in < Date: Wed, 1 Nov 2023 13:02:43 -0400 Subject: [PATCH 238/245] Add headmask and tailmask keywords to dataset connect. Ensure existing noe data is overwritten if present. --- src/AssociatedData_Connect.cpp | 8 ++++ src/AssociatedData_Connect.h | 2 + src/Exec_DataSetCmd.cpp | 75 ++++++++++++++++++++++++++++++---- 3 files changed, 76 insertions(+), 9 deletions(-) diff --git a/src/AssociatedData_Connect.cpp b/src/AssociatedData_Connect.cpp index 1a774154d1..469e531088 100644 --- a/src/AssociatedData_Connect.cpp +++ b/src/AssociatedData_Connect.cpp @@ -2,6 +2,14 @@ #include "CpptrajStdio.h" #include "ArgList.h" +/** CONSTRUCTOR - head and tail atom */ +AssociatedData_Connect::AssociatedData_Connect(int head, int tail) : + AssociatedData(CONNECT) +{ + connect_.push_back( head ); + connect_.push_back( tail ); +} + const char* AssociatedData_Connect::HelpText = "[head ] [tail ]"; int AssociatedData_Connect::ProcessAdataArgs(ArgList& argIn) { diff --git a/src/AssociatedData_Connect.h b/src/AssociatedData_Connect.h index 4c24a34422..400c0dc7c2 100644 --- a/src/AssociatedData_Connect.h +++ b/src/AssociatedData_Connect.h @@ -8,6 +8,8 @@ class AssociatedData_Connect : public AssociatedData { public: /// Empty CONSTRUCTOR AssociatedData_Connect() : AssociatedData(CONNECT) {} + /// CONSTRUCTOR - head and tail atom + AssociatedData_Connect(int, int); // ----- Inherited functions ------- static const char* HelpText; int ProcessAdataArgs(ArgList&); diff --git a/src/Exec_DataSetCmd.cpp b/src/Exec_DataSetCmd.cpp index 6c8b76906c..9d60c346f8 100644 --- a/src/Exec_DataSetCmd.cpp +++ b/src/Exec_DataSetCmd.cpp @@ -59,7 +59,8 @@ void Exec_DataSetCmd::Help(ArgList& argIn) const { } else if (argIn.hasKey("shift")) { Help_Shift(); } else if (argIn.hasKey("connect")) { - mprintf(" connect %s\n", AssociatedData_Connect::HelpText); + mprintf(" connect {%s | [headmask ] [tailmask ]}\n", + AssociatedData_Connect::HelpText); } else if (argIn.hasKey("mode")) { mprintf(" [mode ] [type ] [ ...]\n"); mprintf(" : "); @@ -303,17 +304,49 @@ Exec::RetType Exec_DataSetCmd::ModifyPoints(CpptrajState& State, ArgList& argIn, return CpptrajState::OK; } +/// Function to select a single atom from a Topology based on mask expression +static inline int select_atom(std::string const& maskexpr, Topology const& topIn) +{ + AtomMask mask; + if (mask.SetMaskString( maskexpr )) { + mprinterr("Error: Invalid mask expression: %s\n", maskexpr.c_str()); + return -2; + } + if (topIn.SetupIntegerMask( mask )) { + mprinterr("Error: Could not set up mask %s\n", mask.MaskString()); + return -2; + } + if (mask.None()) { + mprintf("Warning: Mask %s selects no atoms for %s\n", mask.MaskString(), topIn.c_str()); + return -1; + } + if (mask.Nselected() > 1) { + mprinterr("Error: Mask %s selects more than 1 atom for %s\n", mask.MaskString(), topIn.c_str()); + return -2; + } + return mask[0]; +} + // Exec_DataSetCmd::SetConnect() Exec::RetType Exec_DataSetCmd::SetConnect(CpptrajState& State, ArgList& argIn) { // Keywords AssociatedData_Connect connect; - if (connect.ProcessAdataArgs(argIn)) { - mprinterr("Error: Could not process 'connect' keywords.\n"); - return CpptrajState::ERR; + std::string headmaskstr = argIn.GetStringKey("headmask"); + std::string tailmaskstr = argIn.GetStringKey("tailmask"); + bool use_mask = true; + if (headmaskstr.empty() && tailmaskstr.empty()) { + use_mask = false; + if (connect.ProcessAdataArgs(argIn)) { + mprinterr("Error: Could not process 'connect' keywords.\n"); + return CpptrajState::ERR; + } + mprintf("\t"); + connect.Ainfo(); + mprintf("\n"); + } else { + if (!headmaskstr.empty()) mprintf("\tHead atom mask: %s\n", headmaskstr.c_str()); + if (!tailmaskstr.empty()) mprintf("\tTail atom mask: %s\n", tailmaskstr.c_str()); } - mprintf("\t"); - connect.Ainfo(); - mprintf("\n"); // Get Data set(s) typedef std::vector DCarray; DCarray inputSets; @@ -338,12 +371,28 @@ Exec::RetType Exec_DataSetCmd::SetConnect(CpptrajState& State, ArgList& argIn) { } mprintf("\t%zu sets.\n", inputSets.size()); for (DCarray::const_iterator it = inputSets.begin(); it != inputSets.end(); ++it) { + // Process mask if needed + if (use_mask) { + int head = -1; + if (!headmaskstr.empty()) + head = select_atom(headmaskstr, (*it)->Top()); + if (head < -1) return CpptrajState::ERR; + int tail = -1; + if (!tailmaskstr.empty()) + tail = select_atom(tailmaskstr, (*it)->Top()); + if (tail < -1) return CpptrajState::ERR; + if (head == -1 && tail == -1) { + mprinterr("Error: Neither head atom nor tail atom could be set via mask.\n"); + return CpptrajState::ERR; + } + connect = AssociatedData_Connect(head, tail); + } // Check for existing associated data AssociatedData_Connect* ad = (AssociatedData_Connect*)(*it)->GetAssociatedData(AssociatedData::CONNECT); if (ad == 0) { (*it)->AssociateData( &connect ); } else { - mprintf("Warning: Overwriting associated data in '%s'.\n", (*it)->legend()); + mprintf("Warning: Overwriting existing connect data in '%s'.\n", (*it)->legend()); *ad = connect; } } @@ -967,7 +1016,15 @@ Exec::RetType Exec_DataSetCmd::ChangeModeType(CpptrajState const& State, ArgList mprintf("Warning: '%s': Expected 2D matrix data set type for mode '%s'\n", (*ds)->legend(), MetaData::ModeString(dmode)); } - if ( dtype == MetaData::NOE ) (*ds)->AssociateData( &noeData ); + if ( dtype == MetaData::NOE ) { + AssociatedData_NOE* ad = (AssociatedData_NOE*)(*ds)->GetAssociatedData(AssociatedData::NOE); + if (ad == 0) { + (*ds)->AssociateData( &noeData ); + } else { + mprintf("Warning: Overwriting existing NOE data for %s\n", (*ds)->legend()); + *ad = noeData; + } + } mprintf("\t\t'%s'\n", (*ds)->legend()); MetaData md = (*ds)->Meta(); md.SetScalarMode( dmode ); From 64add9b2563c06740a6f7232e7ea8de21f65cb3f Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 13:03:12 -0400 Subject: [PATCH 239/245] Test using headmask/tailmask --- test/Test_Sequence/RunTest.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/Test_Sequence/RunTest.sh b/test/Test_Sequence/RunTest.sh index c19383a9da..223c04748f 100755 --- a/test/Test_Sequence/RunTest.sh +++ b/test/Test_Sequence/RunTest.sh @@ -4,7 +4,8 @@ TESTNAME='Sequence tests' -CleanFiles cpptraj.in Mol.mol2 Mol2.mol2 MOC.mol2 CNALA.mol2 Mol3.mol2 +CleanFiles cpptraj.in Mol.mol2 Mol2.mol2 MOC.mol2 CNALA.mol2 \ + Mol3.mol2 Mol4.mol2 INPUT='-i cpptraj.in' @@ -35,8 +36,14 @@ loadcrd CNALA.mol2 parm CNALA.mol2 name CNALA dataset connect CNALA head 1 sequence MOC CNALA name Mol3 crdout Mol3 Mol3.mol2 + +dataset connect MOC tailmask @O5 +dataset connect CNALA headmask @N +sequence MOC CNALA name Mol4 +crdout Mol4 Mol4.mol2 EOF RunCpptraj "$TESTNAME, mol2 files" DoTest Mol.mol2.save Mol3.mol2 +DoTest Mol.mol2.save Mol4.mol2 EndTest From 5a57813774e5e18d5fd26b45e5324753343f32bd Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 13:13:38 -0400 Subject: [PATCH 240/245] Add manual entries for sequence and dataset connect --- doc/cpptraj.lyx | 228 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 226 insertions(+), 2 deletions(-) diff --git a/doc/cpptraj.lyx b/doc/cpptraj.lyx index dd68dc8651..26fdfc93df 100644 --- a/doc/cpptraj.lyx +++ b/doc/cpptraj.lyx @@ -6253,7 +6253,7 @@ The following COORDS data set commands are available: \begin_layout Standard \align center \begin_inset Tabular - + @@ -6588,6 +6588,26 @@ Rotate specified dihedral to specified value or by given increment. \begin_inset Text +\begin_layout Plain Layout +sequence +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Create a new molecule from a sequence of COORDS sets. +\end_layout + +\end_inset + + + + +\begin_inset Text + \begin_layout Plain Layout splitcoords \end_layout @@ -8855,6 +8875,131 @@ rotatedihedral crdset TZ2 value 35 res 8 type chip crdout TZ2 tz2.rotate.1.mol2 \end_layout +\begin_layout Subsection +sequence +\begin_inset CommandInset label +LatexCommand label +name "subsec:cpptraj-sequence" + +\end_inset + + +\end_layout + +\begin_layout LyX-Code +sequence name ... +\end_layout + +\begin_layout LyX-Code + [{libset } ...] +\end_layout + +\begin_deeper +\begin_layout Description +name +\begin_inset space ~ +\end_inset + + Name of final molecule. +\end_layout + +\begin_layout Description + +\begin_inset space ~ +\end_inset + + Name of COORDS set (with connection info). +\end_layout + +\begin_layout Description +[{libset +\begin_inset space ~ +\end_inset + +} +\begin_inset space ~ +\end_inset + +...} One or more set name prefixes of data sets (libraries) containing units. +\end_layout + +\end_deeper +\begin_layout Standard +Connect units in different COORDS sets together to form a single molecule. + Internal coordinates are used to try to determine the correct geometry + around connection sites. + The COORDS sets must have connection information set, either from reading + in an Amber OFF library file or set manually via +\series bold +\emph on +dataset +\series default +\emph default + +\series bold +connect +\series default + (see +\begin_inset CommandInset ref +LatexCommand vref +reference "subsec:cpptraj-datasetcmd" +plural "false" +caps "false" +noprefix "false" + +\end_inset + +). +\end_layout + +\begin_layout Standard +For example, the following reads in two Mol2 files as COORDS sets, sets + up connection atoms, then creates a molecule via +\series bold +\emph on +sequence: +\end_layout + +\begin_layout LyX-Code +parm MOC.mol2 +\end_layout + +\begin_layout LyX-Code +loadcrd MOC.mol2 parm MOC.mol2 name MOC +\end_layout + +\begin_layout LyX-Code +dataset connect MOC tailmask @O5 +\end_layout + +\begin_layout LyX-Code +parm CNALA.mol2 +\end_layout + +\begin_layout LyX-Code +loadcrd CNALA.mol2 parm CNALA.mol2 name CNALA +\end_layout + +\begin_layout LyX-Code +dataset connect CNALA headmask @N +\end_layout + +\begin_layout LyX-Code +sequence MOC CNALA name Mol +\end_layout + +\begin_layout LyX-Code +crdout Mol Mol.mol2 +\end_layout + \begin_layout Subsection splitcoords \end_layout @@ -10212,6 +10357,13 @@ reference "subsec:cpptraj-filter" \begin_layout Subsection dataset +\begin_inset CommandInset label +LatexCommand label +name "subsec:cpptraj-datasetcmd" + +\end_inset + + \end_layout \begin_layout LyX-Code @@ -10250,6 +10402,11 @@ dataset { legend | | \end_layout +\begin_layout LyX-Code + connect {[head ] [tail ]|[headmask ] + [tailmask ]} +\end_layout + \begin_layout LyX-Code dim {xdim|ydim|zdim|ndim <#>} [label - + \begin_inset Text \begin_layout Plain Layout @@ -3921,7 +3926,7 @@ NetCDF Data \end_inset - + \begin_inset Text \begin_layout Plain Layout @@ -3930,7 +3935,7 @@ NetCDF Data \end_inset - + \begin_inset Text \begin_layout Plain Layout @@ -3939,7 +3944,7 @@ netcdf \end_inset - + \begin_inset Text \begin_layout Plain Layout @@ -3948,13 +3953,107 @@ All data \end_inset - + \begin_inset Text \begin_layout Plain Layout Only state info saved for pH data. \end_layout +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +Amber Prep File +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +.prepin +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +prepin +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +COORDS +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Read Only +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +Amber OFF Library File +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +.off, .lib +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +off,lib +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +COORDS +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Read Only +\end_layout + \end_inset From 162417429ffa9340e747b86442d1da7364e53809 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 13:29:50 -0400 Subject: [PATCH 242/245] Fix up help and manual entry for graft --- doc/cpptraj.lyx | 88 ++++++++++++++++++++++++++++++++++------------ src/Exec_Graft.cpp | 12 ++++--- 2 files changed, 72 insertions(+), 28 deletions(-) diff --git a/doc/cpptraj.lyx b/doc/cpptraj.lyx index 168fdc22d6..e2bf82d411 100644 --- a/doc/cpptraj.lyx +++ b/doc/cpptraj.lyx @@ -7627,19 +7627,17 @@ graft \end_layout \begin_layout LyX-Code -graft src [srcframe <#>] [srcfitmask ] [srcmask ] +graft src [srcframe <#>] [srcmask [srccharge ]] \end_layout \begin_layout LyX-Code - srccharge -\end_layout - -\begin_layout LyX-Code - tgt [tgtframe <#>] [tgtfitmask ] [tgtmask ] + tgt [tgtframe <#>] [tgtmask [tgtcharge ] +] \end_layout \begin_layout LyX-Code - tgtcharge + {ic | [srcfitmask ] [tgtfitmask ]} \end_layout \begin_layout LyX-Code @@ -7667,14 +7665,6 @@ COORDS> Source coordinates. <#>] 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 ~ @@ -7683,6 +7673,7 @@ COORDS> Source coordinates. ] Atoms to keep from source (default all). \end_layout +\begin_deeper \begin_layout Description [srccharge \begin_inset space ~ @@ -7692,6 +7683,7 @@ COORDS> Source coordinates. atoms equals via scaling. \end_layout +\end_deeper \begin_layout Description tgt \begin_inset space ~ @@ -7713,28 +7705,42 @@ COORDS> Target coordinates that will be grafted onto. \end_layout \begin_layout Description -[tgtfitmask +[tgtmask \begin_inset space ~ \end_inset -] Atoms from target to use if RMS-fitting source onto target. +] Atoms to keep from target (default all). \end_layout +\begin_deeper \begin_layout Description -[tgtmask +[tgtcharge \begin_inset space ~ \end_inset -] Atoms to keep from target (default all). +] If trimming atoms from target, ensure sum of charges on remaining + atoms equals via scaling. \end_layout +\end_deeper \begin_layout Description -[tgtcharge +[ic] Connect source and target using internal coordinates. +\end_layout + +\begin_layout Description +[srcfitmask \begin_inset space ~ \end_inset -] If trimming atoms from target, ensure sum of charges on remaining - atoms equals via scaling. +] Atoms from source to use if RMS-fitting source onto target. +\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 @@ -7756,7 +7762,8 @@ COORDS> Name of output COORDS set containing source grafted onto target. ,] Create a bond between target atom selected by and source atoms selected by in the final structure. - May be specified multiple times. + Must be specified only once if connecting via internal coordinates, otherwise + may be specified multiple times. \end_layout \end_deeper @@ -7787,6 +7794,8 @@ bond \series default keyword can be used to create bonds between target and source in the final structure. + If using internal coordinates to connect the units, exactly one bond must + be specified. \end_layout \begin_layout Subsection @@ -9030,6 +9039,22 @@ name> Name of final molecule. ...} One or more set name prefixes of data sets (libraries) containing units. \end_layout +\begin_layout Standard +Data sets created: +\end_layout + +\begin_layout Description + COORDS set containing final molecule. +\end_layout + \end_deeper \begin_layout Standard Connect units in different COORDS sets together to form a single molecule. @@ -9261,6 +9286,23 @@ parmindex file>] File to write calculated Z-matrix to. \end_layout +\begin_layout Standard +Data sets created: +\end_layout + +\begin_layout Description + If 'zset', COORDS set containing final coordinates. + Otherwise contains Z-matrix data. +\end_layout + \end_deeper \begin_layout Standard Command for working with Z-matrices. diff --git a/src/Exec_Graft.cpp b/src/Exec_Graft.cpp index 88bc55188e..6a9016ff2a 100644 --- a/src/Exec_Graft.cpp +++ b/src/Exec_Graft.cpp @@ -121,12 +121,14 @@ int Exec_Graft::select_bond_idx(std::string const& bond0maskstr, Topology const& // Exec_Graft::Help() void Exec_Graft::Help() const { - mprintf("\tsrc [srcframe <#>] [srcfitmask ] [srcmask ]\n" - "\t[srccharge \n" - "\ttgt [tgtframe <#>] [tgtfitmask ] [tgtmask ]\n" - "\t[tgtcharge \n" + mprintf("\tsrc [srcframe <#>] [srcmask [srccharge ]]\n" + "\ttgt [tgtframe <#>] [tgtmask [tgtcharge ]]\n" + "\t{ic | [srcfitmask ] [tgtfitmask ]}\n" "\tname [bond , ...]\n" - " Graft coordinates from source to coordinates in target.\n"); + " Graft coordinates from source to coordinates in target.\n" + " If 'ic' is specified use internal coordinates to link the coordinates,\n" + " otherwise rely on rms-fitting. If 'ic' is specified, exactly 1 bond\n" + " must be specified.\n"); } // Exec_Graft::Execute() From 9c9243336ca8bab14c9c905b1e17d6ec916a204b Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 1 Nov 2023 13:33:28 -0400 Subject: [PATCH 243/245] Version 6.21.0. Minor version bump for the addition of internal coordinates handling and related commands zmatrix and sequence; also the reading of Amber prep and lib file formats. --- src/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Version.h b/src/Version.h index 7c898f252d..f4967b2642 100644 --- a/src/Version.h +++ b/src/Version.h @@ -12,7 +12,7 @@ * Whenever a number that precedes is incremented, all subsequent * numbers should be reset to 0. */ -#define CPPTRAJ_INTERNAL_VERSION "V6.20.6" +#define CPPTRAJ_INTERNAL_VERSION "V6.21.0" /// PYTRAJ relies on this #define CPPTRAJ_VERSION_STRING CPPTRAJ_INTERNAL_VERSION #endif From 5b5f87fac47de2a380bdd028d29e7a638f042035 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 2 Nov 2023 08:59:26 -0400 Subject: [PATCH 244/245] Fix LD_LIBRARY_PATH in YML --- .github/workflows/merge-gate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/merge-gate.yml b/.github/workflows/merge-gate.yml index e707ce0eef..9260adea1e 100644 --- a/.github/workflows/merge-gate.yml +++ b/.github/workflows/merge-gate.yml @@ -83,7 +83,7 @@ jobs: make install cd .. export PATH=$HOME/bin:$PATH - export LD_LIBRARY_PATH=$HOME/lib:$PATH + export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH export DO_PARALLEL="mpirun -n 2" if [ $USE_OPENMP = "yes" ]; then export OMP_NUM_THREADS=1 From 15b414fb17059fe1f06a1fb245678315fa8e9fea Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 2 Nov 2023 10:55:51 -0400 Subject: [PATCH 245/245] Do clang tests even if not on osx --- configure | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/configure b/configure index b635608b99..38282377c9 100755 --- a/configure +++ b/configure @@ -2342,10 +2342,7 @@ EOF CXXFLAGS="$CXXFLAGS -DMPICH_IGNORE_CXX_SEEK" fi fi - # ----- Mac OSX -------------------------------- - if [ "$PLATFORM" = 'Darwin' ] ; then - SHARED_SUFFIX='.dylib' - if [ "$COMPILERS" = 'clang' ] ; then + if [ "$COMPILERS" = 'clang' ] ; then # On OSX with clang, some libraries may be built with libstdc++ and will # fail to link without this flag. cat > testp.cpp <