1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
|
.. _molck:
Molecular Checker (Molck)
--------------------------------------------------------------------------------
The Molecular Checker (Molck) is a tool for cleaning up molecular structures
and making them conform to the :doc:`compound library <../../conop/compoundlib>`.
Molck removes any residues and atoms that are not defined in the compound
library. This means that if the structure contains residues or atoms that
are not part of the compound library, they will be removed during the cleaning
process.
.. caution::
Do not use Molck if you need to preserve residues or atoms that are not
defined in the compound library. For example, if your structure contains
ligands or other custom molecules that are not in the compound library,
using Molck would not preserve these components.
Programmatic usage
##################
Molecular Checker (Molck) could be called directly from the code using Molck
function:
.. code-block:: python
#! /bin/env python
"""Run Molck with Python API.
This is an exemplary procedure on how to run Molck using Python API which is
equivalent to the command line:
molck <PDB PATH> --rm=hyd,oxt,nonstd,unk \
--fix-ele --out=<OUTPUT PATH> \
--complib=<PATH TO compounds.chemlib>
"""
from ost.io import LoadPDB, SavePDB
from ost.mol.alg import MolckSettings, Molck
from ost.conop import CompoundLib
pdbid = "<PDB PATH>"
lib = CompoundLib.Load("<PATH TO compounds.chemlib>")
# Using Molck function
ent = LoadPDB(pdbid)
ms = MolckSettings(rm_unk_atoms=True,
rm_non_std=True,
rm_hyd_atoms=True,
rm_oxt_atoms=True,
rm_zero_occ_atoms=False,
colored=False,
map_nonstd_res=False,
assign_elem=True)
Molck(ent, lib, ms)
SavePDB(ent, "<OUTPUT PATH>")
It can also be split into subsequent commands for greater controll:
.. code-block:: python
#! /bin/env python
"""Run Molck with Python API.
This is an exemplary procedure on how to run Molck using Python API which is
equivalent to the command line:
molck <PDB PATH> --rm=hyd,oxt,nonstd,unk \
--fix-ele --out=<OUTPUT PATH> \
--complib=<PATH TO compounds.chemlib>
"""
from ost.io import LoadPDB, SavePDB
from ost.mol.alg import (RemoveAtoms, MapNonStandardResidues,
CleanUpElementColumn)
from ost.conop import CompoundLib
pdbid = "<PDB PATH>"
lib = CompoundLib.Load("<PATH TO compounds.chemlib>")
map_nonstd = False
# Using function chain
ent = LoadPDB(pdbid)
if map_nonstd:
MapNonStandardResidues(lib=lib, ent=ent)
RemoveAtoms(lib=lib,
ent=ent,
rm_unk_atoms=True,
rm_non_std=True,
rm_hyd_atoms=True,
rm_oxt_atoms=True,
rm_zero_occ_atoms=False,
colored=False)
CleanUpElementColumn(lib=lib, ent=ent)
SavePDB(ent, "<OUTPUT PATH>")
API
###
.. class:: MolckSettings(rm_unk_atoms=True, rm_non_std=False, \
rm_hyd_atoms=True, rm_oxt_atoms=False, \
rm_zero_occ_atoms=False, colored=False, \
map_nonstd_res=True, assign_elem=True)
Stores settings used for Molecular Checker.
:param rm_unk_atoms: Sets :attr:`rm_unk_atoms`.
:param rm_non_std: Sets :attr:`rm_non_std`.
:param rm_hyd_atoms: Sets :attr:`rm_hyd_atoms`.
:param rm_oxt_atoms: Sets :attr:`rm_oxt_atoms`.
:param rm_zero_occ_atoms: Sets :attr:`rm_zero_occ_atoms`.
:param colored: Sets :attr:`colored`.
:param map_nonstd_res: Sets :attr:`map_nonstd_res`.
:param assign_elem: Sets :attr:`assign_elem`.
.. attribute:: rm_unk_atoms
.. tip::
This flag should **always** be set to True. Other flags will behave
unexpectedly otherwise.
Remove unknown atoms. That is 1) any atom from residues that are not
present in the compound library (provided at Molck call) and 2) any atom
with a name that is not present in the respective entries of the compound
library.
:type: :class:`bool`
.. attribute:: rm_non_std
Remove all residues not one of the 20 standard amino acids.
This removes all other residues including unknown residues, ligands,
saccharides and nucleotides (including the 4 standard nucleotides).
:type: :class:`bool`
.. attribute:: rm_hyd_atoms
Remove hydrogen atoms. That's all atoms with element specified as H or D
in the respective entries of the compound library (provided at Molck call).
Unknown atoms (see :attr:`rm_unk_atoms`) are not removed by this flag. If you
really want to get rid of every hydrogen, you need to combine it with
:attr:`rm_unk_atoms`.
:type: :class:`bool`
.. attribute:: rm_oxt_atoms
Remove all atoms with name "OXT". That's typically terminal oxygens in protein
chains, but this might remove arbitrary atoms in other molecules. You should
only use this flag in combination with :attr:`rm_non_std`.
:type: :class:`bool`
.. attribute:: rm_zero_occ_atoms
Remove atoms with zero occupancy.
:type: :class:`bool`
.. attribute:: colored
Whether output should be colored.
:type: :class:`bool`
.. attribute:: map_nonstd_res
Maps modified residues back to the parent amino acid, for example
MSE -> MET, SEP -> SER.
:type: :class:`bool`
.. attribute:: assign_elem
Assigns elements as defined in the respective entries of the compound
library (provided at Molck call). For unknown atoms (see definition in
:attr:`rm_unk_atoms`), the element is set to an empty string.
To avoid empty strings as elements, this property should only be applied
in combination with :attr:`rm_unk_atoms`.
:type: :class:`bool`
.. method:: ToString()
:return: String representation of the MolckSettings.
:rtype: :class:`str`
.. warning::
The API here is set such that the functions modify the passed structure *ent*
in-place. If this is not ok, please work on a copy of the structure.
.. function:: Molck(ent, lib, settings, [prune=True])
Runs Molck on provided entity. Reprocesses *ent* with
:class:`ost.conop.HeuristicProcessor` and given *lib* once done.
:param ent: Structure to check
:type ent: :class:`~ost.mol.EntityHandle`
:param lib: Compound library
:type lib: :class:`~ost.conop.CompoundLib`
:param settings: Molck settings
:type settings: :class:`MolckSettings`
:param prune: Whether to remove residues/chains that don't contain atoms
anymore after Molck cleanup
:type prune: :class:`bool`
.. function:: MapNonStandardResidues(ent, lib, reprocess=True)
Maps modified residues back to the parent amino acid, for example MSE -> MET.
:param ent: Structure to check
:type ent: :class:`~ost.mol.EntityHandle`
:param lib: Compound library
:type lib: :class:`~ost.conop.CompoundLib`
:param reprocess: The function generates a deep copy of *ent*. Highly
recommended to enable *reprocess* that runs
:class:`ost.conop.HeuristicProcessor` with given *lib*.
If set to False, you'll have no connectivity etc. after
calling this function.
.. function:: RemoveAtoms(ent, lib, rm_unk_atoms=True, rm_non_std=False, \
rm_hyd_atoms=True, rm_oxt_atoms=False, \
rm_zero_occ_atoms=False, colored=False,
reprocess=True)
Removes atoms and residues according to some criteria.
:param ent: Structure to check
:type ent: :class:`~ost.mol.EntityHandle`
:param lib: Compound library
:type lib: :class:`~ost.conop.CompoundLib`
:param rm_unk_atoms: See :attr:`MolckSettings.rm_unk_atoms`
:param rm_non_std: See :attr:`MolckSettings.rm_non_std`
:param rm_hyd_atoms: See :attr:`MolckSettings.rm_hyd_atoms`
:param rm_oxt_atoms: See :attr:`MolckSettings.rm_oxt_atoms`
:param rm_zero_occ_atoms: See :attr:`MolckSettings.rm_zero_occ_atoms`
:param colored: See :attr:`MolckSettings.colored`
:param reprocess: Removing atoms may impact certain annotations on the
structure (chem class etc.) which are set by
:class:`ost.conop.Processor`. If set to True,
a :class:`ost.conop.HeuristicProcessor` with given
*lib* reprocesses *ent*.
.. function:: CleanUpElementColumn(ent, lib)
Assigns elements as defined in the respective entries of the compound library
as described in :attr:`MolckSettings.assign_elem`. This should only be called
after :func:`RemoveAtoms` with :attr:`rm_unk_atoms` set to True.
:param ent: Structure to check
:type ent: :class:`~ost.mol.EntityHandle`
:param lib: Compound library
:type lib: :class:`~ost.conop.CompoundLib`
|