PDBQTFile#
- class biotite.structure.io.pdbqt.PDBQTFile[source]#
Bases:
TextFileThis class represents an AutoDock PDBQT file.
This class only provides rudimentary support for reading/writing the pure atom information.
EXPERIMENTAL: Future API changes are probable.
Examples
Write biotin as flexible ligand into a PDBQT file:
>>> import os.path >>> ligand = residue("BTN") >>> file = PDBQTFile() >>> mask = file.set_structure(ligand, rotatable_bonds="all") >>> # Print removed nonpolar hydrogen atoms >>> print(ligand[~mask]) HET 0 BTN H101 H 3.745 1.171 0.974 HET 0 BTN H102 H 4.071 1.343 -0.767 HET 0 BTN H91 H 2.802 -0.740 -1.211 HET 0 BTN H92 H 2.476 -0.912 0.530 HET 0 BTN H81 H 1.289 1.265 0.523 HET 0 BTN H82 H 1.616 1.437 -1.218 HET 0 BTN H71 H 0.346 -0.646 -1.662 HET 0 BTN H72 H 0.020 -0.818 0.079 HET 0 BTN H2 H -0.838 1.576 -1.627 HET 0 BTN H61 H -3.797 1.837 1.286 HET 0 BTN H62 H -3.367 2.738 -0.205 HET 0 BTN H5 H -4.307 0.812 -1.205 HET 0 BTN H4 H -2.451 -0.038 -2.252 >>> print(file) ROOT HETATM 1 C11 BTN 0 5.089 -0.280 0.173 1.00 0.00 0.258 C HETATM 2 O11 BTN 0 4.956 -1.473 0.030 1.00 0.00 -0.264 OA ENDROOT BRANCH 1 3 HETATM 3 O12 BTN 0 6.299 0.233 0.444 1.00 0.00 -0.331 OA HETATM 17 HO2 BTN 0 7.034 -0.391 0.517 1.00 0.00 0.221 HD ENDBRANCH 1 3 BRANCH 1 4 HETATM 4 C10 BTN 0 3.896 0.631 0.039 1.00 0.00 0.105 C BRANCH 4 5 HETATM 5 C9 BTN 0 2.651 -0.200 -0.276 1.00 0.00 0.010 C BRANCH 5 6 HETATM 6 C8 BTN 0 1.440 0.725 -0.412 1.00 0.00 0.002 C BRANCH 6 7 HETATM 7 C7 BTN 0 0.196 -0.106 -0.727 1.00 0.00 0.016 C BRANCH 7 8 HETATM 8 C2 BTN 0 -1.015 0.819 -0.863 1.00 0.00 0.065 C HETATM 9 S1 BTN 0 -1.419 1.604 0.751 1.00 0.00 -0.154 SA HETATM 10 C6 BTN 0 -3.205 1.827 0.371 1.00 0.00 0.090 C HETATM 11 C5 BTN 0 -3.530 0.581 -0.476 1.00 0.00 0.091 C HETATM 12 N1 BTN 0 -3.970 -0.507 0.412 1.00 0.00 -0.239 NA HETATM 13 C3 BTN 0 -3.141 -1.549 0.271 1.00 0.00 0.272 C HETATM 14 O3 BTN 0 -3.271 -2.589 0.888 1.00 0.00 -0.259 OA HETATM 15 N2 BTN 0 -2.154 -1.343 -0.612 1.00 0.00 -0.239 NA HETATM 16 C4 BTN 0 -2.289 0.010 -1.175 1.00 0.00 0.093 C HETATM 18 HN1 BTN 0 -4.738 -0.474 1.004 1.00 0.00 0.132 HD HETATM 19 HN2 BTN 0 -1.462 -1.982 -0.843 1.00 0.00 0.132 HD ENDBRANCH 7 8 ENDBRANCH 6 7 ENDBRANCH 5 6 ENDBRANCH 4 5 ENDBRANCH 1 4 TORSDOF 6 >>> file.write(os.path.join(path_to_directory, "1l2y_mod.pdb"))
- copy()#
Create a deep copy of this object.
- Returns:
- copy
A copy of this object.
- get_remarks(model=None)#
Get the content of
REMARKSlines.- Parameters:
- modelint, optional
If this parameter is given, the function will return a string from the remarks corresponding to the given model number (starting at 1). Negative values are used to index models starting from the last model insted of the first model. If this parameter is omitted, a list of strings containing all models will be returned, even if the structure contains only one model.
- Returns:
- linesstr or list of str
The content of
REMARKSlines, without the leading'REMARKS'.
- get_structure(model=None)#
Get an
AtomArrayorAtomArrayStackfrom the PDBQT file.- Parameters:
- modelint, optional
If this parameter is given, the function will return an
AtomArrayfrom the atoms corresponding to the given model number (starting at 1). Negative values are used to index models starting from the last model insted of the first model. If this parameter is omitted, anAtomArrayStackcontaining all models will be returned, even if the structure contains only one model.
- Returns:
- arrayAtomArray or AtomArrayStack
The return type depends on the model parameter.
- classmethod read(file, *args, **kwargs)#
Parse a file (or file-like object).
- Parameters:
- filefile-like object or str
The file to be read. Alternatively a file path can be supplied.
- Returns:
- fileFile
An instance from the respective
Filesubclass representing the parsed file.
- static read_iter(file)#
Create an iterator over each line of the given text file.
- Parameters:
- filefile-like object or str
The file to be read. Alternatively a file path can be supplied.
- Yields:
- linestr
The current line in the file.
- set_structure(atoms, charges=None, atom_types=None, rotatable_bonds=None, root=None, include_torsdof=True)#
Write an
AtomArrayinto the PDBQT file.- Parameters:
- atomsAtomArray, shape=(n,)
The atoms to be written into this file. Must have an associated
BondList.- chargesndarray, shape=(n,), dtype=float, optional
Partial charges for each atom in atoms. By default, the charges are calculated using the PEOE method (
partial_charges()).- atom_typesndarray, shape=(n,), dtype=”U1”, optional
Custom AutoDock atom types for each atom in atoms.
- rotatable_bondsNone or ‘rigid’ or ‘all’ or BondList, optional
This parameter describes, how rotatable bonds are handled, with respect to
ROOT,BRANCHandENDBRANCHlines.None- The molecule is handled as rigid receptor: NoROOT,BRANCHandENDBRANCHlines will be written.'rigid'- The molecule is handled as rigid ligand: Only aROOTline will be written.'all'- The molecule is handled as flexible ligand: AROOTline will be written and all rotatable bonds are included usingBRANCHandENDBRANCHlines.BondList- The molecule is handled as flexible ligand: AROOTline will be written and all bonds in the givenBondListare considered flexible viaBRANCHandENDBRANCHlines.
- rootint, optional
Specifies the index of the atom following the
ROOTline. Setting the root atom is useful for specifying the anchor in flexible side chains. This parameter has no effect, if rotatable_bonds isNone. By default, the first atom is also the root atom.- include_torsdofbool, optional
By default, a
TORSDOF(torsional degrees of freedom) record is written at the end of the file. By setting this parameter to false, the record is omitted.
- Returns:
- maskndarray, shape=(n,), dtype=bool
A boolean mask, that is
Falsefor each atom of the inputatoms, that was removed due to being a nonpolar hydrogen.
- write(file)#
Write the contents of this object into a file (or file-like object).
- Parameters:
- filefile-like object or str
The file to be written to. Alternatively a file path can be supplied.
- static write_iter(file, lines)#
Iterate over the given lines of text and write each line into the specified file.
In contrast to
write(), each line of text is not stored in an intermediateTextFile, but is directly written to the file. Hence, this static method may save a large amount of memory if a large file should be written, especially if the lines are provided as generator.- Parameters:
- filefile-like object or str
The file to be written to. Alternatively a file path can be supplied.
- linesgenerator or array-like of str
The lines of text to be written. Must not include line break characters.