C++ API¶
-
class
bson_oid_t
¶ - #include <MongoObject.h>
- Return
- Parameters
oid_string
:oid
:
-
class
bson_oid_t
- #include <MongoObject.h>
- Return
- Parameters
oid_string
:oid
:
-
class
bson_t
¶ is inspected
- Return
string contained under the
- Parameters
key
:
- Parameters
key
:
-
class
bson_t
is inspected
- Return
string contained under the
- Parameters
key
:
- Parameters
key
:
-
class
Curve
¶ - #include <Curve.h>
This method multiplies to the y-values of the current instance of a object the y-values of another
- Parameters
v
: An object of the typevalid
: If this parameter is false (default value) the y-values are directly multiplied without check for overlap. If this parameter is true only the overlapping y-values are multiplied. The overlap is judged by the values of the x-axis (TODO).
Public Functions
-
void
set_x
(double *input, int n_input)¶
-
void
set_ex
(double *input, int n_input)¶
-
void
set_y
(double *input, int n_input)¶
-
void
set_ey
(double *input, int n_input)¶
-
void
get_x
(double **output, int *n_output)¶
-
void
get_y
(double **output, int *n_output)¶
-
double
sum
()¶
-
size_t
size
()¶
-
Curve
(double *x, unsigned int nx, double *y, unsigned int ny, double *ey, unsigned int ney, std::string name_x, std::string name_y)¶
-
Curve
(double *x, unsigned int nx, double *y, unsigned int ny, std::string name_x, std::string name_y)¶
-
Curve
(double *x, unsigned int nx, double *y, unsigned int ny, double *ey, unsigned int ney)¶
-
Curve
(double *x, unsigned int nx, double *y, unsigned int ny)¶
-
Curve
(double dt, unsigned int nx)¶
-
Curve
()¶
-
~Curve
()¶
-
void
shift
(double value)¶ Shifts the x Axis by a floating point number.
- Parameters
value
:
-
void
resize
(size_t v)¶
Protected Attributes
Friends
-
friend
Curve::Decay
-
class
get_value_vector
¶ This attribute can point to another Port (default value nullptr). If the attribute points to another port, the value returned by the method the value the other Port.
-
class
MongoObject
: public std::enable_shared_from_this<MongoObject>¶ - #include <MongoObject.h>
The object identification number of the.
Disconnects the the DB.
Connects the instance of database.
The BSON document of the
A BSON document containing the document excluding a set of keys
Returns true if the instance of the to the DB
- Return
- Return
a bson_t document
- Parameters
first
: is the first key to exclude....
: more keys to exclude
Writes connected MongoDB
- Return
Subclassed by Node, Port, Session
Public Functions
-
~MongoObject
()¶
-
bool
connect_to_db
(const std::string &uri_string, const std::string &db_string, const std::string &app_string, const std::string &collection_string)¶ - Return
True if connected successfully
- Parameters
uri_string
:db_string
:app_string
:collection_string
:
-
template<typename
T
>
boolconnect_object_to_db
(T o)¶ Connects other object to the same MongoDB
- Return
True if connected successfully
- Template Parameters
T
:
- Parameters
o
: The object that is connected to the same MongoDB
-
void
disconnect_from_db
()¶
-
bool
is_connected_to_db
()¶
-
virtual bool
write_to_db
()¶
-
std::string
create_copy_in_db
()¶ Creates a copy of the object in the connected MongoDB with a new OID.
- Return
The OID of the copy
-
virtual bool
read_from_db
(const std::string &oid_string)¶ Read the content of an existing BSON document into the current object
- Return
True if successful otherwise false
- Parameters
oid_string
: Object identifier of the queried document in the DB
-
bool
read_json
(std::string json_string)¶ Read the content of a JSON string into a MongoObject
- Return
- Parameters
json_string
:
-
void
set_own_oid
(std::string oid_str)¶ Set the own object identifier without duplicate check
- Parameters
oid_str
:
-
std::shared_ptr<MongoObject>
get_ptr
()¶
-
void
set_string
(std::string key, std::string str)¶ Create and / or set a string in the MongoObject accessed by
- Parameters
key
:key
: the key to access the contentstr
: The content
-
void
set_oid
(const char *key, bson_oid_t value)¶
-
virtual std::shared_ptr<MongoObject>
operator[]
(std::string key)¶
-
bool
operator==
(MongoObject const &b)¶
Public Static Functions
-
static std::list<std::shared_ptr<MongoObject>>
get_instances
()¶
Protected Functions
-
bson_oid_t
get_bson_oid
()¶ get_own_bson_oid() Returns the object’s ObjectId value (see: https://docs.mongodb.com/manual/reference/bson-types/#objectid)
- Return
-
const bson_t *
get_document
()¶ Pointer to the BSON document of the MongoObject
- Return
-
bool
write_to_db
(const bson_t &doc, int write_option = 0)¶ Writes a BSON document to the connected MongoDB.
- Return
true in case of a successful write.
- Parameters
doc
: a pointer to the BSON document that is written to the MongoDBwrite_option
: integer specifying the write mode - 1: replaces the document (no upsert), 2: insert the document das a new document, default: updates an existing document.
-
bool
read_from_db
()¶
Protected Static Functions
-
static void
append_string
(bson_t *dst, std::string key, std::string content, size_t size = 0)¶ Append a string to a BSON document
- Parameters
dst
: pointer to the target BSON documentkey
: the key of the string int the target BSON documentcontent
: the string that will be written to the BSON documentsize
: optional parameter for the string size in the BSON document.
-
static std::string
oid_to_string
(bson_oid_t oid)¶
-
static bool
string_to_oid
(const std::string &oid_string, bson_oid_t *oid)¶
Private Members
-
bool
is_connected_to_db_
¶
-
mongoc_uri_t *
uri
¶
-
mongoc_client_t *
client
¶
-
bson_error_t
error
¶
-
mongoc_collection_t *
collection
¶
Private Static Attributes
-
std::list<std::shared_ptr<MongoObject>>
registered_objects
¶
Friends
-
std::ostream &
operator<<
(std::ostream &out, MongoObject &o)¶
-
class
Node
: public MongoObject¶ - #include <CNode.h>
Public Functions
-
~Node
()¶
-
bool
read_from_db
(const std::string &oid_string)¶ Read the content of an existing BSON document into the current object
- Return
True if successful otherwise false
- Parameters
oid_string
: Object identifier of the queried document in the DB
-
void
evaluate
()¶
-
bool
is_valid
()¶
-
bool
inputs_valid
()¶
-
bool
write_to_db
()¶
-
void
set_valid
(bool is_valid = false)¶
Public Members
-
std::shared_ptr<NodeCallback>
callback_class
¶ A pointer to a function that operates on an input Port instance (first argument) and writes to an output Port instance (second argument)
Protected Functions
-
void
fill_input_output_port_lookups
()¶
-
-
class
NodeCallback
¶ - #include <NodeCallback.h>
-
class
Port
: public MongoObject, private std::enable_shared_from_this<Port>¶ - #include <Port.h>
Public Functions
-
size_t
current_size
()¶
-
~Port
()¶
-
Port
(bool fixed = false, bool is_output = false, bool is_reactive = false, bool is_bounded = false, double lb = 0, double ub = 0, int value_type = 1, std::string name = "")¶
-
int
get_value_type
()¶
-
void
set_value_type
(int v)¶
-
template<typename
T
>
voidupdate_buffer
()¶
-
template<typename
T
>
voidget_own_value
(T **output, int *n_output, bool update_local_buffer = false)¶
-
void
update_attached_node
()¶
-
void
set_bounded
(bool bounded)¶
-
bool
bound_is_valid
()¶
-
bool
is_bounded
()¶
-
void
set_bounds
(double *input, int n_input)¶
-
void
get_bounds
(double **output, int *n_output)¶
-
bool
is_fixed
()¶
-
void
set_fixed
(bool fixed)¶
-
bool
is_output
()¶
-
void
set_port_type
(bool is_output)¶
-
bool
is_reactive
()¶
-
bool
is_float
()¶
-
void
set_reactive
(bool reactive)¶
-
bool
write_to_db
()¶
-
bool
read_from_db
(const std::string &oid_string)¶ Read the content of an existing BSON document into the current object
- Return
True if successful otherwise false
- Parameters
oid_string
: Object identifier of the queried document in the DB
-
void
get_bytes
(unsigned char **output, int *n_output, bool copy = false)¶
-
void
set_bytes
(unsigned char *input, int n_input)¶
-
void
set_buffer_ptr
(size_t ptr, int n_elements, int element_size)¶
-
size_t
get_buffer_ptr
()¶
-
bool
unlink
()¶
-
bool
is_linked
()¶
Public Members
-
int
value_type
= 0¶
Private Functions
-
bool
remove_links_to_port
()¶
-
size_t
-
class
Session
: public MongoObject¶ - #include <Session.h>
-
class
string
¶ - #include <MongoObject.h>
- Return
- Parameters
oid
:
-
class
string
- #include <MongoObject.h>
- Return
- Parameters
oid
:
-
namespace
FluorescenceDecay
¶
-
namespace
Functions
¶ Functions
-
void
shift
(double value, std::vector<double> &x)¶ Shifts a vector by a floating number.
This function shifts the y-axis and consider non-integer values by determining the integer part of the shift and the floating part of the shift value, e.g., for the shift 4.66 the integer part is 4 and the floating part is 0.66. Next the array is shifted by the integer part and a copy of the array is shifted by the integer part + 1. Finally, the weighted sum of the both arrays is calculated.
- Parameters
value
:x
:
-
void
copy_vector_to_array
(std::vector<double> &v, double **out, int *nout)¶ Allocates memory on a pointer to an array and copies the content of a vector to the newly allocated memory.
This function is mainly used for numpy array SWIGs
- Parameters
v
:out
:nout
:
-
void
copy_vector_to_array
(std::vector<double> &v, double *out, int nout)¶ Copy an array and copies the content of a vector to already allocated memory.
This function is mainly used for numpy array SWIGs
- Parameters
v
:out
:nout
:
-
void
copy_two_vectors_to_interleaved_array
(std::vector<double> &v1, std::vector<double> &v2, double **out, int *nout)¶ This function copies two vectors of equal size to an interleaved array
- Parameters
v1
:v2
:out
:nout
:
-
template<typename
T
>
voidvalue2internal
(T *values, int n_values, double lower_bound, double upper_bound)¶ Maps the array of values \( max(bound_1, bound_2) - abs(bound_1-bound_2)/(exp(value / abs(bound_1-bound_2))+1) \)
- Parameters
in
: place to values to the interval (min, max) determined by the parametersbound_1
: andbound_2.
: The values are mapped to the interval by:
- Template Parameters
T
: The type of the values
- Parameters
values
: (InOut)n_values
: (In)lower_bound
: (In)upper_bound
: (In)
-
template<typename
T
>
voidinternal2value
(T *values, int n_values, double lower_bound, double upper_bound)¶
-
template<typename
T
>
voidbound_values
(T *values, int n_values, double lower_bound, double upper_bound)¶
-
void
convolve_sum_of_exponentials
(double *out, int n_out, const double *lifetime_spectrum, int n_lifetime_spectrum, const double *irf, int n_irf, int convolution_stop, double dt)¶ This function convolves a sum of exponential decays with an instrument response function (IRF)
The sum of exponential decays is passed by the lifetime array
- Parameters
lifetime_spectrum
: that contains the amplitudes and the corresponding fluorescence lifetimes in an interleaved array (amplitude_1, lifetime_1, amplitude_2, lifetime_2, …). The instrument response function is passed by the arrayirf.
: The IRF and the and the sum of exponential decays are convolved up to the indexconvolution_stop.
: In this convolution, the time axis is uniform an linear with a time interval specified by the parameterdt.
:out
: The array to which the convoluted decay is written ton_out
: The number of elements in the output arraylifetime_spectrum
: The array containing the fluorescence lifetimes and the amplitudesn_lifetime_spectrum
: The number of fluorescence lifetimesirf
: The array containing the instrument response functionn_irf
: The number of elements of the instrument response functionconvolution_stop
: The stop of the convolutiondt
: The time resolution
-
void
convolve_sum_of_exponentials_periodic
(double *out, int n_out, const double *lifetime, int n_lifetimes, const double *irf, int n_irf, int start, int stop, double dt, double period)¶ This function convolves a sum of exponential decays with an instrument response function (IRF)
The sum of exponential decays is passed by the lifetime array
- Parameters
lifetime
: that contains the amplitudes and the corresponding fluorescence lifetimes in an interleaved array (amplitude_1, lifetime_1, amplitude_2, lifetime_2, …). The instrument response function is passed by the arrayirf.
: The IRF and the and the sum of exponential decays are convolved up to the indexconvolution_stop.
: In this convolution, the time axis is uniform an linear with a time interval specified by the parameterdt.
:out
: The array to which the convoluted decay is written ton_out
: The number of elements in the output arraylifetime
: The array containing the fluorescence lifetimes and the amplitudesn_lifetimes
: The number of fluorescence lifetimesirf
: The array containing the instrument response functionn_irf
: The number of elements of the instrument response functionstart
: The start index of the convolutionstop
: The stop index of the convolutiondt
: The time resolutionperiod
: The time between repeated excitation intervals
-
std::vector<double>
diff
(std::vector<double> v)¶ Calculates the discrete difference for an vector
- Return
- Parameters
v
:
-
uint64_t
get_time
()¶ Returns the current time in milliseconds as a uint64
- Return
-
void
add_documents
(bson_t *src, bson_t *dst, std::vector<std::string> skip)¶ Adds the content in the bson_t document src to the document dst omitting the keys provided by the vector skip.
-
void
-
namespace
std
¶ STL namespace.
-
file
Curve.h
- #include <vector>#include <algorithm>#include <string>#include <Functions.h>#include <fstream>#include <bson.h>
-
file
CNode.h
- #include <string>#include <vector>#include <memory>#include <map>#include <algorithm>#include <rttr/registration>#include “MongoObject.h”#include “Port.h”#include “NodeCallback.h”
Defines
-
VERSION
¶
-
-
file
Functions.h
- #include <vector>#include <algorithm>#include <math.h>#include <iostream>#include <chrono>#include <bson.h>
-
file
MongoObject.h
- #include <iostream>#include <map>#include <set>#include <vector>#include <list>#include <memory>#include <cmath>#include <iterator>#include <string>#include <sstream>#include <nlohmann/json.hpp>#include <mongoc.h>#include “Functions.h”
Typedefs
-
using
json
= nlohmann::json¶
-
using
-
file
NodeCallback.h
- #include <functional>#include <rttr/registration>#include <Port.h>#include <CNode.h>#include <Functions.h>#include <FlexLabel/FlexLabel.h>
-
file
Port.h
- #include <cstdint>#include <memory>#include <algorithm>#include <cmath>#include <cstdlib>#include <CNode.h>
-
file
Session.h
- #include <map>#include <memory>#include <nlohmann/json.hpp>#include “MongoObject.h”#include “CNode.h”#include “Port.h”
-
file
README.md
-
dir
/home/docs/checkouts/readthedocs.org/user_builds/chinet/checkouts/development/include/_old
-
dir
/home/docs/checkouts/readthedocs.org/user_builds/chinet/checkouts/development/include
-
page
index
-
General description
chinet is a C++ library to create optimize, sample, and archive global models. A global model is a model, that unites multiple data-sets and seeks for a joint description of the united dataset.
Global models can unite datasets of the same kind or datasets of different types. A typical examples of a global model in fluorescence experiments is the joint description of multiple fluorescence correlation curves in a titration and the joint description of multiple fluorescence decay curves reporting on FRET in a biomolecular structure by a single structural model.
Computing a global model with a large diverse set of different data can be computationally expensive. To reduce the computational costs and to decrease the evaluation time of a global model defined by chinet, the mutual dependencies of the model parameters are modeled by a graph structure that connects “computing nodes”. When a a set of parameters is changed only computing nodes that are affected by these changes are evaluated. Independent nodes are evaluated in parallel.
The state of the evaluation graph can be written to a database for documentation purposes and reconstructed using unique identifies provided by the database.
chinet is NOT intended as ready-to-use software for specific application purposes.
Goals
reactive dataflow model framework
fast inter computation node communication
define and store models jointly with associated data identifies in data base.
Platform independent C/C++ library with interfaces for scripting libraries
Building and Installation
C++ shared library
The C++ shared library can be installed from source with cmake:
git clone --recursive https://github.com/tpeulen/chinet.git mkdir chinet/build; cd chinet/build cmake .. sudo make install
On Linux you can build and install a package instead (prefered):
Python bindings
The Python bindings can be either be installed by downloading and compiling the source code or by using a precompiled distribution for Python anaconda environment.
The following commands can be used to download and compile the source code:
git clone --recursive https://github.com/tpeulen/chinet.git cd chinet sudo python setup.py install
In an anaconda environment the library can be installed by the following command:
conda install -c tpeulen chinet
For most users the later approach is recommended. Currently, pre-compiled packages for the anaconda distribution system are available for:
Windows: Python 3.7
Linux: Python 3.7
macOS: Python 3.7
Legacy 32-bit platforms and the deprecated Python 2.7 are not supported.
Examples
import chinet as cn v1 = 23.0 v2 = 29.0 p1 = cn.Port() p1.value = v1 p2 = cn.Port(v1) p3 = cn.Port( value=v1, fixed=True ) p4 = cn.Port( value=v1, fixed=False ) p5 = cn.Port(v2) p5.link = p4 print(p4.value == p1.value)
License
chinet is released under the open source MIT license.