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

More...

Inherits _ApoObject.

Public Member Functions

None __init__ (self, FilePath path)
 Constructs an owning wrapper from one CHARMM coordinate file.
 
int getNumAtoms (self)
 Returns the parsed atom count.
 
list[list[float]] getCoordinates (self)
 Returns a copied nested list of Cartesian coordinates.
 

Detailed Description

Owns coordinates parsed from one CHARMM CRD or COR file.

Construct the wrapper from a str, bytes, os.PathLike[str], or os.PathLike[bytes] path. The path is converted with os.fsencode, copied through the C ABI, and not retained. Native parsing completes synchronously before construction returns.

getCoordinates() returns a newly allocated nested Python list in atom-major [x, y, z] order. Returned values never alias native storage. The wrapper owns one C handle. close(), destroy(), and context-manager exit release it idempotently. Accessing a getter after closure raises RuntimeError.

The wrapper provides no internal synchronization. Do not overlap close() with another method call from a different thread.

See also
coordinates

Constructor & Destructor Documentation

◆ __init__()

None apocharmm.charmm_crd.CharmmCrd.__init__ (   self,
FilePath  path 
)

Constructs an owning wrapper from one CHARMM coordinate file.

Standard and extended CHARMM fixed-width coordinate records are supported. File-name extensions are not validated. The encoded path and file contents are not retained after native construction finishes.

Parameters
[in]pathPath supplied as str, bytes, os.PathLike[str], or os.PathLike[bytes]. Its encoded representation must be nonempty.
Exceptions
TypeErrorIf path cannot be converted by os.fsencode.
ApoCharmmErrorIf the encoded path is empty, the file cannot be read, the atom count or a coordinate record is malformed, a coordinate is non-finite, or native host allocation fails.
RuntimeErrorIf APOCHARMM_LIBRARY_PATH is unset or empty, or native construction reports success but produces a NULL handle.
OSErrorIf the configured apoCHARMM C ABI shared library cannot be loaded.
Postcondition
On success, this wrapper owns a live coordinate handle.
Warning
An encoded path containing an embedded null byte is truncated at that byte by the C-string boundary instead of being rejected.

Member Function Documentation

◆ getCoordinates()

list[list[float]] apocharmm.charmm_crd.CharmmCrd.getCoordinates (   self)

Returns a copied nested list of Cartesian coordinates.

The result contains one three-element list per atom in [x, y, z] order. Values are Python float objects copied from native double-precision host storage and use angstroms. An empty coordinate set returns an empty list.

Returns
Newly allocated list[list[float]] with exact shape (N, 3).
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf the native count or coordinate getter rejects the handle or output buffer.
OverflowErrorIf 3 * N cannot be represented as a ctypes array length.
MemoryErrorIf the temporary C buffer or returned Python lists cannot be allocated.
Postcondition
Mutating the returned lists does not modify native coordinates.

◆ getNumAtoms()

int apocharmm.charmm_crd.CharmmCrd.getNumAtoms (   self)

Returns the parsed atom count.

Returns
Non-negative dimensionless Python int.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf the native handle is invalid or reports a negative atom count.