IMP logo
IMP Reference Guide  develop.34c5cf4f65,2026/02/03
The Integrative Modeling Platform
example/__init__.py
1 # This file was automatically generated by SWIG (https://www.swig.org).
2 # Version 4.3.1
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-2026 IMP Inventors. All rights reserved.
10 
11 
12 
13 
14 from sys import version_info as _swig_python_version_info
15 import _IMP_example
16 
17 try:
18  import builtins as __builtin__
19 except ImportError:
20  import __builtin__
21 
22 def _swig_repr(self):
23  try:
24  strthis = "proxy of " + self.this.__repr__()
25  except __builtin__.Exception:
26  strthis = ""
27  return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
28 
29 
30 def _swig_setattr_nondynamic_instance_variable(set):
31  def set_instance_attr(self, name, value):
32  if name == "this":
33  set(self, name, value)
34  elif name == "thisown":
35  self.this.own(value)
36  elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
37  set(self, name, value)
38  else:
39  raise AttributeError("You cannot add instance attributes to %s" % self)
40  return set_instance_attr
41 
42 
43 def _swig_setattr_nondynamic_class_variable(set):
44  def set_class_attr(cls, name, value):
45  if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
46  set(cls, name, value)
47  else:
48  raise AttributeError("You cannot add class attributes to %s" % cls)
49  return set_class_attr
50 
51 
52 def _swig_add_metaclass(metaclass):
53  """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
54  def wrapper(cls):
55  return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
56  return wrapper
57 
58 
59 class _SwigNonDynamicMeta(type):
60  """Meta class to enforce nondynamic attributes (no new attributes) for a class"""
61  __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
62 
63 
64 import weakref
65 
66 class IMP_EXAMPLE_SwigPyIterator(object):
67  r"""Proxy of C++ swig::IMP_EXAMPLE_SwigPyIterator class."""
68 
69  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
70 
71  def __init__(self, *args, **kwargs):
72  raise AttributeError("No constructor defined - class is abstract")
73  __repr__ = _swig_repr
74  __swig_destroy__ = _IMP_example.delete_IMP_EXAMPLE_SwigPyIterator
75 
76  def value(self):
77  r"""value(IMP_EXAMPLE_SwigPyIterator self) -> PyObject *"""
78  return _IMP_example.IMP_EXAMPLE_SwigPyIterator_value(self)
79 
80  def incr(self, n=1):
81  r"""incr(IMP_EXAMPLE_SwigPyIterator self, size_t n=1) -> IMP_EXAMPLE_SwigPyIterator"""
82  return _IMP_example.IMP_EXAMPLE_SwigPyIterator_incr(self, n)
83 
84  def decr(self, n=1):
85  r"""decr(IMP_EXAMPLE_SwigPyIterator self, size_t n=1) -> IMP_EXAMPLE_SwigPyIterator"""
86  return _IMP_example.IMP_EXAMPLE_SwigPyIterator_decr(self, n)
87 
88  def distance(self, x):
89  r"""distance(IMP_EXAMPLE_SwigPyIterator self, IMP_EXAMPLE_SwigPyIterator x) -> ptrdiff_t"""
90  return _IMP_example.IMP_EXAMPLE_SwigPyIterator_distance(self, x)
91 
92  def equal(self, x):
93  r"""equal(IMP_EXAMPLE_SwigPyIterator self, IMP_EXAMPLE_SwigPyIterator x) -> bool"""
94  return _IMP_example.IMP_EXAMPLE_SwigPyIterator_equal(self, x)
95 
96  def copy(self):
97  r"""copy(IMP_EXAMPLE_SwigPyIterator self) -> IMP_EXAMPLE_SwigPyIterator"""
98  return _IMP_example.IMP_EXAMPLE_SwigPyIterator_copy(self)
99 
100  def next(self):
101  r"""next(IMP_EXAMPLE_SwigPyIterator self) -> PyObject *"""
102  return _IMP_example.IMP_EXAMPLE_SwigPyIterator_next(self)
103 
104  def __next__(self):
105  r"""__next__(IMP_EXAMPLE_SwigPyIterator self) -> PyObject *"""
106  return _IMP_example.IMP_EXAMPLE_SwigPyIterator___next__(self)
107 
108  def previous(self):
109  r"""previous(IMP_EXAMPLE_SwigPyIterator self) -> PyObject *"""
110  return _IMP_example.IMP_EXAMPLE_SwigPyIterator_previous(self)
111 
112  def advance(self, n):
113  r"""advance(IMP_EXAMPLE_SwigPyIterator self, ptrdiff_t n) -> IMP_EXAMPLE_SwigPyIterator"""
114  return _IMP_example.IMP_EXAMPLE_SwigPyIterator_advance(self, n)
115 
116  def __eq__(self, x):
117  r"""__eq__(IMP_EXAMPLE_SwigPyIterator self, IMP_EXAMPLE_SwigPyIterator x) -> bool"""
118  return _IMP_example.IMP_EXAMPLE_SwigPyIterator___eq__(self, x)
119 
120  def __ne__(self, x):
121  r"""__ne__(IMP_EXAMPLE_SwigPyIterator self, IMP_EXAMPLE_SwigPyIterator x) -> bool"""
122  return _IMP_example.IMP_EXAMPLE_SwigPyIterator___ne__(self, x)
123 
124  def __iadd__(self, n):
125  r"""__iadd__(IMP_EXAMPLE_SwigPyIterator self, ptrdiff_t n) -> IMP_EXAMPLE_SwigPyIterator"""
126  return _IMP_example.IMP_EXAMPLE_SwigPyIterator___iadd__(self, n)
127 
128  def __isub__(self, n):
129  r"""__isub__(IMP_EXAMPLE_SwigPyIterator self, ptrdiff_t n) -> IMP_EXAMPLE_SwigPyIterator"""
130  return _IMP_example.IMP_EXAMPLE_SwigPyIterator___isub__(self, n)
131 
132  def __add__(self, n):
133  r"""__add__(IMP_EXAMPLE_SwigPyIterator self, ptrdiff_t n) -> IMP_EXAMPLE_SwigPyIterator"""
134  return _IMP_example.IMP_EXAMPLE_SwigPyIterator___add__(self, n)
135 
136  def __sub__(self, *args):
137  r"""
138  __sub__(IMP_EXAMPLE_SwigPyIterator self, ptrdiff_t n) -> IMP_EXAMPLE_SwigPyIterator
139  __sub__(IMP_EXAMPLE_SwigPyIterator self, IMP_EXAMPLE_SwigPyIterator x) -> ptrdiff_t
140  """
141  return _IMP_example.IMP_EXAMPLE_SwigPyIterator___sub__(self, *args)
142  def __iter__(self):
143  return self
144 
145 # Register IMP_EXAMPLE_SwigPyIterator in _IMP_example:
146 _IMP_example.IMP_EXAMPLE_SwigPyIterator_swigregister(IMP_EXAMPLE_SwigPyIterator)
147 
148 _value_types=[]
149 _object_types=[]
150 _raii_types=[]
151 _plural_types=[]
152 
153 IMP_DEBUG = _IMP_example.IMP_DEBUG
154 
155 IMP_RELEASE = _IMP_example.IMP_RELEASE
156 
157 IMP_SILENT = _IMP_example.IMP_SILENT
158 
159 IMP_PROGRESS = _IMP_example.IMP_PROGRESS
160 
161 IMP_TERSE = _IMP_example.IMP_TERSE
162 
163 IMP_VERBOSE = _IMP_example.IMP_VERBOSE
164 
165 IMP_MEMORY = _IMP_example.IMP_MEMORY
166 
167 IMP_NONE = _IMP_example.IMP_NONE
168 
169 IMP_USAGE = _IMP_example.IMP_USAGE
170 
171 IMP_INTERNAL = _IMP_example.IMP_INTERNAL
172 
173 IMP_KERNEL_HAS_LOG4CXX = _IMP_example.IMP_KERNEL_HAS_LOG4CXX
174 
175 IMP_COMPILER_HAS_CEREAL_RAW_POINTER = _IMP_example.IMP_COMPILER_HAS_CEREAL_RAW_POINTER
176 
177 IMP_COMPILER_HAS_DEBUG_VECTOR = _IMP_example.IMP_COMPILER_HAS_DEBUG_VECTOR
178 
179 IMP_COMPILER_HAS_RANDOM_SHUFFLE = _IMP_example.IMP_COMPILER_HAS_RANDOM_SHUFFLE
180 
181 IMP_COMPILER_HAS_THREE_WAY = _IMP_example.IMP_COMPILER_HAS_THREE_WAY
182 
183 IMP_KERNEL_HAS_BOOST_RANDOM = _IMP_example.IMP_KERNEL_HAS_BOOST_RANDOM
184 
185 IMP_KERNEL_HAS_NUMPY = _IMP_example.IMP_KERNEL_HAS_NUMPY
186 
187 IMP_KERNEL_HAS_BOOST_SYSTEM = _IMP_example.IMP_KERNEL_HAS_BOOST_SYSTEM
188 
189 IMP_KERNEL_HAS_GPERFTOOLS = _IMP_example.IMP_KERNEL_HAS_GPERFTOOLS
190 
191 IMP_KERNEL_HAS_TCMALLOC_HEAPCHECKER = _IMP_example.IMP_KERNEL_HAS_TCMALLOC_HEAPCHECKER
192 
193 IMP_KERNEL_HAS_TCMALLOC_HEAPPROFILER = _IMP_example.IMP_KERNEL_HAS_TCMALLOC_HEAPPROFILER
194 
195 IMPKERNEL_SHOW_WARNINGS = _IMP_example.IMPKERNEL_SHOW_WARNINGS
196 
197 
198 import sys
199 class _DirectorObjects:
200  """@internal Simple class to keep references to director objects
201  to prevent premature deletion."""
202  def __init__(self):
203  self._objects = []
204  def register(self, obj):
205  """Take a reference to a director object; will only work for
206  refcounted C++ classes"""
207  if hasattr(obj, 'get_ref_count'):
208  self._objects.append(obj)
209  def cleanup(self):
210  """Only drop our reference and allow cleanup by Python if no other
211  Python references exist (we hold 3 references: one in self._objects,
212  one in x, and one in the argument list for getrefcount) *and* no
213  other C++ references exist (the Python object always holds one)"""
214  objs = [x for x in self._objects if sys.getrefcount(x) > 3 \
215  or x.get_ref_count() > 1]
216 # Do in two steps so the references are kept until the end of the
217 # function (deleting references may trigger a fresh call to this method)
218  self._objects = objs
219  def get_object_count(self):
220  """Get number of director objects (useful for testing only)"""
221  return len(self._objects)
222 _director_objects = _DirectorObjects()
223 
224 class _ostream(object):
225  r"""Proxy of C++ std::ostream class."""
226 
227  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
228 
229  def __init__(self, *args, **kwargs):
230  raise AttributeError("No constructor defined")
231  __repr__ = _swig_repr
232 
233  def write(self, osa_buf):
234  r"""write(_ostream self, char const * osa_buf)"""
235  return _IMP_example._ostream_write(self, osa_buf)
236 
237 # Register _ostream in _IMP_example:
238 _IMP_example._ostream_swigregister(_ostream)
239 IMP_C_OPEN_BINARY = _IMP_example.IMP_C_OPEN_BINARY
240 
241 import IMP
242 IMP_CGAL_HAS_BOOST_FILESYSTEM = _IMP_example.IMP_CGAL_HAS_BOOST_FILESYSTEM
243 
244 IMP_CGAL_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_CGAL_HAS_BOOST_PROGRAMOPTIONS
245 
246 IMP_CGAL_HAS_BOOST_RANDOM = _IMP_example.IMP_CGAL_HAS_BOOST_RANDOM
247 
248 IMP_CGAL_HAS_NUMPY = _IMP_example.IMP_CGAL_HAS_NUMPY
249 
250 IMPCGAL_SHOW_WARNINGS = _IMP_example.IMPCGAL_SHOW_WARNINGS
251 
252 import IMP.cgal
253 IMP_ALGEBRA_HAS_IMP_CGAL = _IMP_example.IMP_ALGEBRA_HAS_IMP_CGAL
254 
255 IMP_ALGEBRA_HAS_BOOST_FILESYSTEM = _IMP_example.IMP_ALGEBRA_HAS_BOOST_FILESYSTEM
256 
257 IMP_ALGEBRA_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_ALGEBRA_HAS_BOOST_PROGRAMOPTIONS
258 
259 IMP_ALGEBRA_HAS_BOOST_RANDOM = _IMP_example.IMP_ALGEBRA_HAS_BOOST_RANDOM
260 
261 IMP_ALGEBRA_HAS_CGAL = _IMP_example.IMP_ALGEBRA_HAS_CGAL
262 
263 IMP_ALGEBRA_HAS_NUMPY = _IMP_example.IMP_ALGEBRA_HAS_NUMPY
264 
265 IMP_ALGEBRA_HAS_ANN = _IMP_example.IMP_ALGEBRA_HAS_ANN
266 
267 IMPALGEBRA_SHOW_WARNINGS = _IMP_example.IMPALGEBRA_SHOW_WARNINGS
268 
269 import IMP.algebra
270 IMP_DISPLAY_HAS_IMP_CGAL = _IMP_example.IMP_DISPLAY_HAS_IMP_CGAL
271 
272 IMP_DISPLAY_HAS_BOOST_FILESYSTEM = _IMP_example.IMP_DISPLAY_HAS_BOOST_FILESYSTEM
273 
274 IMP_DISPLAY_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_DISPLAY_HAS_BOOST_PROGRAMOPTIONS
275 
276 IMP_DISPLAY_HAS_BOOST_RANDOM = _IMP_example.IMP_DISPLAY_HAS_BOOST_RANDOM
277 
278 IMP_DISPLAY_HAS_CGAL = _IMP_example.IMP_DISPLAY_HAS_CGAL
279 
280 IMP_DISPLAY_HAS_NUMPY = _IMP_example.IMP_DISPLAY_HAS_NUMPY
281 
282 IMPDISPLAY_SHOW_WARNINGS = _IMP_example.IMPDISPLAY_SHOW_WARNINGS
283 
284 import IMP.display
285 IMP_SCORE_FUNCTOR_HAS_IMP_CGAL = _IMP_example.IMP_SCORE_FUNCTOR_HAS_IMP_CGAL
286 
287 IMP_SCORE_FUNCTOR_HAS_BOOST_FILESYSTEM = _IMP_example.IMP_SCORE_FUNCTOR_HAS_BOOST_FILESYSTEM
288 
289 IMP_SCORE_FUNCTOR_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_SCORE_FUNCTOR_HAS_BOOST_PROGRAMOPTIONS
290 
291 IMP_SCORE_FUNCTOR_HAS_BOOST_RANDOM = _IMP_example.IMP_SCORE_FUNCTOR_HAS_BOOST_RANDOM
292 
293 IMP_SCORE_FUNCTOR_HAS_CGAL = _IMP_example.IMP_SCORE_FUNCTOR_HAS_CGAL
294 
295 IMP_SCORE_FUNCTOR_HAS_HDF5 = _IMP_example.IMP_SCORE_FUNCTOR_HAS_HDF5
296 
297 IMP_SCORE_FUNCTOR_HAS_NUMPY = _IMP_example.IMP_SCORE_FUNCTOR_HAS_NUMPY
298 
299 IMPSCOREFUNCTOR_SHOW_WARNINGS = _IMP_example.IMPSCOREFUNCTOR_SHOW_WARNINGS
300 
301 import IMP.score_functor
302 IMP_STATISTICS_HAS_IMP_CGAL = _IMP_example.IMP_STATISTICS_HAS_IMP_CGAL
303 
304 IMP_STATISTICS_HAS_BOOST_FILESYSTEM = _IMP_example.IMP_STATISTICS_HAS_BOOST_FILESYSTEM
305 
306 IMP_STATISTICS_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_STATISTICS_HAS_BOOST_PROGRAMOPTIONS
307 
308 IMP_STATISTICS_HAS_BOOST_RANDOM = _IMP_example.IMP_STATISTICS_HAS_BOOST_RANDOM
309 
310 IMP_STATISTICS_HAS_CGAL = _IMP_example.IMP_STATISTICS_HAS_CGAL
311 
312 IMP_STATISTICS_HAS_NUMPY = _IMP_example.IMP_STATISTICS_HAS_NUMPY
313 
314 IMPSTATISTICS_SHOW_WARNINGS = _IMP_example.IMPSTATISTICS_SHOW_WARNINGS
315 
316 import IMP.statistics
317 IMP_CORE_HAS_IMP_CGAL = _IMP_example.IMP_CORE_HAS_IMP_CGAL
318 
319 IMP_CORE_HAS_IMP_KERNEL = _IMP_example.IMP_CORE_HAS_IMP_KERNEL
320 
321 IMP_CORE_HAS_BOOST_FILESYSTEM = _IMP_example.IMP_CORE_HAS_BOOST_FILESYSTEM
322 
323 IMP_CORE_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_CORE_HAS_BOOST_PROGRAMOPTIONS
324 
325 IMP_CORE_HAS_BOOST_RANDOM = _IMP_example.IMP_CORE_HAS_BOOST_RANDOM
326 
327 IMP_CORE_HAS_CGAL = _IMP_example.IMP_CORE_HAS_CGAL
328 
329 IMP_CORE_HAS_HDF5 = _IMP_example.IMP_CORE_HAS_HDF5
330 
331 IMP_CORE_HAS_NUMPY = _IMP_example.IMP_CORE_HAS_NUMPY
332 
333 IMPCORE_SHOW_WARNINGS = _IMP_example.IMPCORE_SHOW_WARNINGS
334 
335 import IMP.core
336 IMP_CONTAINER_HAS_IMP_ALGEBRA = _IMP_example.IMP_CONTAINER_HAS_IMP_ALGEBRA
337 
338 IMP_CONTAINER_HAS_IMP_CGAL = _IMP_example.IMP_CONTAINER_HAS_IMP_CGAL
339 
340 IMP_CONTAINER_HAS_IMP_DISPLAY = _IMP_example.IMP_CONTAINER_HAS_IMP_DISPLAY
341 
342 IMP_CONTAINER_HAS_IMP_KERNEL = _IMP_example.IMP_CONTAINER_HAS_IMP_KERNEL
343 
344 IMP_CONTAINER_HAS_IMP_SCORE_FUNCTOR = _IMP_example.IMP_CONTAINER_HAS_IMP_SCORE_FUNCTOR
345 
346 IMP_CONTAINER_HAS_BOOST_FILESYSTEM = _IMP_example.IMP_CONTAINER_HAS_BOOST_FILESYSTEM
347 
348 IMP_CONTAINER_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_CONTAINER_HAS_BOOST_PROGRAMOPTIONS
349 
350 IMP_CONTAINER_HAS_BOOST_RANDOM = _IMP_example.IMP_CONTAINER_HAS_BOOST_RANDOM
351 
352 IMP_CONTAINER_HAS_CGAL = _IMP_example.IMP_CONTAINER_HAS_CGAL
353 
354 IMP_CONTAINER_HAS_HDF5 = _IMP_example.IMP_CONTAINER_HAS_HDF5
355 
356 IMP_CONTAINER_HAS_NUMPY = _IMP_example.IMP_CONTAINER_HAS_NUMPY
357 
358 IMP_CONTAINER_HAS_PYTHON_IHM = _IMP_example.IMP_CONTAINER_HAS_PYTHON_IHM
359 
360 IMP_CONTAINER_HAS_GOOGLE_DENSE_HASH_MAP = _IMP_example.IMP_CONTAINER_HAS_GOOGLE_DENSE_HASH_MAP
361 
362 IMP_CONTAINER_HAS_ROBIN_MAP = _IMP_example.IMP_CONTAINER_HAS_ROBIN_MAP
363 
364 IMPCONTAINER_SHOW_WARNINGS = _IMP_example.IMPCONTAINER_SHOW_WARNINGS
365 
366 import IMP.container
367 IMP_ATOM_HAS_IMP_CGAL = _IMP_example.IMP_ATOM_HAS_IMP_CGAL
368 
369 IMP_ATOM_HAS_IMP_KERNEL = _IMP_example.IMP_ATOM_HAS_IMP_KERNEL
370 
371 IMP_ATOM_HAS_IMP_SCORE_FUNCTOR = _IMP_example.IMP_ATOM_HAS_IMP_SCORE_FUNCTOR
372 
373 IMP_ATOM_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_ATOM_HAS_BOOST_PROGRAMOPTIONS
374 
375 IMP_ATOM_HAS_BOOST_RANDOM = _IMP_example.IMP_ATOM_HAS_BOOST_RANDOM
376 
377 IMP_ATOM_HAS_BOOST_REGEX = _IMP_example.IMP_ATOM_HAS_BOOST_REGEX
378 
379 IMP_ATOM_HAS_CGAL = _IMP_example.IMP_ATOM_HAS_CGAL
380 
381 IMP_ATOM_HAS_HDF5 = _IMP_example.IMP_ATOM_HAS_HDF5
382 
383 IMP_ATOM_HAS_NUMPY = _IMP_example.IMP_ATOM_HAS_NUMPY
384 
385 IMP_ATOM_HAS_PYTHON_IHM = _IMP_example.IMP_ATOM_HAS_PYTHON_IHM
386 
387 IMPATOM_SHOW_WARNINGS = _IMP_example.IMPATOM_SHOW_WARNINGS
388 
389 IMP_ATOM_TYPE_INDEX = _IMP_example.IMP_ATOM_TYPE_INDEX
390 
391 IMP_RESIDUE_TYPE_INDEX = _IMP_example.IMP_RESIDUE_TYPE_INDEX
392 
393 IMP_HIERARCHY_TYPE_INDEX = _IMP_example.IMP_HIERARCHY_TYPE_INDEX
394 
395 IMP_CHAIN_TYPE_INDEX = _IMP_example.IMP_CHAIN_TYPE_INDEX
396 
397 import IMP.atom
398 IMP_EM_HAS_IMP_CGAL = _IMP_example.IMP_EM_HAS_IMP_CGAL
399 
400 IMP_EM_HAS_IMP_CONTAINER = _IMP_example.IMP_EM_HAS_IMP_CONTAINER
401 
402 IMP_EM_HAS_IMP_DISPLAY = _IMP_example.IMP_EM_HAS_IMP_DISPLAY
403 
404 IMP_EM_HAS_IMP_SCORE_FUNCTOR = _IMP_example.IMP_EM_HAS_IMP_SCORE_FUNCTOR
405 
406 IMP_EM_HAS_BOOST_FILESYSTEM = _IMP_example.IMP_EM_HAS_BOOST_FILESYSTEM
407 
408 IMP_EM_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_EM_HAS_BOOST_PROGRAMOPTIONS
409 
410 IMP_EM_HAS_BOOST_RANDOM = _IMP_example.IMP_EM_HAS_BOOST_RANDOM
411 
412 IMP_EM_HAS_BOOST_REGEX = _IMP_example.IMP_EM_HAS_BOOST_REGEX
413 
414 IMP_EM_HAS_CGAL = _IMP_example.IMP_EM_HAS_CGAL
415 
416 IMP_EM_HAS_HDF5 = _IMP_example.IMP_EM_HAS_HDF5
417 
418 IMP_EM_HAS_NUMPY = _IMP_example.IMP_EM_HAS_NUMPY
419 
420 IMP_EM_HAS_PYTHON_IHM = _IMP_example.IMP_EM_HAS_PYTHON_IHM
421 
422 IMPEM_SHOW_WARNINGS = _IMP_example.IMPEM_SHOW_WARNINGS
423 
424 import IMP.em
425 IMP_SAXS_HAS_IMP_CGAL = _IMP_example.IMP_SAXS_HAS_IMP_CGAL
426 
427 IMP_SAXS_HAS_IMP_CONTAINER = _IMP_example.IMP_SAXS_HAS_IMP_CONTAINER
428 
429 IMP_SAXS_HAS_IMP_DISPLAY = _IMP_example.IMP_SAXS_HAS_IMP_DISPLAY
430 
431 IMP_SAXS_HAS_IMP_KERNEL = _IMP_example.IMP_SAXS_HAS_IMP_KERNEL
432 
433 IMP_SAXS_HAS_IMP_SCORE_FUNCTOR = _IMP_example.IMP_SAXS_HAS_IMP_SCORE_FUNCTOR
434 
435 IMP_SAXS_HAS_BOOST_FILESYSTEM = _IMP_example.IMP_SAXS_HAS_BOOST_FILESYSTEM
436 
437 IMP_SAXS_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_SAXS_HAS_BOOST_PROGRAMOPTIONS
438 
439 IMP_SAXS_HAS_BOOST_RANDOM = _IMP_example.IMP_SAXS_HAS_BOOST_RANDOM
440 
441 IMP_SAXS_HAS_BOOST_REGEX = _IMP_example.IMP_SAXS_HAS_BOOST_REGEX
442 
443 IMP_SAXS_HAS_CGAL = _IMP_example.IMP_SAXS_HAS_CGAL
444 
445 IMP_SAXS_HAS_HDF5 = _IMP_example.IMP_SAXS_HAS_HDF5
446 
447 IMP_SAXS_HAS_NUMPY = _IMP_example.IMP_SAXS_HAS_NUMPY
448 
449 IMP_SAXS_HAS_PYTHON_IHM = _IMP_example.IMP_SAXS_HAS_PYTHON_IHM
450 
451 IMPSAXS_SHOW_WARNINGS = _IMP_example.IMPSAXS_SHOW_WARNINGS
452 
453 import IMP.saxs
454 IMP_ISD_HAS_IMP_CGAL = _IMP_example.IMP_ISD_HAS_IMP_CGAL
455 
456 IMP_ISD_HAS_IMP_DISPLAY = _IMP_example.IMP_ISD_HAS_IMP_DISPLAY
457 
458 IMP_ISD_HAS_IMP_SCORE_FUNCTOR = _IMP_example.IMP_ISD_HAS_IMP_SCORE_FUNCTOR
459 
460 IMP_ISD_HAS_BOOST_FILESYSTEM = _IMP_example.IMP_ISD_HAS_BOOST_FILESYSTEM
461 
462 IMP_ISD_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_ISD_HAS_BOOST_PROGRAMOPTIONS
463 
464 IMP_ISD_HAS_BOOST_RANDOM = _IMP_example.IMP_ISD_HAS_BOOST_RANDOM
465 
466 IMP_ISD_HAS_BOOST_REGEX = _IMP_example.IMP_ISD_HAS_BOOST_REGEX
467 
468 IMP_ISD_HAS_CGAL = _IMP_example.IMP_ISD_HAS_CGAL
469 
470 IMP_ISD_HAS_HDF5 = _IMP_example.IMP_ISD_HAS_HDF5
471 
472 IMP_ISD_HAS_NUMPY = _IMP_example.IMP_ISD_HAS_NUMPY
473 
474 IMP_ISD_HAS_PYTHON_IHM = _IMP_example.IMP_ISD_HAS_PYTHON_IHM
475 
476 IMPISD_SHOW_WARNINGS = _IMP_example.IMPISD_SHOW_WARNINGS
477 
478 import IMP.isd
479 IMP_RMF_HAS_IMP_CGAL = _IMP_example.IMP_RMF_HAS_IMP_CGAL
480 
481 IMP_RMF_HAS_IMP_EM = _IMP_example.IMP_RMF_HAS_IMP_EM
482 
483 IMP_RMF_HAS_IMP_SAXS = _IMP_example.IMP_RMF_HAS_IMP_SAXS
484 
485 IMP_RMF_HAS_IMP_SCORE_FUNCTOR = _IMP_example.IMP_RMF_HAS_IMP_SCORE_FUNCTOR
486 
487 IMP_RMF_HAS_IMP_STATISTICS = _IMP_example.IMP_RMF_HAS_IMP_STATISTICS
488 
489 IMP_RMF_HAS_BOOST_FILESYSTEM = _IMP_example.IMP_RMF_HAS_BOOST_FILESYSTEM
490 
491 IMP_RMF_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_RMF_HAS_BOOST_PROGRAMOPTIONS
492 
493 IMP_RMF_HAS_BOOST_RANDOM = _IMP_example.IMP_RMF_HAS_BOOST_RANDOM
494 
495 IMP_RMF_HAS_BOOST_REGEX = _IMP_example.IMP_RMF_HAS_BOOST_REGEX
496 
497 IMP_RMF_HAS_CGAL = _IMP_example.IMP_RMF_HAS_CGAL
498 
499 IMP_RMF_HAS_HDF5 = _IMP_example.IMP_RMF_HAS_HDF5
500 
501 IMP_RMF_HAS_NUMPY = _IMP_example.IMP_RMF_HAS_NUMPY
502 
503 IMP_RMF_HAS_PYTHON_IHM = _IMP_example.IMP_RMF_HAS_PYTHON_IHM
504 
505 IMPRMF_SHOW_WARNINGS = _IMP_example.IMPRMF_SHOW_WARNINGS
506 
507 import IMP.rmf
508 import RMF
509 IMP_DOMINO_HAS_IMP_ATOM = _IMP_example.IMP_DOMINO_HAS_IMP_ATOM
510 
511 IMP_DOMINO_HAS_IMP_CGAL = _IMP_example.IMP_DOMINO_HAS_IMP_CGAL
512 
513 IMP_DOMINO_HAS_IMP_EM = _IMP_example.IMP_DOMINO_HAS_IMP_EM
514 
515 IMP_DOMINO_HAS_IMP_ISD = _IMP_example.IMP_DOMINO_HAS_IMP_ISD
516 
517 IMP_DOMINO_HAS_IMP_KERNEL = _IMP_example.IMP_DOMINO_HAS_IMP_KERNEL
518 
519 IMP_DOMINO_HAS_IMP_RMF = _IMP_example.IMP_DOMINO_HAS_IMP_RMF
520 
521 IMP_DOMINO_HAS_IMP_SAXS = _IMP_example.IMP_DOMINO_HAS_IMP_SAXS
522 
523 IMP_DOMINO_HAS_IMP_SCORE_FUNCTOR = _IMP_example.IMP_DOMINO_HAS_IMP_SCORE_FUNCTOR
524 
525 IMP_DOMINO_HAS_BOOST_FILESYSTEM = _IMP_example.IMP_DOMINO_HAS_BOOST_FILESYSTEM
526 
527 IMP_DOMINO_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_DOMINO_HAS_BOOST_PROGRAMOPTIONS
528 
529 IMP_DOMINO_HAS_BOOST_RANDOM = _IMP_example.IMP_DOMINO_HAS_BOOST_RANDOM
530 
531 IMP_DOMINO_HAS_BOOST_REGEX = _IMP_example.IMP_DOMINO_HAS_BOOST_REGEX
532 
533 IMP_DOMINO_HAS_CGAL = _IMP_example.IMP_DOMINO_HAS_CGAL
534 
535 IMP_DOMINO_HAS_HDF5 = _IMP_example.IMP_DOMINO_HAS_HDF5
536 
537 IMP_DOMINO_HAS_NUMPY = _IMP_example.IMP_DOMINO_HAS_NUMPY
538 
539 IMP_DOMINO_HAS_RMF = _IMP_example.IMP_DOMINO_HAS_RMF
540 
541 IMP_DOMINO_HAS_PYTHON_IHM = _IMP_example.IMP_DOMINO_HAS_PYTHON_IHM
542 
543 IMPDOMINO_SHOW_WARNINGS = _IMP_example.IMPDOMINO_SHOW_WARNINGS
544 
545 import RMF_HDF5
546 import IMP.domino
547 IMP_EXAMPLE_HAS_IMP_ALGEBRA = _IMP_example.IMP_EXAMPLE_HAS_IMP_ALGEBRA
548 
549 IMP_EXAMPLE_HAS_IMP_CGAL = _IMP_example.IMP_EXAMPLE_HAS_IMP_CGAL
550 
551 IMP_EXAMPLE_HAS_IMP_DISPLAY = _IMP_example.IMP_EXAMPLE_HAS_IMP_DISPLAY
552 
553 IMP_EXAMPLE_HAS_IMP_EM = _IMP_example.IMP_EXAMPLE_HAS_IMP_EM
554 
555 IMP_EXAMPLE_HAS_IMP_ISD = _IMP_example.IMP_EXAMPLE_HAS_IMP_ISD
556 
557 IMP_EXAMPLE_HAS_IMP_KERNEL = _IMP_example.IMP_EXAMPLE_HAS_IMP_KERNEL
558 
559 IMP_EXAMPLE_HAS_IMP_RMF = _IMP_example.IMP_EXAMPLE_HAS_IMP_RMF
560 
561 IMP_EXAMPLE_HAS_IMP_SAXS = _IMP_example.IMP_EXAMPLE_HAS_IMP_SAXS
562 
563 IMP_EXAMPLE_HAS_IMP_SCORE_FUNCTOR = _IMP_example.IMP_EXAMPLE_HAS_IMP_SCORE_FUNCTOR
564 
565 IMP_EXAMPLE_HAS_IMP_STATISTICS = _IMP_example.IMP_EXAMPLE_HAS_IMP_STATISTICS
566 
567 IMP_EXAMPLE_HAS_BOOST_FILESYSTEM = _IMP_example.IMP_EXAMPLE_HAS_BOOST_FILESYSTEM
568 
569 IMP_EXAMPLE_HAS_BOOST_GRAPH = _IMP_example.IMP_EXAMPLE_HAS_BOOST_GRAPH
570 
571 IMP_EXAMPLE_HAS_BOOST_PROGRAMOPTIONS = _IMP_example.IMP_EXAMPLE_HAS_BOOST_PROGRAMOPTIONS
572 
573 IMP_EXAMPLE_HAS_BOOST_RANDOM = _IMP_example.IMP_EXAMPLE_HAS_BOOST_RANDOM
574 
575 IMP_EXAMPLE_HAS_BOOST_REGEX = _IMP_example.IMP_EXAMPLE_HAS_BOOST_REGEX
576 
577 IMP_EXAMPLE_HAS_CGAL = _IMP_example.IMP_EXAMPLE_HAS_CGAL
578 
579 IMP_EXAMPLE_HAS_HDF5 = _IMP_example.IMP_EXAMPLE_HAS_HDF5
580 
581 IMP_EXAMPLE_HAS_NUMPY = _IMP_example.IMP_EXAMPLE_HAS_NUMPY
582 
583 IMP_EXAMPLE_HAS_RMF = _IMP_example.IMP_EXAMPLE_HAS_RMF
584 
585 IMP_EXAMPLE_HAS_PYTHON_IHM = _IMP_example.IMP_EXAMPLE_HAS_PYTHON_IHM
586 
587 IMP_EXAMPLE_HAS_EXAMPLEDEPENDENCY = _IMP_example.IMP_EXAMPLE_HAS_EXAMPLEDEPENDENCY
588 
589 IMPEXAMPLE_SHOW_WARNINGS = _IMP_example.IMPEXAMPLE_SHOW_WARNINGS
590 
591 
592 _object_types.append("ExampleRestraint")
593 
594 
595 def _object_cast_to_ExampleRestraint(o):
596  r"""_object_cast_to_ExampleRestraint(Object o) -> ExampleRestraint"""
597  return _IMP_example._object_cast_to_ExampleRestraint(o)
598 
599 def ExampleDecorators(l=[]):
600  return [ExampleDecorator(x) for x in l]
601 _plural_types.append("ExampleDecorators")
602 
603 
604 _value_types.append("ExampleDecorator")
605 
606 
607 _object_types.append("ExampleUnaryFunction")
608 
609 
610 def _object_cast_to_ExampleUnaryFunction(o):
611  r"""_object_cast_to_ExampleUnaryFunction(Object o) -> ExampleUnaryFunction"""
612  return _IMP_example._object_cast_to_ExampleUnaryFunction(o)
613 
614 _object_types.append("ExampleSingletonModifier")
615 
616 
617 def _object_cast_to_ExampleSingletonModifier(o):
618  r"""_object_cast_to_ExampleSingletonModifier(Object o) -> ExampleSingletonModifier"""
619  return _IMP_example._object_cast_to_ExampleSingletonModifier(o)
620 
621 _object_types.append("ExamplePairScore")
622 
623 
624 def _object_cast_to_ExamplePairScore(o):
625  r"""_object_cast_to_ExamplePairScore(Object o) -> ExamplePairScore"""
626  return _IMP_example._object_cast_to_ExamplePairScore(o)
627 
628 _object_types.append("ExampleSubsetFilterTable")
629 
630 
631 def _object_cast_to_ExampleSubsetFilterTable(o):
632  r"""_object_cast_to_ExampleSubsetFilterTable(Object o) -> ExampleSubsetFilterTable"""
633  return _IMP_example._object_cast_to_ExampleSubsetFilterTable(o)
634 
635 _object_types.append("ExampleConstraint")
636 
637 
638 def _object_cast_to_ExampleConstraint(o):
639  r"""_object_cast_to_ExampleConstraint(Object o) -> ExampleConstraint"""
640  return _IMP_example._object_cast_to_ExampleConstraint(o)
641 
642 _object_types.append("ExampleObject")
643 
644 
645 def _object_cast_to_ExampleObject(o):
646  r"""_object_cast_to_ExampleObject(Object o) -> ExampleObject"""
647  return _IMP_example._object_cast_to_ExampleObject(o)
648 
649 ExampleTemplateClass3Ds=list
650 _plural_types.append("ExampleTemplateClass3Ds")
651 _value_types.append("ExampleTemplateClass3D")
652 
653 
654 def create_model_and_particles():
655  m = IMP.Model()
658  IMP.algebra.Vector3D(10,10,10))
659  for i in range(0,100):
660  p = m.add_particle("p")
661  sc.add(p)
664  d.set_coordinates_are_optimized(True)
665  return (m, sc)
666 
667 
668 
670  """An example restraint written in Python.
671  This should be functionally equivalent to the C++ ExampleRestraint.
672  """
673  def __init__(self, m, p, k):
674  super().__init__(m, "PythonExampleRestraint%1%")
675  self.p, self.k = p, k
676 
678  """Pure Python implementation of the restraint"""
679  d = IMP.core.XYZ(self.get_model(), self.p)
680  score = .5 * self.k * d.get_z() * d.get_z()
681  if sa.get_derivative_accumulator():
682  deriv = self.k * d.get_z()
683  d.add_to_derivative(2, deriv, sa.get_derivative_accumulator())
684  sa.add_score(score)
685 
686  def _get_jax(self):
687  """Implementation of the restraint using JAX"""
688  import functools
689  def jax_restraint(X, k, pi):
690  xyz = X['xyz'][pi]
691  return 0.5 * k * xyz[2] * xyz[2]
692  f = functools.partial(jax_restraint, k=self.k, pi=self.p)
693  return self._wrap_jax(f)
694 
695  def do_get_inputs(self):
696  return [self.get_model().get_particle(self.p)]
697 
698 
699 
700 
702  """An example PairScore written in Python.
703  This should be functionally equivalent to the C++ ExamplePairScore.
704  """
705  def __init__(self, x0, k):
706  super().__init__()
707  self.x0, self.k = x0, k
708 
709  def evaluate_index(self, m, pip, da):
710  """Pure Python implementation of the score"""
711  d0 = IMP.core.XYZ(m, pip[0])
712  d1 = IMP.core.XYZ(m, pip[1])
713  diff = (d0.get_coordinates()
714  - d1.get_coordinates()).get_magnitude() - self.x0
715  score = .5 * self.k * diff * diff
716  if da:
717 # derivatives are requested
718  delta = d0.get_coordinates() - d1.get_coordinates()
719  udelta = delta.get_unit_vector()
720  dv = self.k * diff
721  d0.add_to_derivatives(udelta * dv, da)
722  d1.add_to_derivatives(-udelta * dv, da)
723  return score
724 
725  def do_get_inputs(self, m, pis):
726  return IMP.get_particles(m, pis)
727 
728 
729 
730 
732  """An example UnaryFunction written in Python.
733  This should be functionally equivalent to the C++ ExampleUnaryFunction.
734  """
735  def __init__(self, center, k):
736  super().__init__()
737  self.center, self.k = center, k
738 
739  def evaluate_with_derivative(self, feature):
740  return (self.evaluate(feature), self.k * (feature - self.center))
741 
742  def evaluate(self, feature):
743  return .5 * self.k * (feature - self.center) * (feature - self.center)
744 
745 
746 
747 
749  """An example Constraint written in Python.
750  This should be functionally equivalent to the C++ ExampleConstraint.
751  """
752 
753  k = None
754 
755  def __init__(self, p):
756  super().__init__(p.get_model(), "ExampleConstraint%1%")
757  self.p = p
758  if self.k is None:
759  PythonExampleConstraint.k = IMP.IntKey("Constraint key")
760  if not p.has_attribute(self.k):
761  p.add_attribute(self.k, 0)
762 
763  def do_update_attributes(self):
764  self.p.set_value(self.k, self.p.get_value(self.k) + 1)
765 
766  def do_update_derivatives(self, da):
767  pass
768 
769  def do_get_inputs(self):
770  return [self.p]
771 
772  def do_get_outputs(self):
773  return [self.p]
774 
775 
776 
777 
779  """An example SingletonModifier written in Python.
780  This should be functionally equivalent to the C++
781  ExampleSingletonModifier.
782  """
783 
784  def __init__(self, bb):
785  super().__init__("ExampleSingletonModifier%1%")
786  self.bb = bb
787 
788  def apply_index(self, m, pi):
789  d = IMP.core.XYZ(m, pi)
790  for i in range(3):
791 # shift the coordinate until it is in the box
792  while d.get_coordinate(i) < self.bb.get_corner(0)[i]:
793  d.set_coordinate(i,d.get_coordinate(i) + \
794  (self.bb.get_corner(1)[i] - self.bb.get_corner(0)[i]))
795  while d.get_coordinate(i) > self.bb.get_corner(1)[i]:
796  d.set_coordinate(i,d.get_coordinate(i) - \
797  (self.bb.get_corner(1)[i] - self.bb.get_corner(0)[i]))
798 
799  def do_get_inputs(self, m, pis):
800  return IMP.get_particles(m, pis)
801 
802  def do_get_outputs(self, m, pis):
803  return self.do_get_inputs(m, pis)
804 
805 
807  r"""Proxy of C++ IMP::example::ExampleRestraint class."""
808 
809  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
810 
811  def __init__(self, *args):
812  r"""
813  __init__(ExampleRestraint self, Model m, ParticleIndex p, double k) -> ExampleRestraint
814  __init__(ExampleRestraint self) -> ExampleRestraint
815  """
816  _IMP_example.ExampleRestraint_swiginit(self, _IMP_example.new_ExampleRestraint(*args))
817 
818  def get_force_constant(self):
819  r"""get_force_constant(ExampleRestraint self) -> double"""
820  return _IMP_example.ExampleRestraint_get_force_constant(self)
821 
822  def get_index(self):
823  r"""get_index(ExampleRestraint self) -> ParticleIndex"""
824  return _IMP_example.ExampleRestraint_get_index(self)
825 
826  def do_add_score_and_derivatives(self, sa):
827  r"""do_add_score_and_derivatives(ExampleRestraint self, ScoreAccumulator sa)"""
828  return _IMP_example.ExampleRestraint_do_add_score_and_derivatives(self, sa)
829 
830  def do_get_inputs(self):
831  r"""do_get_inputs(ExampleRestraint self) -> IMP::ModelObjectsTemp"""
832  return _IMP_example.ExampleRestraint_do_get_inputs(self)
833 
834  def get_version_info(self):
835  r"""get_version_info(ExampleRestraint self) -> VersionInfo"""
836  return _IMP_example.ExampleRestraint_get_version_info(self)
837  __swig_destroy__ = _IMP_example.delete_ExampleRestraint
838 
839  def __str__(self):
840  r"""__str__(ExampleRestraint self) -> std::string"""
841  return _IMP_example.ExampleRestraint___str__(self)
842 
843  def __repr__(self):
844  r"""__repr__(ExampleRestraint self) -> std::string"""
845  return _IMP_example.ExampleRestraint___repr__(self)
846 
847  @staticmethod
848  def get_from(o):
849  return _object_cast_to_ExampleRestraint(o)
850 
851 
852  def _get_as_binary(self):
853  r"""_get_as_binary(ExampleRestraint self) -> PyObject *"""
854  return _IMP_example.ExampleRestraint__get_as_binary(self)
855 
856  def _set_from_binary(self, p):
857  r"""_set_from_binary(ExampleRestraint self, PyObject * p)"""
858  return _IMP_example.ExampleRestraint__set_from_binary(self, p)
859 
860  def __getstate__(self):
861  p = self._get_as_binary()
862  if len(self.__dict__) > 1:
863  d = self.__dict__.copy()
864  del d['this']
865  p = (d, p)
866  return p
867 
868  def __setstate__(self, p):
869  if not hasattr(self, 'this'):
870  self.__init__()
871  if isinstance(p, tuple):
872  d, p = p
873  self.__dict__.update(d)
874  return self._set_from_binary(p)
875 
876 
877  def _get_jax(self):
878  """Implementation of the restraint using JAX.
879  For a Restraint, we must return a single JAX function which
880  takes a single argument, the JAX Model, and returns its score.
881  The JAX Model (here called `jm`) is a JAX object which contains
882  the same information as the IMP Model, as a simple Python dict.
883  For example, jm['xyz'] is an N x 3 array of XYZ coordinates."""
884  import functools
885  def jax_restraint(jm, k, pi):
886  # Get the xyz coordinates for particle pi in the JAX Model
887  xyz = jm['xyz'][pi]
888  # Score the Z coordinate. Note that we do not need to calculate
889  # its first derivatives; this is handled automatically by JAX.
890  return 0.5 * k * xyz[2] * xyz[2]
891  # We must return a function which takes only one argument, `jm`.
892  # Here we use functools.partial to "bake in" the other parameters
893  # k and pi, getting their values from the IMP Restraint object.
894  f = functools.partial(jax_restraint, k=self.get_force_constant(),
895  pi=self.get_index())
896  # Finally, we use the helper method _wrap_jax to return an object
897  # that contains our JAX function and other restraint-specific
898  # information, such as the weight
899  return self._wrap_jax(f)
900 
901 
902 # Register ExampleRestraint in _IMP_example:
903 _IMP_example.ExampleRestraint_swigregister(ExampleRestraint)
905  r"""Proxy of C++ IMP::example::ExampleDecorator class."""
906 
907  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
908 
909  def get_decorator_name(self):
910  r"""get_decorator_name(ExampleDecorator self) -> std::string"""
911  return _IMP_example.ExampleDecorator_get_decorator_name(self)
912 
913  def set_decorator_name(self, nm):
914  r"""set_decorator_name(ExampleDecorator self, std::string nm)"""
915  return _IMP_example.ExampleDecorator_set_decorator_name(self, nm)
916 
917  def __init__(self, *args):
918  r"""
919  __init__(ExampleDecorator self) -> ExampleDecorator
920  __init__(ExampleDecorator self, Model m, ParticleIndex id) -> ExampleDecorator
921  __init__(ExampleDecorator self, _ParticleAdaptor d) -> ExampleDecorator
922  """
923  _IMP_example.ExampleDecorator_swiginit(self, _IMP_example.new_ExampleDecorator(*args))
924 
925  @staticmethod
926  def get_is_setup(*args):
927  r"""
928  get_is_setup(Model m, ParticleIndex pi) -> bool
929  get_is_setup(_ParticleAdaptor p) -> bool
930  """
931  return _IMP_example.ExampleDecorator_get_is_setup(*args)
932 
933  def show(self, *args):
934  r"""show(ExampleDecorator self, _ostream out=std::cout)"""
935  return _IMP_example.ExampleDecorator_show(self, *args)
936 
937  @staticmethod
938  def setup_particle(*args):
939  r"""
940  setup_particle(Model m, ParticleIndex pi, std::string name) -> ExampleDecorator
941  setup_particle(_ParticleAdaptor pa, std::string name) -> ExampleDecorator
942  """
943  return _IMP_example.ExampleDecorator_setup_particle(*args)
944 
945  def add_attribute(self, *args):
946  r"""
947  add_attribute(ExampleDecorator self, FloatKey k, IMP::Float v, bool opt)
948  add_attribute(ExampleDecorator self, FloatKey a0, IMP::Float a1)
949  add_attribute(ExampleDecorator self, IntKey a0, IMP::Int a1)
950  add_attribute(ExampleDecorator self, FloatsKey a0, IMP::Floats a1)
951  add_attribute(ExampleDecorator self, IntsKey a0, IMP::Ints a1)
952  add_attribute(ExampleDecorator self, StringKey a0, IMP::String a1)
953  add_attribute(ExampleDecorator self, ParticleIndexKey a0, Particle a1)
954  add_attribute(ExampleDecorator self, ObjectKey a0, Object a1)
955  add_attribute(ExampleDecorator self, SparseFloatKey a0, IMP::Float a1)
956  add_attribute(ExampleDecorator self, SparseIntKey a0, IMP::Int a1)
957  add_attribute(ExampleDecorator self, SparseStringKey a0, IMP::String a1)
958  add_attribute(ExampleDecorator self, SparseParticleIndexKey a0, ParticleIndex a1)
959  """
960  return _IMP_example.ExampleDecorator_add_attribute(self, *args)
961 
962  def get_value(self, *args):
963  r"""
964  get_value(ExampleDecorator self, FloatKey a0) -> IMP::Float
965  get_value(ExampleDecorator self, IntKey a0) -> IMP::Int
966  get_value(ExampleDecorator self, FloatsKey a0) -> IMP::Floats
967  get_value(ExampleDecorator self, IntsKey a0) -> IMP::Ints
968  get_value(ExampleDecorator self, StringKey a0) -> IMP::String
969  get_value(ExampleDecorator self, ParticleIndexKey a0) -> Particle
970  get_value(ExampleDecorator self, ObjectKey a0) -> Object
971  get_value(ExampleDecorator self, SparseFloatKey a0) -> IMP::Float
972  get_value(ExampleDecorator self, SparseIntKey a0) -> IMP::Int
973  get_value(ExampleDecorator self, SparseStringKey a0) -> IMP::String
974  get_value(ExampleDecorator self, SparseParticleIndexKey a0) -> ParticleIndex
975  """
976  return _IMP_example.ExampleDecorator_get_value(self, *args)
977 
978  def set_value(self, *args):
979  r"""
980  set_value(ExampleDecorator self, FloatKey a0, IMP::Float a1)
981  set_value(ExampleDecorator self, IntKey a0, IMP::Int a1)
982  set_value(ExampleDecorator self, FloatsKey a0, IMP::Floats a1)
983  set_value(ExampleDecorator self, IntsKey a0, IMP::Ints a1)
984  set_value(ExampleDecorator self, StringKey a0, IMP::String a1)
985  set_value(ExampleDecorator self, ParticleIndexKey a0, Particle a1)
986  set_value(ExampleDecorator self, ObjectKey a0, Object a1)
987  set_value(ExampleDecorator self, SparseFloatKey a0, IMP::Float a1)
988  set_value(ExampleDecorator self, SparseIntKey a0, IMP::Int a1)
989  set_value(ExampleDecorator self, SparseStringKey a0, IMP::String a1)
990  set_value(ExampleDecorator self, SparseParticleIndexKey a0, ParticleIndex a1)
991  """
992  return _IMP_example.ExampleDecorator_set_value(self, *args)
993 
994  def remove_attribute(self, *args):
995  r"""
996  remove_attribute(ExampleDecorator self, FloatKey a0)
997  remove_attribute(ExampleDecorator self, IntKey a0)
998  remove_attribute(ExampleDecorator self, FloatsKey a0)
999  remove_attribute(ExampleDecorator self, IntsKey a0)
1000  remove_attribute(ExampleDecorator self, StringKey a0)
1001  remove_attribute(ExampleDecorator self, ParticleIndexKey a0)
1002  remove_attribute(ExampleDecorator self, ObjectKey a0)
1003  remove_attribute(ExampleDecorator self, SparseFloatKey a0)
1004  remove_attribute(ExampleDecorator self, SparseIntKey a0)
1005  remove_attribute(ExampleDecorator self, SparseStringKey a0)
1006  remove_attribute(ExampleDecorator self, SparseParticleIndexKey a0)
1007  """
1008  return _IMP_example.ExampleDecorator_remove_attribute(self, *args)
1009 
1010  def has_attribute(self, *args):
1011  r"""
1012  has_attribute(ExampleDecorator self, FloatKey a0) -> bool
1013  has_attribute(ExampleDecorator self, IntKey a0) -> bool
1014  has_attribute(ExampleDecorator self, FloatsKey a0) -> bool
1015  has_attribute(ExampleDecorator self, IntsKey a0) -> bool
1016  has_attribute(ExampleDecorator self, StringKey a0) -> bool
1017  has_attribute(ExampleDecorator self, ParticleIndexKey a0) -> bool
1018  has_attribute(ExampleDecorator self, ObjectKey a0) -> bool
1019  has_attribute(ExampleDecorator self, SparseFloatKey a0) -> bool
1020  has_attribute(ExampleDecorator self, SparseIntKey a0) -> bool
1021  has_attribute(ExampleDecorator self, SparseStringKey a0) -> bool
1022  has_attribute(ExampleDecorator self, SparseParticleIndexKey a0) -> bool
1023  """
1024  return _IMP_example.ExampleDecorator_has_attribute(self, *args)
1025 
1026  def get_derivative(self, a0):
1027  r"""get_derivative(ExampleDecorator self, FloatKey a0) -> double"""
1028  return _IMP_example.ExampleDecorator_get_derivative(self, a0)
1029 
1030  def get_name(self):
1031  r"""get_name(ExampleDecorator self) -> std::string"""
1032  return _IMP_example.ExampleDecorator_get_name(self)
1033 
1034  def clear_caches(self):
1035  r"""clear_caches(ExampleDecorator self)"""
1036  return _IMP_example.ExampleDecorator_clear_caches(self)
1037 
1038  def set_name(self, a0):
1039  r"""set_name(ExampleDecorator self, std::string a0)"""
1040  return _IMP_example.ExampleDecorator_set_name(self, a0)
1041 
1042  def set_check_level(self, a0):
1043  r"""set_check_level(ExampleDecorator self, IMP::CheckLevel a0)"""
1044  return _IMP_example.ExampleDecorator_set_check_level(self, a0)
1045 
1046  def add_to_derivative(self, a0, a1, a2):
1047  r"""add_to_derivative(ExampleDecorator self, FloatKey a0, double a1, DerivativeAccumulator a2)"""
1048  return _IMP_example.ExampleDecorator_add_to_derivative(self, a0, a1, a2)
1049 
1050  def set_is_optimized(self, a0, a1):
1051  r"""set_is_optimized(ExampleDecorator self, FloatKey a0, bool a1)"""
1052  return _IMP_example.ExampleDecorator_set_is_optimized(self, a0, a1)
1053 
1054  def get_is_optimized(self, a0):
1055  r"""get_is_optimized(ExampleDecorator self, FloatKey a0) -> bool"""
1056  return _IMP_example.ExampleDecorator_get_is_optimized(self, a0)
1057 
1058  def get_check_level(self):
1059  r"""get_check_level(ExampleDecorator self) -> IMP::CheckLevel"""
1060  return _IMP_example.ExampleDecorator_get_check_level(self)
1061 
1062  def __eq__(self, *args):
1063  r"""
1064  __eq__(ExampleDecorator self, ExampleDecorator o) -> bool
1065  __eq__(ExampleDecorator self, Particle d) -> bool
1066  """
1067  return _IMP_example.ExampleDecorator___eq__(self, *args)
1068 
1069  def __ne__(self, *args):
1070  r"""
1071  __ne__(ExampleDecorator self, ExampleDecorator o) -> bool
1072  __ne__(ExampleDecorator self, Particle d) -> bool
1073  """
1074  return _IMP_example.ExampleDecorator___ne__(self, *args)
1075 
1076  def __le__(self, *args):
1077  r"""
1078  __le__(ExampleDecorator self, ExampleDecorator o) -> bool
1079  __le__(ExampleDecorator self, Particle d) -> bool
1080  """
1081  return _IMP_example.ExampleDecorator___le__(self, *args)
1082 
1083  def __lt__(self, *args):
1084  r"""
1085  __lt__(ExampleDecorator self, ExampleDecorator o) -> bool
1086  __lt__(ExampleDecorator self, Particle d) -> bool
1087  """
1088  return _IMP_example.ExampleDecorator___lt__(self, *args)
1089 
1090  def __ge__(self, *args):
1091  r"""
1092  __ge__(ExampleDecorator self, ExampleDecorator o) -> bool
1093  __ge__(ExampleDecorator self, Particle d) -> bool
1094  """
1095  return _IMP_example.ExampleDecorator___ge__(self, *args)
1096 
1097  def __gt__(self, *args):
1098  r"""
1099  __gt__(ExampleDecorator self, ExampleDecorator o) -> bool
1100  __gt__(ExampleDecorator self, Particle d) -> bool
1101  """
1102  return _IMP_example.ExampleDecorator___gt__(self, *args)
1103 
1104  def __hash__(self):
1105  r"""__hash__(ExampleDecorator self) -> std::size_t"""
1106  return _IMP_example.ExampleDecorator___hash__(self)
1107 
1108  def __str__(self):
1109  r"""__str__(ExampleDecorator self) -> std::string"""
1110  return _IMP_example.ExampleDecorator___str__(self)
1111 
1112  def __repr__(self):
1113  r"""__repr__(ExampleDecorator self) -> std::string"""
1114  return _IMP_example.ExampleDecorator___repr__(self)
1115 
1116  def _get_as_binary(self):
1117  r"""_get_as_binary(ExampleDecorator self) -> PyObject *"""
1118  return _IMP_example.ExampleDecorator__get_as_binary(self)
1119 
1120  def _set_from_binary(self, p):
1121  r"""_set_from_binary(ExampleDecorator self, PyObject * p)"""
1122  return _IMP_example.ExampleDecorator__set_from_binary(self, p)
1123 
1124  def __getstate__(self):
1125  p = self._get_as_binary()
1126  if len(self.__dict__) > 1:
1127  d = self.__dict__.copy()
1128  del d['this']
1129  p = (d, p)
1130  return p
1131 
1132  def __setstate__(self, p):
1133  if not hasattr(self, 'this'):
1134  self.__init__()
1135  if isinstance(p, tuple):
1136  d, p = p
1137  self.__dict__.update(d)
1138  return self._set_from_binary(p)
1139 
1140  __swig_destroy__ = _IMP_example.delete_ExampleDecorator
1141 
1142 # Register ExampleDecorator in _IMP_example:
1143 _IMP_example.ExampleDecorator_swigregister(ExampleDecorator)
1144 
1145 def __lshift__(out, n):
1146  r"""__lshift__(_ostream out, ExampleDecorator n) -> _ostream"""
1147  return _IMP_example.__lshift__(out, n)
1149  r"""Proxy of C++ IMP::example::ExampleUnaryFunction class."""
1150 
1151  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1152 
1153  def __init__(self, *args):
1154  r"""
1155  __init__(ExampleUnaryFunction self, IMP::Float center, IMP::Float k) -> ExampleUnaryFunction
1156  __init__(ExampleUnaryFunction self) -> ExampleUnaryFunction
1157  """
1158  _IMP_example.ExampleUnaryFunction_swiginit(self, _IMP_example.new_ExampleUnaryFunction(*args))
1159 
1160  def get_center(self):
1161  r"""get_center(ExampleUnaryFunction self) -> IMP::Float"""
1162  return _IMP_example.ExampleUnaryFunction_get_center(self)
1163 
1164  def get_force_constant(self):
1165  r"""get_force_constant(ExampleUnaryFunction self) -> IMP::Float"""
1166  return _IMP_example.ExampleUnaryFunction_get_force_constant(self)
1167 
1168  def get_version_info(self):
1169  r"""get_version_info(ExampleUnaryFunction self) -> VersionInfo"""
1170  return _IMP_example.ExampleUnaryFunction_get_version_info(self)
1171  __swig_destroy__ = _IMP_example.delete_ExampleUnaryFunction
1172 
1173  def __str__(self):
1174  r"""__str__(ExampleUnaryFunction self) -> std::string"""
1175  return _IMP_example.ExampleUnaryFunction___str__(self)
1176 
1177  def __repr__(self):
1178  r"""__repr__(ExampleUnaryFunction self) -> std::string"""
1179  return _IMP_example.ExampleUnaryFunction___repr__(self)
1180 
1181  @staticmethod
1182  def get_from(o):
1183  return _object_cast_to_ExampleUnaryFunction(o)
1184 
1185 
1186  def _get_as_binary(self):
1187  r"""_get_as_binary(ExampleUnaryFunction self) -> PyObject *"""
1188  return _IMP_example.ExampleUnaryFunction__get_as_binary(self)
1189 
1190  def _set_from_binary(self, p):
1191  r"""_set_from_binary(ExampleUnaryFunction self, PyObject * p)"""
1192  return _IMP_example.ExampleUnaryFunction__set_from_binary(self, p)
1193 
1194  def __getstate__(self):
1195  p = self._get_as_binary()
1196  if len(self.__dict__) > 1:
1197  d = self.__dict__.copy()
1198  del d['this']
1199  p = (d, p)
1200  return p
1201 
1202  def __setstate__(self, p):
1203  if not hasattr(self, 'this'):
1204  self.__init__()
1205  if isinstance(p, tuple):
1206  d, p = p
1207  self.__dict__.update(d)
1208  return self._set_from_binary(p)
1209 
1210 
1211  def _get_jax(self):
1212  """Implementation of the unary function using JAX"""
1213  import functools
1214  def score(feature, center, k):
1215  return 0.5 * k * (feature - center) ** 2
1216  return functools.partial(score, center=self.get_center(),
1217  k=self.get_force_constant())
1218 
1219 
1220 # Register ExampleUnaryFunction in _IMP_example:
1221 _IMP_example.ExampleUnaryFunction_swigregister(ExampleUnaryFunction)
1222 class ExampleObject(IMP.Object):
1223  r"""Proxy of C++ IMP::example::ExampleObject class."""
1224 
1225  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1226 
1227  def __init__(self, *args):
1228  r"""
1229  __init__(ExampleObject self, IMP::Floats const & data) -> ExampleObject
1230  __init__(ExampleObject self) -> ExampleObject
1231  """
1232  _IMP_example.ExampleObject_swiginit(self, _IMP_example.new_ExampleObject(*args))
1233 
1234  def get_data(self, i):
1235  r"""get_data(ExampleObject self, unsigned int i) -> double"""
1236  return _IMP_example.ExampleObject_get_data(self, i)
1237 
1238  def get_version_info(self):
1239  r"""get_version_info(ExampleObject self) -> VersionInfo"""
1240  return _IMP_example.ExampleObject_get_version_info(self)
1241  __swig_destroy__ = _IMP_example.delete_ExampleObject
1242 
1243  def __str__(self):
1244  r"""__str__(ExampleObject self) -> std::string"""
1245  return _IMP_example.ExampleObject___str__(self)
1246 
1247  def __repr__(self):
1248  r"""__repr__(ExampleObject self) -> std::string"""
1249  return _IMP_example.ExampleObject___repr__(self)
1250 
1251  @staticmethod
1252  def get_from(o):
1253  return _object_cast_to_ExampleObject(o)
1254 
1255 
1256  def _get_as_binary(self):
1257  r"""_get_as_binary(ExampleObject self) -> PyObject *"""
1258  return _IMP_example.ExampleObject__get_as_binary(self)
1259 
1260  def _set_from_binary(self, p):
1261  r"""_set_from_binary(ExampleObject self, PyObject * p)"""
1262  return _IMP_example.ExampleObject__set_from_binary(self, p)
1263 
1264  def __getstate__(self):
1265  p = self._get_as_binary()
1266  if len(self.__dict__) > 1:
1267  d = self.__dict__.copy()
1268  del d['this']
1269  p = (d, p)
1270  return p
1271 
1272  def __setstate__(self, p):
1273  if not hasattr(self, 'this'):
1274  self.__init__()
1275  if isinstance(p, tuple):
1276  d, p = p
1277  self.__dict__.update(d)
1278  return self._set_from_binary(p)
1279 
1280 
1281 # Register ExampleObject in _IMP_example:
1282 _IMP_example.ExampleObject_swigregister(ExampleObject)
1284  r"""Proxy of C++ IMP::example::ExampleSingletonModifier class."""
1285 
1286  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1287 
1288  def __init__(self, *args):
1289  r"""
1290  __init__(ExampleSingletonModifier self, BoundingBox3D bb) -> ExampleSingletonModifier
1291  __init__(ExampleSingletonModifier self) -> ExampleSingletonModifier
1292  """
1293  _IMP_example.ExampleSingletonModifier_swiginit(self, _IMP_example.new_ExampleSingletonModifier(*args))
1294 
1295  def get_bounding_box(self):
1296  r"""get_bounding_box(ExampleSingletonModifier self) -> BoundingBox3D"""
1297  return _IMP_example.ExampleSingletonModifier_get_bounding_box(self)
1298 
1299  def do_get_inputs(self, m, pis):
1300  r"""do_get_inputs(ExampleSingletonModifier self, Model m, IMP::ParticleIndexes const & pis) -> IMP::ModelObjectsTemp"""
1301  return _IMP_example.ExampleSingletonModifier_do_get_inputs(self, m, pis)
1302 
1303  def do_get_outputs(self, m, pis):
1304  r"""do_get_outputs(ExampleSingletonModifier self, Model m, IMP::ParticleIndexes const & pis) -> IMP::ModelObjectsTemp"""
1305  return _IMP_example.ExampleSingletonModifier_do_get_outputs(self, m, pis)
1306 
1307  def get_version_info(self):
1308  r"""get_version_info(ExampleSingletonModifier self) -> VersionInfo"""
1309  return _IMP_example.ExampleSingletonModifier_get_version_info(self)
1310  __swig_destroy__ = _IMP_example.delete_ExampleSingletonModifier
1311 
1312  def __str__(self):
1313  r"""__str__(ExampleSingletonModifier self) -> std::string"""
1314  return _IMP_example.ExampleSingletonModifier___str__(self)
1315 
1316  def __repr__(self):
1317  r"""__repr__(ExampleSingletonModifier self) -> std::string"""
1318  return _IMP_example.ExampleSingletonModifier___repr__(self)
1319 
1320  @staticmethod
1321  def get_from(o):
1322  return _object_cast_to_ExampleSingletonModifier(o)
1323 
1324 
1325  def _get_as_binary(self):
1326  r"""_get_as_binary(ExampleSingletonModifier self) -> PyObject *"""
1327  return _IMP_example.ExampleSingletonModifier__get_as_binary(self)
1328 
1329  def _set_from_binary(self, p):
1330  r"""_set_from_binary(ExampleSingletonModifier self, PyObject * p)"""
1331  return _IMP_example.ExampleSingletonModifier__set_from_binary(self, p)
1332 
1333  def __getstate__(self):
1334  p = self._get_as_binary()
1335  if len(self.__dict__) > 1:
1336  d = self.__dict__.copy()
1337  del d['this']
1338  p = (d, p)
1339  return p
1340 
1341  def __setstate__(self, p):
1342  if not hasattr(self, 'this'):
1343  self.__init__()
1344  if isinstance(p, tuple):
1345  d, p = p
1346  self.__dict__.update(d)
1347  return self._set_from_binary(p)
1348 
1349 
1350  def _get_jax(self, m, index=None):
1351  """Implementation of the modifier using JAX"""
1352  import functools
1353  import jax.numpy as jnp
1354  def apply_func(jm, indexes, box):
1355  jm['xyz'] = jm['xyz'].at[index].set(
1356  jnp.mod(jm['xyz'][index], box[1] - box[0]) + box[0])
1357  return jm
1358  box = jnp.array([self.get_bounding_box().get_corner(x)
1359  for x in range(2)])
1360  return self._wrap_jax(
1361  functools.partial(apply_func, box=box))
1362 
1363 
1364 # Register ExampleSingletonModifier in _IMP_example:
1365 _IMP_example.ExampleSingletonModifier_swigregister(ExampleSingletonModifier)
1367  r"""Proxy of C++ IMP::example::ExamplePairScore class."""
1368 
1369  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1370 
1371  def __init__(self, *args):
1372  r"""
1373  __init__(ExamplePairScore self, double x0, double k) -> ExamplePairScore
1374  __init__(ExamplePairScore self) -> ExamplePairScore
1375  """
1376  _IMP_example.ExamplePairScore_swiginit(self, _IMP_example.new_ExamplePairScore(*args))
1377 
1378  def get_mean(self):
1379  r"""get_mean(ExamplePairScore self) -> double"""
1380  return _IMP_example.ExamplePairScore_get_mean(self)
1381 
1382  def get_force_constant(self):
1383  r"""get_force_constant(ExamplePairScore self) -> double"""
1384  return _IMP_example.ExamplePairScore_get_force_constant(self)
1385 
1386  def do_get_inputs(self, m, pis):
1387  r"""do_get_inputs(ExamplePairScore self, Model m, IMP::ParticleIndexes const & pis) -> IMP::ModelObjectsTemp"""
1388  return _IMP_example.ExamplePairScore_do_get_inputs(self, m, pis)
1389 
1390  def evaluate_indexes(self, m, p, da, lower_bound, upper_bound, all_indexes_checked=False):
1391  r"""evaluate_indexes(ExamplePairScore self, Model m, IMP::ParticleIndexPairs const & p, DerivativeAccumulator da, unsigned int lower_bound, unsigned int upper_bound, bool all_indexes_checked=False) -> double"""
1392  return _IMP_example.ExamplePairScore_evaluate_indexes(self, m, p, da, lower_bound, upper_bound, all_indexes_checked)
1393 
1394  def evaluate_indexes_scores(self, m, p, da, lower_bound, upper_bound, score, all_indexes_checked=False):
1395  r"""evaluate_indexes_scores(ExamplePairScore self, Model m, IMP::ParticleIndexPairs const & p, DerivativeAccumulator da, unsigned int lower_bound, unsigned int upper_bound, DistBase score, bool all_indexes_checked=False) -> double"""
1396  return _IMP_example.ExamplePairScore_evaluate_indexes_scores(self, m, p, da, lower_bound, upper_bound, score, all_indexes_checked)
1397 
1398  def evaluate_indexes_delta(self, m, p, da, indexes, score, all_indexes_checked=False):
1399  r"""evaluate_indexes_delta(ExamplePairScore self, Model m, IMP::ParticleIndexPairs const & p, DerivativeAccumulator da, std::vector< unsigned int,std::allocator< unsigned int > > const & indexes, DistBase score, bool all_indexes_checked=False) -> double"""
1400  return _IMP_example.ExamplePairScore_evaluate_indexes_delta(self, m, p, da, indexes, score, all_indexes_checked)
1401 
1402  def evaluate_if_good_indexes(self, m, p, da, max, lower_bound, upper_bound, all_indexes_checked=False):
1403  r"""evaluate_if_good_indexes(ExamplePairScore self, Model m, IMP::ParticleIndexPairs const & p, DerivativeAccumulator da, double max, unsigned int lower_bound, unsigned int upper_bound, bool all_indexes_checked=False) -> double"""
1404  return _IMP_example.ExamplePairScore_evaluate_if_good_indexes(self, m, p, da, max, lower_bound, upper_bound, all_indexes_checked)
1405 
1406  def get_version_info(self):
1407  r"""get_version_info(ExamplePairScore self) -> VersionInfo"""
1408  return _IMP_example.ExamplePairScore_get_version_info(self)
1409  __swig_destroy__ = _IMP_example.delete_ExamplePairScore
1410 
1411  def __str__(self):
1412  r"""__str__(ExamplePairScore self) -> std::string"""
1413  return _IMP_example.ExamplePairScore___str__(self)
1414 
1415  def __repr__(self):
1416  r"""__repr__(ExamplePairScore self) -> std::string"""
1417  return _IMP_example.ExamplePairScore___repr__(self)
1418 
1419  @staticmethod
1420  def get_from(o):
1421  return _object_cast_to_ExamplePairScore(o)
1422 
1423 
1424  def _get_as_binary(self):
1425  r"""_get_as_binary(ExamplePairScore self) -> PyObject *"""
1426  return _IMP_example.ExamplePairScore__get_as_binary(self)
1427 
1428  def _set_from_binary(self, p):
1429  r"""_set_from_binary(ExamplePairScore self, PyObject * p)"""
1430  return _IMP_example.ExamplePairScore__set_from_binary(self, p)
1431 
1432  def __getstate__(self):
1433  p = self._get_as_binary()
1434  if len(self.__dict__) > 1:
1435  d = self.__dict__.copy()
1436  del d['this']
1437  p = (d, p)
1438  return p
1439 
1440  def __setstate__(self, p):
1441  if not hasattr(self, 'this'):
1442  self.__init__()
1443  if isinstance(p, tuple):
1444  d, p = p
1445  self.__dict__.update(d)
1446  return self._set_from_binary(p)
1447 
1448 
1449  def _get_jax(self):
1450  """Implementation of the score using JAX"""
1451  import jax.numpy as jnp
1452  import functools
1453  def pair_score(jm, indexes, x0, k):
1454  xyzs = jm['xyz'][indexes]
1455  diff = jnp.linalg.norm(xyzs[:,0] - xyzs[:,1], axis=1) - x0
1456  return 0.5 * k * diff * diff
1457  f = functools.partial(pair_score, x0=self.get_mean(),
1458  k=self.get_force_constant())
1459  return self._wrap_jax(f)
1460 
1461 
1462 # Register ExamplePairScore in _IMP_example:
1463 _IMP_example.ExamplePairScore_swigregister(ExamplePairScore)
1465  r"""Proxy of C++ IMP::example::ExampleSubsetFilterTable class."""
1466 
1467  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1468 
1469  def __init__(self, max_diff, pt):
1470  r"""__init__(ExampleSubsetFilterTable self, unsigned int max_diff, IMP::ParticlesTemp const & pt) -> ExampleSubsetFilterTable"""
1471  _IMP_example.ExampleSubsetFilterTable_swiginit(self, _IMP_example.new_ExampleSubsetFilterTable(max_diff, pt))
1472 
1473  def get_version_info(self):
1474  r"""get_version_info(ExampleSubsetFilterTable self) -> VersionInfo"""
1475  return _IMP_example.ExampleSubsetFilterTable_get_version_info(self)
1476  __swig_destroy__ = _IMP_example.delete_ExampleSubsetFilterTable
1477 
1478  def __str__(self):
1479  r"""__str__(ExampleSubsetFilterTable self) -> std::string"""
1480  return _IMP_example.ExampleSubsetFilterTable___str__(self)
1481 
1482  def __repr__(self):
1483  r"""__repr__(ExampleSubsetFilterTable self) -> std::string"""
1484  return _IMP_example.ExampleSubsetFilterTable___repr__(self)
1485 
1486  @staticmethod
1487  def get_from(o):
1488  return _object_cast_to_ExampleSubsetFilterTable(o)
1489 
1490 
1491 # Register ExampleSubsetFilterTable in _IMP_example:
1492 _IMP_example.ExampleSubsetFilterTable_swigregister(ExampleSubsetFilterTable)
1494  r"""Proxy of C++ IMP::example::ExampleConstraint class."""
1495 
1496  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1497 
1498  def __init__(self, *args):
1499  r"""
1500  __init__(ExampleConstraint self, Particle p) -> ExampleConstraint
1501  __init__(ExampleConstraint self) -> ExampleConstraint
1502  """
1503  _IMP_example.ExampleConstraint_swiginit(self, _IMP_example.new_ExampleConstraint(*args))
1504 
1505  def get_index(self):
1506  r"""get_index(ExampleConstraint self) -> ParticleIndex"""
1507  return _IMP_example.ExampleConstraint_get_index(self)
1508 
1509  def do_get_inputs(self):
1510  r"""do_get_inputs(ExampleConstraint self) -> IMP::ModelObjectsTemp"""
1511  return _IMP_example.ExampleConstraint_do_get_inputs(self)
1512 
1513  def do_get_outputs(self):
1514  r"""do_get_outputs(ExampleConstraint self) -> IMP::ModelObjectsTemp"""
1515  return _IMP_example.ExampleConstraint_do_get_outputs(self)
1516 
1517  @staticmethod
1518  def get_key():
1519  r"""get_key() -> IntKey"""
1520  return _IMP_example.ExampleConstraint_get_key()
1521 
1522  def get_version_info(self):
1523  r"""get_version_info(ExampleConstraint self) -> VersionInfo"""
1524  return _IMP_example.ExampleConstraint_get_version_info(self)
1525  __swig_destroy__ = _IMP_example.delete_ExampleConstraint
1526 
1527  def __str__(self):
1528  r"""__str__(ExampleConstraint self) -> std::string"""
1529  return _IMP_example.ExampleConstraint___str__(self)
1530 
1531  def __repr__(self):
1532  r"""__repr__(ExampleConstraint self) -> std::string"""
1533  return _IMP_example.ExampleConstraint___repr__(self)
1534 
1535  @staticmethod
1536  def get_from(o):
1537  return _object_cast_to_ExampleConstraint(o)
1538 
1539 
1540  def _get_as_binary(self):
1541  r"""_get_as_binary(ExampleConstraint self) -> PyObject *"""
1542  return _IMP_example.ExampleConstraint__get_as_binary(self)
1543 
1544  def _set_from_binary(self, p):
1545  r"""_set_from_binary(ExampleConstraint self, PyObject * p)"""
1546  return _IMP_example.ExampleConstraint__set_from_binary(self, p)
1547 
1548  def __getstate__(self):
1549  p = self._get_as_binary()
1550  if len(self.__dict__) > 1:
1551  d = self.__dict__.copy()
1552  del d['this']
1553  p = (d, p)
1554  return p
1555 
1556  def __setstate__(self, p):
1557  if not hasattr(self, 'this'):
1558  self.__init__()
1559  if isinstance(p, tuple):
1560  d, p = p
1561  self.__dict__.update(d)
1562  return self._set_from_binary(p)
1563 
1564 
1565  def _get_jax(self):
1566  """Implementation of the constraint using JAX.
1567  Similar to a Restraint, we must return a single JAX function which
1568  takes as input a JAX Model. However, in this case the function
1569  must return a new JAX Model, with the constraint applied."""
1570  import functools
1571  def apply_func(jm, key, index):
1572  # JAX arrays are immutable so we cannot simply say
1573  # jm[key][index] += 1
1574  # Instead, we must return a new array which is a modified
1575  # version of the original using the JAX `at` method
1576  jm[key] = jm[key].at[index].add(1)
1577  return jm
1578  key = self.get_key()
1579  f = functools.partial(apply_func, key=key.get_string(),
1580  index=self.get_index())
1581  # _wrap_jax also takes an optional `keys` argument which is a list
1582  # of the IMP attribute keys used by the JAX function. These will be
1583  # added to the JAX Model object (although the Model will always
1584  # have `xyz` and `r` keys, for coordinates and radii).
1585  return self._wrap_jax(f, keys=(key,))
1586 
1587 
1588 # Register ExampleConstraint in _IMP_example:
1589 _IMP_example.ExampleConstraint_swigregister(ExampleConstraint)
1590 
1591 def get_number_of_incidences(psa, psb, point_distance):
1592  r"""get_number_of_incidences(IMP::ParticlesTemp const & psa, IMP::ParticlesTemp const & psb, double point_distance) -> unsigned int"""
1593  return _IMP_example.get_number_of_incidences(psa, psb, point_distance)
1594 
1595 def create_chain_restraint(m, ps, length_factor, k, name):
1596  r"""create_chain_restraint(Model m, IMP::ParticleIndexes const & ps, double length_factor, double k, std::string name) -> Restraint"""
1597  return _IMP_example.create_chain_restraint(m, ps, length_factor, k, name)
1598 
1599 def create_excluded_volume(m, ps, k, name):
1600  r"""create_excluded_volume(Model m, IMP::ParticleIndexes const & ps, double k, std::string name) -> Restraint"""
1601  return _IMP_example.create_excluded_volume(m, ps, k, name)
1602 class ExampleTemplateClass3D(object):
1603  r"""Proxy of C++ IMP::example::ExampleTemplateClassD< 3 > class."""
1604 
1605  thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1606 
1607  def __init__(self, *args):
1608  r"""
1609  __init__(ExampleTemplateClass3D self) -> ExampleTemplateClass3D
1610  __init__(ExampleTemplateClass3D self, Vector3D a, Vector3D b) -> ExampleTemplateClass3D
1611  """
1612  _IMP_example.ExampleTemplateClass3D_swiginit(self, _IMP_example.new_ExampleTemplateClass3D(*args))
1613 
1614  def get_point(self, i):
1615  r"""get_point(ExampleTemplateClass3D self, unsigned int i) -> Vector3D"""
1616  return _IMP_example.ExampleTemplateClass3D_get_point(self, i)
1617 
1618  def show(self, *args):
1619  r"""show(ExampleTemplateClass3D self, _ostream out=std::cout)"""
1620  return _IMP_example.ExampleTemplateClass3D_show(self, *args)
1621 
1622  def __str__(self):
1623  r"""__str__(ExampleTemplateClass3D self) -> std::string"""
1624  return _IMP_example.ExampleTemplateClass3D___str__(self)
1625 
1626  def __repr__(self):
1627  r"""__repr__(ExampleTemplateClass3D self) -> std::string"""
1628  return _IMP_example.ExampleTemplateClass3D___repr__(self)
1629  __swig_destroy__ = _IMP_example.delete_ExampleTemplateClass3D
1630 
1631 # Register ExampleTemplateClass3D in _IMP_example:
1632 _IMP_example.ExampleTemplateClass3D_swigregister(ExampleTemplateClass3D)
1633 
1634 def get_module_name():
1635  r"""get_module_name() -> std::string const"""
1636  return _IMP_example.get_module_name()
1637 
1638 def get_module_version():
1639  r"""get_module_version() -> std::string const"""
1640  return _IMP_example.get_module_version()
1641 
1642 def get_example_path(fname):
1643  r"""get_example_path(std::string fname) -> std::string"""
1644  return _IMP_example.get_example_path(fname)
1645 
1646 def get_data_path(fname):
1647  r"""get_data_path(std::string fname) -> std::string"""
1648  return _IMP_example.get_data_path(fname)
1649 
1650 from . import _version_check
1651 _version_check.check_version(get_module_version())
1652 __version__ = get_module_version()
1653 
1654 
unsigned int get_number_of_incidences(const ParticlesTemp &psa, const ParticlesTemp &psb, double point_distance)
Definition: counting.h:23
A base class for modifiers of ParticlesTemp.
Abstract class for scoring object(s) of type ParticleIndexPair.
Definition: PairScore.h:44
double get_mean(const cv::Mat &mat, const cvIntMat &mask)
virtual double evaluate(double feature) const
Calculate score with respect to the given feature.
Definition: UnaryFunction.h:35
An example PairScore written in Python.
An example SingletonModifier written in Python.
Various classes to hold sets of particles.
static XYZR setup_particle(Model *m, ParticleIndex pi)
Definition: XYZR.h:48
An example UnaryFunction written in Python.
Make CGAL functionality available to IMP.
A line segment templated on the dimension.
ParticlesTemp get_particles(Model *m, const ParticleIndexes &ps)
Get the particles from a list of indexes.
virtual void clear_caches()
Definition: Object.h:270
virtual ModelObjectsTemp do_get_outputs(Model *m, const ParticleIndexes &pis) const =0
Overload this method to specify the outputs.
Composable functors to implement scores via compile-time composition.
Restraint * create_excluded_volume(Model *m, const ParticleIndexes &ps, double k, std::string name)
Vector3D get_random_vector_in(const Cylinder3D &c)
Generate a random vector in a cylinder with uniform density.
Code to compute statistical measures.
Implement a constraint on the Model.
Definition: Constraint.h:49
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
An example simple object which is reference counted.
Definition: ExampleObject.h:31
A simple decorator which adds a name to a particle.
An example Constraint written in Python.
def evaluate_index
Pure Python implementation of the score.
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
Common base class for heavy weight IMP objects.
Definition: Object.h:111
Store a list of ParticleIndexes.
An example restraint written in Python.
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const =0
Overload this method to specify the inputs.
Restrain a particle to be in the x,y plane.
Basic utilities for handling cryo-electron microscopy 3D density maps.
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
Interface to specialized Particle types (e.g. atoms)
Definition: Decorator.h:119
virtual ModelObjectsTemp do_get_outputs() const =0
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...
virtual void apply_index(Model *m, ParticleIndex v) const =0
std::string get_module_version()
Return the version of this module, as a string.
virtual VersionInfo get_version_info() const
Get information about the module and version of the object.
Definition: Object.h:206
virtual DerivativePair evaluate_with_derivative(double feature) const
Calculate score and derivative with respect to the given feature.
Definition: UnaryFunction.h:50
VectorD< 3 > Vector3D
Definition: VectorD.h:408
def do_add_score_and_derivatives
Pure Python implementation of the restraint.
void set_check_level(CheckLevel l)
Apply a harmonic to the distance between two particles.
Restraint * create_chain_restraint(Model *m, const ParticleIndexes &ps, double length_factor, double k, std::string name)
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
Model * get_model() const
Definition: ModelObject.h:64
A trivial constraint that just increments a counter.
Output IMP model data in various file formats.
Functionality for loading, creating, manipulating and scoring atomic structures.
std::string get_data_path(std::string file_name)
Return the full path to one of this module's data files.
Support for the RMF file format for storing hierarchical molecular data and markup.
Abstract single variable functor class for score functions.
Definition: UnaryFunction.h:27
virtual ModelObjectsTemp do_get_inputs() const =0
Divide-and-conquer inferential optimization in discrete space.
Support for small angle X-ray scattering (SAXS) data.
Inferential scoring building on methods developed as part of the Inferential Structure Determination ...
A restraint is a term in an IMP ScoringFunction.
Definition: Restraint.h:56