FastqPuri
|
Construction of tree, check paths, write tree, read in tree. More...
Go to the source code of this file.
Classes | |
struct | _node |
Node structure: formed out of T_ACGT pointers to Node structure. More... | |
struct | _tree |
structure containing a T_ACGT-tree. More... | |
Typedefs | |
typedef struct _node | Node |
Node structure: formed out of T_ACGT pointers to Node structure. | |
typedef struct _tree | Tree |
structure containing a T_ACGT-tree. More... | |
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). | |
double | check_path (Tree *tree_ptr, char *read, int Lread) |
checks if read is found in tree and outputs a score More... | |
Tree * | tree_from_fasta (Fa_data *fasta, int L) |
create Tree structure from fasta structure. 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... | |
Construction of tree, check paths, write tree, read in tree.
structure containing a T_ACGT-tree.
The tree structure is stored in a pointer to pointer to Node. We grow the structure on the flight as we need more memory. In the outer direction, we start by allocating NPOOL_2D pointers to Node. In the inner direction, we allocate NPOOL_1D Nodes and fill them as we read the fasta file. When all of them are allocated, we allocate again NPOOL_1D. If NPOOL_2D pointers to Node are allocated, the outer dimension is reallocated with +NPOOL_2D extra elements. L is the depth of the tree, pool_count is the number on Node* elements used so far, pool_available is the number of Nodes available in every moment, and nnodes is the total number of nodes filled in. We limit the number of allocated nodes to UINT_MAX (we cannot count more nodes!).
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: