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