mdtraj.formats.PDBTrajectoryFile
- class mdtraj.formats.PDBTrajectoryFile(filename, mode='r', force_overwrite=True, standard_names=True, top=None, bond_orders=False)[source]
Interface for reading and writing Protein Data Bank (PDB) files
- Parameters:
filename (path-like) – The filename to open. A path to a file on disk.
mode ({'r', 'w'}) – The mode in which to open the file, either ‘r’ for read or ‘w’ for write.
force_overwrite (bool) – If opened in write mode, and a file by the name of filename already exists on disk, should we overwrite it?
standard_names (bool, default=True) – If True, non-standard atomnames and residuenames are standardized to conform with the current PDB format version. If set to false, this step is skipped.
top (mdtraj.core.Topology, default=None) – if you give a topology as input the topology won’t be parsed from the pdb file it saves time if you have to parse a big number of files
bond_orders (bool, default=False) – If False (default), the parser ignores any additional duplicate bonds in the CONECT section. If True, the reader will respect and infer bond order/type based on the CONECT section, where consecutive listing of bonds are treated as having a higher bond order. If the bond is listed multiple times in the CONECT section, the highest listed bond order prevails.
- positions
- Type:
np.ndarray, shape=(n_frames, n_atoms, 3)
- topology
- Type:
- closed
- Type:
bool
Notes
When writing pdb files, mdtraj follows the PDB3.0 standard as closely as possible. During reading however, we try to be more lenient. For instance, we will parse common nonstandard atom names during reading, and convert them into the standard names. The replacement table used by mdtraj is at {mdtraj_source}/formats/pdb/data/pdbNames.xml.
See also
mdtraj.load_pdbHigh-level wrapper that returns a
md.Trajectory
- Attributes:
Methods
close()Close the PDB file
set_chain_names(values)Set the cycle of chain names used when writing PDB files
write(positions, topology[, modelIndex, ...])Write a PDB file to disk
- __init__(filename, mode='r', force_overwrite=True, standard_names=True, top=None, bond_orders=False)[source]
Methods
__init__(filename[, mode, force_overwrite, ...])close()Close the PDB file
set_chain_names(values)Set the cycle of chain names used when writing PDB files
write(positions, topology[, modelIndex, ...])Write a PDB file to disk
Attributes
Whether the file is closed
distance_unitThe cartesian coordinates of all of the atoms in each frame.
The topology from this PDB file.
unitcell_anglesThe unitcell angles (3-tuple) in this PDB file.
unitcell_lengthsThe unitcell lengths (3-tuple) in this PDB file.