IMP  2.0.1
The Integrative Modeling Platform
IMP::base Namespace Reference

See IMP.base Overview for more information.

Classes

struct  AddBoolFlag
 
struct  AddFloatFlag
 
struct  AddIntFlag
 
struct  AddStringFlag
 
class  Array
 A class to store an fixed array of same-typed values. More...
 
class  ConstVector
 Store an array of values of the same type. More...
 
class  CreateLogContext
 Create a new log context. More...
 
class  EventException
 An exception that signifies some event occurred. More...
 
class  Exception
 The general base class for IMP exceptions. More...
 
class  Index
 
class  IndexException
 An exception for a request for an invalid member of a container. More...
 
class  IndexVector
 
class  InputAdaptor
 
struct  InternalException
 A general exception for an intenal error in IMP. More...
 
class  IOException
 An input/output exception. More...
 
class  LRUCache
 
class  map
 
class  Memoizer
 
class  ModelException
 An exception which is thrown when the Model has attributes with invalid values. More...
 
class  NonCopyable
 
class  Object
 Common base class for heavy weight IMP objects. More...
 
struct  OwnerPointer
 A reference counted pointer to an Object. More...
 
class  piecewise_linear_distribution
 
struct  Pointer
 A reference counted pointer to an object. More...
 
class  RAII
 
class  RefCounted
 Common base class for ref counted objects. More...
 
class  set
 
class  SetCheckState
 A class to change and restore check state. More...
 
class  SetLogState
 A class to change and restore log state. More...
 
class  SetLogTarget
 
class  SetNumberOfThreads
 
class  Showable
 
class  SparseSymmetricPairMemoizer
 
class  TextInput
 
class  TextOutput
 
class  TrackedObject
 
class  Tracker
 
struct  UncheckedWeakPointer
 A weak pointer to an IMP::Object or IMP::RefCountedObject. More...
 
class  UsageException
 An exception for an invalid usage of IMP. More...
 
class  Value
 
class  ValueException
 An exception for an invalid value being passed to IMP. More...
 
class  Vector
 
class  VersionInfo
 Version and module information for Objects. More...
 
struct  WarningContext
 
struct  WeakPointer
 

Typedefs

typedef IMP::base::Vector
< IMP::base::Pointer< Object > > 
Objects
 A list of objects. More...
 
typedef ::boost::rand48 RandomNumberGenerator
 
typedef IMP::base::Vector
< SetCheckState
SetCheckStates
 
typedef IMP::base::Vector
< SetLogState
SetLogStates
 
typedef IMP::base::Vector
< TextInput
TextInputs
 
typedef IMP::base::Vector
< TextOutput
TextOutputs
 
typedef IMP::base::Vector
< VersionInfo
VersionInfos
 

Enumerations

enum  CheckLevel { DEFAULT_CHECK = -1, NONE = 0, USAGE = 1, USAGE_AND_INTERNAL = 2 }
 Specify the level of runtime checks performed. More...
 
enum  LogLevel {
  DEFAULT = -1, SILENT = 0, WARNING = 0 +1, PROGRESS = 2,
  TERSE = 3, VERBOSE = 4, MEMORY = 4 +1
}
 The log levels supported by IMP. More...
 

Functions

TextOutput create_temporary_file (std::string prefix="imp_temp", std::string suffix="")
 
std::string create_temporary_file_name (std::string prefix="imp_temp", std::string suffix="")
 
template<class Tag >
unsigned int get_as_unsigned_int (Index< Tag > i)
 
std::string get_data_path (std::string file_name)
 Return the full path to installed data. More...
 
std::string get_example_path (std::string file_name)
 Return the path to installed example data for this module. More...
 
template<class Tag >
Index< Tag > get_invalid_index ()
 
Strings get_live_object_names ()
 
Objects get_live_objects ()
 
TextOutput get_log_target ()
 
boost::uint64_t get_random_seed ()
 
std::string get_relative_path (std::string base, std::string relative)
 
std::string get_unique_name (std::string templ)
 
template<class T >
std::size_t hash_value (const T &t)
 
std::size_t hash_value (double d)
 
std::size_t hash_value (int d)
 
std::size_t hash_value (bool d)
 
std::size_t hash_value (const std::string &d)
 
template<class T >
std::size_t hash_value (const std::vector< T > &t)
 
template<class T >
std::size_t hash_value (const __gnu_debug::vector< T > &t)
 
template<class T >
bool isinf (const T &a)
 Return true if a number is infinite.
 
template<class T >
bool isnan (const T &a)
 Return true if a number is NaN. More...
 
template<class O >
O * object_cast (Object *o)
 
std::ostream & operator<< (std::ostream &out, const Showable &s)
 
template<class Tag , class Container , class T >
void resize_to_fit (Container &v, Index< Tag > i, const T &default_value=T())
 
void set_log_target (TextOutput l)
 Set the target for the log. More...
 
void set_print_deprecation_messages (bool tf)
 Toggle printing of warnings on using deprecated classes. More...
 
void set_show_leaked_objects (bool tf)
 
template<class A >
void swap (ConstVector< A > &a, ConstVector< A > &b)
 
void write_help (std::ostream &out=std::cerr)
 

Variables

RandomNumberGenerator random_number_generator
 A shared random number generator. More...
 
bool run_quick_test
 

Standard module methods

All IMP modules have a set of standard methods to help get information about the module and about files associated with the module.

std::string get_module_version ()
 
std::string get_module_name ()
 

Error checking and reporting

By default IMP performs a variety of runtime error checks. These can be controlled using the IMP::set_check_level function. Call IMP::set_check_level with IMP::NONE to disable all checks when you are performing your optimization as opposed to testing your code. Make sure you run your code with the level set to at least USAGE before running your final optimization to make sure that IMP is used correctly.

Error handling is provided by IMP/exception.h,

Use the gdbinit file provided in tools to automatically have gdb break when IMP errors are detected.

void set_check_level (CheckLevel tf)
 Control runtime checks in the code. More...
 
CheckLevel get_check_level ()
 Get the current audit mode.
 
void handle_error (const char *msg)
 

Flags

These methods add support for shared command line flags to IMP. Programs that use this have access to flags declared in modules which allow users to do things like control log level and turn on and off profiling to see what is going on. These functions are python accessible.

In C++, you can also use the AddFloatFlag, AddStringFlag, AddBoolFlag and AddIntFlag classes to add flags statically.

std::string get_executable_name ()
 
void setup_from_argv (int argc, char **argv, std::string description)
 
Strings setup_from_argv (int argc, char **argv, std::string description, std::string positional_description, int num_positional)
 
void setup_from_argv (const Strings &argv, std::string description)
 
Strings setup_from_argv (const Strings &argv, std::string description, std::string positional_description, int num_positional)
 
void add_string_flag (std::string name, std::string default_value, std::string description)
 
std::string get_string_flag (std::string name)
 
void add_int_flag (std::string name, size_t default_value, std::string description)
 
size_t get_int_flag (std::string name)
 
void add_bool_flag (std::string name, std::string description)
 
bool get_bool_flag (std::string name)
 
void add_float_flag (std::string name, double default_value, std::string description)
 
double get_float_flag (std::string name)
 

Logging

IMP provides tools for controlling the amount of log output produced and directing it to the terminal or a file. Only log messages tagged with a lower level than the current LogLevel are emitted. In addition to a global log level (get_log_level(), set_log_level()), each IMP::Object has an internal log level (IMP::Object::get_log_level(), IMP::Object::set_log_level()) which is used when executing code on that object.

Logging is provided by IMP/log.h.

People implementing IMP::Object classes should also see IMP_OBJECT_LOG() and IMP::SetLogState.

All logging is disabled when IMP is built using build='fast'.

void add_to_log (LogLevel level, std::string to_write)
 Write a string to the log, for python.
 
void set_log_level (LogLevel l)
 Set the current global log level. More...
 
void set_log_timer (bool tb)
 Set whether log messages are tagged with the current log time.
 
void reset_log_timer ()
 Reset the log timer.
 
LogLevel get_log_level ()
 Get the currently active log level. More...
 

Create a progress bar in the terminal

void set_progress_display (std::string description, unsigned int steps)
 
void add_to_progress_display (unsigned int step=1)
 

Number of threads

Get and set the default number of threads to use in IMP.

unsigned int get_number_of_threads ()
 
void set_number_of_threads (unsigned int n)
 

Typedef Documentation

Store a set of objects.

Definition at line 61 of file types.h.

Pass or store a set of SetCheckState .

Definition at line 58 of file SetCheckState.h.

Pass or store a set of SetLogState .

Definition at line 54 of file SetLogState.h.

Pass or store a set of TextInput .

Definition at line 158 of file base/file.h.

Pass or store a set of TextOutput .

Definition at line 159 of file base/file.h.

Pass or store a set of VersionInfo .

Definition at line 49 of file base/VersionInfo.h.

Enumeration Type Documentation

Enumerator
DEFAULT_CHECK 

Use the default check level (eg IMP::base::Object::set_check_level()).

NONE 

Perform no runtime checks.

USAGE 

Perform checks that IMP is being called correctly.

USAGE_AND_INTERNAL 

Check internal IMP invariants. This is to be used for debugging IMP.

Definition at line 53 of file enums.h.

Enumerator
DEFAULT 

Use to specify that the global log level should be used (eg in IMP::base::Object::set_log_level())

SILENT 

Do not output any text.

WARNING 

Output only warnings.

PROGRESS 

Output only progress meter style displays and occasional printouts when switching phases of work.

TERSE 

Output a line or two per evaluation call.

VERBOSE 

Produce copious output to allow someone to trace through the computation.

MEMORY 

Log memory allocations and frees.

Definition at line 18 of file enums.h.

Function Documentation

void IMP::base::add_bool_flag ( std::string  name,
std::string  description 
)

For python use. Default is always false.

void IMP::base::add_float_flag ( std::string  name,
double  default_value,
std::string  description 
)

For python use.

void IMP::base::add_int_flag ( std::string  name,
size_t  default_value,
std::string  description 
)

For python use.

void IMP::base::add_string_flag ( std::string  name,
std::string  default_value,
std::string  description 
)

For python use.

void IMP::base::add_to_progress_display ( unsigned int  step = 1)

Set the current progress. When it equals the number of steps, the bar is done.

TextOutput IMP::base::create_temporary_file ( std::string  prefix = "imp_temp",
std::string  suffix = "" 
)

Create a temporary file. The path can be extracted from the TextOutput.

If suffix is non-empty, there is some small chance of a collision on non-BSD systems as a unique temporary file is first created, and then a file with that suffix appended is created.

std::string IMP::base::create_temporary_file_name ( std::string  prefix = "imp_temp",
std::string  suffix = "" 
)

Create a temporary file.

If suffix is non-empty, there is some small chance of a collision on non-BSD systems as a unique temporary file is first created, and then a file with that suffix appended is created.

bool IMP::base::get_bool_flag ( std::string  name)

For python use.

std::string IMP::base::get_data_path ( std::string  file_name)

Each module has its own data directory, so be sure to use the version of this function in the correct module. To read the data file "data_library" that was placed in the data directory of module "mymodule", do something like

std::ifstream in(IMP::mymodule::get_data_path("data_library"));

This will ensure that the code works when IMP is installed or used via the tools/imppy.sh script.

std::string IMP::base::get_example_path ( std::string  file_name)

Each module has its own example directory, so be sure to use the version of this function in the correct module. For example to read the file example_protein.pdb located in the examples directory of the IMP::atom module, do

IMP::atom::read_pdb(IMP::atom::get_example_path("example_protein.pdb", model));

This will ensure that the code works when IMP is installed or used via the tools/imppy.sh script.

std::string IMP::base::get_executable_name ( )

Return the name of the current executable.

double IMP::base::get_float_flag ( std::string  name)

For python use.

size_t IMP::base::get_int_flag ( std::string  name)

For python use.

Strings IMP::base::get_live_object_names ( )

Return the names of all live objects, use this to check for memory leaks.

Objects IMP::base::get_live_objects ( )

Return the points to all live objects, use this to check for memory leaks.

LogLevel IMP::base::get_log_level ( )

This may not always match the value passed to set_log_level() as objects can temporarily override the global level while they are evaluating.

Definition at line 81 of file base/log.h.

unsigned int IMP::base::get_number_of_threads ( )

Get the current number of threads requested.

boost::uint64_t IMP::base::get_random_seed ( )

Return the initial random seed.

std::string IMP::base::get_relative_path ( std::string  base,
std::string  relative 
)

Return a path to a file relative to another file. For example if base is path/to/config.file and relative is data/image0.jpg then the return value would be path/to/data/image0.jpg. This function should be used when processing configuration files so that the meaning of the configuration file does not change if current working directory changes.

std::string IMP::base::get_string_flag ( std::string  name)

For python use.

std::string IMP::base::get_unique_name ( std::string  templ)

Return a unique name produced from the string by replacing %1% with a sequential number.

void IMP::base::handle_error ( const char *  msg)

This function is called whenever IMP detects an error. It can be useful to add a breakpoint in the function when using a debugger.

template<class T >
bool IMP::base::isnan ( const T &  a)

With certain compiler settings the compiler can optimize out a!=a (and certain intel chips had issues with it too).

Definition at line 24 of file math.h.

template<class O >
O* IMP::base::object_cast ( Object *  o)

Up (or down) cast an IMP Object-derived class. If the cast does not succeed a ValueException will be thrown. Use a dynamic_cast if you prefer to have a nullptr returned.

Definition at line 24 of file object_cast.h.

void IMP::base::set_check_level ( CheckLevel  tf)

The default level of checks is USAGE for release builds and USAGE_AND_INTERNAL for debug builds.

Definition at line 80 of file base/exception.h.

void IMP::base::set_log_level ( LogLevel  l)

Note that this should not, currently, be used directly during Model::evaluate() calls.

void IMP::base::set_log_target ( TextOutput  l)

See TextOutput for options. Python users should use SetLogTarget instead.

void IMP::base::set_number_of_threads ( unsigned int  n)

Set the current number of threads to a number greater or equal to 1. Setting it to 1 disables multithreaded evaluation.

void IMP::base::set_print_deprecation_messages ( bool  tf)

If set to true (the default) a warning is printed every time a class marked as deprecated is used.

See Also
IMP_DEPRECATED
void IMP::base::set_progress_display ( std::string  description,
unsigned int  steps 
)

Set up the progress bar with the passed description.

See IMP_PROGRESS_DISPLAY().

void IMP::base::set_show_leaked_objects ( bool  tf)

Set whether to complain about objects not being properly cleaned up.

void IMP::base::setup_from_argv ( int  argc,
char **  argv,
std::string  description 
)

Parse the command line flags and return the positional arguments.

Parameters
[in]argcargc
[in]argvargv
[in]descriptionA message describing what the program does.
Examples:
atom/dope_and_excluded_volume.cpp.
Strings IMP::base::setup_from_argv ( int  argc,
char **  argv,
std::string  description,
std::string  positional_description,
int  num_positional 
)

Parse the command line flags and return the positional arguments.

Parameters
[in]argcargc
[in]argvargv
[in]descriptionA message describing what the program does.
[in]positional_descriptionA message describing the the positional arguments
[in]num_positionalA positive integer to require that many positional arguments, or a negative integer to require at least that many.
void IMP::base::setup_from_argv ( const Strings &  argv,
std::string  description 
)

Parse the command line flags and return the positional arguments. For python.

Parameters
[in]argvsys.argv
[in]descriptionA message describing what the program does.
Strings IMP::base::setup_from_argv ( const Strings &  argv,
std::string  description,
std::string  positional_description,
int  num_positional 
)

Parse the command line flags and return the positional arguments. For python.

Parameters
[in]argvsys.argv
[in]descriptionA message describing what the program does.
[in]positional_descriptionA message describing the positional arguments, eg "input.pdb output.pdb"
[in]num_positionalA positive integer to require that many positional arguments, or a negative integer to require at least that many.
void IMP::base::write_help ( std::ostream &  out = std::cerr)

Prints out the help message, useful if you have extra error checking and the flags don't pass it.

Variable Documentation

RandomNumberGenerator IMP::base::random_number_generator
The random number generator is seeded based of of the current time. To
provide a better seed or use a constant seed call
random_number_generator.seed(x) with a 32 bit int or a 64 bit unsigned int.

This generator can be used by the

Boost.Random distributions.

bool IMP::base::run_quick_test

Executables can inspect this flag and when it is true, run a shorter, simpler version of their code to just make sure things work.