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