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