IMP  2.0.1
The Integrative Modeling Platform
system/__init__.py
1 # This file was automatically generated by SWIG (http://www.swig.org).
2 # Version 2.0.8
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 
9 from sys import version_info
10 if version_info >= (2,6,0):
11  def swig_import_helper():
12  from os.path import dirname
13  import imp
14  fp = None
15  try:
16  fp, pathname, description = imp.find_module('_IMP_system', [dirname(__file__)])
17  except ImportError:
18  import _IMP_system
19  return _IMP_system
20  if fp is not None:
21  try:
22  _mod = imp.load_module('_IMP_system', fp, pathname, description)
23  finally:
24  fp.close()
25  return _mod
26  _IMP_system = swig_import_helper()
27  del swig_import_helper
28 else:
29  import _IMP_system
30 del version_info
31 try:
32  _swig_property = property
33 except NameError:
34  pass # Python < 2.2 doesn't have 'property'.
35 def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
36  if (name == "thisown"): return self.this.own(value)
37  if (name == "this"):
38  if type(value).__name__ == 'SwigPyObject':
39  self.__dict__[name] = value
40  return
41  method = class_type.__swig_setmethods__.get(name,None)
42  if method: return method(self,value)
43  if (not static):
44  self.__dict__[name] = value
45  else:
46  raise AttributeError("You cannot add attributes to %s" % self)
47 
48 def _swig_setattr(self,class_type,name,value):
49  return _swig_setattr_nondynamic(self,class_type,name,value,0)
50 
51 def _swig_getattr(self,class_type,name):
52  if (name == "thisown"): return self.this.own()
53  method = class_type.__swig_getmethods__.get(name,None)
54  if method: return method(self)
55  raise AttributeError(name)
56 
57 def _swig_repr(self):
58  try: strthis = "proxy of " + self.this.__repr__()
59  except: strthis = ""
60  return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
61 
62 try:
63  _object = object
64  _newclass = 1
65 except AttributeError:
66  class _object : pass
67  _newclass = 0
68 
69 
70 try:
71  import weakref
72  weakref_proxy = weakref.proxy
73 except:
74  weakref_proxy = lambda x: x
75 
76 
77 class IMP_SYSTEM_SwigPyIterator(_object):
78  """Proxy of C++ swig::IMP_SYSTEM_SwigPyIterator class"""
79  __swig_setmethods__ = {}
80  __setattr__ = lambda self, name, value: _swig_setattr(self, IMP_SYSTEM_SwigPyIterator, name, value)
81  __swig_getmethods__ = {}
82  __getattr__ = lambda self, name: _swig_getattr(self, IMP_SYSTEM_SwigPyIterator, name)
83  def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract")
84  __repr__ = _swig_repr
85  __swig_destroy__ = _IMP_system.delete_IMP_SYSTEM_SwigPyIterator
86  __del__ = lambda self : None;
87  def value(self):
88  """value(IMP_SYSTEM_SwigPyIterator self) -> PyObject *"""
89  return _IMP_system.IMP_SYSTEM_SwigPyIterator_value(self)
90 
91  def incr(self, n=1):
92  """
93  incr(IMP_SYSTEM_SwigPyIterator self, size_t n=1) -> IMP_SYSTEM_SwigPyIterator
94  incr(IMP_SYSTEM_SwigPyIterator self) -> IMP_SYSTEM_SwigPyIterator
95  """
96  return _IMP_system.IMP_SYSTEM_SwigPyIterator_incr(self, n)
97 
98  def decr(self, n=1):
99  """
100  decr(IMP_SYSTEM_SwigPyIterator self, size_t n=1) -> IMP_SYSTEM_SwigPyIterator
101  decr(IMP_SYSTEM_SwigPyIterator self) -> IMP_SYSTEM_SwigPyIterator
102  """
103  return _IMP_system.IMP_SYSTEM_SwigPyIterator_decr(self, n)
104 
105  def distance(self, *args):
106  """distance(IMP_SYSTEM_SwigPyIterator self, IMP_SYSTEM_SwigPyIterator x) -> ptrdiff_t"""
107  return _IMP_system.IMP_SYSTEM_SwigPyIterator_distance(self, *args)
108 
109  def equal(self, *args):
110  """equal(IMP_SYSTEM_SwigPyIterator self, IMP_SYSTEM_SwigPyIterator x) -> bool"""
111  return _IMP_system.IMP_SYSTEM_SwigPyIterator_equal(self, *args)
112 
113  def copy(self):
114  """copy(IMP_SYSTEM_SwigPyIterator self) -> IMP_SYSTEM_SwigPyIterator"""
115  return _IMP_system.IMP_SYSTEM_SwigPyIterator_copy(self)
116 
117  def next(self):
118  """next(IMP_SYSTEM_SwigPyIterator self) -> PyObject *"""
119  return _IMP_system.IMP_SYSTEM_SwigPyIterator_next(self)
120 
121  def __next__(self):
122  """__next__(IMP_SYSTEM_SwigPyIterator self) -> PyObject *"""
123  return _IMP_system.IMP_SYSTEM_SwigPyIterator___next__(self)
124 
125  def previous(self):
126  """previous(IMP_SYSTEM_SwigPyIterator self) -> PyObject *"""
127  return _IMP_system.IMP_SYSTEM_SwigPyIterator_previous(self)
128 
129  def advance(self, *args):
130  """advance(IMP_SYSTEM_SwigPyIterator self, ptrdiff_t n) -> IMP_SYSTEM_SwigPyIterator"""
131  return _IMP_system.IMP_SYSTEM_SwigPyIterator_advance(self, *args)
132 
133  def __eq__(self, *args):
134  """__eq__(IMP_SYSTEM_SwigPyIterator self, IMP_SYSTEM_SwigPyIterator x) -> bool"""
135  return _IMP_system.IMP_SYSTEM_SwigPyIterator___eq__(self, *args)
136 
137  def __ne__(self, *args):
138  """__ne__(IMP_SYSTEM_SwigPyIterator self, IMP_SYSTEM_SwigPyIterator x) -> bool"""
139  return _IMP_system.IMP_SYSTEM_SwigPyIterator___ne__(self, *args)
140 
141  def __iadd__(self, *args):
142  """__iadd__(IMP_SYSTEM_SwigPyIterator self, ptrdiff_t n) -> IMP_SYSTEM_SwigPyIterator"""
143  return _IMP_system.IMP_SYSTEM_SwigPyIterator___iadd__(self, *args)
144 
145  def __isub__(self, *args):
146  """__isub__(IMP_SYSTEM_SwigPyIterator self, ptrdiff_t n) -> IMP_SYSTEM_SwigPyIterator"""
147  return _IMP_system.IMP_SYSTEM_SwigPyIterator___isub__(self, *args)
148 
149  def __add__(self, *args):
150  """__add__(IMP_SYSTEM_SwigPyIterator self, ptrdiff_t n) -> IMP_SYSTEM_SwigPyIterator"""
151  return _IMP_system.IMP_SYSTEM_SwigPyIterator___add__(self, *args)
152 
153  def __sub__(self, *args):
154  """
155  __sub__(IMP_SYSTEM_SwigPyIterator self, ptrdiff_t n) -> IMP_SYSTEM_SwigPyIterator
156  __sub__(IMP_SYSTEM_SwigPyIterator self, IMP_SYSTEM_SwigPyIterator x) -> ptrdiff_t
157  """
158  return _IMP_system.IMP_SYSTEM_SwigPyIterator___sub__(self, *args)
159 
160  def __iter__(self): return self
161 IMP_SYSTEM_SwigPyIterator_swigregister = _IMP_system.IMP_SYSTEM_SwigPyIterator_swigregister
162 IMP_SYSTEM_SwigPyIterator_swigregister(IMP_SYSTEM_SwigPyIterator)
163 
164 _value_types=[]
165 _object_types=[]
166 _raii_types=[]
167 _plural_types=[]
168 
169 IMP_HAS_DEPRECATED = _IMP_system.IMP_HAS_DEPRECATED
170 IMP_DEBUG = _IMP_system.IMP_DEBUG
171 IMP_RELEASE = _IMP_system.IMP_RELEASE
172 IMP_SILENT = _IMP_system.IMP_SILENT
173 IMP_PROGRESS = _IMP_system.IMP_PROGRESS
174 IMP_TERSE = _IMP_system.IMP_TERSE
175 IMP_VERBOSE = _IMP_system.IMP_VERBOSE
176 IMP_NONE = _IMP_system.IMP_NONE
177 IMP_USAGE = _IMP_system.IMP_USAGE
178 IMP_INTERNAL = _IMP_system.IMP_INTERNAL
179 IMP_COMPILER_HAS_AUTO = _IMP_system.IMP_COMPILER_HAS_AUTO
180 IMP_COMPILER_HAS_DEBUG_VECTOR = _IMP_system.IMP_COMPILER_HAS_DEBUG_VECTOR
181 IMP_COMPILER_HAS_NULLPTR = _IMP_system.IMP_COMPILER_HAS_NULLPTR
182 IMP_BASE_HAS_BOOST_RANDOM = _IMP_system.IMP_BASE_HAS_BOOST_RANDOM
183 IMP_BASE_HAS_GPERFTOOLS = _IMP_system.IMP_BASE_HAS_GPERFTOOLS
184 IMP_BASE_HAS_LOG4CXX = _IMP_system.IMP_BASE_HAS_LOG4CXX
185 IMP_BASE_HAS_TCMALLOC_HEAPCHECKER = _IMP_system.IMP_BASE_HAS_TCMALLOC_HEAPCHECKER
186 IMP_BASE_HAS_TCMALLOC_HEAPPROFILER = _IMP_system.IMP_BASE_HAS_TCMALLOC_HEAPPROFILER
187 import sys
188 class _DirectorObjects(object):
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 
206 
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 DEFAULT_CHECK = _IMP_system.DEFAULT_CHECK
214 NONE = _IMP_system.NONE
215 USAGE = _IMP_system.USAGE
216 USAGE_AND_INTERNAL = _IMP_system.USAGE_AND_INTERNAL
217 
218 def set_check_level(*args):
219  """set_check_level(IMP::base::CheckLevel tf)"""
220  return _IMP_system.set_check_level(*args)
221 
222 def get_check_level():
223  """get_check_level() -> IMP::base::CheckLevel"""
224  return _IMP_system.get_check_level()
225 class _ostream(_object):
226  """Proxy of C++ std::ostream class"""
227  __swig_setmethods__ = {}
228  __setattr__ = lambda self, name, value: _swig_setattr(self, _ostream, name, value)
229  __swig_getmethods__ = {}
230  __getattr__ = lambda self, name: _swig_getattr(self, _ostream, name)
231  def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
232  __repr__ = _swig_repr
233  def write(self, *args):
234  """write(_ostream self, char const * osa_buf)"""
235  return _IMP_system._ostream_write(self, *args)
236 
237 _ostream_swigregister = _IMP_system._ostream_swigregister
238 _ostream_swigregister(_ostream)
239 
240 IMP_COMPILER_HAS_OVERRIDE = _IMP_system.IMP_COMPILER_HAS_OVERRIDE
241 IMP_COMPILER_HAS_FINAL = _IMP_system.IMP_COMPILER_HAS_FINAL
242 import IMP.base
243 IMP_CGAL_HAS_BOOST_FILESYSTEM = _IMP_system.IMP_CGAL_HAS_BOOST_FILESYSTEM
244 IMP_CGAL_HAS_BOOST_PROGRAMOPTIONS = _IMP_system.IMP_CGAL_HAS_BOOST_PROGRAMOPTIONS
245 IMP_CGAL_HAS_BOOST_RANDOM = _IMP_system.IMP_CGAL_HAS_BOOST_RANDOM
246 IMP_CGAL_HAS_BOOST_SYSTEM = _IMP_system.IMP_CGAL_HAS_BOOST_SYSTEM
247 import IMP.cgal
248 IMP_ALGEBRA_HAS_IMP_CGAL = _IMP_system.IMP_ALGEBRA_HAS_IMP_CGAL
249 IMP_ALGEBRA_HAS_BOOST_FILESYSTEM = _IMP_system.IMP_ALGEBRA_HAS_BOOST_FILESYSTEM
250 IMP_ALGEBRA_HAS_BOOST_PROGRAMOPTIONS = _IMP_system.IMP_ALGEBRA_HAS_BOOST_PROGRAMOPTIONS
251 IMP_ALGEBRA_HAS_BOOST_RANDOM = _IMP_system.IMP_ALGEBRA_HAS_BOOST_RANDOM
252 IMP_ALGEBRA_HAS_BOOST_SYSTEM = _IMP_system.IMP_ALGEBRA_HAS_BOOST_SYSTEM
253 IMP_ALGEBRA_HAS_CGAL = _IMP_system.IMP_ALGEBRA_HAS_CGAL
254 IMP_ALGEBRA_HAS_ANN = _IMP_system.IMP_ALGEBRA_HAS_ANN
255 import IMP.algebra
256 IMP_KERNEL_HAS_IMP_CGAL = _IMP_system.IMP_KERNEL_HAS_IMP_CGAL
257 IMP_KERNEL_HAS_BOOST_PROGRAMOPTIONS = _IMP_system.IMP_KERNEL_HAS_BOOST_PROGRAMOPTIONS
258 IMP_KERNEL_HAS_BOOST_RANDOM = _IMP_system.IMP_KERNEL_HAS_BOOST_RANDOM
259 IMP_KERNEL_HAS_BOOST_SYSTEM = _IMP_system.IMP_KERNEL_HAS_BOOST_SYSTEM
260 IMP_KERNEL_HAS_CGAL = _IMP_system.IMP_KERNEL_HAS_CGAL
261 import IMP.kernel
262 IMP_SYSTEM_HAS_IMP_ALGEBRA = _IMP_system.IMP_SYSTEM_HAS_IMP_ALGEBRA
263 IMP_SYSTEM_HAS_IMP_BASE = _IMP_system.IMP_SYSTEM_HAS_IMP_BASE
264 IMP_SYSTEM_HAS_IMP_CGAL = _IMP_system.IMP_SYSTEM_HAS_IMP_CGAL
265 IMP_SYSTEM_HAS_BOOST_FILESYSTEM = _IMP_system.IMP_SYSTEM_HAS_BOOST_FILESYSTEM
266 IMP_SYSTEM_HAS_BOOST_PROGRAMOPTIONS = _IMP_system.IMP_SYSTEM_HAS_BOOST_PROGRAMOPTIONS
267 IMP_SYSTEM_HAS_BOOST_RANDOM = _IMP_system.IMP_SYSTEM_HAS_BOOST_RANDOM
268 IMP_SYSTEM_HAS_BOOST_SYSTEM = _IMP_system.IMP_SYSTEM_HAS_BOOST_SYSTEM
269 IMP_SYSTEM_HAS_CGAL = _IMP_system.IMP_SYSTEM_HAS_CGAL
270 import sys
271 import re
272 import os
273 import os.path
274 from optparse import OptionParser
275 
276 def _get_script_name():
277  return os.path.splitext(os.path.split(sys.argv[0])[1])[0]
278 
279 def _get_script_path():
280  return os.path.split(sys.argv[0])[0]
281 
282 def _get_is_sample():
283  return _get_script_name().startswith("sample")
284 
285 def _get_number_of_samples():
286  for i in range(0,100):
287  if not os.path.exists(os.path.join(_get_script_path(),
288  "sample_"+str(i)+".py")):
289  return i
290 
291 def _get_is_analysis():
292  return _get_script_name().startswith("analyze")
293 
294 def _get_is_setup():
295  return _get_script_name() == "setup"
296 
297 
298 def _get_script_index():
299  return int(_get_script_name().split("_")[1])
300 
301 def _get_default_input():
302  if _get_is_sample() and _get_script_index()==0:
303  return "setup"
304  elif _get_is_sample():
305  return "sampled_"+str(_get_script_index()-1)
306  elif _get_is_analysis() and _get_script_index()==0:
307  return "sampled_"+str(_get_number_of_samples()-1)
308  elif _get_is_analysis():
309  return "analyzed_"+str(_get_script_index()-1)
310  else:
311  raise ValueError("bad script name, expect sample_n or analyze_n")
312 
313 def _get_default_output():
314  if _get_is_sample():
315  return "sampled_"+str(_get_script_index())
316  elif _get_is_analysis():
317  return "analyzed_"+str(_get_script_index())
318  elif _get_is_setup():
319  return "setup"
320 
321 
322 def _is_sample():
323  ptn="sample_.*.py"
324  r= re.compile(ptn)
325  nm= os.path.split(sys.argv[0])[1]
326  #print nm, r.match(nm), ptn
327  return r.search(nm)
328 
329 def _is_sample_0():
330  return sys.argv[0].endswith("sample_0.py")
331 
332 
333 
334 def _create_parser():
335  parser = OptionParser(usage='%prog [options]')
336  parser.add_option(
337  '-o', '--output-dir', dest='output_dir', default='auto',
338  help='Where to put the output for the script',
339  )
340  if not _is_sample_0():
341  parser.add_option(
342  '-i', '--input-dir', dest='input_dir', default='auto',
343  help='Where to find input for the script',
344  )
345  parser.add_option(
346  '-d', '--data-dir', dest='data_dir', default='auto',
347  help='Where to find data for the script',
348  )
349  if _is_sample():
350  parser.add_option(
351  '-j', '--job', dest='job_index',
352  help='The index for the current job')
353  parser.add_option(
354  '-n', '--num-jobs', dest='num_jobs',
355  help='The total number of jobs to divide things into')
356  parser.add_option(
357  '-t', '--test', action="store_true", default=False, dest='test',
358  help='Just run a smaller version of the sampling to test things.')
359  return parser
360 
361 parser=_create_parser()
362 (options, args) = parser.parse_args()
363 
365  """Return the index and the number of parts to divide the job in to."""
366  if options.test:
367  if options.job_index or options.num_jobs:
368  parser.error("--test and -j or -n cannot be specified at "
369  "the same time.")
370  return (0, 1000)
371  return (int(options.job_index),int(options.num_jobs))
372 
373 def get_is_test():
374  """Return whether this run is called with --test. Scripts that use this
375  can't don't expect -j and -n and so an error will be thrown if
376  they are passed."""
377  if options.job_index or options.num_jobs:
378  parser.error("This sampling script cannot be broken up into jobs. "
379  "Only --test is supported.")
380  return options.test
381 
382 
383 
384 def get_input_path(name):
385  """Get the path where the current script should find output of the
386  last script"""
387  id=options.input_dir
388  if id=="auto":
389  id= _get_default_input()
390  return os.path.join(id, name)
391 
392 def get_output_path(name):
393  """Get the path to where the current script should write output files"""
394  od=options.output_dir
395  if od=="auto":
396  od= _get_default_output()
397  if not os.path.exists(od):
398  os.makedirs(od)
399  return os.path.join(od, name)
400 
401 
402 def get_data_input_path(name):
403  """Get the path where the current script should find data files"""
404  da= options.data_dir
405  if da=="auto":
406  da= os.path.join(os.path.split(sys.argv[0])[0], "data")
407  return os.path.join(da, name)
408 
409 
410 def get_module_version():
411  """get_module_version() -> std::string const"""
412  return _IMP_system.get_module_version()
413 
414 def get_example_path(*args):
415  """get_example_path(std::string fname) -> std::string"""
416  return _IMP_system.get_example_path(*args)
417 
418 def get_data_path(*args):
419  """get_data_path(std::string fname) -> std::string"""
420  return _IMP_system.get_data_path(*args)
421 import _version_check
422 _version_check.check_version(get_module_version())
423 
424 # This file is compatible with both classic and new-style classes.
425 
426