RingDecomposerLib 1.0
RingDecomposerLib.h
Go to the documentation of this file.
1 /*
2  * This file is part of the RingDecomposerLib, licensed
3  * under BSD New license (see LICENSE in the root directory).
4  * Copyright (c) 2016
5  * University of Hamburg, ZBH - Center for Bioinformatics
6  * Niek Andresen, Florian Flachsenberg, Matthias Rarey
7  *
8  * Please cite:
9  *
10  * Kolodzik, A.; Urbaczek, S.; Rarey, M.
11  * Unique Ring Families: A Chemically Meaningful Description
12  * of Molecular Ring Topologies.
13  * J. Chem. Inf. Model., 2012, 52 (8), pp 2013-2021
14  *
15  * Flachsenberg, F.; Andresen, N.; Rarey, M.
16  * RingDecomposerLib: An Open-Source Implementation of
17  * Unique Ring Families and Other Cycle Bases.
18  * J. Chem. Inf. Model., 2017, 57 (2), pp 122-126
19  */
20 
27 #ifndef RING_DECOMPOSER_LIB_H
28 #define RING_DECOMPOSER_LIB_H
29 
30 #if (defined( _WIN32 ) && defined( _MSC_VER ) )
31  /* Win32 & MS VC ++ */
32  #define RDL_API __declspec(dllexport)
33 #elif __GNUC__ >= 4 || defined(__clang__)
34  #define RDL_API __attribute__((visibility("default")))
35 #else
36  #define RDL_API
37 #endif
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
50 typedef struct RDL_data RDL_data;
51 
68 typedef struct RDL_graph RDL_graph;
69 
73 typedef unsigned RDL_node;
74 
78 typedef RDL_node RDL_edge[2];
79 
83 typedef enum RDL_ERROR_LEVEL {
84  RDL_DEBUG,
85  RDL_WARNING,
86  RDL_ERROR,
87  RDL_INITIALIZE_OUTPUT
89 
90 /*
91  * @brief output function for writing errors/warnings
92  *
93  * @param level `RDL_ERROR_LEVEL` specifying the level of the message
94  * @param m message associated with the event
95  */
96 typedef void (*RDL_outputFunction) (RDL_ERROR_LEVEL level, const char* m, ...);
97 
99 RDL_API extern RDL_outputFunction RDL_outputFunc;
100 
112 RDL_API
113 void RDL_setOutputFunction(RDL_outputFunction func);
114 
118 RDL_API
119 void RDL_writeToStderr(RDL_ERROR_LEVEL level, const char* fmt, ...);
120 
124 RDL_API
125 void RDL_writeNothing(RDL_ERROR_LEVEL level, const char* fmt, ...);
126 
128 RDL_API extern const unsigned RDL_INVALID_RESULT;
130 RDL_API extern const unsigned RDL_DUPLICATE_EDGE;
132 RDL_API extern const unsigned RDL_NO_RINGSYSTEM;
134 RDL_API extern const double RDL_INVALID_RC_COUNT;
135 
141 RDL_API
142 RDL_graph *RDL_initNewGraph(unsigned nof_nodes);
143 
149 RDL_API
150 void RDL_deleteGraph(RDL_graph *graph);
151 
160 RDL_API
161 unsigned RDL_addUEdge(RDL_graph *graph, RDL_node node1, RDL_node node2);
162 
170 RDL_API
171 RDL_data *RDL_calculate(RDL_graph *input_graph);
172 
178 RDL_API
179 void RDL_deleteData(RDL_data *data);
180 
186 RDL_API
187 unsigned RDL_getNofURF(const RDL_data *data);
188 
194 RDL_API
195 unsigned RDL_getNofRCF(const RDL_data *data);
196 
203 RDL_API
204 unsigned RDL_getWeightForURF(const RDL_data *data, unsigned index);
205 
212 RDL_API
213 unsigned RDL_getWeightForRCF(const RDL_data *data, unsigned index);
214 
224 RDL_API
225 unsigned RDL_getNodesForURF(const RDL_data *data, unsigned index,
226  RDL_node **RDL_node_array_ptr);
227 
239 RDL_API
240 unsigned RDL_getEdgesForURF(const RDL_data *data, unsigned index,
241  RDL_edge **RDL_edge_array_ptr);
242 
252 RDL_API
253 unsigned RDL_getNodesForRCF(const RDL_data *data, unsigned index,
254  RDL_node **RDL_node_array_ptr);
255 
267 RDL_API
268 unsigned RDL_getEdgesForRCF(const RDL_data *data, unsigned index,
269  RDL_edge **RDL_edge_array_ptr);
270 
280 RDL_API
281 unsigned RDL_getNofURFContainingNode(const RDL_data *data, RDL_node node);
282 
293 RDL_API
294 unsigned RDL_getNofURFContainingEdge(const RDL_data *data, RDL_node node1,
295  RDL_node node2);
296 
306 RDL_API
307 unsigned RDL_getNofRCFContainingNode(const RDL_data *data, RDL_node node);
308 
319 RDL_API
320 unsigned RDL_getNofRCFContainingEdge(const RDL_data *data, RDL_node node1,
321  RDL_node node2);
322 
337 RDL_API
338 unsigned RDL_getURFsContainingNode(const RDL_data *data, RDL_node node,
339  unsigned **RDL_ids_ptr);
340 
356 RDL_API
357 unsigned RDL_getURFsContainingEdge(const RDL_data *data, RDL_node node1,
358  RDL_node node2, unsigned **RDL_ids_ptr);
359 
374 RDL_API
375 unsigned RDL_getRCFsContainingNode(const RDL_data *data, RDL_node node,
376  unsigned **RDL_ids_ptr);
377 
393 RDL_API
394 unsigned RDL_getRCFsContainingEdge(const RDL_data *data, RDL_node node1,
395  RDL_node node2, unsigned **RDL_ids_ptr);
396 
401 typedef struct RDL_cycle {
403  RDL_edge *edges;
405  unsigned weight;
407  unsigned urf;
409  unsigned rcf;
410 } RDL_cycle;
411 
416 RDL_API
417 void RDL_deleteCycle(RDL_cycle *cycle);
418 
438 
445 RDL_API
447 
456 RDL_API
458 
464 RDL_API
470 RDL_API
472 
484 RDL_API
485 unsigned RDL_getRCyclesForURF(const RDL_data *data, unsigned index,
486  RDL_cycle ***RDL_cycle_array_ptr);
487 
495 RDL_API
496 RDL_cycleIterator* RDL_getRCyclesForURFIterator(const RDL_data *data, unsigned index);
497 
509 RDL_API
510 unsigned RDL_getRCyclesForRCF(const RDL_data *data, unsigned index,
511  RDL_cycle ***RDL_cycle_array_ptr);
512 
520 RDL_API
521 RDL_cycleIterator* RDL_getRCyclesForRCFIterator(const RDL_data *data, unsigned index);
522 
534 RDL_API
535 unsigned RDL_getRCycles(const RDL_data *data, RDL_cycle ***RDL_cycle_array_ptr);
536 
543 RDL_API
545 
553 RDL_API
554 double RDL_getNofRCForURF(const RDL_data *data, unsigned index);
555 
563 RDL_API
564 double RDL_getNofRCForRCF(const RDL_data *data, unsigned index);
565 
572 RDL_API
573 double RDL_getNofRC(const RDL_data *data);
574 
586 RDL_API
587 unsigned RDL_getSSSR(const RDL_data *data, RDL_cycle ***RDL_cycle_array_ptr);
588 
599 RDL_API
600 unsigned RDL_getRCPrototypes(const RDL_data *data,
601  RDL_cycle ***RDL_cycle_array_ptr);
602 
610 RDL_API
611 void RDL_deleteCycles(RDL_cycle **cycles, unsigned number);
612 
632 RDL_API
633 unsigned RDL_translateCycArray(const RDL_data *data,
634  RDL_cycle **old_array,
635  unsigned number,
636  char ***RDL_cycle_array_ptr);
637 
644 RDL_API
645 void RDL_deleteEdgeIdxArray(char **cycles, unsigned number);
646 
655 RDL_API
656 unsigned RDL_getEdgeArray(const RDL_data *data, RDL_edge **RDL_edge_array_ptr);
657 
663 RDL_API
664 unsigned RDL_getNofEdges(const RDL_data *data);
665 
675 RDL_API
676 unsigned RDL_getEdgeId(const RDL_data *data, unsigned from, unsigned to);
677 
683 RDL_API
684 unsigned RDL_getNofRingsystems(const RDL_data* data);
685 
693 RDL_API
694 unsigned RDL_getNofNodesForRingsystem(const RDL_data *data, unsigned idx);
695 
703 RDL_API
704 unsigned RDL_getNofEdgesForRingsystem(const RDL_data *data, unsigned idx);
705 
716 RDL_API
718  const RDL_data *data, unsigned idx, RDL_edge** edges);
719 
730 RDL_API
732  const RDL_data *data, unsigned idx, RDL_node** nodes);
733 
743 RDL_API
744 unsigned RDL_getRingsystemForEdge(
745  const RDL_data* data, unsigned from, unsigned to);
746 
747 #ifdef __cplusplus
748 } /* extern "C" */
749 #endif
750 
751 #endif
RDL_API unsigned RDL_getWeightForRCF(const RDL_data *data, unsigned index)
Returns the weight of each cycle in the RCF identified by its index.
RDL_ERROR_LEVEL
error levels for custom logging functions
Definition: RingDecomposerLib.h:83
RDL_node RDL_edge[2]
An edge is represented by an array of size two containing the adjacent nodes.
Definition: RingDecomposerLib.h:78
RDL_API const unsigned RDL_DUPLICATE_EDGE
Duplicate edge indicator.
RDL_API unsigned RDL_getNofRingsystems(const RDL_data *data)
Get the number of ring systems in the graph.
struct RDL_data RDL_data
Structure representing a calculation result.
Definition: RingDecomposerLib.h:50
RDL_API double RDL_getNofRC(const RDL_data *data)
Gives the number of relevant cycles.
RDL_API RDL_graph * RDL_initNewGraph(unsigned nof_nodes)
Initializes a new RDL_graph.
RDL_API unsigned RDL_getSSSR(const RDL_data *data, RDL_cycle ***RDL_cycle_array_ptr)
Gives a set of cycles that forms a Minimal Cycle Basis of the graph.
RDL_API unsigned RDL_getURFsContainingEdge(const RDL_data *data, RDL_node node1, RDL_node node2, unsigned **RDL_ids_ptr)
Gives all URFs containing the edge.
RDL_API unsigned RDL_getRingsystemForEdge(const RDL_data *data, unsigned from, unsigned to)
Get the ring system id for given edge.
RDL_API unsigned RDL_addUEdge(RDL_graph *graph, RDL_node node1, RDL_node node2)
Adds an undirected edge to the graph.
RDL_API unsigned RDL_getEdgesForURF(const RDL_data *data, unsigned index, RDL_edge **RDL_edge_array_ptr)
Gives the edges of an URF identified with its index.
RDL_API unsigned RDL_getNodesForRCF(const RDL_data *data, unsigned index, RDL_node **RDL_node_array_ptr)
Gives the nodes of an RCF identified with its index in an array of RDL_node.
RDL_API const double RDL_INVALID_RC_COUNT
Invalid number of RCs.
RDL_API unsigned RDL_getURFsContainingNode(const RDL_data *data, RDL_node node, unsigned **RDL_ids_ptr)
Gives all URFs containing the node.
RDL_API unsigned RDL_getNofEdgesForRingsystem(const RDL_data *data, unsigned idx)
Get the number of edges in the ring system.
RDL_API void RDL_writeNothing(RDL_ERROR_LEVEL level, const char *fmt,...)
No output function.
unsigned weight
Definition: RingDecomposerLib.h:405
struct RDL_graph RDL_graph
Datastructure representing a graph for calculations.
Definition: RingDecomposerLib.h:68
RDL_API unsigned RDL_getNofRCF(const RDL_data *data)
Returns the number of RCFs.
RDL_edge * edges
Definition: RingDecomposerLib.h:403
RDL_API unsigned RDL_getRCFsContainingNode(const RDL_data *data, RDL_node node, unsigned **RDL_ids_ptr)
Gives all RCFs containing the node.
RDL_API void RDL_deleteCycleIterator(RDL_cycleIterator *it)
Free memory of the cycle iterator.
RDL_API RDL_cycleIterator * RDL_getRCyclesForURFIterator(const RDL_data *data, unsigned index)
Get iterator for all relevant cycles of the URF with the given index.
RDL_API double RDL_getNofRCForURF(const RDL_data *data, unsigned index)
Gives the number of relevant cycles in this URF.
Definition: RingDecomposerLib.h:401
RDL_API void RDL_setOutputFunction(RDL_outputFunction func)
Set the output function for warning and error messages.
RDL_API unsigned RDL_getRCyclesForURF(const RDL_data *data, unsigned index, RDL_cycle ***RDL_cycle_array_ptr)
Gives all relevant cycles of the URF with the given index.
RDL_API void RDL_deleteCycles(RDL_cycle **cycles, unsigned number)
Deallocates the structure given by RDL_getRCycles(), RDL_getSSSR(), RDL_getRCPrototypes() and RDL_get...
RDL_API unsigned RDL_getNodesForRingsystem(const RDL_data *data, unsigned idx, RDL_node **nodes)
Get the nodes in the ring system.
RDL_API unsigned RDL_getNofRCFContainingNode(const RDL_data *data, RDL_node node)
Returns the number of RCFs that contain the given node.
RDL_API const unsigned RDL_INVALID_RESULT
Invalid result indicator.
unsigned rcf
Definition: RingDecomposerLib.h:409
RDL_API unsigned RDL_getNofEdges(const RDL_data *data)
Get the number of edges in the graph.
RDL_API RDL_cycleIterator * RDL_getRCyclesForRCFIterator(const RDL_data *data, unsigned index)
Get iterator for all relevant cycles of the RCF with the given index.
RDL_API unsigned RDL_getEdgeArray(const RDL_data *data, RDL_edge **RDL_edge_array_ptr)
Gives the edges of the graph.
RDL_API unsigned RDL_getNofURFContainingEdge(const RDL_data *data, RDL_node node1, RDL_node node2)
Returns the number of URFs that contain the RDL_edge defined by the two given nodes.
RDL_API void RDL_deleteData(RDL_data *data)
Deletes RDL_data from memory, including the RDL_graph.
RDL_API unsigned RDL_getNodesForURF(const RDL_data *data, unsigned index, RDL_node **RDL_node_array_ptr)
Gives the nodes of an URF identified with its index in an array of RDL_node.
RDL_API unsigned RDL_getEdgeId(const RDL_data *data, unsigned from, unsigned to)
Get the id of the edge.
RDL_API unsigned RDL_getRCPrototypes(const RDL_data *data, RDL_cycle ***RDL_cycle_array_ptr)
Gives a list of relevant cycle prototypes (one for each RCF).
unsigned RDL_node
A node is represented by its index in the graph (0 to |V|-1).
Definition: RingDecomposerLib.h:73
RDL_API unsigned RDL_getRCycles(const RDL_data *data, RDL_cycle ***RDL_cycle_array_ptr)
Gives a list of all relevant cycles.
RDL_API unsigned RDL_translateCycArray(const RDL_data *data, RDL_cycle **old_array, unsigned number, char ***RDL_cycle_array_ptr)
Translates the results of RDL_getRCycles(), RDL_getSSSR(), RDL_getRCPrototypes() and RDL_getRCyclesFo...
unsigned urf
Definition: RingDecomposerLib.h:407
RDL_API double RDL_getNofRCForRCF(const RDL_data *data, unsigned index)
Gives the number of relevant cycles in this RCF.
RDL_API RDL_outputFunction RDL_outputFunc
the output function for warnings and errors
RDL_API const unsigned RDL_NO_RINGSYSTEM
No ringsystem indicator.
RDL_API unsigned RDL_getRCyclesForRCF(const RDL_data *data, unsigned index, RDL_cycle ***RDL_cycle_array_ptr)
Gives all relevant cycles of the RCF with the given index.
RDL_API unsigned RDL_getWeightForURF(const RDL_data *data, unsigned index)
Returns the weight of each cycle in the URF identified by its index.
struct RDL_cycleIterator RDL_cycleIterator
Iterator for relevant cycles.
Definition: RingDecomposerLib.h:437
RDL_API unsigned RDL_getEdgesForRingsystem(const RDL_data *data, unsigned idx, RDL_edge **edges)
Get the edges in the ring system.
RDL_API unsigned RDL_getEdgesForRCF(const RDL_data *data, unsigned index, RDL_edge **RDL_edge_array_ptr)
Gives the edges of an RCF identified with its index.
RDL_API unsigned RDL_getNofURF(const RDL_data *data)
Returns the number of URFs.
RDL_API unsigned RDL_getRCFsContainingEdge(const RDL_data *data, RDL_node node1, RDL_node node2, unsigned **RDL_ids_ptr)
Gives all RCFs containing the edge.
RDL_API RDL_cycleIterator * RDL_cycleIteratorNext(RDL_cycleIterator *it)
Advance the cycle iterator by one.
RDL_API RDL_cycle * RDL_cycleIteratorGetCycle(RDL_cycleIterator *it)
Get the cycle as RDL_cycle.
RDL_API void RDL_writeToStderr(RDL_ERROR_LEVEL level, const char *fmt,...)
An output function for writing everything to stderr.
RDL_API unsigned RDL_getNofURFContainingNode(const RDL_data *data, RDL_node node)
Returns the number of URFs that contain the given node.
RDL_API unsigned RDL_getNofRCFContainingEdge(const RDL_data *data, RDL_node node1, RDL_node node2)
Returns the number of RCFs that contain the RDL_edge defined by the two given nodes.
RDL_API RDL_data * RDL_calculate(RDL_graph *input_graph)
Calculates the RDL_data structure of the given graph and returns it.
RDL_API void RDL_deleteEdgeIdxArray(char **cycles, unsigned number)
Deallocates the structure given by RDL_translateCycArray(), if called on its result and return value ...
RDL_API void RDL_deleteCycle(RDL_cycle *cycle)
Free memory of RDL_cycle.
RDL_API RDL_cycleIterator * RDL_getRCyclesIterator(const RDL_data *data)
Get iterator for all relevant cycles.
RDL_API void RDL_deleteGraph(RDL_graph *graph)
Delete RDL_graph.
RDL_API unsigned RDL_getNofNodesForRingsystem(const RDL_data *data, unsigned idx)
Get the number of nodes in the ring system.
RDL_API int RDL_cycleIteratorAtEnd(RDL_cycleIterator *it)
Check if iterator is at end (invalid)
struct RDL_cycle RDL_cycle