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