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