NetSci
Loading...
Searching...
No Matches
network.h
1//
2// Created by astokely on 5/2/23.
3//
4
5#ifndef NETSCI_NETWORK_H
6#define NETSCI_NETWORK_H
7
8#include <map>
9#include "node.h"
10
11
12class Network {
13public:
14 /**
15 * \brief Default constructor for Network.
16 *
17 * Constructs an empty Network object.
18 */
20
21 /**
22 * \brief Destructor for Network.
23 */
25
26 /**
27 * \brief Initialize the Network with trajectory and topology files.
28 *
29 * Initializes the Network by loading trajectory and topology files.
30 *
31 * \param trajectoryFile Path to the trajectory file.
32 * \param topologyFile Path to the topology file.
33 * \param firstFrame Index of the first frame to consider.
34 * \param lastFrame Index of the last frame to consider.
35 * \param stride Stride between frames.
36 *
37 * @PythonExample{NetChem_Network_init.py}
38 */
39 void init(
40 const std::string &trajectoryFile,
41 const std::string &topologyFile,
42 int firstFrame,
43 int lastFrame,
44 int stride=1
45 );
46
47 /**
48 * \brief Get the number of nodes in the Network.
49 *
50 * Returns the number of nodes in the Network.
51 *
52 * \return The number of nodes.
53 *
54 * @PythonExample{NetChem_Network_numNodes.py}
55 */
56 int numNodes() const;
57
58 /**
59 * \brief Get the node coordinates as a CuArray.
60 *
61 * Returns a pointer to the CuArray object containing the node coordinates.
62 *
63 * \return A pointer to the CuArray containing the node coordinates.
64 *
65 * @PythonExample{NetChem_Network_nodeCoordinates1.py}
66 */
68
69 /**
70 * \brief Get a reference to the vector of nodes in the Network.
71 *
72 * Returns a reference to the vector of nodes in the Network.
73 *
74 * \return A reference to the vector of nodes.
75 *
76 * @PythonExample{NetChem_Network_nodes.py}
77 */
78 std::vector<Node*>& nodes();
79
80 /**
81 * \brief Get the number of frames in the Network.
82 *
83 * Returns the number of frames in the Network.
84 *
85 * \return The number of frames.
86 *
87 * @PythonExample{NetChem_Network_numFrames.py}
88 */
89 int numFrames() const;
90
91 /**
92 * \brief Get the node corresponding to the Atom with the given index.
93 *
94 * Returns a pointer to the Node object that the Atom with the
95 * specified index is part of
96 *
97 * \param atomIndex The index of the Atom.
98 * \return A pointer to the Node corresponding to the Atom index.
99 *
100 * @PythonExample{NetChem_Network_nodeFromAtomIndex.py}
101 */
102 Node* nodeFromAtomIndex(int atomIndex);
103
104 /**
105 * \brief Get the Atoms object associated with the Network.
106 *
107 * Returns a pointer to the Atoms object associated with the Network.
108 *
109 * \return A pointer to the Atoms object.
110 *
111 * @PythonExample{NetChem_Network_atoms.py}
112 */
113 Atoms* atoms() const;
114
115 /**
116 * \brief Parse a PDB file to populate the Network.
117 *
118 * Parses the specified PDB file to populate the Network with Atom and Node objects.
119 *
120 * \param fname Path to the PDB file.
121 */
122 void parsePdb(const std::string& fname);
123
124 /**
125 * \brief Parse a DCD file to populate the Network.
126 *
127 * Parses the specified DCD file to populate the Network with node coordinates.
128 *
129 * \param fname Path to the node coordinates file.
130 * \param firstFrame Index of the first frame to consider.
131 * \param lastFrame Index of the last frame to consider.
132 * \param stride Stride between frames.
133 */
135 const std::string &nodeCoordinates,
136 int firstFrame,
137 int lastFrame,
138 int stride
139 );
140
141 /**
142 * \brief Save the Network as a JSON file.
143 *
144 * Saves the Network as a JSON file.
145 *
146 * \param jsonFile Path to the JSON file.
147 *
148 * @PythonExample{NetChem_Network_save.py}
149 */
150 void save(const std::string& jsonFile);
151
152 /**
153 * \brief Load a Network from a JSON file.
154 *
155 * Loads a Network from the specified JSON file.
156 *
157 * \param jsonFile Path to the JSON file.
158 *
159 * @PythonExample{NetChem_Network_load.py}
160 */
161 void load(const std::string& jsonFile);
162
163 /**
164 * \brief Set the node coordinates from a file.
165 *
166 * Sets the node coordinates from the specified node coordinates file.
167 *
168 * \param nodeCoordinatesFile Path to the node coordinates file.
169 *
170 * @PythonExample{NetChem_Network_nodeCoordinates2.py}
171 */
172 void nodeCoordinates(const std::string& nodeCoordinatesFile);
173
174private:
175 friend nlohmann::adl_serializer<Network*>;
176 std::vector<Node*> nodeAtomIndexVector_; // Vector of nodes.
177 // The position of each node corresponds to the index of an Atom
178 // in the Node.
179 std::vector<Node*> nodes_; // Vector of nodes sorted by node index.
180 int numNodes_; // Number of nodes.
181 int numFrames_; // Number of frames.
182 CuArray<float>* nodeCoordinates_; // Coordinates of nodes.
183 Atoms* atoms_; // Atoms object.
184};
185
186#endif //NETSCI_NETWORK_H
Definition atoms.h:15
Manages CUDA-supported arrays, offering initialization, memory management, and data manipulation....
Definition cuarray.h:24
Definition network.h:12
int numNodes() const
Get the number of nodes in the Network.
Atoms * atoms() const
Get the Atoms object associated with the Network.
Network()
Default constructor for Network.
void nodeCoordinates(const std::string &nodeCoordinatesFile)
Set the node coordinates from a file.
Node * nodeFromAtomIndex(int atomIndex)
Get the node corresponding to the Atom with the given index.
std::vector< Node * > & nodes()
Get a reference to the vector of nodes in the Network.
void init(const std::string &trajectoryFile, const std::string &topologyFile, int firstFrame, int lastFrame, int stride=1)
Initialize the Network with trajectory and topology files.
void parseDcd(const std::string &nodeCoordinates, int firstFrame, int lastFrame, int stride)
Parse a DCD file to populate the Network.
void parsePdb(const std::string &fname)
Parse a PDB file to populate the Network.
~Network()
Destructor for Network.
CuArray< float > * nodeCoordinates()
Get the node coordinates as a CuArray.
int numFrames() const
Get the number of frames in the Network.
void save(const std::string &jsonFile)
Save the Network as a JSON file.
void load(const std::string &jsonFile)
Load a Network from a JSON file.
Represents a node in a graph.
Definition node.h:16