Bloom Filter Trie: include/snippets.h File Reference

Bloom Filter Trie

- Main Page
- Data Structures
- Files

- File List
- Globals

Macros
snippets.h File Reference

Code snippets using a BFT. More...

Go to the source code of this file.

## Macros
#define | V_NOT_VISITED 0
| Flag for marked vertices indicating the vertex has not been visited before. More...
#define | V_VISITED 1
| Flag for marked vertices indicating the vertex has been visited before. More...

## Functions
K-mer extraction functions
These functions extract k-mers stored in a BFT to disk. The last argument of extract_pangenome_kmers_to_disk() is of type BFT_func_ptr, you can use extract_core_kmers(), extract_dispensable_kmers() or extract_singleton_kmers() to extract core, dispensable or singleton k-mers.
size_t | extract_core_kmers (BFT_kmer *kmer, BFT *graph, va_list args)
| Function of type BFT_func_ptr extracting a core k-mer to disk. More...
size_t | extract_dispensable_kmers (BFT_kmer *kmer, BFT *graph, va_list args)
| Function of type BFT_func_ptr extracting a dispensable k-mer to disk. More...
size_t | extract_singleton_kmers (BFT_kmer *kmer, BFT *graph, va_list args)
| Function of type BFT_func_ptr extracting a singleton k-mer to disk. More...
void | extract_pangenome_kmers_to_disk (BFT *graph, char *filename_output, BFT_func_ptr f)
| Function extracting pan-genome (core/dispensable/singleton) k-mers from a BFT to disk. More...
Path extraction functions
These functions extract simple (non branching) paths of k-mers stored in a BFT to disk.
size_t | extract_simple_paths (BFT_kmer *kmer, BFT *graph, va_list args)
| Function of type BFT_func_ptr extracting from a non-branching k-mer the simple (non branching) path in which it is. More...
void | extract_simple_paths_to_disk (BFT *graph, char *filename_output)
| Function extracting from a colored de Bruijn graph stored as a BFT all simple (non branching) paths. More...
size_t | extract_core_simple_paths (BFT_kmer *kmer, BFT *graph, va_list args)
| Function of type BFT_func_ptr extracting from a non-branching core k-mer the simple (non branching) path in which it is. More...
void | extract_simple_core_paths_to_disk (BFT *graph, double core_ratio, char *filename_output)
| Function extracting from a colored de Bruijn graph stored as a BFT all simple (non branching) core paths. More...
Graph traversal functions
These functions iterate over a colored de Bruijn graph stored as a BFT.
size_t | BFS (BFT_kmer *kmer, BFT *graph, va_list args)
| Function of type BFT_func_ptr starting a Breadth-First Search traversal from a k-mer. More...
size_t | BFS_subgraph (BFT_kmer *kmer, BFT *graph, va_list args)
| Function of type BFT_func_ptr starting a Breadth-First Search traversal from a k-mer that is part of a subgraph. More...
size_t | DFS (BFT_kmer *kmer, BFT *graph, va_list args)
| Function of type BFT_func_ptr starting a Depth-First Search traversal from a k-mer. More...
size_t | DFS_subgraph (BFT_kmer *kmer, BFT *graph, va_list args)
| Function of type BFT_func_ptr starting a Depth-First Search traversal from a k-mer that is part of a subgraph. More...
bool | is_in_subgraph (BFT_kmer *kmer, BFT *graph, int nb_id_genomes, const va_list args)
| Function computing if a k-mer is part of a subgraph. More...
void | cdbg_traversal (BFT *graph, BFT_func_ptr f,...)
| Function traversing a colored de Bruijn graph stored as a BFT. More...
size_t | nb_connected_components (BFT_kmer *kmer, BFT *graph, va_list args)
| Function of type BFT_func_ptr calling a traversal method (DFS/BFS, DFS_subgraph/BFS_subgraph) on a k-mer to determine if it is in a new connected component. More...
void | get_nb_connected_component (BFT *graph,...)
| Compute the number of connected components in a colored de-Bruijn graph. More...

## Detailed Description

Code snippets using a BFT.

The purpose of this file is to give examples of how to use the functions of the BFT API (bft.h).

## Macro Definition Documentation

#define V_NOT_VISITED 0

Flag for marked vertices indicating the vertex has not been visited before.

#define V_VISITED 1

Flag for marked vertices indicating the vertex has been visited before.

## Function Documentation

size_t BFS | ( | BFT_kmer * | kmer,
|  | BFT * | graph,
|  | va_list | args
| ) |  |

Function of type BFT_func_ptr starting a Breadth-First Search traversal from a k-mer.

Parameters

  kmer | is a k-mer from the BFT graph.
  graph | is the BFT from which kmer is from.
  args | contains additional parameters given to the calling function (here none).

Returns
  true if it is a new connected component, else false.

size_t BFS_subgraph | ( | BFT_kmer * | kmer,
|  | BFT * | graph,
|  | va_list | args
| ) |  |

Function of type BFT_func_ptr starting a Breadth-First Search traversal from a k-mer that is part of a subgraph.

Parameters

  kmer | is a k-mer from the BFT graph.
  graph | is the BFT from which kmer is from.
  args | contains additional parameters given to the calling function. Here, it contains a number of genome ids, followed by the genome ids, that a k-mer must contain to be considered part of the subgraph.

Returns
  true if it is a new connected component, else false.

void cdbg_traversal | ( | BFT * | graph,
|  | BFT_func_ptr | f,
|  |  | ...
| ) |  |

Function traversing a colored de Bruijn graph stored as a BFT.

Parameters

  graph | is a BFT representing a colored de Bruijn graph.
  f | is the traversal function (DFS/BFS, DFS_subgraph/BFS_subgraph) to use.
  ... | is the additional arguments to transfer to f() (if there are some).

size_t DFS | ( | BFT_kmer * | kmer,
|  | BFT * | graph,
|  | va_list | args
| ) |  |

Function of type BFT_func_ptr starting a Depth-First Search traversal from a k-mer.

Parameters

  kmer | is a k-mer from the BFT graph.
  graph | is the BFT from which kmer is from.
  args | contains additional parameters given to the calling function (here none).

Returns
  true if it is a new connected component, else false.

size_t DFS_subgraph | ( | BFT_kmer * | kmer,
|  | BFT * | graph,
|  | va_list | args
| ) |  |

Function of type BFT_func_ptr starting a Depth-First Search traversal from a k-mer that is part of a subgraph.

Parameters

  kmer | is a k-mer from the BFT graph.
  graph | is the BFT from which kmer is from.
  args | contains additional parameters given to the calling function. Here, it contains a number of genome ids, followed by the genome ids, that a k-mer must contain to be considered part of the subgraph.

Returns
  true if it is a new connected component, else false.

size_t extract_core_kmers | ( | BFT_kmer * | kmer,
|  | BFT * | graph,
|  | va_list | args
| ) |  |

Function of type BFT_func_ptr extracting a core k-mer to disk.

A core k-mer contains in its annotation all genome ids inserted in the graph.

Parameters

  kmer | is a k-mer from the BFT graph.
  graph | is the BFT from which kmer is from.
  args | contains all additional parameters given to extract_pangenome_kmers_to_disk(): A pointer to a file where to write the k-mer and a pointer to the current number of k-mers written.

size_t extract_core_simple_paths | ( | BFT_kmer * | kmer,
|  | BFT * | graph,
|  | va_list | args
| ) |  |

Function of type BFT_func_ptr extracting from a non-branching core k-mer the simple (non branching) path in which it is.

args contains as argument a core_ratio float (between 0 to 1) indicating the ratio of genome ids (compared to the total number of genome ids) that a k-mer annotation must contain to be considered being part of a core simple path.

Parameters

  kmer | is a k-mer from the BFT graph.
  graph | is the BFT from which kmer is from.
  args | contains all additional parameters given to extract_simple_core_paths_to_disk(): A pointer to a file where to write paths and a pointer to the current max. size of a path written in the file.

size_t extract_dispensable_kmers | ( | BFT_kmer * | kmer,
|  | BFT * | graph,
|  | va_list | args
| ) |  |

Function of type BFT_func_ptr extracting a dispensable k-mer to disk.

A dispensable k-mer contains in its annotation less than all genome ids inserted in the graph.

Parameters

  kmer | is a k-mer from the BFT graph.
  graph | is the BFT from which kmer is from.
  args | contains all additional parameters given to extract_pangenome_kmers_to_disk(): A pointer to a file where to write the k-mer and a pointer to the current number of k-mers written.

void extract_pangenome_kmers_to_disk | ( | BFT * | graph,
|  | char * | filename_output,
|  | BFT_func_ptr | f
| ) |  |

Function extracting pan-genome (core/dispensable/singleton) k-mers from a BFT to disk.

A core k-mer contains in its annotation all genome ids inserted in the graph. A dispensable k-mer contains in its annotation less than all genome ids inserted in the graph. A singleton k-mer contains in its annotation one genome id inserted in the graph.

Parameters

  graph | is a BFT from which k-mers must be extracted.
  filename_output | is the name of the file where to write the k-mers.
  f | is a function of type BFT_func_ptr (like extract_core_kmers(), extract_dispensable_kmers(), and extract_singleton_kmers()) which write a pan-genome k-mer to disk.

void extract_simple_core_paths_to_disk | ( | BFT * | graph,
|  | double | core_ratio,
|  | char * | filename_output
| ) |  |

Function extracting from a colored de Bruijn graph stored as a BFT all simple (non branching) core paths.

Parameters

  graph | is a colored de Bruijn graph stored as a BFT.
  core_ratio | is a float (between 0 to 1) indicating the ratio of genome ids (compared to the total number of genome ids inserted in graph) that a k-mer annotation must contain to be considered being part of a core simple path.
  filename_output | is the name of the file where to write the simple core paths.

size_t extract_simple_paths | ( | BFT_kmer * | kmer,
|  | BFT * | graph,
|  | va_list | args
| ) |  |

Function of type BFT_func_ptr extracting from a non-branching k-mer the simple (non branching) path in which it is.

Parameters

  kmer | is a k-mer from the BFT graph.
  graph | is the BFT from which kmer is from.
  args | contains all additional parameters given to extract_simple_paths_to_disk(): A pointer to a file where to write paths and a pointer to the current max. size of a path written in the file.

void extract_simple_paths_to_disk | ( | BFT * | graph,
|  | char * | filename_output
| ) |  |

Function extracting from a colored de Bruijn graph stored as a BFT all simple (non branching) paths.

Parameters

  graph | is a colored de Bruijn graph stored as a BFT.
  filename_output | is the name of the file where to write the simple paths.

size_t extract_singleton_kmers | ( | BFT_kmer * | kmer,
|  | BFT * | graph,
|  | va_list | args
| ) |  |

Function of type BFT_func_ptr extracting a singleton k-mer to disk.

Singleton k-mer contains in its annotation one genome id inserted in the graph.

Parameters

  kmer | is a k-mer from the BFT graph.
  graph | is the BFT from which kmer is from.
  args | contains all additional parameters given to extract_pangenome_kmers_to_disk(): A pointer to a file where to write the k-mer and a pointer to the current number of k-mers written.

void get_nb_connected_component | ( | BFT * | graph,
|  |  | ...
| ) |  |

Compute the number of connected components in a colored de-Bruijn graph.

Parameters

  graph | is a BFT representing a colored de Bruijn graph.
  ... | is the additional arguments to transfer to nb_connected_components() (traversal method and additional arguments if there are some).

bool is_in_subgraph | ( | BFT_kmer * | kmer,
|  | BFT * | graph,
|  | int | nb_id_genomes,
|  | const va_list | args
| ) |  |

Function computing if a k-mer is part of a subgraph.

A subgraph is determined by k-mers having in their annotation specific genome ids.

Parameters

  kmer | is a k-mer from the BFT graph.
  graph | is the BFT from which kmer is from.
  nb_id_genomes | is the number of genome ids that a k-mer must contain to be considered part of the subgraph.
  args | contains additional parameters given to the calling function. Here, it contains the genome ids that a k-mer must contain to be considered part of the subgraph.

Returns
  true if it is a new connected component, else false.

size_t nb_connected_components | ( | BFT_kmer * | kmer,
|  | BFT * | graph,
|  | va_list | args
| ) |  |

Function of type BFT_func_ptr calling a traversal method (DFS/BFS, DFS_subgraph/BFS_subgraph) on a k-mer to determine if it is in a new connected component.

Parameters

  kmer | is a k-mer from the BFT graph.
  graph | is the BFT from which kmer is from.
  args | contains additional parameters given to the calling function. Here, it contains the traversal method to call and its additional arguments.