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