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