RDKit
Open-source cheminformatics and machine learning.
Trajectory.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2003-2016 Sereina Riniker, Paolo Tosco
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 
11 #include <RDGeneral/export.h>
12 #ifndef RD_TRAJECTORY_H
13 #define RD_TRAJECTORY_H
14 #include <vector>
15 #include "Snapshot.h"
16 
17 namespace RDKit {
18 
19 class ROMol;
20 
22  public:
23  /*! \brief Constructor
24  \param dimension represents the dimensionality of this Trajectory's coordinate tuples;
25  this is normally 2 (2D coordinates) or 3 (3D coordinates)
26  \param numPoints is the number of coordinate tuples associated to each Snapshot
27  \param snapshotVect (optional, defaults to NULL) is a pointer to a SnapshotVect
28  used to initialize the Trajectory; if not NULL, the Trajectory takes ownership
29  of the SnapshotVect
30  */
31  Trajectory(unsigned int dimension, unsigned int numPoints, SnapshotVect *snapshotVect = NULL);
32  /*! \brief Copy constructor
33  */
34  Trajectory(const Trajectory &other);
35  /*! \return the dimensionality of this Trajectory's coordinate tuples
36  */
37  unsigned int dimension() const {
38  return d_dimension;
39  }
40  /*! \return the number of coordinate tuples associated to each Snapshot
41  */
42  unsigned int numPoints() const {
43  return d_numPoints;
44  }
45  /*! \return the number of Snapshots associated to this Trajectory
46  */
47  size_t size() const {
48  return d_snapshotVect->size();
49  }
50  /*! \brief Appends a Snapshot to this Trajectory
51  \param s is the Snapshot to be added; the Trajectory
52  takes ownership of the snapshot coordinates
53  \return the zero-based index position of the added Snapshot
54  */
55  unsigned int addSnapshot(const Snapshot &s);
56  /*! \param snapshotNum is the zero-based index of the retrieved Snapshot
57  \return a const reference to the relevant Snapshot in the Trajectory
58  */
59  const Snapshot &getSnapshot(unsigned int snapshotNum) const;
60  /*! \brief Inserts a Snapshot into this Trajectory
61  \param snapshotNum is the zero-based index of the Trajectory's Snapshot
62  before which the Snapshot s will be inserted
63  \param s is the Snapshot to be inserted; the Trajectory
64  takes ownership of the snapshot coordinates
65  \return the zero-based index position of the inserted Snapshot
66  */
67  unsigned int insertSnapshot(unsigned int snapshotNum, Snapshot s);
68  /*! \brief Removes a Snapshot from this Trajectory
69  \param snapshotNum is the zero-based index of Snapshot to be removed
70  \return the zero-based index position of the Snapshot after the
71  removed one; if the last Snapshot was removed, it returns the
72  size of the trajectory
73  */
74  unsigned int removeSnapshot(unsigned int snapshotNum);
75  //! Clear all Snapshots from a Trajectory
76  void clear() {
77  d_snapshotVect->clear();
78  };
79  //! Add conformations from the Trajectory to a molecule
80  /*!
81  \param mol - ROMol to which Conformers with coordinates from the Trajectory will be added;
82  the Trajectory must have numPoints() == mol.getNumAtoms()
83  \param from - the first Snapshot that will be added as a Conformer; defaults to -1 (first available)
84  \param to - the last Snapshot that will be added as a Conformer; defaults to -1 (all)
85  \return the number of conformations added
86  */
87  unsigned int addConformersToMol(ROMol &mol, int from = -1, int to = -1);
88  private:
89  // dimensionality of this Trajectory's coordinates;
90  // this is normally 2 (2D coordinates) or 3 (3D coordinates)
91  const unsigned int d_dimension;
92  // number of coordinate tuples associated to each Snapshot
93  const unsigned int d_numPoints;
94  // smart_ptr to vector holding the Snapshots for this Trajectory
95  boost::shared_ptr<SnapshotVect> d_snapshotVect;
96 };
97 /*! \brief Reads coordinates from an AMBER trajectory file
98  into the traj Trajectory object
99  \return the number of Snapshot objects read in
100  */
101 RDKIT_TRAJECTORY_EXPORT unsigned int readAmberTrajectory(const std::string &fName, Trajectory &traj);
102 /*! \brief Reads coordinates from a GROMOS trajectory file
103  into the traj Trajectory object
104  \return the number of Snapshot objects read in
105  */
106 RDKIT_TRAJECTORY_EXPORT unsigned int readGromosTrajectory(const std::string &fName, Trajectory &traj);
107 
108 }
109 #endif
RDKIT_TRAJECTORY_EXPORT unsigned int readGromosTrajectory(const std::string &fName, Trajectory &traj)
Reads coordinates from a GROMOS trajectory file into the traj Trajectory object.
size_t size() const
Definition: Trajectory.h:47
void clear()
Clear all Snapshots from a Trajectory.
Definition: Trajectory.h:76
Std stuff.
Definition: Atom.h:30
std::vector< Snapshot > SnapshotVect
Definition: Snapshot.h:19
unsigned int numPoints() const
Definition: Trajectory.h:42
unsigned int dimension() const
Definition: Trajectory.h:37
#define RDKIT_TRAJECTORY_EXPORT
Definition: export.h:658
RDKIT_TRAJECTORY_EXPORT unsigned int readAmberTrajectory(const std::string &fName, Trajectory &traj)
Reads coordinates from an AMBER trajectory file into the traj Trajectory object.