IMP logo
IMP Reference Guide  2.16.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-2021 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_NUMPY_swigconstant(_IMP_modeller)
269 IMP_KERNEL_HAS_NUMPY = _IMP_modeller.IMP_KERNEL_HAS_NUMPY
270 
271 _IMP_modeller.IMP_KERNEL_HAS_GPERFTOOLS_swigconstant(_IMP_modeller)
272 IMP_KERNEL_HAS_GPERFTOOLS = _IMP_modeller.IMP_KERNEL_HAS_GPERFTOOLS
273 
274 _IMP_modeller.IMP_KERNEL_HAS_TCMALLOC_HEAPCHECKER_swigconstant(_IMP_modeller)
275 IMP_KERNEL_HAS_TCMALLOC_HEAPCHECKER = _IMP_modeller.IMP_KERNEL_HAS_TCMALLOC_HEAPCHECKER
276 
277 _IMP_modeller.IMP_KERNEL_HAS_TCMALLOC_HEAPPROFILER_swigconstant(_IMP_modeller)
278 IMP_KERNEL_HAS_TCMALLOC_HEAPPROFILER = _IMP_modeller.IMP_KERNEL_HAS_TCMALLOC_HEAPPROFILER
279 
280 _IMP_modeller.IMPKERNEL_SHOW_WARNINGS_swigconstant(_IMP_modeller)
281 IMPKERNEL_SHOW_WARNINGS = _IMP_modeller.IMPKERNEL_SHOW_WARNINGS
282 
283 import sys
284 class _DirectorObjects(object):
285  """@internal Simple class to keep references to director objects
286  to prevent premature deletion."""
287  def __init__(self):
288  self._objects = []
289  def register(self, obj):
290  """Take a reference to a director object; will only work for
291  refcounted C++ classes"""
292  if hasattr(obj, 'get_ref_count'):
293  self._objects.append(obj)
294  def cleanup(self):
295  """Only drop our reference and allow cleanup by Python if no other
296  Python references exist (we hold 3 references: one in self._objects,
297  one in x, and one in the argument list for getrefcount) *and* no
298  other C++ references exist (the Python object always holds one)"""
299  objs = [x for x in self._objects if sys.getrefcount(x) > 3 \
300  or x.get_ref_count() > 1]
301 # Do in two steps so the references are kept until the end of the
302 # function (deleting references may trigger a fresh call to this method)
303  self._objects = objs
304  def get_object_count(self):
305  """Get number of director objects (useful for testing only)"""
306  return len(self._objects)
307 _director_objects = _DirectorObjects()
308 
309 class _ostream(object):
310  """Proxy of C++ std::ostream class"""
311  thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
312 
313  def __init__(self, *args, **kwargs):
314  raise AttributeError("No constructor defined")
315  __repr__ = _swig_repr
316 
317  def write(self, osa_buf):
318  """write(_ostream self, char const * osa_buf)"""
319  return _IMP_modeller._ostream_write(self, osa_buf)
320 
321 _ostream_swigregister = _IMP_modeller._ostream_swigregister
322 _ostream_swigregister(_ostream)
323 
324 
325 _IMP_modeller.IMP_COMPILER_HAS_OVERRIDE_swigconstant(_IMP_modeller)
326 IMP_COMPILER_HAS_OVERRIDE = _IMP_modeller.IMP_COMPILER_HAS_OVERRIDE
327 
328 _IMP_modeller.IMP_COMPILER_HAS_FINAL_swigconstant(_IMP_modeller)
329 IMP_COMPILER_HAS_FINAL = _IMP_modeller.IMP_COMPILER_HAS_FINAL
330 
331 _IMP_modeller.IMP_HAS_NOEXCEPT_swigconstant(_IMP_modeller)
332 IMP_HAS_NOEXCEPT = _IMP_modeller.IMP_HAS_NOEXCEPT
333 
334 _IMP_modeller.IMP_C_OPEN_BINARY_swigconstant(_IMP_modeller)
335 IMP_C_OPEN_BINARY = _IMP_modeller.IMP_C_OPEN_BINARY
336 import IMP
337 
338 _IMP_modeller.IMP_CGAL_HAS_BOOST_FILESYSTEM_swigconstant(_IMP_modeller)
339 IMP_CGAL_HAS_BOOST_FILESYSTEM = _IMP_modeller.IMP_CGAL_HAS_BOOST_FILESYSTEM
340 
341 _IMP_modeller.IMP_CGAL_HAS_BOOST_PROGRAMOPTIONS_swigconstant(_IMP_modeller)
342 IMP_CGAL_HAS_BOOST_PROGRAMOPTIONS = _IMP_modeller.IMP_CGAL_HAS_BOOST_PROGRAMOPTIONS
343 
344 _IMP_modeller.IMP_CGAL_HAS_BOOST_RANDOM_swigconstant(_IMP_modeller)
345 IMP_CGAL_HAS_BOOST_RANDOM = _IMP_modeller.IMP_CGAL_HAS_BOOST_RANDOM
346 
347 _IMP_modeller.IMP_CGAL_HAS_BOOST_SYSTEM_swigconstant(_IMP_modeller)
348 IMP_CGAL_HAS_BOOST_SYSTEM = _IMP_modeller.IMP_CGAL_HAS_BOOST_SYSTEM
349 
350 _IMP_modeller.IMP_CGAL_HAS_NUMPY_swigconstant(_IMP_modeller)
351 IMP_CGAL_HAS_NUMPY = _IMP_modeller.IMP_CGAL_HAS_NUMPY
352 
353 _IMP_modeller.IMPCGAL_SHOW_WARNINGS_swigconstant(_IMP_modeller)
354 IMPCGAL_SHOW_WARNINGS = _IMP_modeller.IMPCGAL_SHOW_WARNINGS
355 import IMP.cgal
356 
357 _IMP_modeller.IMP_ALGEBRA_HAS_IMP_CGAL_swigconstant(_IMP_modeller)
358 IMP_ALGEBRA_HAS_IMP_CGAL = _IMP_modeller.IMP_ALGEBRA_HAS_IMP_CGAL
359 
360 _IMP_modeller.IMP_ALGEBRA_HAS_BOOST_FILESYSTEM_swigconstant(_IMP_modeller)
361 IMP_ALGEBRA_HAS_BOOST_FILESYSTEM = _IMP_modeller.IMP_ALGEBRA_HAS_BOOST_FILESYSTEM
362 
363 _IMP_modeller.IMP_ALGEBRA_HAS_BOOST_PROGRAMOPTIONS_swigconstant(_IMP_modeller)
364 IMP_ALGEBRA_HAS_BOOST_PROGRAMOPTIONS = _IMP_modeller.IMP_ALGEBRA_HAS_BOOST_PROGRAMOPTIONS
365 
366 _IMP_modeller.IMP_ALGEBRA_HAS_BOOST_RANDOM_swigconstant(_IMP_modeller)
367 IMP_ALGEBRA_HAS_BOOST_RANDOM = _IMP_modeller.IMP_ALGEBRA_HAS_BOOST_RANDOM
368 
369 _IMP_modeller.IMP_ALGEBRA_HAS_BOOST_SYSTEM_swigconstant(_IMP_modeller)
370 IMP_ALGEBRA_HAS_BOOST_SYSTEM = _IMP_modeller.IMP_ALGEBRA_HAS_BOOST_SYSTEM
371 
372 _IMP_modeller.IMP_ALGEBRA_HAS_CGAL_swigconstant(_IMP_modeller)
373 IMP_ALGEBRA_HAS_CGAL = _IMP_modeller.IMP_ALGEBRA_HAS_CGAL
374 
375 _IMP_modeller.IMP_ALGEBRA_HAS_NUMPY_swigconstant(_IMP_modeller)
376 IMP_ALGEBRA_HAS_NUMPY = _IMP_modeller.IMP_ALGEBRA_HAS_NUMPY
377 
378 _IMP_modeller.IMP_ALGEBRA_HAS_ANN_swigconstant(_IMP_modeller)
379 IMP_ALGEBRA_HAS_ANN = _IMP_modeller.IMP_ALGEBRA_HAS_ANN
380 
381 _IMP_modeller.IMPALGEBRA_SHOW_WARNINGS_swigconstant(_IMP_modeller)
382 IMPALGEBRA_SHOW_WARNINGS = _IMP_modeller.IMPALGEBRA_SHOW_WARNINGS
383 import IMP.algebra
384 
385 _IMP_modeller.IMP_DISPLAY_HAS_IMP_CGAL_swigconstant(_IMP_modeller)
386 IMP_DISPLAY_HAS_IMP_CGAL = _IMP_modeller.IMP_DISPLAY_HAS_IMP_CGAL
387 
388 _IMP_modeller.IMP_DISPLAY_HAS_BOOST_FILESYSTEM_swigconstant(_IMP_modeller)
389 IMP_DISPLAY_HAS_BOOST_FILESYSTEM = _IMP_modeller.IMP_DISPLAY_HAS_BOOST_FILESYSTEM
390 
391 _IMP_modeller.IMP_DISPLAY_HAS_BOOST_PROGRAMOPTIONS_swigconstant(_IMP_modeller)
392 IMP_DISPLAY_HAS_BOOST_PROGRAMOPTIONS = _IMP_modeller.IMP_DISPLAY_HAS_BOOST_PROGRAMOPTIONS
393 
394 _IMP_modeller.IMP_DISPLAY_HAS_BOOST_RANDOM_swigconstant(_IMP_modeller)
395 IMP_DISPLAY_HAS_BOOST_RANDOM = _IMP_modeller.IMP_DISPLAY_HAS_BOOST_RANDOM
396 
397 _IMP_modeller.IMP_DISPLAY_HAS_BOOST_SYSTEM_swigconstant(_IMP_modeller)
398 IMP_DISPLAY_HAS_BOOST_SYSTEM = _IMP_modeller.IMP_DISPLAY_HAS_BOOST_SYSTEM
399 
400 _IMP_modeller.IMP_DISPLAY_HAS_CGAL_swigconstant(_IMP_modeller)
401 IMP_DISPLAY_HAS_CGAL = _IMP_modeller.IMP_DISPLAY_HAS_CGAL
402 
403 _IMP_modeller.IMP_DISPLAY_HAS_NUMPY_swigconstant(_IMP_modeller)
404 IMP_DISPLAY_HAS_NUMPY = _IMP_modeller.IMP_DISPLAY_HAS_NUMPY
405 
406 _IMP_modeller.IMPDISPLAY_SHOW_WARNINGS_swigconstant(_IMP_modeller)
407 IMPDISPLAY_SHOW_WARNINGS = _IMP_modeller.IMPDISPLAY_SHOW_WARNINGS
408 import IMP.display
409 
410 _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_IMP_CGAL_swigconstant(_IMP_modeller)
411 IMP_SCORE_FUNCTOR_HAS_IMP_CGAL = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_IMP_CGAL
412 
413 _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_BOOST_FILESYSTEM_swigconstant(_IMP_modeller)
414 IMP_SCORE_FUNCTOR_HAS_BOOST_FILESYSTEM = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_BOOST_FILESYSTEM
415 
416 _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_BOOST_PROGRAMOPTIONS_swigconstant(_IMP_modeller)
417 IMP_SCORE_FUNCTOR_HAS_BOOST_PROGRAMOPTIONS = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_BOOST_PROGRAMOPTIONS
418 
419 _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_BOOST_RANDOM_swigconstant(_IMP_modeller)
420 IMP_SCORE_FUNCTOR_HAS_BOOST_RANDOM = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_BOOST_RANDOM
421 
422 _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_BOOST_SYSTEM_swigconstant(_IMP_modeller)
423 IMP_SCORE_FUNCTOR_HAS_BOOST_SYSTEM = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_BOOST_SYSTEM
424 
425 _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_CGAL_swigconstant(_IMP_modeller)
426 IMP_SCORE_FUNCTOR_HAS_CGAL = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_CGAL
427 
428 _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_HDF5_swigconstant(_IMP_modeller)
429 IMP_SCORE_FUNCTOR_HAS_HDF5 = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_HDF5
430 
431 _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_NUMPY_swigconstant(_IMP_modeller)
432 IMP_SCORE_FUNCTOR_HAS_NUMPY = _IMP_modeller.IMP_SCORE_FUNCTOR_HAS_NUMPY
433 
434 _IMP_modeller.IMPSCOREFUNCTOR_SHOW_WARNINGS_swigconstant(_IMP_modeller)
435 IMPSCOREFUNCTOR_SHOW_WARNINGS = _IMP_modeller.IMPSCOREFUNCTOR_SHOW_WARNINGS
436 import IMP.score_functor
437 
438 _IMP_modeller.IMP_CORE_HAS_IMP_CGAL_swigconstant(_IMP_modeller)
439 IMP_CORE_HAS_IMP_CGAL = _IMP_modeller.IMP_CORE_HAS_IMP_CGAL
440 
441 _IMP_modeller.IMP_CORE_HAS_IMP_KERNEL_swigconstant(_IMP_modeller)
442 IMP_CORE_HAS_IMP_KERNEL = _IMP_modeller.IMP_CORE_HAS_IMP_KERNEL
443 
444 _IMP_modeller.IMP_CORE_HAS_BOOST_FILESYSTEM_swigconstant(_IMP_modeller)
445 IMP_CORE_HAS_BOOST_FILESYSTEM = _IMP_modeller.IMP_CORE_HAS_BOOST_FILESYSTEM
446 
447 _IMP_modeller.IMP_CORE_HAS_BOOST_PROGRAMOPTIONS_swigconstant(_IMP_modeller)
448 IMP_CORE_HAS_BOOST_PROGRAMOPTIONS = _IMP_modeller.IMP_CORE_HAS_BOOST_PROGRAMOPTIONS
449 
450 _IMP_modeller.IMP_CORE_HAS_BOOST_RANDOM_swigconstant(_IMP_modeller)
451 IMP_CORE_HAS_BOOST_RANDOM = _IMP_modeller.IMP_CORE_HAS_BOOST_RANDOM
452 
453 _IMP_modeller.IMP_CORE_HAS_BOOST_SYSTEM_swigconstant(_IMP_modeller)
454 IMP_CORE_HAS_BOOST_SYSTEM = _IMP_modeller.IMP_CORE_HAS_BOOST_SYSTEM
455 
456 _IMP_modeller.IMP_CORE_HAS_CGAL_swigconstant(_IMP_modeller)
457 IMP_CORE_HAS_CGAL = _IMP_modeller.IMP_CORE_HAS_CGAL
458 
459 _IMP_modeller.IMP_CORE_HAS_HDF5_swigconstant(_IMP_modeller)
460 IMP_CORE_HAS_HDF5 = _IMP_modeller.IMP_CORE_HAS_HDF5
461 
462 _IMP_modeller.IMP_CORE_HAS_NUMPY_swigconstant(_IMP_modeller)
463 IMP_CORE_HAS_NUMPY = _IMP_modeller.IMP_CORE_HAS_NUMPY
464 
465 _IMP_modeller.IMPCORE_SHOW_WARNINGS_swigconstant(_IMP_modeller)
466 IMPCORE_SHOW_WARNINGS = _IMP_modeller.IMPCORE_SHOW_WARNINGS
467 import IMP.core
468 
469 _IMP_modeller.IMP_MODELLER_HAS_IMP_ALGEBRA_swigconstant(_IMP_modeller)
470 IMP_MODELLER_HAS_IMP_ALGEBRA = _IMP_modeller.IMP_MODELLER_HAS_IMP_ALGEBRA
471 
472 _IMP_modeller.IMP_MODELLER_HAS_IMP_CGAL_swigconstant(_IMP_modeller)
473 IMP_MODELLER_HAS_IMP_CGAL = _IMP_modeller.IMP_MODELLER_HAS_IMP_CGAL
474 
475 _IMP_modeller.IMP_MODELLER_HAS_IMP_DISPLAY_swigconstant(_IMP_modeller)
476 IMP_MODELLER_HAS_IMP_DISPLAY = _IMP_modeller.IMP_MODELLER_HAS_IMP_DISPLAY
477 
478 _IMP_modeller.IMP_MODELLER_HAS_IMP_KERNEL_swigconstant(_IMP_modeller)
479 IMP_MODELLER_HAS_IMP_KERNEL = _IMP_modeller.IMP_MODELLER_HAS_IMP_KERNEL
480 
481 _IMP_modeller.IMP_MODELLER_HAS_IMP_SCORE_FUNCTOR_swigconstant(_IMP_modeller)
482 IMP_MODELLER_HAS_IMP_SCORE_FUNCTOR = _IMP_modeller.IMP_MODELLER_HAS_IMP_SCORE_FUNCTOR
483 
484 _IMP_modeller.IMP_MODELLER_HAS_BOOST_FILESYSTEM_swigconstant(_IMP_modeller)
485 IMP_MODELLER_HAS_BOOST_FILESYSTEM = _IMP_modeller.IMP_MODELLER_HAS_BOOST_FILESYSTEM
486 
487 _IMP_modeller.IMP_MODELLER_HAS_BOOST_PROGRAMOPTIONS_swigconstant(_IMP_modeller)
488 IMP_MODELLER_HAS_BOOST_PROGRAMOPTIONS = _IMP_modeller.IMP_MODELLER_HAS_BOOST_PROGRAMOPTIONS
489 
490 _IMP_modeller.IMP_MODELLER_HAS_BOOST_RANDOM_swigconstant(_IMP_modeller)
491 IMP_MODELLER_HAS_BOOST_RANDOM = _IMP_modeller.IMP_MODELLER_HAS_BOOST_RANDOM
492 
493 _IMP_modeller.IMP_MODELLER_HAS_BOOST_SYSTEM_swigconstant(_IMP_modeller)
494 IMP_MODELLER_HAS_BOOST_SYSTEM = _IMP_modeller.IMP_MODELLER_HAS_BOOST_SYSTEM
495 
496 _IMP_modeller.IMP_MODELLER_HAS_CGAL_swigconstant(_IMP_modeller)
497 IMP_MODELLER_HAS_CGAL = _IMP_modeller.IMP_MODELLER_HAS_CGAL
498 
499 _IMP_modeller.IMP_MODELLER_HAS_HDF5_swigconstant(_IMP_modeller)
500 IMP_MODELLER_HAS_HDF5 = _IMP_modeller.IMP_MODELLER_HAS_HDF5
501 
502 _IMP_modeller.IMP_MODELLER_HAS_NUMPY_swigconstant(_IMP_modeller)
503 IMP_MODELLER_HAS_NUMPY = _IMP_modeller.IMP_MODELLER_HAS_NUMPY
504 
505 _IMP_modeller.IMP_MODELLER_HAS_PYTHON_IHM_swigconstant(_IMP_modeller)
506 IMP_MODELLER_HAS_PYTHON_IHM = _IMP_modeller.IMP_MODELLER_HAS_PYTHON_IHM
507 
508 _IMP_modeller.IMPMODELLER_SHOW_WARNINGS_swigconstant(_IMP_modeller)
509 IMPMODELLER_SHOW_WARNINGS = _IMP_modeller.IMPMODELLER_SHOW_WARNINGS
510 
511 
512 import math
513 import imp
514 import os
515 import sys
516 import tempfile
517 import shutil
518 import IMP.atom
519 import IMP.container
520 import modeller.scripts
521 import modeller.optimizers
522 
523 
524 # Use Modeller 10 class names
525 if not hasattr(modeller.terms, 'EnergyTerm'):
526  modeller.terms.EnergyTerm = modeller.terms.energy_term
527  modeller.Selection = modeller.selection
528 
529 
530 class _TempDir(object):
531  """Make a temporary directory that is deleted when the object is."""
532 
533  def __init__(self):
534  self.tmpdir = tempfile.mkdtemp()
535 
536  def __del__(self):
537  shutil.rmtree(self.tmpdir, ignore_errors=True)
538 
539 
540 class IMPRestraints(modeller.terms.EnergyTerm):
541  """A Modeller restraint which evaluates an IMP scoring function.
542  This can be used to incorporate IMP Restraints into an existing
543  comparative modeling pipeline, or to use Modeller optimizers or
544  protocols.
545  """
546 
547  _physical_type = modeller.physical.absposition
548 
549  def __init__(self, particles, scoring_function=None):
550  """Constructor.
551  @param particles A list of the IMP atoms (as Particle objects),
552  same order as the Modeller atoms.
553  @param scoring_function An IMP::ScoringFunction object that will
554  be incorporated into the Modeller score (molpdf).
555  @note since Modeller, unlike IMP, is sensitive to the ordering
556  of atoms, it usually makes sense to create the model in
557  Modeller and then use ModelLoader to load it into IMP,
558  since that will preserve the Modeller atom ordering in IMP.
559  """
560  modeller.terms.EnergyTerm.__init__(self)
561  self._particles = particles
562  if scoring_function:
563  self._sf = scoring_function
564  else:
565  self._sf = particles[0].get_model()
566 
567  def eval(self, mdl, deriv, indats):
568  atoms = self.indices_to_atoms(mdl, indats)
569  _copy_modeller_coords_to_imp(atoms, self._particles)
570  if len(self._particles) == 0:
571  score = 0.
572  else:
573  score = self._sf.evaluate(deriv)
574  if deriv:
575  dvx = [0.] * len(indats)
576  dvy = [0.] * len(indats)
577  dvz = [0.] * len(indats)
578  _get_imp_derivs(self._particles, dvx, dvy, dvz)
579  return (score, dvx, dvy, dvz)
580  else:
581  return score
582 
583 
585  """An IMP restraint using all defined Modeller restraints.
586  This is useful if you want to use Modeller restraints with an IMP
587  optimizer, or in combination with IMP restraints.
588 
589  @note Currently only the coordinates of the atoms are translated
590  between Modeller and IMP; thus, a Modeller restraint which
591  uses any other attribute (e.g. charge) will not react if
592  this attribute is changed by IMP.
593  """
594 
595  def __init__(self, model, modeller_model, particles):
596  """Constructor.
597  @param model The IMP Model object.
598  @param modeller_model The Modeller model object.
599  @param particles A list of the IMP atoms (as Particle objects),
600  in the same order as the Modeller atoms.
601  @note since Modeller, unlike IMP, is sensitive to the ordering
602  of atoms, it usually makes sense to create the model in
603  Modeller and then use ModelLoader to load it into IMP,
604  since that will preserve the Modeller atom ordering in IMP.
605  """
606  def get_particle(x):
607  if hasattr(x, 'get_particle'):
608  return x.get_particle()
609  else:
610  return x
611  IMP.Restraint.__init__(self, model, "ModellerRestraints %1%")
612  self._modeller_model = modeller_model
613  self._particles = [get_particle(x) for x in particles]
614 
615  def unprotected_evaluate(self, accum):
616  atoms = self._modeller_model.atoms
617  sel = modeller.Selection(self._modeller_model)
618  _copy_imp_coords_to_modeller(self._particles, atoms)
619  energies = sel.energy()
620  if accum:
621  _add_modeller_derivs_to_imp(atoms, self._particles, accum)
622 
623  return energies[0]
624 
625  def get_version_info(self):
626  return IMP.VersionInfo("IMP developers", "0.1")
627  def do_show(self, fh):
628  fh.write("ModellerRestraints")
629  def do_get_inputs(self):
630  return self._particles
631 
632 
633 def _copy_imp_coords_to_modeller(particles, atoms):
634  """Copy atom coordinates from IMP to Modeller"""
635  xkey = IMP.FloatKey("x")
636  ykey = IMP.FloatKey("y")
637  zkey = IMP.FloatKey("z")
638  for (num, at) in enumerate(atoms):
639  at.x = particles[num].get_value(xkey)
640  at.y = particles[num].get_value(ykey)
641  at.z = particles[num].get_value(zkey)
642 
643 
644 def _copy_modeller_coords_to_imp(atoms, particles):
645  """Copy atom coordinates from Modeller to IMP"""
646  xkey = IMP.FloatKey("x")
647  ykey = IMP.FloatKey("y")
648  zkey = IMP.FloatKey("z")
649  for (num, at) in enumerate(atoms):
650  particles[num].set_value(xkey, at.x)
651  particles[num].set_value(ykey, at.y)
652  particles[num].set_value(zkey, at.z)
653 
654 
655 def _add_modeller_derivs_to_imp(atoms, particles, accum):
656  """Add atom derivatives from Modeller to IMP"""
657  for (num, at) in enumerate(atoms):
658  xyz = IMP.core.XYZ(particles[num])
659  xyz.add_to_derivative(0, at.dvx, accum)
660  xyz.add_to_derivative(1, at.dvy, accum)
661  xyz.add_to_derivative(2, at.dvz, accum)
662 
663 
664 def _get_imp_derivs(particles, dvx, dvy, dvz):
665  """Move atom derivatives from IMP to Modeller"""
666  xkey = IMP.FloatKey("x")
667  ykey = IMP.FloatKey("y")
668  zkey = IMP.FloatKey("z")
669  for idx in range(0, len(dvx)):
670  dvx[idx] = particles[idx].get_derivative(xkey)
671  dvy[idx] = particles[idx].get_derivative(ykey)
672  dvz[idx] = particles[idx].get_derivative(zkey)
673 
674 
675 # Generators to create IMP UnaryFunction objects from Modeller parameters:
676 def _HarmonicLowerBoundGenerator(parameters, modalities):
677  (mean, stdev) = parameters
679  return IMP.core.HarmonicLowerBound(mean, k)
680 
681 def _HarmonicUpperBoundGenerator(parameters, modalities):
682  (mean, stdev) = parameters
684  return IMP.core.HarmonicUpperBound(mean, k)
685 
686 def _HarmonicGenerator(parameters, modalities):
687  (mean, stdev) = parameters
689  return IMP.core.Harmonic(mean, k)
690 
691 def _CosineGenerator(parameters, modalities):
692  (phase, force_constant) = parameters
693  (periodicity,) = modalities
694  return IMP.core.Cosine(force_constant, periodicity, phase)
695 
696 def _LinearGenerator(parameters, modalities):
697  (scale,) = parameters
698  return IMP.core.Linear(0, scale)
699 
700 def _SplineGenerator(parameters, modalities):
701  (open, low, high, delta, lowderiv, highderiv) = parameters[:6]
702  values = []
703  for v in parameters[6:]:
704  values.append(v)
705  if open < 0.0:
706  return IMP.core.ClosedCubicSpline(values, low, delta)
707  else:
708  return IMP.core.OpenCubicSpline(values, low, delta)
709 
710 #: Mapping from Modeller math form number to a unary function generator
711 _unary_func_generators = {
712  1: _HarmonicLowerBoundGenerator,
713  2: _HarmonicUpperBoundGenerator,
714  3: _HarmonicGenerator,
715  7: _CosineGenerator,
716  8: _LinearGenerator,
717  10: _SplineGenerator,
718 }
719 
720 # Generators to make IMP Restraint objects from Modeller features
721 def _DistanceRestraintGenerator(form, modalities, atoms, parameters):
722  unary_func_gen = _unary_func_generators[form]
723  return IMP.core.DistanceRestraint(atoms[0].get_model(),
724  unary_func_gen(parameters, modalities),
725  atoms[0], atoms[1])
726 
727 def _AngleRestraintGenerator(form, modalities, atoms, parameters):
728  unary_func_gen = _unary_func_generators[form]
729  return IMP.core.AngleRestraint(atoms[0].get_model(),
730  unary_func_gen(parameters, modalities),
731  atoms[0], atoms[1], atoms[2])
732 
733 def _MultiBinormalGenerator(form, modalities, atoms, parameters):
734  nterms = modalities[0]
735  if len(parameters) != nterms * 6:
736  raise ValueError("Incorrect number of parameters (%d) for multiple "
737  "binormal restraint - expecting %d (%d terms * 6)" \
738  % (len(parameters), nterms * 6, nterms))
739  r = IMP.core.MultipleBinormalRestraint(atoms[0].get_model(),
740  atoms[:4], atoms[4:8])
741  for i in range(nterms):
743  t.set_weight(parameters[i])
744  t.set_means((parameters[nterms + i * 2],
745  parameters[nterms + i * 2 + 1]))
746  t.set_standard_deviations((parameters[nterms * 3 + i * 2],
747  parameters[nterms * 3 + i * 2 + 1]))
748  t.set_correlation(parameters[nterms * 5 + i])
749  r.add_term(t)
750  return r
751 
752 def _DihedralRestraintGenerator(form, modalities, atoms, parameters):
753  if form == 9:
754  return _MultiBinormalGenerator(form, modalities, atoms, parameters)
755  unary_func_gen = _unary_func_generators[form]
756  return IMP.core.DihedralRestraint(atoms[0].get_model(),
757  unary_func_gen(parameters, modalities),
758  atoms[0], atoms[1], atoms[2], atoms[3])
759 
760 def _get_protein_atom_particles(protein):
761  """Given a protein particle, get the flattened list of all child atoms"""
762  atom_particles = []
763  for ichain in range(protein.get_number_of_children()):
764  chain = protein.get_child(ichain)
765  for ires in range(chain.get_number_of_children()):
766  residue = chain.get_child(ires)
767  for iatom in range(residue.get_number_of_children()):
768  atom = residue.get_child(iatom)
769  atom_particles.append(atom.get_particle())
770  return atom_particles
771 
772 def _load_restraints_line(line, atom_particles):
773  """Parse a single Modeller restraints file line and return the
774  corresponding IMP restraint."""
775  spl = line.split()
776  typ = spl.pop(0)
777  if typ == 'MODELLER5':
778  return
779  elif typ != 'R':
780  raise NotImplementedError("Only 'R' lines currently read from " + \
781  "Modeller restraints files")
782  form = int(spl.pop(0))
783  modalities = [int(spl.pop(0))]
784  features = [int(spl.pop(0))]
785 # Discard group
786  spl.pop(0)
787  natoms = [int(spl.pop(0))]
788  nparam = int(spl.pop(0))
789  nfeat = int(spl.pop(0))
790  for i in range(nfeat - 1):
791  modalities.append(int(spl.pop(0)))
792  features.append(int(spl.pop(0)))
793  natoms.append(int(spl.pop(0)))
794  atoms = [int(spl.pop(0)) for x in range(natoms[0])]
795  for i in range(len(atoms)):
796  atoms[i] = atom_particles[atoms[i] - 1]
797  parameters = [float(spl.pop(0)) for x in range(nparam)]
798  restraint_generators = {
799  1 : _DistanceRestraintGenerator,
800  2 : _AngleRestraintGenerator,
801  3 : _DihedralRestraintGenerator,
802  4 : _DihedralRestraintGenerator,
803  }
804  restraint_gen = restraint_generators[features[0]]
805  return restraint_gen(form, modalities, atoms, parameters)
806 
807 
808 def _load_entire_restraints_file(filename, protein):
809  """Yield a set of IMP restraints from a Modeller restraints file."""
810  atoms = _get_protein_atom_particles(protein)
811  with open(filename, 'r') as fh:
812  for line in fh:
813  try:
814  rsr = _load_restraints_line(line, atoms)
815  if rsr is not None:
816  yield rsr
817  except Exception as err:
818  print("Cannot read restraints file line:\n" + line)
819  raise
820 
821 
822 def _copy_residue(r, model):
823  """Copy residue information from modeller to imp"""
824 #print "residue "+str(r)
825  p=IMP.Particle(model)
827  r.index)
828  p.set_name(str("residue "+r.num));
829  return p
830 
831 
832 def _copy_atom(a, model):
833  """Copy atom information from modeller"""
834 #print "atom "+str(a)
835  p=IMP.Particle(model)
837  xyzd= IMP.core.XYZ.setup_particle(p, IMP.algebra.Vector3D(a.x, a.y, a.z))
838 # Alignment structures don't have charges or atom types; models do
839  if hasattr(a, 'charge'):
841  if hasattr(a, 'type'):
842  IMP.atom.CHARMMAtom.setup_particle(p, a.type.name)
843  ap.set_input_index(a.index)
844  return p
845 
846 def _copy_chain(c, model):
847  """Copy chain information from modeller"""
848 #print "atom "+str(a)
849  p=IMP.Particle(model)
850 #set the chain name
851  cp = IMP.atom.Chain.setup_particle(p,c.name)
852  return p
853 
854 def _get_forcefield(submodel):
855  if submodel == 3:
857  IMP.atom.get_data_path('top_heav.lib'),
858  IMP.atom.get_data_path('par.lib'))
859  else:
861  IMP.atom.get_data_path('top.lib'),
862  IMP.atom.get_data_path('par.lib'))
863  return ff
864 
865 def add_soft_sphere_radii(hierarchy, submodel, scale=1.0, filename=None):
866  """Add radii to the hierarchy using the Modeller radius library, radii.lib.
867  Each radius is scaled by the given scale (Modeller usually scales radii
868  by a factor of 0.82). submodel specifies the topology submodel, which is
869  the column in radii.lib to use."""
870  if filename is None:
871  filename = IMP.atom.get_data_path('radii.lib')
872  radii = {}
873  with open(filename) as fh:
874  for line in fh:
875  if line.startswith('#'): continue
876  spl = line.split()
877  if len(spl) > 11:
878  radii[spl[0]] = float(spl[submodel])
879  atoms = IMP.atom.get_by_type(hierarchy, IMP.atom.ATOM_TYPE)
880  for a in atoms:
881  p = a.get_particle()
882  ct = IMP.atom.CHARMMAtom(p).get_charmm_type()
883  if ct in radii:
884  radius = radii[ct] * scale
886  IMP.core.XYZR(p).set_radius(radius)
887  else:
889 
890 
891 class ModelLoader(object):
892  """Read a Modeller model into IMP. After creating this object, the atoms
893  in the Modeller model can be loaded into IMP using the load_atoms()
894  method, then optionally any Modeller static restraints can be read in
895  with load_static_restraints() or load_static_restraints_file().
896 
897  This class can also be used to read Modeller alignment structures;
898  however, only load_atoms() will be useful in such a case (since
899  alignment structures don't have restraints or other information).
900 
901  """
902 
903  def __init__(self, modeller_model):
904  """Constructor.
905  @param modeller_model The Modeller model or alignment structure
906  object to read.
907  """
908  self._modeller_model = modeller_model
909 
910  def load_atoms(self, model):
911  """Construct an IMP::atom::Hierarchy that contains the same atoms as
912  the Modeller model or alignment structure.
913 
914  IMP atoms created from a Modeller model will be given charges and
915  CHARMM types, extracted from the model. Alignment structures don't
916  contain this information, so the IMP atoms won't either.
917 
918  @param model The IMP::Model object in which the hierarchy will be
919  created. The highest level hierarchy node is a PROTEIN.
920  @return the newly-created root IMP::atom::Hierarchy.
921  """
922  pp = IMP.Particle(model)
924  self._atoms = {}
925  for chain in self._modeller_model.chains:
926  cp = IMP.Particle(model)
927  hcp = IMP.atom.Chain.setup_particle(cp, chain.name)
928 # We don't really know the type yet
929  hpp.add_child(hcp)
930  for residue in chain.residues:
931  rp = _copy_residue(residue, model)
932  hrp = IMP.atom.Hierarchy(rp)
933  hcp.add_child(hrp)
934  for atom in residue.atoms:
935  ap = _copy_atom(atom, model)
936  hap = IMP.atom.Hierarchy(ap)
937  hrp.add_child(hap)
938  self._atoms[atom.index] = ap
939  lastres = hrp
940  self._modeller_hierarchy = hpp
941  return hpp
942 
943  def _get_nonbonded_list(self, atoms, pair_filter, edat, distance):
944  nbl = IMP.container.ClosePairContainer(atoms, distance,
945  edat.update_dynamic)
946 
947 # Exclude the same sets of atoms as Modeller
948  if pair_filter is None:
949  pair_filter = IMP.atom.StereochemistryPairFilter()
950  if edat.excl_local[0]:
951  pair_filter.set_bonds(list(self.load_bonds()))
952  if edat.excl_local[1]:
953  pair_filter.set_angles(list(self.load_angles()))
954  if edat.excl_local[2]:
955  pair_filter.set_dihedrals(list(self.load_dihedrals()))
956  nbl.add_pair_filter(pair_filter)
957  return nbl
958 
959  def load_bonds(self):
960  """Load the Modeller bond topology into the IMP model. Each bond is
961  represented in IMP as an IMP::atom::Bond, with no defined length
962  or stiffness. These bonds are primarily useful as input to
963  IMP::atom::StereochemistryPairFilter, to exclude bond interactions
964  from the nonbonded list. Typically the contribution to the scoring
965  function from the bonds is included in the Modeller static restraints
966  (use load_static_restraints() or load_static_restraints_file() to
967  load these). If you want to regenerate the stereochemistry in IMP,
968  do not use these functions (as then stereochemistry scoring terms
969  and exclusions would be double-counted) and instead use the
970  IMP::atom::CHARMMTopology class.
971 
972  You must call load_atoms() prior to using this function.
973  @see load_angles(), load_dihedrals(), load_impropers()
974  @return A generator listing all of the bonds.
975  """
976  if not hasattr(self, '_modeller_hierarchy'):
977  raise ValueError("Call load_atoms() first.")
978  for (maa, mab) in self._modeller_model.bonds:
979  pa = self._atoms[maa.index]
980  pb = self._atoms[mab.index]
982  ba= IMP.atom.Bonded(pa)
983  else:
986  bb= IMP.atom.Bonded(pb)
987  else:
989  yield IMP.atom.create_bond(ba, bb,
990  IMP.atom.Bond.SINGLE).get_particle()
991 
992  def load_angles(self):
993  """Load the Modeller angle topology into the IMP model.
994  See load_bonds() for more details."""
995  return self._internal_load_angles(self._modeller_model.angles,
997 
998  def load_dihedrals(self):
999  """Load the Modeller dihedral topology into the IMP model.
1000  See load_bonds() for more details."""
1001  return self._internal_load_angles(self._modeller_model.dihedrals,
1003 
1004  def load_impropers(self):
1005  """Load the Modeller improper topology into the IMP model.
1006  See load_bonds() for more details."""
1007  return self._internal_load_angles(self._modeller_model.impropers,
1009 
1010  def _internal_load_angles(self, angles, angle_class):
1011  if not hasattr(self, '_modeller_hierarchy'):
1012  raise ValueError("Call load_atoms() first.")
1013  for modeller_atoms in angles:
1014  imp_particles = [self._atoms[x.index] for x in modeller_atoms]
1015  p = IMP.Particle(imp_particles[0].get_model())
1016  a = angle_class.setup_particle(p,
1017  *[IMP.core.XYZ(x) for x in imp_particles])
1018  yield a.get_particle()
1019 
1020  def load_static_restraints_file(self, filename):
1021  """Convert a Modeller static restraints file into equivalent
1022  IMP::Restraints. load_atoms() must have been called first to read
1023  in the atoms that the restraints will act upon.
1024  @param filename Name of the Modeller restraints file. The restraints
1025  in this file are assumed to act upon the model read in by
1026  load_atoms(); no checking is done to enforce this.
1027  @return A Python generator of the newly-created IMP::Restraint
1028  objects.
1029  """
1030  if not hasattr(self, '_modeller_hierarchy'):
1031  raise ValueError("Call load_atoms() first.")
1032  return _load_entire_restraints_file(filename, self._modeller_hierarchy)
1033 
1034 
1036  """Convert the current set of Modeller static restraints into equivalent
1037  IMP::Restraints. load_atoms() must have been called first to read
1038  in the atoms that the restraints will act upon.
1039  @return A Python generator of the newly-created IMP::Restraint
1040  objects.
1041  """
1042  class _RestraintGenerator(object):
1043  """Simple generator wrapper"""
1044  def __init__(self, gen):
1045  self._gen = gen
1046  def __iter__(self, *args, **keys):
1047  return self
1048  def close(self, *args, **keys):
1049  return self._gen.close(*args, **keys)
1050  def next(self):
1051  return next(self._gen)
1052  __next__ = next
1053  def send(self, *args, **keys):
1054  return self._gen.send(*args, **keys)
1055  def throw(self, *args, **keys):
1056  return self._gen.throw(*args, **keys)
1057 # Write current restraints into a temporary file
1058  t = _TempDir()
1059  rsrfile = os.path.join(t.tmpdir, 'restraints.rsr')
1060  self._modeller_model.restraints.write(file=rsrfile)
1061 # Read the file back in
1062  gen = self.load_static_restraints_file(rsrfile)
1063  wrap = _RestraintGenerator(gen)
1064 # Ensure that tmpdir remains until we're done with the generator
1065  wrap._tempdir = t
1066  return wrap
1067 
1068  def load_dynamic_restraints(self, pair_filter=None):
1069  """Convert Modeller dynamic restraints into IMP::Restraint objects.
1070 
1071  For each currently active Modeller dynamic restraint
1072  (e.g. soft-sphere, electrostatics) an equivalent IMP::Restraint
1073  is created.
1074  load_atoms() must have been called first to read
1075  in the atoms that the restraints will act upon.
1076 
1077  If pair_filter is given, it is an IMP::PairFilter object to exclude
1078  pairs from the nonbonded lists used by the dynamic restraints.
1079  Otherwise, an IMP::atom::StereochemistryPairFilter object is created
1080  to exclude Modeller bonds, angles and dihedrals, as specified by
1081  edat.excl_local. (Note that this calls load_bonds(), load_angles()
1082  and load_dihedrals(), so will create duplicate lists of bonds if
1083  those methods are called manually as well.)
1084 
1085  @note Currently only soft-sphere, electrostatic and Lennard-Jones
1086  restraints are loaded.
1087  @return A Python generator of the newly-created IMP::Restraint
1088  objects.
1089  """
1090  if not hasattr(self, '_modeller_hierarchy'):
1091  raise ValueError("Call load_atoms() first.")
1092  edat = self._modeller_model.env.edat
1093  libs = self._modeller_model.env.libs
1094  atoms = IMP.atom.get_leaves(self._modeller_hierarchy)
1095  m = atoms[0].get_model()
1097 
1098  if edat.dynamic_sphere:
1099 # Note: cannot use Modeller's cutoff distance, as that is
1100 # center-to-center; IMP's is sphere surface-surface
1101  nbl = self._get_nonbonded_list(atoms, pair_filter, edat, 0.)
1102 # No way to get Modeller radii, so we have to reassign them
1103  add_soft_sphere_radii(self._modeller_hierarchy,
1104  libs.topology.submodel, edat.radii_factor)
1105  k = \
1109  yield IMP.container.PairsRestraint(ps, nbl)
1110 
1111  if edat.dynamic_lennard or edat.dynamic_coulomb:
1112 # 3.0 is roughly the max. atom diameter
1113  d = max(edat.contact_shell - 3.0, 0.0)
1114  nbl = self._get_nonbonded_list(atoms, pair_filter, edat, d)
1115  ff = _get_forcefield(libs.topology.submodel)
1116  ff.add_radii(self._modeller_hierarchy)
1117 
1118  if edat.dynamic_lennard:
1119  ff.add_well_depths(self._modeller_hierarchy)
1120  sf = IMP.atom.ForceSwitch(edat.lennard_jones_switch[0],
1121  edat.lennard_jones_switch[1])
1123  yield IMP.container.PairsRestraint(ps, nbl)
1124 
1125  if edat.dynamic_coulomb:
1126  sf = IMP.atom.ForceSwitch(edat.coulomb_switch[0],
1127  edat.coulomb_switch[1])
1128  ps = IMP.atom.CoulombPairScore(sf)
1129  ps.set_relative_dielectric(edat.relative_dielectric)
1130  yield IMP.container.PairsRestraint(ps, nbl)
1131 
1132 
1133 
1134 def get_module_version():
1135  """get_module_version() -> std::string const"""
1136  return _IMP_modeller.get_module_version()
1137 
1138 def get_example_path(fname):
1139  """get_example_path(std::string fname) -> std::string"""
1140  return _IMP_modeller.get_example_path(fname)
1141 
1142 def get_data_path(fname):
1143  """get_data_path(std::string fname) -> std::string"""
1144  return _IMP_modeller.get_data_path(fname)
1145 
1146 from . import _version_check
1147 _version_check.check_version(get_module_version())
1148 __version__ = get_module_version()
1149 
1150 
1151 
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_module_version()
Return the version of this module, as a string.
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:160
A single binormal term in a MultipleBinormalRestraint.
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.
static bool get_is_setup(const IMP::ParticleAdaptor &p)
Definition: XYZR.h:47
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:63
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)
Get the indexes from a list of particle pairs.
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
Modeller-style multiple binormal (phi/psi) restraint.
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.
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:421
A filter that excludes bonds, angles and dihedrals.
Read a Modeller model into IMP.
Class to handle individual particles of a Model object.
Definition: Particle.h:41
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:81
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:54
Harmonic function (symmetric about the mean)
Definition: core/Harmonic.h:24
A decorator for a particle with x,y,z coordinates and a radius.
Definition: XYZR.h:27