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