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