IMP  2.3.0
The Integrative Modeling Platform
modeller/__init__.py
1 # This file was automatically generated by SWIG (http://www.swig.org).
2 # Version 3.0.2
3 #
4 # Do not make changes to this file unless you know what you are doing--modify
5 # the SWIG interface file instead.
6 
7 
8 
9 
10 
11 from sys import version_info
12 if version_info >= (2,6,0):
13  def swig_import_helper():
14  from os.path import dirname
15  import imp
16  fp = None
17  try:
18  fp, pathname, description = imp.find_module('_IMP_modeller', [dirname(__file__)])
19  except ImportError:
20  import _IMP_modeller
21  return _IMP_modeller
22  if fp is not None:
23  try:
24  _mod = imp.load_module('_IMP_modeller', fp, pathname, description)
25  finally:
26  fp.close()
27  return _mod
28  _IMP_modeller = swig_import_helper()
29  del swig_import_helper
30 else:
31  import _IMP_modeller
32 del version_info
33 try:
34  _swig_property = property
35 except NameError:
36  pass # Python < 2.2 doesn't have 'property'.
37 def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
38  if (name == "thisown"): return self.this.own(value)
39  if (name == "this"):
40  if type(value).__name__ == 'SwigPyObject':
41  self.__dict__[name] = value
42  return
43  method = class_type.__swig_setmethods__.get(name,None)
44  if method: return method(self,value)
45  if (not static):
46  self.__dict__[name] = value
47  else:
48  raise AttributeError("You cannot add attributes to %s" % self)
49 
50 def _swig_setattr(self,class_type,name,value):
51  return _swig_setattr_nondynamic(self,class_type,name,value,0)
52 
53 def _swig_getattr(self,class_type,name):
54  if (name == "thisown"): return self.this.own()
55  method = class_type.__swig_getmethods__.get(name,None)
56  if method: return method(self)
57  raise AttributeError(name)
58 
59 def _swig_repr(self):
60  try: strthis = "proxy of " + self.this.__repr__()
61  except: strthis = ""
62  return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
63 
64 try:
65  _object = object
66  _newclass = 1
67 except AttributeError:
68  class _object : pass
69  _newclass = 0
70 
71 
72 try:
73  import weakref
74  weakref_proxy = weakref.proxy
75 except:
76  weakref_proxy = lambda x: x
77 
78 
79 class IMP_MODELLER_SwigPyIterator(_object):
80  """Proxy of C++ swig::IMP_MODELLER_SwigPyIterator class"""
81  __swig_setmethods__ = {}
82  __setattr__ = lambda self, name, value: _swig_setattr(self, IMP_MODELLER_SwigPyIterator, name, value)
83  __swig_getmethods__ = {}
84  __getattr__ = lambda self, name: _swig_getattr(self, IMP_MODELLER_SwigPyIterator, name)
85  def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract")
86  __repr__ = _swig_repr
87  __swig_destroy__ = _IMP_modeller.delete_IMP_MODELLER_SwigPyIterator
88  __del__ = lambda self : None;
89  def value(self):
90  """value(IMP_MODELLER_SwigPyIterator self) -> PyObject *"""
91  return _IMP_modeller.IMP_MODELLER_SwigPyIterator_value(self)
92 
93  def incr(self, n=1):
94  """
95  incr(IMP_MODELLER_SwigPyIterator self, size_t n=1) -> IMP_MODELLER_SwigPyIterator
96  incr(IMP_MODELLER_SwigPyIterator self) -> IMP_MODELLER_SwigPyIterator
97  """
98  return _IMP_modeller.IMP_MODELLER_SwigPyIterator_incr(self, n)
99 
100  def decr(self, n=1):
101  """
102  decr(IMP_MODELLER_SwigPyIterator self, size_t n=1) -> IMP_MODELLER_SwigPyIterator
103  decr(IMP_MODELLER_SwigPyIterator self) -> IMP_MODELLER_SwigPyIterator
104  """
105  return _IMP_modeller.IMP_MODELLER_SwigPyIterator_decr(self, n)
106 
107  def distance(self, *args):
108  """distance(IMP_MODELLER_SwigPyIterator self, IMP_MODELLER_SwigPyIterator x) -> ptrdiff_t"""
109  return _IMP_modeller.IMP_MODELLER_SwigPyIterator_distance(self, *args)
110 
111  def equal(self, *args):
112  """equal(IMP_MODELLER_SwigPyIterator self, IMP_MODELLER_SwigPyIterator x) -> bool"""
113  return _IMP_modeller.IMP_MODELLER_SwigPyIterator_equal(self, *args)
114 
115  def copy(self):
116  """copy(IMP_MODELLER_SwigPyIterator self) -> IMP_MODELLER_SwigPyIterator"""
117  return _IMP_modeller.IMP_MODELLER_SwigPyIterator_copy(self)
118 
119  def next(self):
120  """next(IMP_MODELLER_SwigPyIterator self) -> PyObject *"""
121  return _IMP_modeller.IMP_MODELLER_SwigPyIterator_next(self)
122 
123  def __next__(self):
124  """__next__(IMP_MODELLER_SwigPyIterator self) -> PyObject *"""
125  return _IMP_modeller.IMP_MODELLER_SwigPyIterator___next__(self)
126 
127  def previous(self):
128  """previous(IMP_MODELLER_SwigPyIterator self) -> PyObject *"""
129  return _IMP_modeller.IMP_MODELLER_SwigPyIterator_previous(self)
130 
131  def advance(self, *args):
132  """advance(IMP_MODELLER_SwigPyIterator self, ptrdiff_t n) -> IMP_MODELLER_SwigPyIterator"""
133  return _IMP_modeller.IMP_MODELLER_SwigPyIterator_advance(self, *args)
134 
135  def __eq__(self, *args):
136  """__eq__(IMP_MODELLER_SwigPyIterator self, IMP_MODELLER_SwigPyIterator x) -> bool"""
137  return _IMP_modeller.IMP_MODELLER_SwigPyIterator___eq__(self, *args)
138 
139  def __ne__(self, *args):
140  """__ne__(IMP_MODELLER_SwigPyIterator self, IMP_MODELLER_SwigPyIterator x) -> bool"""
141  return _IMP_modeller.IMP_MODELLER_SwigPyIterator___ne__(self, *args)
142 
143  def __iadd__(self, *args):
144  """__iadd__(IMP_MODELLER_SwigPyIterator self, ptrdiff_t n) -> IMP_MODELLER_SwigPyIterator"""
145  return _IMP_modeller.IMP_MODELLER_SwigPyIterator___iadd__(self, *args)
146 
147  def __isub__(self, *args):
148  """__isub__(IMP_MODELLER_SwigPyIterator self, ptrdiff_t n) -> IMP_MODELLER_SwigPyIterator"""
149  return _IMP_modeller.IMP_MODELLER_SwigPyIterator___isub__(self, *args)
150 
151  def __add__(self, *args):
152  """__add__(IMP_MODELLER_SwigPyIterator self, ptrdiff_t n) -> IMP_MODELLER_SwigPyIterator"""
153  return _IMP_modeller.IMP_MODELLER_SwigPyIterator___add__(self, *args)
154 
155  def __sub__(self, *args):
156  """
157  __sub__(IMP_MODELLER_SwigPyIterator self, ptrdiff_t n) -> IMP_MODELLER_SwigPyIterator
158  __sub__(IMP_MODELLER_SwigPyIterator self, IMP_MODELLER_SwigPyIterator x) -> ptrdiff_t
159  """
160  return _IMP_modeller.IMP_MODELLER_SwigPyIterator___sub__(self, *args)
161 
162  def __iter__(self): return self
163 IMP_MODELLER_SwigPyIterator_swigregister = _IMP_modeller.IMP_MODELLER_SwigPyIterator_swigregister
164 IMP_MODELLER_SwigPyIterator_swigregister(IMP_MODELLER_SwigPyIterator)
165 
166 _value_types=[]
167 _object_types=[]
168 _raii_types=[]
169 _plural_types=[]
170 
171 IMP_DEBUG = _IMP_modeller.IMP_DEBUG
172 IMP_RELEASE = _IMP_modeller.IMP_RELEASE
173 IMP_SILENT = _IMP_modeller.IMP_SILENT
174 IMP_PROGRESS = _IMP_modeller.IMP_PROGRESS
175 IMP_TERSE = _IMP_modeller.IMP_TERSE
176 IMP_VERBOSE = _IMP_modeller.IMP_VERBOSE
177 IMP_MEMORY = _IMP_modeller.IMP_MEMORY
178 IMP_NONE = _IMP_modeller.IMP_NONE
179 IMP_USAGE = _IMP_modeller.IMP_USAGE
180 IMP_INTERNAL = _IMP_modeller.IMP_INTERNAL
181 IMP_BASE_HAS_LOG4CXX = _IMP_modeller.IMP_BASE_HAS_LOG4CXX
182 IMP_COMPILER_HAS_AUTO = _IMP_modeller.IMP_COMPILER_HAS_AUTO
183 IMP_COMPILER_HAS_DEBUG_VECTOR = _IMP_modeller.IMP_COMPILER_HAS_DEBUG_VECTOR
184 IMP_BASE_HAS_BOOST_RANDOM = _IMP_modeller.IMP_BASE_HAS_BOOST_RANDOM
185 IMP_BASE_HAS_GPERFTOOLS = _IMP_modeller.IMP_BASE_HAS_GPERFTOOLS
186 IMP_BASE_HAS_TCMALLOC_HEAPCHECKER = _IMP_modeller.IMP_BASE_HAS_TCMALLOC_HEAPCHECKER
187 IMP_BASE_HAS_TCMALLOC_HEAPPROFILER = _IMP_modeller.IMP_BASE_HAS_TCMALLOC_HEAPPROFILER
188 IMPBASE_SHOW_WARNINGS = _IMP_modeller.IMPBASE_SHOW_WARNINGS
189 import sys
190 class _DirectorObjects(object):
191  """@internal Simple class to keep references to director objects
192  to prevent premature deletion."""
193  def __init__(self):
194  self._objects = []
195  def register(self, obj):
196  """Take a reference to a director object; will only work for
197  refcounted C++ classes"""
198  if hasattr(obj, 'get_ref_count'):
199  self._objects.append(obj)
200  def cleanup(self):
201  """Only drop our reference and allow cleanup by Python if no other
202  Python references exist (we hold 3 references: one in self._objects,
203  one in x, and one in the argument list for getrefcount) *and* no
204  other C++ references exist (the Python object always holds one)"""
205  objs = [x for x in self._objects if sys.getrefcount(x) > 3 \
206  or x.get_ref_count() > 1]
207 
208 
209  self._objects = objs
210  def get_object_count(self):
211  """Get number of director objects (useful for testing only)"""
212  return len(self._objects)
213 _director_objects = _DirectorObjects()
214 
215 DEFAULT_CHECK = _IMP_modeller.DEFAULT_CHECK
216 NONE = _IMP_modeller.NONE
217 USAGE = _IMP_modeller.USAGE
218 USAGE_AND_INTERNAL = _IMP_modeller.USAGE_AND_INTERNAL
219 
220 def set_check_level(*args):
221  """set_check_level(IMP::base::CheckLevel tf)"""
222  return _IMP_modeller.set_check_level(*args)
223 
224 def get_check_level():
225  """get_check_level() -> IMP::base::CheckLevel"""
226  return _IMP_modeller.get_check_level()
227 class _ostream(_object):
228  """Proxy of C++ std::ostream class"""
229  __swig_setmethods__ = {}
230  __setattr__ = lambda self, name, value: _swig_setattr(self, _ostream, name, value)
231  __swig_getmethods__ = {}
232  __getattr__ = lambda self, name: _swig_getattr(self, _ostream, name)
233  def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
234  __repr__ = _swig_repr
235  def write(self, *args):
236  """write(_ostream self, char const * osa_buf)"""
237  return _IMP_modeller._ostream_write(self, *args)
238 
239 _ostream_swigregister = _IMP_modeller._ostream_swigregister
240 _ostream_swigregister(_ostream)
241 
242 IMP_COMPILER_HAS_OVERRIDE = _IMP_modeller.IMP_COMPILER_HAS_OVERRIDE
243 IMP_COMPILER_HAS_FINAL = _IMP_modeller.IMP_COMPILER_HAS_FINAL
244 IMP_HAS_NOEXCEPT = _IMP_modeller.IMP_HAS_NOEXCEPT
245 import IMP.base
246 IMP_CGAL_HAS_BOOST_FILESYSTEM = _IMP_modeller.IMP_CGAL_HAS_BOOST_FILESYSTEM
247 IMP_CGAL_HAS_BOOST_PROGRAMOPTIONS = _IMP_modeller.IMP_CGAL_HAS_BOOST_PROGRAMOPTIONS
248 IMP_CGAL_HAS_BOOST_RANDOM = _IMP_modeller.IMP_CGAL_HAS_BOOST_RANDOM
249 IMP_CGAL_HAS_BOOST_SYSTEM = _IMP_modeller.IMP_CGAL_HAS_BOOST_SYSTEM
250 IMPCGAL_SHOW_WARNINGS = _IMP_modeller.IMPCGAL_SHOW_WARNINGS
251 import IMP.cgal
252 IMP_ALGEBRA_HAS_IMP_CGAL = _IMP_modeller.IMP_ALGEBRA_HAS_IMP_CGAL
253 IMP_ALGEBRA_HAS_BOOST_FILESYSTEM = _IMP_modeller.IMP_ALGEBRA_HAS_BOOST_FILESYSTEM
254 IMP_ALGEBRA_HAS_BOOST_PROGRAMOPTIONS = _IMP_modeller.IMP_ALGEBRA_HAS_BOOST_PROGRAMOPTIONS
255 IMP_ALGEBRA_HAS_BOOST_RANDOM = _IMP_modeller.IMP_ALGEBRA_HAS_BOOST_RANDOM
256 IMP_ALGEBRA_HAS_BOOST_SYSTEM = _IMP_modeller.IMP_ALGEBRA_HAS_BOOST_SYSTEM
257 IMP_ALGEBRA_HAS_CGAL = _IMP_modeller.IMP_ALGEBRA_HAS_CGAL
258 IMP_ALGEBRA_HAS_ANN = _IMP_modeller.IMP_ALGEBRA_HAS_ANN
259 IMPALGEBRA_SHOW_WARNINGS = _IMP_modeller.IMPALGEBRA_SHOW_WARNINGS
260 import IMP.algebra
261 IMP_KERNEL_HAS_IMP_CGAL = _IMP_modeller.IMP_KERNEL_HAS_IMP_CGAL
262 IMP_KERNEL_HAS_BOOST_PROGRAMOPTIONS = _IMP_modeller.IMP_KERNEL_HAS_BOOST_PROGRAMOPTIONS
263 IMP_KERNEL_HAS_BOOST_RANDOM = _IMP_modeller.IMP_KERNEL_HAS_BOOST_RANDOM
264 IMP_KERNEL_HAS_BOOST_SYSTEM = _IMP_modeller.IMP_KERNEL_HAS_BOOST_SYSTEM
265 IMP_KERNEL_HAS_CGAL = _IMP_modeller.IMP_KERNEL_HAS_CGAL
266 IMPKERNEL_SHOW_WARNINGS = _IMP_modeller.IMPKERNEL_SHOW_WARNINGS
267 import IMP.kernel
268 IMP_DISPLAY_HAS_IMP_BASE = _IMP_modeller.IMP_DISPLAY_HAS_IMP_BASE
269 IMP_DISPLAY_HAS_IMP_CGAL = _IMP_modeller.IMP_DISPLAY_HAS_IMP_CGAL
270 IMP_DISPLAY_HAS_BOOST_FILESYSTEM = _IMP_modeller.IMP_DISPLAY_HAS_BOOST_FILESYSTEM
271 IMP_DISPLAY_HAS_BOOST_PROGRAMOPTIONS = _IMP_modeller.IMP_DISPLAY_HAS_BOOST_PROGRAMOPTIONS
272 IMP_DISPLAY_HAS_BOOST_RANDOM = _IMP_modeller.IMP_DISPLAY_HAS_BOOST_RANDOM
273 IMP_DISPLAY_HAS_BOOST_SYSTEM = _IMP_modeller.IMP_DISPLAY_HAS_BOOST_SYSTEM
274 IMP_DISPLAY_HAS_CGAL = _IMP_modeller.IMP_DISPLAY_HAS_CGAL
275 IMPDISPLAY_SHOW_WARNINGS = _IMP_modeller.IMPDISPLAY_SHOW_WARNINGS
276 import IMP.display
277 IMP_SCORE_FUNCTOR_HAS_IMP_CGAL = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_IMP_CGAL
278 IMP_SCORE_FUNCTOR_HAS_BOOST_FILESYSTEM = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_BOOST_FILESYSTEM
279 IMP_SCORE_FUNCTOR_HAS_BOOST_PROGRAMOPTIONS = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_BOOST_PROGRAMOPTIONS
280 IMP_SCORE_FUNCTOR_HAS_BOOST_RANDOM = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_BOOST_RANDOM
281 IMP_SCORE_FUNCTOR_HAS_BOOST_SYSTEM = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_BOOST_SYSTEM
282 IMP_SCORE_FUNCTOR_HAS_CGAL = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_CGAL
283 IMP_SCORE_FUNCTOR_HAS_HDF5 = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_HDF5
284 IMPSCOREFUNCTOR_SHOW_WARNINGS = _IMP_modeller.IMPSCOREFUNCTOR_SHOW_WARNINGS
285 import IMP.score_functor
286 IMP_CORE_HAS_IMP_BASE = _IMP_modeller.IMP_CORE_HAS_IMP_BASE
287 IMP_CORE_HAS_IMP_CGAL = _IMP_modeller.IMP_CORE_HAS_IMP_CGAL
288 IMP_CORE_HAS_IMP_KERNEL = _IMP_modeller.IMP_CORE_HAS_IMP_KERNEL
289 IMP_CORE_HAS_BOOST_FILESYSTEM = _IMP_modeller.IMP_CORE_HAS_BOOST_FILESYSTEM
290 IMP_CORE_HAS_BOOST_PROGRAMOPTIONS = _IMP_modeller.IMP_CORE_HAS_BOOST_PROGRAMOPTIONS
291 IMP_CORE_HAS_BOOST_RANDOM = _IMP_modeller.IMP_CORE_HAS_BOOST_RANDOM
292 IMP_CORE_HAS_BOOST_SYSTEM = _IMP_modeller.IMP_CORE_HAS_BOOST_SYSTEM
293 IMP_CORE_HAS_CGAL = _IMP_modeller.IMP_CORE_HAS_CGAL
294 IMP_CORE_HAS_HDF5 = _IMP_modeller.IMP_CORE_HAS_HDF5
295 IMPCORE_SHOW_WARNINGS = _IMP_modeller.IMPCORE_SHOW_WARNINGS
296 import IMP.core
297 IMP_MODELLER_HAS_IMP_ALGEBRA = _IMP_modeller.IMP_MODELLER_HAS_IMP_ALGEBRA
298 IMP_MODELLER_HAS_IMP_BASE = _IMP_modeller.IMP_MODELLER_HAS_IMP_BASE
299 IMP_MODELLER_HAS_IMP_CGAL = _IMP_modeller.IMP_MODELLER_HAS_IMP_CGAL
300 IMP_MODELLER_HAS_IMP_DISPLAY = _IMP_modeller.IMP_MODELLER_HAS_IMP_DISPLAY
301 IMP_MODELLER_HAS_IMP_KERNEL = _IMP_modeller.IMP_MODELLER_HAS_IMP_KERNEL
302 IMP_MODELLER_HAS_IMP_SCORE_FUNCTOR = _IMP_modeller.IMP_MODELLER_HAS_IMP_SCORE_FUNCTOR
303 IMP_MODELLER_HAS_BOOST_FILESYSTEM = _IMP_modeller.IMP_MODELLER_HAS_BOOST_FILESYSTEM
304 IMP_MODELLER_HAS_BOOST_PROGRAMOPTIONS = _IMP_modeller.IMP_MODELLER_HAS_BOOST_PROGRAMOPTIONS
305 IMP_MODELLER_HAS_BOOST_RANDOM = _IMP_modeller.IMP_MODELLER_HAS_BOOST_RANDOM
306 IMP_MODELLER_HAS_BOOST_SYSTEM = _IMP_modeller.IMP_MODELLER_HAS_BOOST_SYSTEM
307 IMP_MODELLER_HAS_CGAL = _IMP_modeller.IMP_MODELLER_HAS_CGAL
308 IMP_MODELLER_HAS_HDF5 = _IMP_modeller.IMP_MODELLER_HAS_HDF5
309 IMPMODELLER_SHOW_WARNINGS = _IMP_modeller.IMPMODELLER_SHOW_WARNINGS
310 BinormalTermList=list
311 _plural_types.append("BinormalTermList")
312 _value_types.append("BinormalTerm")
313 
314 _object_types.append("MultipleBinormalRestraint")
315 
316 
317 def _object_cast_to_MultipleBinormalRestraint(*args):
318  """_object_cast_to_MultipleBinormalRestraint(Object o) -> MultipleBinormalRestraint"""
319  return _IMP_modeller._object_cast_to_MultipleBinormalRestraint(*args)
320 import math
321 import imp
322 import os
323 import sys
324 import tempfile
325 import shutil
326 import IMP.atom
327 import IMP.container
328 
329 def _import_modeller_scripts_optimizers():
330  """Do the equivalent of "import modeller.scripts, modeller.optimizers".
331  (We can't do the regular import because Python tries a relative import
332  first, and that would load the modeller module in IMP.) This is an
333  absolute import. Once we can require that everybody uses Python 2.6,
334  this should no longer be required."""
335  modeller = _import_module("modeller", "modeller", None)
336  scripts = _import_module("scripts", "modeller.scripts", modeller)
337  optimizers = _import_module("optimizers", "modeller.optimizers", modeller)
338  modeller.scripts = scripts
339  modeller.optimizers = optimizers
340  return modeller
341 
342 def _import_module(partname, fqname, parent):
343  """Import a single Python module, possibly from a parent."""
344  fp, pathname, description = imp.find_module(partname,
345  parent and parent.__path__)
346  try:
347  m = imp.load_module(fqname, fp, pathname, description)
348  finally:
349  # imp module requires that we explicitly close fp, even on exception
350  if fp:
351  fp.close()
352  return m
353 
354 modeller = _import_modeller_scripts_optimizers()
355 
356 
357 class _TempDir(object):
358  """Make a temporary directory that is deleted when the object is."""
359 
360  def __init__(self):
361  self.tmpdir = tempfile.mkdtemp()
362 
363  def __del__(self):
364  shutil.rmtree(self.tmpdir, ignore_errors=True)
365 
366 
367 class IMPRestraints(modeller.terms.energy_term):
368  """A Modeller restraint which evaluates all defined IMP restraints.
369  This can be used to incorporate IMP Restraints into an existing
370  comparative modeling pipeline, or to use Modeller optimizers or
371  protocols.
372  @param particles A list of the IMP atoms (as Particle objects),
373  same order as the Modeller atoms.
374  @note since Modeller, unlike IMP, is sensitive to the ordering
375  of atoms, it usually makes sense to create the model in
376  Modeller and then use ModelLoader to load it into IMP,
377  since that will preserve the Modeller atom ordering in IMP.
378  """
379 
380  _physical_type = modeller.physical.absposition
381 
382  def __init__(self, particles):
383  modeller.terms.energy_term.__init__(self)
384  self._particles = particles
385 
386  def eval(self, mdl, deriv, indats):
387  atoms = self.indices_to_atoms(mdl, indats)
388  _copy_modeller_coords_to_imp(atoms, self._particles)
389  if len(self._particles) == 0:
390  score = 0.
391  else:
392  score = self._particles[0].get_model().evaluate(deriv)
393  if deriv:
394  dvx = [0.] * len(indats)
395  dvy = [0.] * len(indats)
396  dvz = [0.] * len(indats)
397  _get_imp_derivs(self._particles, dvx, dvy, dvz)
398  return (score, dvx, dvy, dvz)
399  else:
400  return score
401 
402 
404  """An IMP restraint using all defined Modeller restraints.
405  This is useful if you want to use Modeller restraints with an IMP
406  optimizer, or in combination with IMP restraints.
407 
408  @param model The IMP Model object.
409  @param modeller_model The Modeller model object.
410  @param particles A list of the IMP atoms (as Particle objects),
411  in the same order as the Modeller atoms.
412  @note since Modeller, unlike IMP, is sensitive to the ordering
413  of atoms, it usually makes sense to create the model in
414  Modeller and then use ModelLoader to load it into IMP,
415  since that will preserve the Modeller atom ordering in IMP.
416  @note Currently only the coordinates of the atoms are translated
417  between Modeller and IMP; thus, a Modeller restraint which
418  uses any other attribute (e.g. charge) will not react if
419  this attribute is changed by IMP.
420  """
421  def __init__(self, model, modeller_model, particles):
422  def get_particle(x):
423  if hasattr(x, 'get_particle'):
424  return x.get_particle()
425  else:
426  return x
427  IMP.Restraint.__init__(self, model, "ModellerRestraints %1%")
428  self._modeller_model = modeller_model
429  self._particles = [get_particle(x) for x in particles]
430 
431  def unprotected_evaluate(self, accum):
432  atoms = self._modeller_model.atoms
433  sel = modeller.selection(self._modeller_model)
434  _copy_imp_coords_to_modeller(self._particles, atoms)
435  energies = sel.energy()
436  if accum:
437  _add_modeller_derivs_to_imp(atoms, self._particles, accum)
438 
439  return energies[0]
440 
441  def get_version_info(self):
442  return IMP.VersionInfo("IMP developers", "0.1")
443  def do_show(self, fh):
444  fh.write("ModellerRestraints")
445  def do_get_inputs(self):
446  return self._particles
447 
448 
449 def _copy_imp_coords_to_modeller(particles, atoms):
450  """Copy atom coordinates from IMP to Modeller"""
451  xkey = IMP.FloatKey("x")
452  ykey = IMP.FloatKey("y")
453  zkey = IMP.FloatKey("z")
454  for (num, at) in enumerate(atoms):
455  at.x = particles[num].get_value(xkey)
456  at.y = particles[num].get_value(ykey)
457  at.z = particles[num].get_value(zkey)
458 
459 
460 def _copy_modeller_coords_to_imp(atoms, particles):
461  """Copy atom coordinates from Modeller to IMP"""
462  xkey = IMP.FloatKey("x")
463  ykey = IMP.FloatKey("y")
464  zkey = IMP.FloatKey("z")
465  for (num, at) in enumerate(atoms):
466  particles[num].set_value(xkey, at.x)
467  particles[num].set_value(ykey, at.y)
468  particles[num].set_value(zkey, at.z)
469 
470 
471 def _add_modeller_derivs_to_imp(atoms, particles, accum):
472  """Add atom derivatives from Modeller to IMP"""
473  for (num, at) in enumerate(atoms):
474  xyz = IMP.core.XYZ(particles[num])
475  xyz.add_to_derivative(0, at.dvx, accum)
476  xyz.add_to_derivative(1, at.dvy, accum)
477  xyz.add_to_derivative(2, at.dvz, accum)
478 
479 
480 def _get_imp_derivs(particles, dvx, dvy, dvz):
481  """Move atom derivatives from IMP to Modeller"""
482  xkey = IMP.FloatKey("x")
483  ykey = IMP.FloatKey("y")
484  zkey = IMP.FloatKey("z")
485  for idx in range(0, len(dvx)):
486  dvx[idx] = particles[idx].get_derivative(xkey)
487  dvy[idx] = particles[idx].get_derivative(ykey)
488  dvz[idx] = particles[idx].get_derivative(zkey)
489 
490 
491 # Generators to create IMP UnaryFunction objects from Modeller parameters:
492 def _HarmonicLowerBoundGenerator(parameters, modalities):
493  (mean, stdev) = parameters
495  return IMP.core.HarmonicLowerBound(mean, k)
496 
497 def _HarmonicUpperBoundGenerator(parameters, modalities):
498  (mean, stdev) = parameters
500  return IMP.core.HarmonicUpperBound(mean, k)
501 
502 def _HarmonicGenerator(parameters, modalities):
503  (mean, stdev) = parameters
505  return IMP.core.Harmonic(mean, k)
506 
507 def _CosineGenerator(parameters, modalities):
508  (phase, force_constant) = parameters
509  (periodicity,) = modalities
510  return IMP.core.Cosine(force_constant, periodicity, phase)
511 
512 def _LinearGenerator(parameters, modalities):
513  (scale,) = parameters
514  return IMP.core.Linear(0, scale)
515 
516 def _SplineGenerator(parameters, modalities):
517  (open, low, high, delta, lowderiv, highderiv) = parameters[:6]
518  values = []
519  for v in parameters[6:]:
520  values.append(v)
521  if open < 0.0:
522  return IMP.core.ClosedCubicSpline(values, low, delta)
523  else:
524  return IMP.core.OpenCubicSpline(values, low, delta)
525 
526 #: Mapping from Modeller math form number to a unary function generator
527 _unary_func_generators = {
528  1: _HarmonicLowerBoundGenerator,
529  2: _HarmonicUpperBoundGenerator,
530  3: _HarmonicGenerator,
531  7: _CosineGenerator,
532  8: _LinearGenerator,
533  10: _SplineGenerator,
534 }
535 
536 # Generators to make IMP Restraint objects from Modeller features
537 def _DistanceRestraintGenerator(form, modalities, atoms, parameters):
538  unary_func_gen = _unary_func_generators[form]
539  return IMP.core.DistanceRestraint(unary_func_gen(parameters, modalities),
540  atoms[0], atoms[1])
541 
542 def _AngleRestraintGenerator(form, modalities, atoms, parameters):
543  unary_func_gen = _unary_func_generators[form]
544  return IMP.core.AngleRestraint(unary_func_gen(parameters, modalities),
545  atoms[0], atoms[1], atoms[2])
546 
547 def _MultiBinormalGenerator(form, modalities, atoms, parameters):
548  nterms = modalities[0]
549  if len(parameters) != nterms * 6:
550  raise ValueError("Incorrect number of parameters (%d) for multiple "
551  "binormal restraint - expecting %d (%d terms * 6)" \
552  % (len(parameters), nterms * 6, nterms))
554  IMP.ParticleQuad(*atoms[4:8]))
555  for i in range(nterms):
557  t.set_weight(parameters[i])
558  t.set_means((parameters[nterms + i * 2],
559  parameters[nterms + i * 2 + 1]))
560  t.set_standard_deviations((parameters[nterms * 3 + i * 2],
561  parameters[nterms * 3 + i * 2 + 1]))
562  t.set_correlation(parameters[nterms * 5 + i])
563  r.add_term(t)
564  return r
565 
566 def _DihedralRestraintGenerator(form, modalities, atoms, parameters):
567  if form == 9:
568  return _MultiBinormalGenerator(form, modalities, atoms, parameters)
569  unary_func_gen = _unary_func_generators[form]
570  return IMP.core.DihedralRestraint(unary_func_gen(parameters, modalities),
571  atoms[0], atoms[1], atoms[2], atoms[3])
572 
573 def _get_protein_atom_particles(protein):
574  """Given a protein particle, get the flattened list of all child atoms"""
575  atom_particles = []
576  #protein = IMP.core.Hierarchy.decorate_particle(protein)
577  for ichain in range(protein.get_number_of_children()):
578  chain = protein.get_child(ichain)
579  for ires in range(chain.get_number_of_children()):
580  residue = chain.get_child(ires)
581  for iatom in range(residue.get_number_of_children()):
582  atom = residue.get_child(iatom)
583  atom_particles.append(atom.get_particle())
584  return atom_particles
585 
586 def _load_restraints_line(line, atom_particles):
587  """Parse a single Modeller restraints file line and return the
588  corresponding IMP restraint."""
589  spl = line.split()
590  typ = spl.pop(0)
591  if typ == 'MODELLER5':
592  return
593  elif typ != 'R':
594  raise NotImplementedError("Only 'R' lines currently read from " + \
595  "Modeller restraints files")
596  form = int(spl.pop(0))
597  modalities = [int(spl.pop(0))]
598  features = [int(spl.pop(0))]
599  # Discard group
600  spl.pop(0)
601  natoms = [int(spl.pop(0))]
602  nparam = int(spl.pop(0))
603  nfeat = int(spl.pop(0))
604  for i in range(nfeat - 1):
605  modalities.append(int(spl.pop(0)))
606  features.append(int(spl.pop(0)))
607  natoms.append(int(spl.pop(0)))
608  atoms = [int(spl.pop(0)) for x in range(natoms[0])]
609  for i in range(len(atoms)):
610  atoms[i] = atom_particles[atoms[i] - 1]
611  parameters = [float(spl.pop(0)) for x in range(nparam)]
612  restraint_generators = {
613  1 : _DistanceRestraintGenerator,
614  2 : _AngleRestraintGenerator,
615  3 : _DihedralRestraintGenerator,
616  }
617  restraint_gen = restraint_generators[features[0]]
618  return restraint_gen(form, modalities, atoms, parameters)
619 
620 
621 def _load_entire_restraints_file(filename, protein):
622  """Yield a set of IMP restraints from a Modeller restraints file."""
623  atoms = _get_protein_atom_particles(protein)
624  fh = open(filename, 'r')
625  for line in fh:
626  try:
627  rsr = _load_restraints_line(line, atoms)
628  if rsr is not None:
629  yield rsr
630  except Exception, err:
631  print "Cannot read restraints file line:\n" + line
632  raise
633 
634 
635 def load_restraints_file(filename, protein):
636  """Convert a Modeller restraints file into IMP::Restraint objects.
637 
638  @deprecated Use ModelLoader instead.
639 
640  @param filename Name of the Modeller restraints file.
641  @param protein An IMP::atom::Hierarchy containing the protein atoms
642  (e.g. as returned by read_pdb). The Modeller restraints
643  file is assumed to act on the same PDB described by
644  protein.
645  @return A Python list of the newly-created IMP::Restraint objects.
646  """
647  return list(_load_entire_restraints_file(filename, protein))
648 
649 
650 def _copy_residue(r, model):
651  """Copy residue information from modeller to imp"""
652  #print "residue "+str(r)
653  p=IMP.Particle(model)
655  r.index)
656  p.set_name(str("residue "+r.num));
657  return p
658 
659 
660 def _copy_atom(a, model):
661  """Copy atom information from modeller"""
662  #print "atom "+str(a)
663  p=IMP.Particle(model)
665  xyzd= IMP.core.XYZ.setup_particle(p, IMP.algebra.Vector3D(a.x, a.y, a.z))
666  # Alignment structures don't have charges or atom types; models do
667  if hasattr(a, 'charge'):
669  if hasattr(a, 'type'):
670  IMP.atom.CHARMMAtom.setup_particle(p, a.type.name)
671  ap.set_input_index(a.index)
672  return p
673 
674 def _copy_chain(c, model):
675  """Copy chain information from modeller"""
676  #print "atom "+str(a)
677  p=IMP.Particle(model)
678  #set the chain name
679  cp = IMP.atom.Chain.setup_particle(p,c.name)
680  return p
681 
682 def _get_forcefield(submodel):
683  if submodel == 3:
685  IMP.atom.get_data_path('top_heav.lib'),
686  IMP.atom.get_data_path('par.lib'))
687  else:
689  IMP.atom.get_data_path('top.lib'),
690  IMP.atom.get_data_path('par.lib'))
691  return ff
692 
693 def add_soft_sphere_radii(hierarchy, submodel, scale=1.0, filename=None):
694  """Add radii to the hierarchy using the Modeller radius library, radii.lib.
695  Each radius is scaled by the given scale (Modeller usually scales radii
696  by a factor of 0.82). submodel specifies the topology submodel, which is
697  the column in radii.lib to use."""
698  if filename is None:
699  filename = IMP.atom.get_data_path('radii.lib')
700  radii = {}
701  for line in open(filename):
702  if line.startswith('#'): continue
703  spl = line.split()
704  if len(spl) > 11:
705  radii[spl[0]] = float(spl[submodel])
706  atoms = IMP.atom.get_by_type(hierarchy, IMP.atom.ATOM_TYPE)
707  for a in atoms:
708  p = a.get_particle()
709  ct = IMP.atom.CHARMMAtom(p).get_charmm_type()
710  if ct in radii:
711  IMP.core.XYZR.setup_particle(p, radii[ct] * scale)
712 
713 
714 class ModelLoader(object):
715  """Read a Modeller model into IMP. After creating this object, the atoms
716  in the Modeller model can be loaded into IMP using the load_atoms()
717  method, then optionally any Modeller static restraints can be read in
718  with load_static_restraints() or load_static_restraints_file().
719 
720  This class can also be used to read Modeller alignment structures;
721  however, only load_atoms() will be useful in such a case (since
722  alignment structures don't have restraints or other information).
723 
724  @param modeller_model The Modeller model or alignment structure
725  object to read.
726  """
727 
728  def __init__(self, modeller_model):
729  self._modeller_model = modeller_model
730 
731  def load_atoms(self, model):
732  """Construct an IMP::atom::Hierarchy that contains the same atoms as
733  the Modeller model or alignment structure.
734 
735  IMP atoms created from a Modeller model will be given charges and
736  CHARMM types, extracted from the model. Alignment structures don't
737  contain this information, so the IMP atoms won't either.
738 
739  @param model The IMP::Model object in which the hierarchy will be
740  created. The highest level hierarchy node is a PROTEIN.
741  @return the newly-created root IMP::atom::Hierarchy.
742  """
743  pp = IMP.Particle(model)
745  self._atoms = {}
746  for chain in self._modeller_model.chains:
747  cp = IMP.Particle(model)
748  hcp = IMP.atom.Chain.setup_particle(cp, chain.name)
749  # We don't really know the type yet
750  hpp.add_child(hcp)
751  for residue in chain.residues:
752  rp = _copy_residue(residue, model)
753  hrp = IMP.atom.Hierarchy.decorate_particle(rp)
754  hcp.add_child(hrp)
755  for atom in residue.atoms:
756  ap = _copy_atom(atom, model)
757  hap = IMP.atom.Hierarchy.decorate_particle(ap)
758  hrp.add_child(hap)
759  self._atoms[atom.index] = ap
760  lastres = hrp
761  self._modeller_hierarchy = hpp
762  return hpp
763 
764  def _get_nonbonded_list(self, atoms, pair_filter, edat, distance):
765  nbl = IMP.container.ClosePairContainer(atoms, distance,
766  edat.update_dynamic)
767 
768  # Exclude the same sets of atoms as Modeller
769  if pair_filter is None:
770  pair_filter = IMP.atom.StereochemistryPairFilter()
771  if edat.excl_local[0]:
772  pair_filter.set_bonds(list(self.load_bonds()))
773  if edat.excl_local[1]:
774  pair_filter.set_angles(list(self.load_angles()))
775  if edat.excl_local[2]:
776  pair_filter.set_dihedrals(list(self.load_dihedrals()))
777  nbl.add_pair_filter(pair_filter)
778  return nbl
779 
780  def load_bonds(self):
781  """Load the Modeller bond topology into the IMP model. Each bond is
782  represented in IMP as an IMP::atom::Bond, with no defined length
783  or stiffness. These bonds are primarily useful as input to
784  IMP::atom::StereochemistryPairFilter, to exclude bond interactions
785  from the nonbonded list. Typically the contribution to the scoring
786  function from the bonds is included in the Modeller static restraints
787  (use load_static_restraints() or load_static_restraints_file() to
788  load these). If you want to regenerate the stereochemistry in IMP,
789  do not use these functions (as then stereochemistry scoring terms
790  and exclusions would be double-counted) and instead use the
791  IMP::atom::CHARMMTopology class.
792 
793  You must call load_atoms() prior to using this function.
794  @see load_angles(), load_dihedrals(), load_impropers()
795  @return A generator listing all of the bonds.
796  """
797  if not hasattr(self, '_modeller_hierarchy'):
798  raise ValueError("Call load_atoms() first.")
799  for (maa, mab) in self._modeller_model.bonds:
800  pa = self._atoms[maa.index]
801  pb = self._atoms[mab.index]
803  ba= IMP.atom.Bonded(pa)
804  else:
807  bb= IMP.atom.Bonded(pb)
808  else:
810  yield IMP.atom.create_bond(ba, bb,
811  IMP.atom.Bond.SINGLE).get_particle()
812 
813  def load_angles(self):
814  """Load the Modeller angle topology into the IMP model.
815  See load_bonds() for more details."""
816  return self._internal_load_angles(self._modeller_model.angles,
818 
819  def load_dihedrals(self):
820  """Load the Modeller dihedral topology into the IMP model.
821  See load_bonds() for more details."""
822  return self._internal_load_angles(self._modeller_model.dihedrals,
824 
825  def load_impropers(self):
826  """Load the Modeller improper topology into the IMP model.
827  See load_bonds() for more details."""
828  return self._internal_load_angles(self._modeller_model.impropers,
830 
831  def _internal_load_angles(self, angles, angle_class):
832  if not hasattr(self, '_modeller_hierarchy'):
833  raise ValueError("Call load_atoms() first.")
834  for modeller_atoms in angles:
835  imp_particles = [self._atoms[x.index] for x in modeller_atoms]
836  p = IMP.Particle(imp_particles[0].get_model())
837  a = angle_class.setup_particle(p,
838  *[IMP.core.XYZ(x) for x in imp_particles])
839  yield a.get_particle()
840 
841  def load_static_restraints_file(self, filename):
842  """Convert a Modeller static restraints file into equivalent
843  IMP::Restraints. load_atoms() must have been called first to read
844  in the atoms that the restraints will act upon.
845  @param filename Name of the Modeller restraints file. The restraints
846  in this file are assumed to act upon the model read in by
847  load_atoms(); no checking is done to enforce this.
848  @return A Python generator of the newly-created IMP::Restraint
849  objects.
850  """
851  if not hasattr(self, '_modeller_hierarchy'):
852  raise ValueError("Call load_atoms() first.")
853  return _load_entire_restraints_file(filename, self._modeller_hierarchy)
854 
855 
857  """Convert the current set of Modeller static restraints into equivalent
858  IMP::Restraints. load_atoms() must have been called first to read
859  in the atoms that the restraints will act upon.
860  @return A Python generator of the newly-created IMP::Restraint
861  objects.
862  """
863  class _RestraintGenerator(object):
864  """Simple generator wrapper"""
865  def __init__(self, gen):
866  self._gen = gen
867  def __iter__(self, *args, **keys):
868  return self
869  def close(self, *args, **keys):
870  return self._gen.close(*args, **keys)
871  def next(self, *args, **keys):
872  return self._gen.next(*args, **keys)
873  def send(self, *args, **keys):
874  return self._gen.send(*args, **keys)
875  def throw(self, *args, **keys):
876  return self._gen.throw(*args, **keys)
877  # Write current restraints into a temporary file
878  t = _TempDir()
879  rsrfile = os.path.join(t.tmpdir, 'restraints.rsr')
880  self._modeller_model.restraints.write(file=rsrfile)
881  # Read the file back in
882  gen = self.load_static_restraints_file(rsrfile)
883  wrap = _RestraintGenerator(gen)
884  # Ensure that tmpdir remains until we're done with the generator
885  wrap._tempdir = t
886  return wrap
887 
888  def load_dynamic_restraints(self, pair_filter=None):
889  """Convert Modeller dynamic restraints into IMP::Restraint objects.
890 
891  For each currently active Modeller dynamic restraint
892  (e.g. soft-sphere, electrostatics) an equivalent IMP::Restraint
893  is created.
894  load_atoms() must have been called first to read
895  in the atoms that the restraints will act upon.
896 
897  If pair_filter is given, it is an IMP::PairFilter object to exclude
898  pairs from the nonbonded lists used by the dynamic restraints.
899  Otherwise, an IMP::atom::StereochemistryPairFilter object is created
900  to exclude Modeller bonds, angles and dihedrals, as specified by
901  edat.excl_local. (Note that this calls load_bonds(), load_angles()
902  and load_dihedrals(), so will create duplicate lists of bonds if
903  those methods are called manually as well.)
904 
905  @note Currently only soft-sphere, electrostatic and Lennard-Jones
906  restraints are loaded.
907  @return A Python generator of the newly-created IMP::Restraint
908  objects.
909  """
910  if not hasattr(self, '_modeller_hierarchy'):
911  raise ValueError("Call load_atoms() first.")
912  edat = self._modeller_model.env.edat
913  libs = self._modeller_model.env.libs
915  IMP.atom.get_leaves(self._modeller_hierarchy))
916 
917  if edat.dynamic_sphere:
918  # Note: cannot use Modeller's cutoff distance, as that is
919  # center-to-center; IMP's is sphere surface-surface
920  nbl = self._get_nonbonded_list(atoms, pair_filter, edat, 0.)
921  # No way to get Modeller radii, so we have to reassign them
922  add_soft_sphere_radii(self._modeller_hierarchy,
923  libs.topology.submodel, edat.radii_factor)
924  k = \
928  yield IMP.container.PairsRestraint(ps, nbl)
929 
930  if edat.dynamic_lennard or edat.dynamic_coulomb:
931  # 3.0 is roughly the max. atom diameter
932  d = max(edat.contact_shell - 3.0, 0.0)
933  nbl = self._get_nonbonded_list(atoms, pair_filter, edat, d)
934  ff = _get_forcefield(libs.topology.submodel)
935  ff.add_radii(self._modeller_hierarchy)
936 
937  if edat.dynamic_lennard:
938  ff.add_well_depths(self._modeller_hierarchy)
939  sf = IMP.atom.ForceSwitch(edat.lennard_jones_switch[0],
940  edat.lennard_jones_switch[1])
942  yield IMP.container.PairsRestraint(ps, nbl)
943 
944  if edat.dynamic_coulomb:
945  sf = IMP.atom.ForceSwitch(edat.coulomb_switch[0],
946  edat.coulomb_switch[1])
948  ps.set_relative_dielectric(edat.relative_dielectric)
949  yield IMP.container.PairsRestraint(ps, nbl)
950 
951 
952 def read_pdb(name, model, special_patches=None):
953  """Construct an IMP::atom::Hierarchy from a PDB file.
954 
955  @deprecated Use IMP::atom::read_pdb() instead to read a PDB file,
956  or ModelLoader to read a Modeller model.
957 
958  @param name The name of the PDB file to read.
959  @param model The IMP::Model object in which the hierarchy will be
960  created. The highest level hierarchy node is a PROTEIN.
961  @param special_patches If given, a function that applies patches
962  (e.g. nucleic acid termini) to the Modeller model.
963  @return the newly-created root IMP::atom::Hierarchy.
964  """
965  e = modeller.environ()
966  e.libs.topology.read('${LIB}/top_heav.lib')
967  e.libs.parameters.read('${LIB}/par.lib')
968  e.io.hetatm=True
969  modeller_model = modeller.scripts.complete_pdb(e, name,
970  special_patches=special_patches)
971  loader = ModelLoader(modeller_model)
972  hpp = loader.load_atoms(model)
973  hpp.get_particle().set_name(name)
974  return hpp
975 
976 
978  """Proxy of C++ IMP::modeller::MultipleBinormalRestraint class"""
979  __swig_setmethods__ = {}
980  for _s in [IMP.kernel.Restraint]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
981  __setattr__ = lambda self, name, value: _swig_setattr(self, MultipleBinormalRestraint, name, value)
982  __swig_getmethods__ = {}
983  for _s in [IMP.kernel.Restraint]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
984  __getattr__ = lambda self, name: _swig_getattr(self, MultipleBinormalRestraint, name)
985  def __init__(self, *args):
986  """__init__(IMP::modeller::MultipleBinormalRestraint self, IMP::kernel::ParticleQuad const & q1, IMP::kernel::ParticleQuad const & q2) -> MultipleBinormalRestraint"""
987  this = _IMP_modeller.new_MultipleBinormalRestraint(*args)
988  try: self.this.append(this)
989  except: self.this = this
990  def add_term(self, *args):
991  """add_term(MultipleBinormalRestraint self, BinormalTerm term)"""
992  return _IMP_modeller.MultipleBinormalRestraint_add_term(self, *args)
993 
994  def do_get_inputs(self):
995  """do_get_inputs(MultipleBinormalRestraint self) -> IMP::kernel::ModelObjectsTemp"""
996  return _IMP_modeller.MultipleBinormalRestraint_do_get_inputs(self)
997 
998  def get_version_info(self):
999  """get_version_info(MultipleBinormalRestraint self) -> VersionInfo"""
1000  return _IMP_modeller.MultipleBinormalRestraint_get_version_info(self)
1001 
1002  def __str__(self):
1003  """__str__(MultipleBinormalRestraint self) -> std::string"""
1004  return _IMP_modeller.MultipleBinormalRestraint___str__(self)
1005 
1006  def __repr__(self):
1007  """__repr__(MultipleBinormalRestraint self) -> std::string"""
1008  return _IMP_modeller.MultipleBinormalRestraint___repr__(self)
1009 
1010  def get_from(o):
1011  return _object_cast_to_MultipleBinormalRestraint(o)
1012  get_from = staticmethod(get_from)
1013 
1014 MultipleBinormalRestraint_swigregister = _IMP_modeller.MultipleBinormalRestraint_swigregister
1015 MultipleBinormalRestraint_swigregister(MultipleBinormalRestraint)
1016 
1017 class BinormalTerm(_object):
1018  """Proxy of C++ IMP::modeller::BinormalTerm class"""
1019  __swig_setmethods__ = {}
1020  __setattr__ = lambda self, name, value: _swig_setattr(self, BinormalTerm, name, value)
1021  __swig_getmethods__ = {}
1022  __getattr__ = lambda self, name: _swig_getattr(self, BinormalTerm, name)
1023  def __init__(self):
1024  """__init__(IMP::modeller::BinormalTerm self) -> BinormalTerm"""
1025  this = _IMP_modeller.new_BinormalTerm()
1026  try: self.this.append(this)
1027  except: self.this = this
1028  def set_correlation(self, *args):
1029  """set_correlation(BinormalTerm self, double correlation)"""
1030  return _IMP_modeller.BinormalTerm_set_correlation(self, *args)
1031 
1032  def set_weight(self, *args):
1033  """set_weight(BinormalTerm self, double weight)"""
1034  return _IMP_modeller.BinormalTerm_set_weight(self, *args)
1035 
1036  def set_means(self, *args):
1037  """set_means(BinormalTerm self, IMP::FloatPair means)"""
1038  return _IMP_modeller.BinormalTerm_set_means(self, *args)
1039 
1040  def set_standard_deviations(self, *args):
1041  """set_standard_deviations(BinormalTerm self, IMP::FloatPair stdevs)"""
1042  return _IMP_modeller.BinormalTerm_set_standard_deviations(self, *args)
1043 
1044  def show(self, *args):
1045  """
1046  show(BinormalTerm self, _ostream out=std::cout)
1047  show(BinormalTerm self)
1048  """
1049  return _IMP_modeller.BinormalTerm_show(self, *args)
1050 
1051  def __str__(self):
1052  """__str__(BinormalTerm self) -> std::string"""
1053  return _IMP_modeller.BinormalTerm___str__(self)
1054 
1055  def __repr__(self):
1056  """__repr__(BinormalTerm self) -> std::string"""
1057  return _IMP_modeller.BinormalTerm___repr__(self)
1058 
1059  __swig_destroy__ = _IMP_modeller.delete_BinormalTerm
1060  __del__ = lambda self : None;
1061 BinormalTerm_swigregister = _IMP_modeller.BinormalTerm_swigregister
1062 BinormalTerm_swigregister(BinormalTerm)
1063 
1064 
1065 def get_module_version():
1066  """get_module_version() -> std::string const"""
1067  return _IMP_modeller.get_module_version()
1068 
1069 def get_example_path(*args):
1070  """get_example_path(std::string fname) -> std::string"""
1071  return _IMP_modeller.get_example_path(*args)
1072 
1073 def get_data_path(*args):
1074  """get_data_path(std::string fname) -> std::string"""
1075  return _IMP_modeller.get_data_path(*args)
1076 import _version_check
1077 _version_check.check_version(get_module_version())
1078 
1079 # This file is compatible with both classic and new-style classes.
1080 
1081 
static Residue setup_particle(kernel::Model *m, ParticleIndex pi, ResidueType t, int index, int insertion_code)
Definition: Residue.h:157
Lower bound harmonic function (non-zero when feature < mean)
def load_static_restraints
Convert the current set of Modeller static restraints into equivalent IMP::Restraints.
static Charged setup_particle(kernel::Model *m, ParticleIndex pi, Float charge)
Definition: Charged.h:46
def read_pdb
Construct an IMP::atom::Hierarchy from a PDB file.
std::string get_example_path(std::string file_name)
Return the path to installed example data for this module.
def load_bonds
Load the Modeller bond topology into the IMP model.
A Modeller restraint which evaluates all defined IMP restraints.
Coulomb (electrostatic) score between a pair of particles.
static CHARMMAtom setup_particle(kernel::Model *m, ParticleIndex pi, String charmm_type)
Definition: CHARMMAtom.h:37
static Atom setup_particle(kernel::Model *m, ParticleIndex pi, Atom other)
Definition: atom/Atom.h:242
Various classes to hold sets of particles.
Upper bound harmonic function (non-zero when feature > mean)
A decorator for a particle which has bonds.
def load_impropers
Load the Modeller improper topology into the IMP model.
Make CGAL functionality available to IMP.
Cosine function.
Definition: Cosine.h:22
void set_check_level(CheckLevel tf)
Control runtime checks in the code.
Definition: exception.h:73
Low level functionality (logging, error handling, profiling, command line flags etc) that is used by ...
std::string get_data_path(std::string file_name)
Return the full path to installed data.
static XYZ setup_particle(kernel::Model *m, ParticleIndex pi)
Definition: XYZ.h:51
Dihedral restraint between four particles.
def load_static_restraints_file
Convert a Modeller static restraints file into equivalent IMP::Restraints.
The type of an atom.
A score on the distance between the surfaces of two spheres.
Return all close unordered pairs of particles taken from the SingletonContainer.
def load_dynamic_restraints
Convert Modeller dynamic restraints into IMP::Restraint objects.
Distance restraint between two particles.
Composable functors to implement scores via compile-time composition.
An IMP restraint using all defined Modeller restraints.
static bool get_is_setup(const IMP::kernel::ParticleAdaptor &p)
CHARMM force field parameters.
Bond create_bond(Bonded a, Bonded b, Bond o)
Connect the two wrapped particles by a custom bond.
def load_dihedrals
Load the Modeller dihedral topology into the IMP model.
static Float get_k_from_standard_deviation(Float sd, Float t=297.15)
Return the k to use for a given Gaussian standard deviation.
Definition: core/Harmonic.h:62
virtual VersionInfo get_version_info() const
Get information about the module and version of the object.
Definition: Object.h:173
A single binormal term in a MultipleBinormalRestraint.
Angle restraint between three particles.
static XYZR setup_particle(kernel::Model *m, ParticleIndex pi)
Definition: XYZR.h:48
static Bonded setup_particle(kernel::Model *m, ParticleIndex pi)
Lennard-Jones score between a pair of particles.
A particle that describes an angle between three particles.
static Hierarchy setup_particle(kernel::Model *m, kernel::ParticleIndex pi, kernel::ParticleIndexesAdaptor children=kernel::ParticleIndexesAdaptor())
Store a kernel::ParticleIndexes.
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
Base functionality and abstract base classes for representation, scoring and sampling.
The type for a residue.
def load_atoms
Construct an IMP::atom::Hierarchy that contains the same atoms as the Modeller model or alignment str...
A restraint is a term in an IMP ScoringFunction.
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
static Chain setup_particle(kernel::Model *m, ParticleIndex pi, std::string id)
Definition: Chain.h:41
def load_restraints_file
Convert a Modeller restraints file into IMP::Restraint objects.
Class to handle individual model particles.
Linear function
Definition: Linear.h:19
def add_soft_sphere_radii
Add radii to the hierarchy using the Modeller radius library, radii.lib.
A particle that describes a dihedral angle between four particles.
def load_angles
Load the Modeller angle topology into the IMP model.
Modeller-style multiple binormal (phi/psi) restraint.
Basic functionality that is expected to be used by a wide variety of IMP users.
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
VectorD< 3 > Vector3D
Definition: VectorD.h:395
virtual ModelObjectsTemp do_get_inputs() const =0
A filter that excludes bonds, angles and dihedrals.
Read a Modeller model into IMP.
std::string get_data_path(std::string file_name)
Return the full path to installed data.
Smooth interaction scores by switching the derivatives (force switch).
Output IMP model data in various file formats.
CheckLevel get_check_level()
Get the current audit mode.
Definition: exception.h:81
Functionality for loading, creating, manipulating and scoring atomic structures.
Hierarchies get_leaves(const Selection &h)
Applies a PairScore to each Pair in a list.
Closed cubic spline function.
A decorator for an atom that has a defined CHARMM type.
Definition: CHARMMAtom.h:24
Harmonic function (symmetric about the mean)
Definition: core/Harmonic.h:24