FastqPuri
|
Construction of tree, check paths, write tree, read in tree. More...
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "tree.h"
#include "Lmer.h"
#include "fopen_gen.h"
Functions | |
Node * | get_new_pool (Tree *tree_ptr) |
reallocs pool_2D (++NPOOL_2D) if all existing nodes have been used More... | |
Node * | new_node_buf (Tree *tree_ptr) |
moves to the next node (allocating new memory if necessary) More... | |
void | free_all_nodes (Tree *tree_ptr) |
frees the whole tree structure More... | |
void | insert_Lmer (Tree *tree_ptr, char *Lmer) |
Lmer insertion in the tree (depth L). | |
void | insert_entry (Tree *tree_ptr, Fa_entry *entry) |
fasta entry insertion in the tree (depth L). | |
Tree * | tree_from_fasta (Fa_data *fasta, int L) |
create Tree structure from fasta structure. More... | |
double | check_path (Tree *tree_ptr, char *read, int Lread) |
checks if read is found in tree and outputs a score More... | |
void | save_tree (Tree *tree_ptr, char *filename) |
saves Tree to disk in filename More... | |
Tree * | read_tree (char *filename) |
read tree from file More... | |
Variables | |
uint64_t | alloc_mem |
Construction of tree, check paths, write tree, read in tree.
double check_path | ( | Tree * | tree_ptr, |
char * | read, | ||
int | Lread | ||
) |
checks if read is found in tree and outputs a score
tree_ptr | pointer to Tree structure |
read | Read or reverse complement |
Lread | length of read |
void free_all_nodes | ( | Tree * | tree_ptr | ) |
frees the whole tree structure
tree_ptr | pointer to Tree structure |
This function deallocates the memory allocated in a Tree structure.
reallocs pool_2D (++NPOOL_2D) if all existing nodes have been used
tree_ptr | pointer to Tree structure |
moves to the next node (allocating new memory if necessary)
tree_ptr | pointer to Tree structure |
The function checks if there are available nodes (information stored in the variable tree_ptr -> pool_available) and goes to the next node. If there is no nodes left, it allocates a new pool_1D, and if there is no room left in the outter dimension, it reallocates NPOOL_2D more Node*'s. If the number of nodes reaches UINT_MAX, the program returns an error message and exits.
Tree* read_tree | ( | char * | filename | ) |
read tree from file
filename | string with the filename |
This function unwinds the process carried out in save_tree and assigns addresses to the children of every given node.
void save_tree | ( | Tree * | tree_ptr, |
char * | filename | ||
) |
saves Tree to disk in filename
tree_ptr | pointer to Tree structure |
filename | string containing filename |
The tree structure is stored as follows: every address is stored in a uint32_t (we are not allowing trees with more than UINT_MAX nodes). For every node, the addresses of the children are stored in the following fashion:
create Tree structure from fasta structure.
fasta | pointer to fasta structure |
L | tree length |
uint64_t alloc_mem |
global variable. Memory allocated in the heap.