NetSci
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Friends | List of all members
Node Class Reference

Represents a node in a graph. More...

#include <node.h>

Public Member Functions

 Node ()
 Default constructor for Node.
 
 ~Node ()
 Destructor for Node.
 
 Node (unsigned int numFrames, unsigned int index_)
 Constructor for Node with specified number of frames and index.
 
void addAtom (Atom *atom, CuArray< float > *coordinates, CuArray< float > *nodeCoordinates)
 Add an Atom to the Node.
 
std::string tag ()
 Get the tag of the Node.
 
unsigned int numAtoms () const
 Get the number of Atoms in the Node.
 
unsigned int index () const
 Get the index of the Node.
 
float totalMass () const
 Get the total mass of the Node.
 
unsigned int hash () const
 Get the hash value of the Node.
 
std::vector< Atom * > atoms () const
 Get a vector of pointers to the Atoms in the Node.
 

Private Attributes

unsigned int _numAtoms
 
std::vector< int > atomIndices_
 
unsigned int _index
 
float _totalMass
 
std::string _tag
 
std::vector< Atom * > atoms_
 
unsigned int _hash = 0
 
unsigned int _numFrames
 

Friends

class Network
 

Detailed Description

Represents a node in a graph.

Constructor & Destructor Documentation

◆ Node()

Node::Node ( unsigned int  numFrames,
unsigned int  index_ 
)

Constructor for Node with specified number of frames and index.

Parameters
numFramesNumber of frames.
index_Index of the node.

Member Function Documentation

◆ addAtom()

void Node::addAtom ( Atom atom,
CuArray< float > *  coordinates,
CuArray< float > *  nodeCoordinates 
)

Add an Atom to the Node.

Adds the specified Atom to the Node along with its corresponding coordinates.

Parameters
atomPointer to the Atom object.
coordinatesPointer to the coordinates array.
nodeCoordinatesPointer to the node coordinates array.

◆ atoms()

std::vector< Atom * > Node::atoms ( ) const

Get a vector of pointers to the Atoms in the Node.

Returns a vector of pointers to the Atoms contained in the Node.

Returns
A vector of pointers to the Atoms in the Node.

Python Example

from netchem import Network, data_files
"""
1000 frame Molecular Dynamics trajectory of a pyrophosphatase system.
The dcd is a binary coordinate file, and the pdb is a single frame
topology file.
"""
dcd, pdb = data_files('pyro')
"""
Construct a network using the entire trajectory.
If you want to use only a subset of the trajectory, you can specify
the first frame, last frame, and stride.
"""
network = Network()
network.init(
trajectoryFile=str(dcd), # Convert the dcd Path object to a string
topologyFile=str(pdb), # Convert the pdb Path object to a string
firstFrame=0,
lastFrame=999,
stride=1
)
"""
For this example, we will use the first node in the network.
"""
node = network.nodes()[0]
"""
To get a vector of all Atom objects in the node, use the atoms() method.
Unlike the atoms method in the Network class, this method returns a vector
of Atom objects instead of an Atoms object. This is for memory efficiency.
"""
atoms = node.atoms()
"""
The Atom object vector is iterable, indexable, and can be converted
to a built-in Python list/tuple using the explicit list and tuple constructors.
"""
atoms_list = list(atoms)
atoms_tuple = tuple(atoms)
"""
Iterate over all atoms in the node and print their information.
For more information on the Atom class, see the Atom class documentation.
"""
for atom in atoms:
print(atom)
print("-" * 80)
Definition network.h:12

◆ hash()

unsigned int Node::hash ( ) const

Get the hash value of the Node.

Returns the hash value of the Node, which is a unique identifier based on its tag and index.

Returns
The hash value of the Node.

◆ index()

unsigned int Node::index ( ) const

Get the index of the Node.

Returns the index of the Node.

Returns
The index of the Node.

Python Example

from netchem import Network, data_files
"""
1000 frame Molecular Dynamics trajectory of a pyrophosphatase system.
The dcd is a binary coordinate file, and the pdb is a single frame
topology file.
"""
dcd, pdb = data_files('pyro')
"""
Construct a network using the entire trajectory.
If you want to use only a subset of the trajectory, you can specify
the first frame, last frame, and stride.
"""
network = Network()
network.init(
trajectoryFile=str(dcd), # Convert the dcd Path object to a string
topologyFile=str(pdb), # Convert the pdb Path object to a string
firstFrame=0,
lastFrame=999,
stride=1
)
"""
For this example, we will use the first node in the network.
"""
node = network.nodes()[0]
"""
Use the Node index method to get the index of the node.
"""
node_index = node.index()
print(node_index)

◆ numAtoms()

unsigned int Node::numAtoms ( ) const

Get the number of Atoms in the Node.

Returns the number of Atoms contained in the Node.

Returns
The number of Atoms in the Node.

Python Example

from netchem import Network, data_files
"""
1000 frame Molecular Dynamics trajectory of a pyrophosphatase system.
The dcd is a binary coordinate file, and the pdb is a single frame
topology file.
"""
dcd, pdb = data_files('pyro')
"""
Construct a network using the entire trajectory.
If you want to use only a subset of the trajectory, you can specify
the first frame, last frame, and stride.
"""
network = Network()
network.init(
trajectoryFile=str(dcd), # Convert the dcd Path object to a string
topologyFile=str(pdb), # Convert the pdb Path object to a string
firstFrame=0,
lastFrame=999,
stride=1
)
"""
For this example, we will use the first node in the network.
"""
node = network.nodes()[0]
"""
Use the Node numAtoms method to get the number of atoms in the node.
"""
num_atoms = node.numAtoms()
print(num_atoms)

◆ tag()

std::string Node::tag ( )

Get the tag of the Node.

Returns the tag of the Node, which represents its unique identifier.

Returns
The tag of the Node.

Python Example

from netchem import Network, data_files
"""
1000 frame Molecular Dynamics trajectory of a pyrophosphatase system.
The dcd is a binary coordinate file, and the pdb is a single frame
topology file.
"""
dcd, pdb = data_files('pyro')
"""
Construct a network using the entire trajectory.
If you want to use only a subset of the trajectory, you can specify
the first frame, last frame, and stride.
"""
network = Network()
network.init(
trajectoryFile=str(dcd), # Convert the dcd Path object to a string
topologyFile=str(pdb), # Convert the pdb Path object to a string
firstFrame=0,
lastFrame=999,
stride=1
)
"""
For this example, we will use the first node in the network.
"""
node = network.nodes()[0]
"""
Use the Node tag method to get the key used to
identify Node atoms. By default, the tag is defined
as the concatenation of the residue name and residue
index, chain id, and fragment id an atom belongs to.
"""
node_tag = node.tag()
print(node_tag)

◆ totalMass()

float Node::totalMass ( ) const

Get the total mass of the Node.

Returns the total mass of the Node, calculated as the sum of the masses of all the Atoms in the Node.

Returns
The total mass of the Node.

Python Example

from netchem import Network, data_files
"""
1000 frame Molecular Dynamics trajectory of a pyrophosphatase system.
The dcd is a binary coordinate file, and the pdb is a single frame
topology file.
"""
dcd, pdb = data_files('pyro')
"""
Construct a network using the entire trajectory.
If you want to use only a subset of the trajectory, you can specify
the first frame, last frame, and stride.
"""
network = Network()
network.init(
trajectoryFile=str(dcd), # Convert the dcd Path object to a string
topologyFile=str(pdb), # Convert the pdb Path object to a string
firstFrame=0,
lastFrame=999,
stride=1
)
"""
For this example, we will use the first node in the network.
"""
node = network.nodes()[0]
"""
Use the Node totalMass method to get the total mass of the node.
"""
total_mass = node.totalMass()
print(total_mass)

The documentation for this class was generated from the following file: