The Python interface is built on top of the C interface, using the ctypes standard module.
This interface is contained in the chemfiles
module, and this page list all
the classes and methods in this module.
chemfiles.logging.
LogLevel
¶chemfiles.logging.
log_level
()¶Get current logging level
chemfiles.logging.
log_to_file
(path)¶Write logs to the file at path
, creating it if needed.
chemfiles.logging.
log_to_stderr
()¶Write logs to the standard error stream. This is the default.
chemfiles.logging.
set_log_level
(level)¶Set the logging level to level
chemfiles.errors.
ArgumentError
¶Error in argument type
chemfiles.errors.
CPPException
(status)¶Error in C++ runtime
chemfiles.errors.
ChemfilesException
¶Base class for all Chemfiles exceptions
chemfiles.errors.
NullPointerError
(message='')¶Got a NULL pointer from C!
chemfiles.
Trajectory
(path, mode='r', fformat='')¶A Trajectory is a chemistry file on the hard drive. It is the main entry point of Chemfiles.
nsteps
()¶Get the number of steps (the number of frames) in a trajectory.
read
()¶Read the next step of the trajectory and return the corresponding frame
read_step
(step)¶Read a specific step in the trajectory and return the corresponding frame
set_cell
(cell)¶Set the unit cell associated with a trajectory. This cell will be used when reading and writing the files, replacing any unit cell in the frames or files.
set_topology
(topology)¶Set the topology associated with a trajectory. This topology will be used when reading and writing the files, replacing any topology in the frames or files.
set_topology_file
(filename)¶Set the topology associated with a trajectory by reading the first
frame of filename
; and extracting the topology of this frame.
sync
()¶Synchronize any buffered content to the hard drive.
write
(frame)¶Write a frame to the trajectory
chemfiles.
Frame
(natoms=0)¶A Frame holds data from one step of a simulation: the current Topology, the positions, and maybe the velocities of the particles in the system.
atom
(index)¶Get a specific Atom
from a frame, given its index in the frame
cell
()¶Get the UnitCell from the Frame
guess_topology
(bonds=True)¶Try to guess the bonds, angles and dihedrals in the system. If
bonds
is True, guess everything; else only guess the angles and
dihedrals from the topology bond list.
has_velocities
()¶Check if the Frame
has velocity information.
natoms
()¶Get the current number of atoms in the Frame
.
positions
()¶Get the positions from the Frame
.
set_cell
(cell)¶Set the UnitCell of the Frame
set_positions
(positions)¶Set the positions in the Frame
.
set_step
(step)¶Set the Frame
step
set_topology
(topology)¶Set the Topology of the Frame
set_velocities
(velocities)¶Set the velocities in the Frame
.
step
()¶Get the Frame
step, i.e. the frame number in the trajectory
topology
()¶Get the Topology
from the Frame
velocities
()¶Get the velocities from the Frame
.
chemfiles.
CellType
¶chemfiles.
UnitCell
(a, b, c, alpha=90.0, beta=90.0, gamma=90.0)¶An UnitCell
represent the box containing the atoms in the system, and
its periodicity.
A unit cell is fully represented by three lenghts (a, b, c); and three angles (alpha, beta, gamma). The angles are stored in degrees, and the lenghts in Angstroms. A cell also has a matricial representation, by projecting the three base vector into an orthonormal base. We choose to represent such matrix as an upper triangular matrix:
a_x b_x c_x |0 b_y c_y |0 0 c_z |
An unit cell also have a cell type, represented by the CellType class.
angles
()¶Get the three angles of an UnitCell
, in degrees.
lengths
()¶Get the three lenghts of an UnitCell
, in Angstroms.
matrix
()¶Get the unit cell matricial representation.
periodicity
()¶Get the cell periodic boundary conditions along the three axis
set_angles
(alpha, beta, gamma)¶Set the three angles of an UnitCell
, in degrees. This is only
possible with TRICLINIC
cells.
set_lengths
(a, b, c)¶Set the three lenghts of an UnitCell
, in Angstroms.
set_periodicity
(x, y, z)¶Set the cell periodic boundary conditions along the three axis
set_type
(celltype)¶Set the type of the unit cell
type
()¶Get the type of the unit cell
volume
()¶Get the volume of the unit cell
chemfiles.
Topology
¶A Topology contains the definition of all the particles in the system, and the liaisons between the particles (bonds, angles, dihedrals, ...).
Only the atoms and the bonds are stored, the angles and the dihedrals are computed automaticaly.
add_bond
(i, j)¶Add a bond between the atoms at indexes i
and j
in the system
angles
()¶Get the list of angles in the system
angles_count
()¶Get the number of angles in the system
append
(atom)¶Add an Atom
at the end of the Topology
atom
(index)¶Get the Atom
at index
from a topology.
bonds
()¶Get the list of bonds in the system
bonds_count
()¶Get the number of bonds in the system
dihedrals
()¶Get the list of dihedral angles in the system
dihedrals_count
()¶Get the number of dihedral angles in the system
isangle
(i, j, k)¶Tell if the atoms at indexes i
, j
and k
constitues an angle
isbond
(i, j)¶Tell if the atoms at indexes i
and j
are bonded together
isdihedral
(i, j, k, m)¶Tell if the atoms at indexes i
, j
, k
and m
constitues a
dihedral angle
natoms
()¶Get the current number of atoms in the Topology
.
remove
(index)¶Remove an Atom
from the Topology
by index. This modify all the
other atoms indexes.
remove_bond
(i, j)¶Remove any existing bond between the atoms at indexes i
and j
in the system
chemfiles.
AtomType
¶Element: Element from the periodic table of elements
CH3 groups, amino-acids are corse-grained atoms.
Dummy: Dummy site, with no physical reality
Undefined: Undefined atom type
chemfiles.
Atom
(name)¶An Atom is a particle in the current Frame. It can be used to store and retrieve informations about a particle, such as mass, name, atomic number, etc.
atomic_number
()¶Try to get the atomic number of the Atom. If the number can not be found, returns -1.
charge
()¶Get the Atom
charge, in number of the electron charge e
covalent_radius
()¶Try to get the covalent radius of the Atom. If the radius can not be found, returns -1.
full_name
()¶Try to get the full name of the Atom. The full name of “He” is “Helium”, and so on. If the name can not be found, returns the empty string.
mass
()¶Get the Atom
mass, in atomic mass units
name
()¶Get the Atom
name
set_charge
(charge)¶Set the Atom
charge, in number of the electron charge e
set_mass
(mass)¶Set the Atom
mass, in atomic mass units
set_name
(name)¶Set the Atom
name
set_type
(atomtype)¶Set the type of the atom
type
()¶Get the type of the atom
vdw_radius
()¶Try to get the Van der Waals radius of the Atom. If the radius can not be found, returns -1.