11 from sys
import version_info
12 if version_info >= (2,6,0):
13 def swig_import_helper():
14 from os.path
import dirname
18 fp, pathname, description = imp.find_module(
'_IMP_system', [dirname(__file__)])
24 _mod = imp.load_module(
'_IMP_system', fp, pathname, description)
28 _IMP_system = swig_import_helper()
29 del swig_import_helper
34 _swig_property = property
37 def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
38 if (name ==
"thisown"):
return self.this.own(value)
40 if type(value).__name__ ==
'SwigPyObject':
41 self.__dict__[name] = value
43 method = class_type.__swig_setmethods__.get(name,
None)
44 if method:
return method(self,value)
46 self.__dict__[name] = value
48 raise AttributeError(
"You cannot add attributes to %s" % self)
50 def _swig_setattr(self,class_type,name,value):
51 return _swig_setattr_nondynamic(self,class_type,name,value,0)
53 def _swig_getattr(self,class_type,name):
54 if (name ==
"thisown"):
return self.this.own()
55 method = class_type.__swig_getmethods__.get(name,
None)
56 if method:
return method(self)
57 raise AttributeError(name)
60 try: strthis =
"proxy of " + self.this.__repr__()
62 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
67 except AttributeError:
74 weakref_proxy = weakref.proxy
76 weakref_proxy =
lambda x: x
79 class IMP_SYSTEM_SwigPyIterator(_object):
80 """Proxy of C++ swig::IMP_SYSTEM_SwigPyIterator class"""
81 __swig_setmethods__ = {}
82 __setattr__ =
lambda self, name, value: _swig_setattr(self, IMP_SYSTEM_SwigPyIterator, name, value)
83 __swig_getmethods__ = {}
84 __getattr__ =
lambda self, name: _swig_getattr(self, IMP_SYSTEM_SwigPyIterator, name)
85 def __init__(self, *args, **kwargs):
raise AttributeError(
"No constructor defined - class is abstract")
87 __swig_destroy__ = _IMP_system.delete_IMP_SYSTEM_SwigPyIterator
88 __del__ =
lambda self :
None;
90 """value(IMP_SYSTEM_SwigPyIterator self) -> PyObject *"""
91 return _IMP_system.IMP_SYSTEM_SwigPyIterator_value(self)
95 incr(IMP_SYSTEM_SwigPyIterator self, size_t n=1) -> IMP_SYSTEM_SwigPyIterator
96 incr(IMP_SYSTEM_SwigPyIterator self) -> IMP_SYSTEM_SwigPyIterator
98 return _IMP_system.IMP_SYSTEM_SwigPyIterator_incr(self, n)
102 decr(IMP_SYSTEM_SwigPyIterator self, size_t n=1) -> IMP_SYSTEM_SwigPyIterator
103 decr(IMP_SYSTEM_SwigPyIterator self) -> IMP_SYSTEM_SwigPyIterator
105 return _IMP_system.IMP_SYSTEM_SwigPyIterator_decr(self, n)
107 def distance(self, *args):
108 """distance(IMP_SYSTEM_SwigPyIterator self, IMP_SYSTEM_SwigPyIterator x) -> ptrdiff_t"""
109 return _IMP_system.IMP_SYSTEM_SwigPyIterator_distance(self, *args)
111 def equal(self, *args):
112 """equal(IMP_SYSTEM_SwigPyIterator self, IMP_SYSTEM_SwigPyIterator x) -> bool"""
113 return _IMP_system.IMP_SYSTEM_SwigPyIterator_equal(self, *args)
116 """copy(IMP_SYSTEM_SwigPyIterator self) -> IMP_SYSTEM_SwigPyIterator"""
117 return _IMP_system.IMP_SYSTEM_SwigPyIterator_copy(self)
120 """next(IMP_SYSTEM_SwigPyIterator self) -> PyObject *"""
121 return _IMP_system.IMP_SYSTEM_SwigPyIterator_next(self)
124 """__next__(IMP_SYSTEM_SwigPyIterator self) -> PyObject *"""
125 return _IMP_system.IMP_SYSTEM_SwigPyIterator___next__(self)
128 """previous(IMP_SYSTEM_SwigPyIterator self) -> PyObject *"""
129 return _IMP_system.IMP_SYSTEM_SwigPyIterator_previous(self)
131 def advance(self, *args):
132 """advance(IMP_SYSTEM_SwigPyIterator self, ptrdiff_t n) -> IMP_SYSTEM_SwigPyIterator"""
133 return _IMP_system.IMP_SYSTEM_SwigPyIterator_advance(self, *args)
135 def __eq__(self, *args):
136 """__eq__(IMP_SYSTEM_SwigPyIterator self, IMP_SYSTEM_SwigPyIterator x) -> bool"""
137 return _IMP_system.IMP_SYSTEM_SwigPyIterator___eq__(self, *args)
139 def __ne__(self, *args):
140 """__ne__(IMP_SYSTEM_SwigPyIterator self, IMP_SYSTEM_SwigPyIterator x) -> bool"""
141 return _IMP_system.IMP_SYSTEM_SwigPyIterator___ne__(self, *args)
143 def __iadd__(self, *args):
144 """__iadd__(IMP_SYSTEM_SwigPyIterator self, ptrdiff_t n) -> IMP_SYSTEM_SwigPyIterator"""
145 return _IMP_system.IMP_SYSTEM_SwigPyIterator___iadd__(self, *args)
147 def __isub__(self, *args):
148 """__isub__(IMP_SYSTEM_SwigPyIterator self, ptrdiff_t n) -> IMP_SYSTEM_SwigPyIterator"""
149 return _IMP_system.IMP_SYSTEM_SwigPyIterator___isub__(self, *args)
151 def __add__(self, *args):
152 """__add__(IMP_SYSTEM_SwigPyIterator self, ptrdiff_t n) -> IMP_SYSTEM_SwigPyIterator"""
153 return _IMP_system.IMP_SYSTEM_SwigPyIterator___add__(self, *args)
155 def __sub__(self, *args):
157 __sub__(IMP_SYSTEM_SwigPyIterator self, ptrdiff_t n) -> IMP_SYSTEM_SwigPyIterator
158 __sub__(IMP_SYSTEM_SwigPyIterator self, IMP_SYSTEM_SwigPyIterator x) -> ptrdiff_t
160 return _IMP_system.IMP_SYSTEM_SwigPyIterator___sub__(self, *args)
162 def __iter__(self):
return self
163 IMP_SYSTEM_SwigPyIterator_swigregister = _IMP_system.IMP_SYSTEM_SwigPyIterator_swigregister
164 IMP_SYSTEM_SwigPyIterator_swigregister(IMP_SYSTEM_SwigPyIterator)
171 IMP_DEBUG = _IMP_system.IMP_DEBUG
172 IMP_RELEASE = _IMP_system.IMP_RELEASE
173 IMP_SILENT = _IMP_system.IMP_SILENT
174 IMP_PROGRESS = _IMP_system.IMP_PROGRESS
175 IMP_TERSE = _IMP_system.IMP_TERSE
176 IMP_VERBOSE = _IMP_system.IMP_VERBOSE
177 IMP_MEMORY = _IMP_system.IMP_MEMORY
178 IMP_NONE = _IMP_system.IMP_NONE
179 IMP_USAGE = _IMP_system.IMP_USAGE
180 IMP_INTERNAL = _IMP_system.IMP_INTERNAL
181 IMP_BASE_HAS_LOG4CXX = _IMP_system.IMP_BASE_HAS_LOG4CXX
182 IMP_COMPILER_HAS_AUTO = _IMP_system.IMP_COMPILER_HAS_AUTO
183 IMP_COMPILER_HAS_DEBUG_VECTOR = _IMP_system.IMP_COMPILER_HAS_DEBUG_VECTOR
184 IMP_BASE_HAS_BOOST_RANDOM = _IMP_system.IMP_BASE_HAS_BOOST_RANDOM
185 IMP_BASE_HAS_GPERFTOOLS = _IMP_system.IMP_BASE_HAS_GPERFTOOLS
186 IMP_BASE_HAS_TCMALLOC_HEAPCHECKER = _IMP_system.IMP_BASE_HAS_TCMALLOC_HEAPCHECKER
187 IMP_BASE_HAS_TCMALLOC_HEAPPROFILER = _IMP_system.IMP_BASE_HAS_TCMALLOC_HEAPPROFILER
188 IMPBASE_SHOW_WARNINGS = _IMP_system.IMPBASE_SHOW_WARNINGS
190 class _DirectorObjects(object):
191 """@internal Simple class to keep references to director objects
192 to prevent premature deletion."""
195 def register(self, obj):
196 """Take a reference to a director object; will only work for
197 refcounted C++ classes"""
198 if hasattr(obj,
'get_ref_count'):
199 self._objects.append(obj)
201 """Only drop our reference and allow cleanup by Python if no other
202 Python references exist (we hold 3 references: one in self._objects,
203 one in x, and one in the argument list for getrefcount) *and* no
204 other C++ references exist (the Python object always holds one)"""
205 objs = [x
for x
in self._objects
if sys.getrefcount(x) > 3 \
206 or x.get_ref_count() > 1]
210 def get_object_count(self):
211 """Get number of director objects (useful for testing only)"""
212 return len(self._objects)
213 _director_objects = _DirectorObjects()
215 DEFAULT_CHECK = _IMP_system.DEFAULT_CHECK
216 NONE = _IMP_system.NONE
217 USAGE = _IMP_system.USAGE
218 USAGE_AND_INTERNAL = _IMP_system.USAGE_AND_INTERNAL
221 """set_check_level(IMP::base::CheckLevel tf)"""
222 return _IMP_system.set_check_level(*args)
225 """get_check_level() -> IMP::base::CheckLevel"""
226 return _IMP_system.get_check_level()
227 class _ostream(_object):
228 """Proxy of C++ std::ostream class"""
229 __swig_setmethods__ = {}
230 __setattr__ =
lambda self, name, value: _swig_setattr(self, _ostream, name, value)
231 __swig_getmethods__ = {}
232 __getattr__ =
lambda self, name: _swig_getattr(self, _ostream, name)
233 def __init__(self, *args, **kwargs):
raise AttributeError(
"No constructor defined")
234 __repr__ = _swig_repr
235 def write(self, *args):
236 """write(_ostream self, char const * osa_buf)"""
237 return _IMP_system._ostream_write(self, *args)
239 _ostream_swigregister = _IMP_system._ostream_swigregister
240 _ostream_swigregister(_ostream)
242 IMP_COMPILER_HAS_OVERRIDE = _IMP_system.IMP_COMPILER_HAS_OVERRIDE
243 IMP_COMPILER_HAS_FINAL = _IMP_system.IMP_COMPILER_HAS_FINAL
244 IMP_HAS_NOEXCEPT = _IMP_system.IMP_HAS_NOEXCEPT
246 IMP_CGAL_HAS_BOOST_FILESYSTEM = _IMP_system.IMP_CGAL_HAS_BOOST_FILESYSTEM
247 IMP_CGAL_HAS_BOOST_PROGRAMOPTIONS = _IMP_system.IMP_CGAL_HAS_BOOST_PROGRAMOPTIONS
248 IMP_CGAL_HAS_BOOST_RANDOM = _IMP_system.IMP_CGAL_HAS_BOOST_RANDOM
249 IMP_CGAL_HAS_BOOST_SYSTEM = _IMP_system.IMP_CGAL_HAS_BOOST_SYSTEM
250 IMPCGAL_SHOW_WARNINGS = _IMP_system.IMPCGAL_SHOW_WARNINGS
252 IMP_ALGEBRA_HAS_IMP_CGAL = _IMP_system.IMP_ALGEBRA_HAS_IMP_CGAL
253 IMP_ALGEBRA_HAS_BOOST_FILESYSTEM = _IMP_system.IMP_ALGEBRA_HAS_BOOST_FILESYSTEM
254 IMP_ALGEBRA_HAS_BOOST_PROGRAMOPTIONS = _IMP_system.IMP_ALGEBRA_HAS_BOOST_PROGRAMOPTIONS
255 IMP_ALGEBRA_HAS_BOOST_RANDOM = _IMP_system.IMP_ALGEBRA_HAS_BOOST_RANDOM
256 IMP_ALGEBRA_HAS_BOOST_SYSTEM = _IMP_system.IMP_ALGEBRA_HAS_BOOST_SYSTEM
257 IMP_ALGEBRA_HAS_CGAL = _IMP_system.IMP_ALGEBRA_HAS_CGAL
258 IMP_ALGEBRA_HAS_ANN = _IMP_system.IMP_ALGEBRA_HAS_ANN
259 IMPALGEBRA_SHOW_WARNINGS = _IMP_system.IMPALGEBRA_SHOW_WARNINGS
261 IMP_KERNEL_HAS_IMP_CGAL = _IMP_system.IMP_KERNEL_HAS_IMP_CGAL
262 IMP_KERNEL_HAS_BOOST_PROGRAMOPTIONS = _IMP_system.IMP_KERNEL_HAS_BOOST_PROGRAMOPTIONS
263 IMP_KERNEL_HAS_BOOST_RANDOM = _IMP_system.IMP_KERNEL_HAS_BOOST_RANDOM
264 IMP_KERNEL_HAS_BOOST_SYSTEM = _IMP_system.IMP_KERNEL_HAS_BOOST_SYSTEM
265 IMP_KERNEL_HAS_CGAL = _IMP_system.IMP_KERNEL_HAS_CGAL
266 IMPKERNEL_SHOW_WARNINGS = _IMP_system.IMPKERNEL_SHOW_WARNINGS
268 IMP_SYSTEM_HAS_IMP_ALGEBRA = _IMP_system.IMP_SYSTEM_HAS_IMP_ALGEBRA
269 IMP_SYSTEM_HAS_IMP_BASE = _IMP_system.IMP_SYSTEM_HAS_IMP_BASE
270 IMP_SYSTEM_HAS_IMP_CGAL = _IMP_system.IMP_SYSTEM_HAS_IMP_CGAL
271 IMP_SYSTEM_HAS_BOOST_FILESYSTEM = _IMP_system.IMP_SYSTEM_HAS_BOOST_FILESYSTEM
272 IMP_SYSTEM_HAS_BOOST_PROGRAMOPTIONS = _IMP_system.IMP_SYSTEM_HAS_BOOST_PROGRAMOPTIONS
273 IMP_SYSTEM_HAS_BOOST_RANDOM = _IMP_system.IMP_SYSTEM_HAS_BOOST_RANDOM
274 IMP_SYSTEM_HAS_BOOST_SYSTEM = _IMP_system.IMP_SYSTEM_HAS_BOOST_SYSTEM
275 IMP_SYSTEM_HAS_CGAL = _IMP_system.IMP_SYSTEM_HAS_CGAL
276 IMPSYSTEM_SHOW_WARNINGS = _IMP_system.IMPSYSTEM_SHOW_WARNINGS
281 from optparse
import OptionParser
283 def _get_script_name():
284 return os.path.splitext(os.path.split(sys.argv[0])[1])[0]
286 def _get_script_path():
287 return os.path.split(sys.argv[0])[0]
289 def _get_is_sample():
290 return _get_script_name().startswith(
"sample")
292 def _get_number_of_samples():
293 for i
in range(0,100):
294 if not os.path.exists(os.path.join(_get_script_path(),
295 "sample_"+str(i)+
".py")):
298 def _get_is_analysis():
299 return _get_script_name().startswith(
"analyze")
302 return _get_script_name() ==
"setup"
305 def _get_script_index():
306 return int(_get_script_name().split(
"_")[1])
308 def _get_default_input():
309 if _get_is_sample()
and _get_script_index()==0:
311 elif _get_is_sample():
312 return "sampled_"+str(_get_script_index()-1)
313 elif _get_is_analysis()
and _get_script_index()==0:
314 return "sampled_"+str(_get_number_of_samples()-1)
315 elif _get_is_analysis():
316 return "analyzed_"+str(_get_script_index()-1)
318 raise ValueError(
"bad script name, expect sample_n or analyze_n")
320 def _get_default_output():
322 return "sampled_"+str(_get_script_index())
323 elif _get_is_analysis():
324 return "analyzed_"+str(_get_script_index())
325 elif _get_is_setup():
332 nm= os.path.split(sys.argv[0])[1]
337 return sys.argv[0].endswith(
"sample_0.py")
341 def _create_parser():
344 '-o',
'--output-dir', dest=
'output_dir', default=
'auto',
345 help=
'Where to put the output for the script',
347 if not _is_sample_0():
349 '-i',
'--input-dir', dest=
'input_dir', default=
'auto',
350 help=
'Where to find input for the script',
353 '-d',
'--data-dir', dest=
'data_dir', default=
'auto',
354 help=
'Where to find data for the script',
358 '-j',
'--job', dest=
'job_index',
359 help=
'The index for the current job')
361 '-n',
'--num-jobs', dest=
'num_jobs',
362 help=
'The total number of jobs to divide things into')
364 '-t',
'--test', action=
"store_true", default=
False, dest=
'test',
365 help=
'Just run a smaller version of the sampling to test things.')
368 parser=_create_parser()
369 (options, args) = parser.parse_args()
372 """Return the index and the number of parts to divide the job in to."""
374 if options.job_index
or options.num_jobs:
375 parser.error(
"--test and -j or -n cannot be specified at "
378 return (int(options.job_index),int(options.num_jobs))
381 """Return whether this run is called with --test. Scripts that use this
382 can't don't expect -j and -n and so an error will be thrown if
384 if options.job_index
or options.num_jobs:
385 parser.error(
"This sampling script cannot be broken up into jobs. "
386 "Only --test is supported.")
392 """Get the path where the current script should find output of the
396 id= _get_default_input()
397 return os.path.join(id, name)
400 """Get the path to where the current script should write output files"""
401 od=options.output_dir
403 od= _get_default_output()
404 if not os.path.exists(od):
406 return os.path.join(od, name)
410 """Get the path where the current script should find data files"""
413 da= os.path.join(os.path.split(sys.argv[0])[0],
"data")
414 return os.path.join(da, name)
417 def get_module_version():
418 """get_module_version() -> std::string const"""
419 return _IMP_system.get_module_version()
422 """get_example_path(std::string fname) -> std::string"""
423 return _IMP_system.get_example_path(*args)
426 """get_data_path(std::string fname) -> std::string"""
427 return _IMP_system.get_data_path(*args)
428 import _version_check
429 _version_check.check_version(get_module_version())
def get_output_path
Get the path to where the current script should write output files.
def get_is_test
Return whether this run is called with –test.
std::string get_data_path(std::string file_name)
Return the full path to installed data.
std::string get_example_path(std::string file_name)
Return the path to installed example data for this module.
See IMP.cgal for more information.
void set_check_level(CheckLevel tf)
Control runtime checks in the code.
See IMP.base for more information.
def get_sample_parameters
Return the index and the number of parts to divide the job in to.
See IMP.kernel for more information.
IMP::kernel::OptionParser OptionParser
See IMP.algebra for more information.
def get_data_input_path
Get the path where the current script should find data files.
CheckLevel get_check_level()
Get the current audit mode.
def get_input_path
Get the path where the current script should find output of the last script.