File: Trajectory.h

package info (click to toggle)
rdkit 202209.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 203,880 kB
  • sloc: cpp: 334,239; python: 80,247; ansic: 24,579; java: 7,667; sql: 2,123; yacc: 1,884; javascript: 1,358; lex: 1,260; makefile: 576; xml: 229; fortran: 183; cs: 181; sh: 101
file content (105 lines) | stat: -rw-r--r-- 4,447 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// Copyright (C) 2003-2016 Sereina Riniker, Paolo Tosco
//
//   @@ All Rights Reserved @@
//  This file is part of the RDKit.
//  The contents are covered by the terms of the BSD license
//  which is included in the file license.txt, found at the root
//  of the RDKit source tree.
//

#include <RDGeneral/export.h>
#ifndef RD_TRAJECTORY_H
#define RD_TRAJECTORY_H
#include <vector>
#include "Snapshot.h"

namespace RDKit {

class ROMol;

class RDKIT_TRAJECTORY_EXPORT Trajectory {
 public:
  /*! \brief Constructor
      \param dimension represents the dimensionality of this Trajectory's
     coordinate tuples; this is normally 2 (2D coordinates) or 3 (3D
     coordinates) \param numPoints is the number of coordinate tuples associated
     to each Snapshot \param snapshotVect (optional, defaults to NULL) is a
     pointer to a SnapshotVect used to initialize the Trajectory; if not NULL,
     the Trajectory takes ownership of the SnapshotVect
   */
  Trajectory(unsigned int dimension, unsigned int numPoints,
             SnapshotVect *snapshotVect = nullptr);
  /*! \brief Copy constructor
   */
  Trajectory(const Trajectory &other);
  /*! \return the dimensionality of this Trajectory's coordinate tuples
   */
  unsigned int dimension() const { return d_dimension; }
  /*! \return the number of coordinate tuples associated to each Snapshot
   */
  unsigned int numPoints() const { return d_numPoints; }
  /*! \return the number of Snapshots associated to this Trajectory
   */
  size_t size() const { return d_snapshotVect->size(); }
  /*! \brief Appends a Snapshot to this Trajectory
      \param s is the Snapshot to be added; the Trajectory
             takes ownership of the snapshot coordinates
      \return the zero-based index position of the added Snapshot
   */
  unsigned int addSnapshot(const Snapshot &s);
  /*! \param snapshotNum is the zero-based index of the retrieved Snapshot
      \return a const reference to the relevant Snapshot in the Trajectory
   */
  const Snapshot &getSnapshot(unsigned int snapshotNum) const;
  /*! \brief Inserts a Snapshot into this Trajectory
      \param snapshotNum is the zero-based index of the Trajectory's Snapshot
             before which the Snapshot s will be inserted
      \param s is the Snapshot to be inserted; the Trajectory
             takes ownership of the snapshot coordinates
      \return the zero-based index position of the inserted Snapshot
   */
  unsigned int insertSnapshot(unsigned int snapshotNum, Snapshot s);
  /*! \brief Removes a Snapshot from this Trajectory
      \param snapshotNum is the zero-based index of Snapshot to be removed
      \return the zero-based index position of the Snapshot after the
              removed one; if the last Snapshot was removed, it returns the
              size of the trajectory
   */
  unsigned int removeSnapshot(unsigned int snapshotNum);
  //! Clear all Snapshots from a Trajectory
  void clear() { d_snapshotVect->clear(); }
  //! Add conformations from the Trajectory to a molecule
  /*!
    \param mol - ROMol to which Conformers with coordinates from the Trajectory
    will be added; the Trajectory must have numPoints() == mol.getNumAtoms()
    \param from - the first Snapshot that will be added as a Conformer; defaults
    to -1 (first available) \param to - the last Snapshot that will be added as
    a Conformer; defaults to -1 (all) \return the number of conformations added
  */
  unsigned int addConformersToMol(ROMol &mol, int from = -1, int to = -1);

 private:
  // dimensionality of this Trajectory's coordinates;
  // this is normally 2 (2D coordinates) or 3 (3D coordinates)
  const unsigned int d_dimension;
  // number of coordinate tuples associated to each Snapshot
  const unsigned int d_numPoints;
  // smart_ptr to vector holding the Snapshots for this Trajectory
  boost::shared_ptr<SnapshotVect> d_snapshotVect;
};
/*! \brief Reads coordinates from an AMBER trajectory file
           into the traj Trajectory object
    \return the number of Snapshot objects read in
 */
RDKIT_TRAJECTORY_EXPORT unsigned int readAmberTrajectory(
    const std::string &fName, Trajectory &traj);
/*! \brief Reads coordinates from a GROMOS trajectory file
           into the traj Trajectory object
    \return the number of Snapshot objects read in
 */
RDKIT_TRAJECTORY_EXPORT unsigned int readGromosTrajectory(
    const std::string &fName, Trajectory &traj);

}  // namespace RDKit
#endif