apoCHARMM 1.0.0
High-performance molecular dynamics simulations on GPUs
 
Loading...
Searching...
No Matches
CharmmCrd Class Reference

Owns Cartesian coordinates parsed from a CHARMM CRD or COR file. More...

#include <CharmmCrd.h>

Inheritance diagram for CharmmCrd:
Coordinates

Public Member Functions

 CharmmCrd (const std::filesystem::path &filePath)
 Constructs coordinates by parsing one CHARMM CRD or COR file.
 
- Public Member Functions inherited from Coordinates
 Coordinates (void)
 Constructs an unset coordinate object.
 
 Coordinates (const std::vector< double3 > &coords)
 Constructs both representations from double-precision coordinates.
 
 Coordinates (const std::vector< float3 > &coords)
 Constructs both representations from single-precision coordinates.
 
 Coordinates (const std::vector< std::vector< double > > &coords)
 Constructs both representations from nested double rows.
 
 Coordinates (const std::vector< std::vector< float > > &coords)
 Constructs both representations from nested float rows.
 
void setNumAtoms (const int numAtoms)
 Sets the atom count and resizes both coordinate vectors.
 
int getNumAtoms (void) const
 Returns the stored atom count.
 
const std::vector< double3 > & getCoordinatesDP (void) const
 Returns the double-precision coordinate vector.
 
std::vector< double3 > & getCoordinatesDP (void)
 Returns mutable double-precision coordinate storage.
 
const std::vector< float3 > & getCoordinatesSP (void) const
 Returns the single-precision coordinate vector.
 
std::vector< float3 > & getCoordinatesSP (void)
 Returns mutable single-precision coordinate storage.
 

Additional Inherited Members

- Protected Attributes inherited from Coordinates
int m_NumAtoms
 
std::vector< double3 > m_CoordinatesDP
 
std::vector< float3 > m_CoordinatesSP
 

Detailed Description

Owns Cartesian coordinates parsed from a CHARMM CRD or COR file.

Construction reads and parses the file synchronously into the inherited host-resident double- and single-precision coordinate vectors. Only Cartesian coordinates are retained. Atom identifiers, residue metadata, segment data, weights, and any other trailing fields are ignored. No file path is retained after construction, and no CUDA allocation, transfer, or synchronization is performed.

Compiler-generated copy and move operations have the same owned-vector semantics as Coordinates. The inherited mutable accessors remain unchecked escape hatches.

Warning
The inherited Coordinates destructor is not virtual. Do not delete this object through a Coordinates pointer.
See also
coordinates
apo_charmm_crd
python_charmm_crd

Constructor & Destructor Documentation

◆ CharmmCrd()

CharmmCrd::CharmmCrd ( const std::filesystem::path &  filePath)

Constructs coordinates by parsing one CHARMM CRD or COR file.

Consecutive nonempty lines beginning with * in column one are treated as title records. The first following line supplies the atom count in its first space-delimited token. An exact uppercase EXT second token selects extended records; otherwise standard records are assumed.

Standard records read X, Y, and Z from one-based columns 21-30, 31-40, and 41-50. Extended records read them from columns 41-60, 61-80, and 81-100. The parsed values must be finite doubles and use angstroms. The file-name extension is not validated.

Parameters
[in]filePathBorrowed file-system path. It must be nonempty. The path and file contents are copied as needed during construction and are not retained after return.
Exceptions
ApoCharmmErrorWith code ApoCharmmErrorCode::InvalidArgument if filePath is empty.
ApoCharmmErrorWith code ApoCharmmErrorCode::Runtime if the file cannot be opened, sized, sought, or read; the atom count is missing, malformed, negative, or greater than INT_MAX; a required coordinate record or field is missing; or a coordinate is malformed, out of range, or non-finite.
std::bad_allocIf file, vector, or diagnostic storage cannot be allocated.
std::length_errorIf file, vector, or diagnostic storage exceeds an implementation limit.
Postcondition
On success, getNumAtoms() is the parsed non-negative count and both inherited coordinate vectors contain that many atom records.
Warning
The parser verifies that each coordinate is a finite double, but does not verify representability as float before constructing the single-precision representation.