/usr/share/pyshared/MMTK/Deformation.py is in python-mmtk 2.7.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | # Deformation energy module
#
# Written by Konrad Hinsen
#
"""
Deformation energies in proteins
This module implements deformational energies for use in the analysis
of motions and conformational changes in macromolecules. A description
of the techniques can be found in the following articles:
| K. Hinsen
| Analysis of domain motions by approximate normal mode calculations
| Proteins 33 (1998): 417-429
| K. Hinsen, A. Thomas, M.J. Field
| Analysis of domain motions in large proteins
| Proteins 34 (1999): 369-382
"""
__docformat__ = 'restructuredtext'
try:
from MMTK_forcefield import NonbondedList
from MMTK_deformation import deformation, reduceDeformation, \
reduceFiniteDeformation
except ImportError:
pass
from MMTK import ParticleProperties
from Scientific import N
#
# Deformation energy evaluations
#
class DeformationEvaluationFunction(object):
def __init__(self, universe, fc_length = 0.7, cutoff = 1.2,
factor = 46402., form = 'exponential'):
self.universe = universe
self.fc_length = fc_length
self.cutoff = cutoff
self.factor = factor
nothing = N.zeros((0,2), N.Int)
self.pairs = NonbondedList(nothing, nothing, nothing,
universe._spec, cutoff)
self.pairs.update(universe.configuration().array)
self.normalize = 0
try:
self.version = self.forms.index(form)
except ValueError:
raise ValueError("unknown functional form")
forms = ['exponential', 'calpha']
def newConfiguration(self):
self.pairs.update(self.universe.configuration().array)
class DeformationFunction(DeformationEvaluationFunction):
"""
Infinite-displacement deformation function
The default values are appropriate for a |C_alpha| model of a protein
with the global scaling described in the reference cited above.
A DeformationFunction object must be called with a single parameter,
which is a ParticleVector object containing the infinitesimal displacements
of the atoms for which the deformation is to be evaluated.
The return value is a ParticleScalar object containing the
deformation value for each atom.
"""
def __init__(self, universe, fc_length = 0.7, cutoff = 1.2,
factor = 46402., form = 'exponential'):
"""
:param universe: the universe for which the deformation function
is defined
:type universe: :class:`~MMTK.Universe.Universe`
:param fc_length: the range parameter r_0 in the pair interaction term
:type fc_length: float
:param cutoff: the cutoff used in the deformation calculation
:type cutoff: float
:param factor: a global scaling factor
:type factor: float
:param form: the functional form ('exponential' or 'calpha')
:type form: str
"""
DeformationEvaluationFunction.__init__(self, universe, fc_length,
cutoff, factor, form)
def __call__(self, vector):
conf = self.universe.configuration()
r = ParticleProperties.ParticleScalar(self.universe)
l = deformation(conf.array, vector.array, self.pairs,
None, r.array, self.cutoff, self.fc_length,
self.factor, self.normalize, 0, self.version)
return r
class NormalizedDeformationFunction(DeformationFunction):
"""
Normalized infinite-displacement deformation function
The default values are appropriate for a |C_alpha| model of a protein
with the global scaling described in the reference cited above.
The normalization is defined by equation 10 of reference 1 (see above).
A NormalizedDeformationFunction object must be called with a single
parameter, which is a ParticleVector object containing the infinitesimal
displacements of the atoms for which the deformation is to be evaluated.
The return value is a ParticleScalar object containing the
deformation value for each atom.
"""
def __init__(self, universe, fc_length = 0.7, cutoff = 1.2,
factor = 46402., form = 'exponential'):
"""
:param universe: the universe for which the deformation function
is defined
:type universe: :class:`~MMTK.Universe.Universe`
:param fc_length: the range parameter r_0 in the pair interaction term
:type fc_length: float
:param cutoff: the cutoff used in the deformation calculation
:type cutoff: float
:param factor: a global scaling factor
:type factor: float
:param form: the functional form ('exponential' or 'calpha')
:type form: str
"""
DeformationFunction.__init__(self, universe, fc_length,
cutoff, factor, form)
def __init__(self, *args, **kwargs):
apply(DeformationFunction.__init__, (self, ) + args, kwargs)
self.normalize = 1
class FiniteDeformationFunction(DeformationEvaluationFunction):
"""
Finite-displacement deformation function
The default values are appropriate for a |C_alpha| model of a protein
with the global scaling described in the reference cited above.
A FiniteDeformationFunction object must be called with a single parameter,
which is a Configuration or a ParticleVector object containing the
alternate configuration of the universe for which the deformation is to be
evaluated. The return value is a ParticleScalar object containing the
deformation value for each atom.
"""
def __init__(self, universe, fc_length = 0.7, cutoff = 1.2,
factor = 46402., form = 'exponential'):
"""
:param universe: the universe for which the deformation function
is defined
:type universe: :class:`~MMTK.Universe.Universe`
:param fc_length: the range parameter r_0 in the pair interaction term
:type fc_length: float
:param cutoff: the cutoff used in the deformation calculation
:type cutoff: float
:param factor: a global scaling factor
:type factor: float
:param form: the functional form ('exponential' or 'calpha')
:type form: str
"""
DeformationEvaluationFunction.__init__(self, universe, fc_length,
cutoff, factor, form)
def __call__(self, vector):
conf = self.universe.configuration()
vector = vector-conf
r = ParticleProperties.ParticleScalar(self.universe)
l = deformation(conf.array, vector.array, self.pairs, None, r.array,
self.cutoff, self.fc_length, self.factor, 0, 1,
self.version)
return r
class DeformationEnergyFunction(DeformationEvaluationFunction):
"""
Infinite-displacement deformation energy function
The deformation energy is the sum of the deformation values over
all atoms of a system.
The default values are appropriate for a |C_alpha| model of a protein
with the global scaling described in the reference cited above.
A DeformationEnergyFunction is called with one or two parameters.
The first parameter is a ParticleVector object containing the
infinitesimal displacements of the atoms for which the deformation
energy is to be evaluated. The optional second argument can be
set to a non-zero value to request the gradients of the energy
in addition to the energy itself. In that case there are two
return values (energy and the gradients in a ParticleVector
object), otherwise only the energy is returned.
"""
def __init__(self, universe, fc_length = 0.7, cutoff = 1.2,
factor = 46402., form = 'exponential'):
"""
:param universe: the universe for which the deformation function
is defined
:type universe: :class:`~MMTK.Universe.Universe`
:param fc_length: the range parameter r_0 in the pair interaction term
:type fc_length: float
:param cutoff: the cutoff used in the deformation calculation
:type cutoff: float
:param factor: a global scaling factor
:type factor: float
:param form: the functional form ('exponential' or 'calpha')
:type form: str
"""
DeformationEvaluationFunction.__init__(self, universe, fc_length,
cutoff, factor, form)
def __call__(self, vector, gradients = None):
conf = self.universe.configuration()
g = None
if gradients is not None:
if ParticleProperties.isParticleProperty(gradients):
g = gradients
elif isinstance(gradients, N.array_type):
g = ParticleProperties.ParticleVector(self.universe, gradients)
elif gradients:
g = ParticleProperties.ParticleVector(self.universe)
if g is None:
g_array = None
else:
g_array = g.array
l = deformation(conf.array, vector.array, self.pairs,
g_array, None, self.cutoff, self.fc_length,
self.factor, self.normalize, 0, self.version)
if g is None:
return l
else:
return l, g
class NormalizedDeformationEnergyFunction(DeformationEnergyFunction):
"""
Normalized infinite-displacement deformation energy function
The normalized deformation energy is the sum of the normalized
deformation values over all atoms of a system.
The default values are appropriate for a |C_alpha| model of a protein
with the global scaling described in the reference cited above.
The normalization is defined by equation 10 of reference 1.
A NormalizedDeformationEnergyFunction is called with one or two parameters.
The first parameter is a ParticleVector object containing the
infinitesimal displacements of the atoms for which the deformation
energy is to be evaluated. The optional second argument can be
set to a non-zero value to request the gradients of the energy
in addition to the energy itself. In that case there are two
return values (energy and the gradients in a ParticleVector
object), otherwise only the energy is returned.
"""
def __init__(self, universe, fc_length = 0.7, cutoff = 1.2,
factor = 46402., form = 'exponential'):
"""
:param universe: the universe for which the deformation function
is defined
:type universe: :class:`~MMTK.Universe.Universe`
:param fc_length: the range parameter r_0 in the pair interaction term
:type fc_length: float
:param cutoff: the cutoff used in the deformation calculation
:type cutoff: float
:param factor: a global scaling factor
:type factor: float
:param form: the functional form ('exponential' or 'calpha')
:type form: str
"""
DeformationEnergyFunction.__init__(self, universe, fc_length,
cutoff, factor, form)
self.normalize = 1
class FiniteDeformationEnergyFunction(DeformationEvaluationFunction):
"""
Finite-displacement deformation energy function
The deformation energy is the sum of the
deformation values over all atoms of a system.
The default values are appropriate for a |C_alpha| model of a protein
with the global scaling described in the reference cited above.
A FiniteDeformationEnergyFunction is called with one or two parameters.
The first parameter is a ParticleVector object containing the
alternate configuration of the universe for which the deformation
energy is to be evaluated. The optional second argument can be
set to a non-zero value to request the gradients of the energy
in addition to the energy itself. In that case there are two
return values (energy and the gradients in a ParticleVector
object), otherwise only the energy is returned.
"""
def __init__(self, universe, fc_length = 0.7, cutoff = 1.2,
factor = 46402., form = 'exponential'):
"""
:param universe: the universe for which the deformation function
is defined
:type universe: :class:`~MMTK.Universe.Universe`
:param fc_length: the range parameter r_0 in the pair interaction term
:type fc_length: float
:param cutoff: the cutoff used in the deformation calculation
:type cutoff: float
:param factor: a global scaling factor
:type factor: float
:param form: the functional form ('exponential' or 'calpha')
:type form: str
"""
DeformationEvaluationFunction.__init__(self, universe, fc_length,
cutoff, factor, form)
def __call__(self, vector, gradients = None):
conf = self.universe.configuration()
g = None
if gradients is not None:
if ParticleProperties.isParticleProperty(gradients):
g = gradients
elif isinstance(gradients, N.array_type):
g = ParticleProperties.ParticleVector(self.universe, gradients)
elif gradients:
g = ParticleProperties.ParticleVector(self.universe)
if g is None:
g_array = None
else:
g_array = g.array
l = deformation(conf.array, vector.array, self.pairs, g_array, None,
self.cutoff, self.fc_length, self.factor,
0, 1, self.version)
if g is None:
return l
else:
return l, g
#
# Deformation energy minimization
#
class DeformationReducer(DeformationEvaluationFunction):
"""
Iterative reduction of the deformation energy
The default values are appropriate for a |C_alpha| model of a protein
with the global scaling described in the reference cited above.
A DeformationReducer is called with two arguments. The first
is a ParticleVector containing the initial infinitesimal displacements
for all atoms. The second is an integer indicating the number of
iterations. The result is a modification of the displacements
by steepest-descent minimization of the deformation energy.
"""
def __init__(self, universe, fc_length = 0.7, cutoff = 1.2,
factor = 46402., form = 'exponential'):
"""
:param universe: the universe for which the deformation function
is defined
:type universe: :class:`~MMTK.Universe.Universe`
:param fc_length: the range parameter r_0 in the pair interaction term
:type fc_length: float
:param cutoff: the cutoff used in the deformation calculation
:type cutoff: float
:param factor: a global scaling factor
:type factor: float
:param form: the functional form ('exponential' or 'calpha')
:type form: str
"""
DeformationEvaluationFunction.__init__(self, universe, fc_length,
cutoff, factor, form)
def __call__(self, vector, niter):
conf = self.universe.configuration()
reduceDeformation(conf.array, vector.array, self.pairs,
self.cutoff, self.fc_length, self.factor, niter,
self.version)
class FiniteDeformationReducer(DeformationEvaluationFunction):
"""
Iterative reduction of the finite-displacement deformation energy
The default values are appropriate for a |C_alpha| model of a protein
with the global scaling described in the reference cited above.
A FiniteDeformationReducer is called with two arguments. The first
is a ParticleVector or Configuration containing the alternate
configuration for which the deformation energy is evaluated.
The second is the RMS distance that defines the termination
condition. The return value a configuration that differs from
the input configuration by approximately the specified RMS distance,
and which is obtained by iterative steepest-descent minimization of
the finite-displacement deformation energy.
"""
def __init__(self, universe, fc_length = 0.7, cutoff = 1.2,
factor = 46402., form = 'exponential'):
"""
:param universe: the universe for which the deformation function
is defined
:type universe: :class:`~MMTK.Universe.Universe`
:param fc_length: the range parameter r_0 in the pair interaction term
:type fc_length: float
:param cutoff: the cutoff used in the deformation calculation
:type cutoff: float
:param factor: a global scaling factor
:type factor: float
:param form: the functional form ('exponential' or 'calpha')
:type form: str
"""
DeformationEvaluationFunction.__init__(self, universe, fc_length,
cutoff, factor, form)
def __call__(self, vector, rms_reduction):
conf = self.universe.configuration()
vector = vector-conf
reduceFiniteDeformation(conf.array, vector.array, self.pairs,
self.cutoff, self.fc_length, self.factor,
rms_reduction, self.version)
return conf+vector
|