biotite.structure.io.pdb.PDBFile

class biotite.structure.io.pdb.PDBFile[source]

Bases: biotite.file.TextFile

This class represents a PDB file.

The usage of PDBxFile is encouraged in favor of this class.

This class only provides support for reading/writing the pure atom information (ATOM, HETATM, *MODEL and ENDMDL records). TER records cannot be written.

See also

PDBxFile

Examples

Load a \*.pdb file, modify the structure and save the new structure into a new file:

>>> import os.path
>>> file = PDBFile()
>>> file.read(os.path.join(path_to_structures, "1l2y.pdb"))
>>> array_stack = file.get_structure()
>>> array_stack_mod = rotate(array_stack, [1,2,3])
>>> file = PDBFile()
>>> file.set_structure(array_stack_mod)
>>> file.write(os.path.join(path_to_directory, "1l2y_mod.pdb"))
get_structure(self, model=None, insertion_code=[], altloc=[], extra_fields=[])[source]

Get an AtomArray or AtomArrayStack from the PDB file.

Parameters
modelint, optional

If this parameter is given, the function will return an AtomArray from the atoms corresponding to the given model ID. If this parameter is omitted, an AtomArrayStack containing all models will be returned, even if the structure contains only one model.

insertion_codelist of tuple, optional

In case the structure contains insertion codes, those can be specified here: Each tuple consists of an integer, specifying the residue ID, and a letter, specifying the insertion code. By default no insertions are used.

altloclist of tuple, optional

In case the structure contains altloc entries, those can be specified here: Each tuple consists of an integer, specifying the residue ID, and a letter, specifying the altloc ID. By default the location with the altloc ID “A” is used.

extra_fieldslist of str, optional

The strings in the list are optional annotation categories that should be stored in the output array or stack. There are 4 optional annotation identifiers: ‘atom_id’, ‘b_factor’, ‘occupancy’ and ‘charge’.

Returns
arrayAtomArray or AtomArrayStack

The return type depends on the model parameter.

set_structure(self, array)[source]

Set the AtomArray or AtomArrayStack for the file.

This makes also use of the optional annotation arrays ‘atom_id’, ‘b_factor’, ‘occupancy’ and ‘charge’.

Parameters
arrayAtomArray or AtomArrayStack

The array or stack to be saved into this file. If a stack is given, each array in the stack is saved as separate model.

copy(self)

Create a deep copy of this object.

Returns
copy

A copy of this object.

read(self, file)

Parse a file (or file-like object) and store the content in this object.

Parameters
file_namefile-like object or str

The file to be read. Alternatively a file path can be supplied.

write(self, file)

Write the contents of this object into a file (or file-like object).

Parameters
file_namefile-like object or str

The file to be written to. Alternatively a file path can be supplied.