FastqPuri
tree.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (C) 2017 by Paula Perez Rubio *
3  * *
4  * This file is part of FastqPuri. *
5  * *
6  * FastqPuri is free software: you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as *
8  * published by the Free Software Foundation, either version 3 of the *
9  * License, or (at your option) any later version. *
10  * *
11  * FastqPuri is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with FastqPuri. *
18  * If not, see <http://www.gnu.org/licenses/>. *
19  ****************************************************************************/
20 
30 #ifndef TREE_H_
31 #define TREE_H_
32 #include <stdint.h>
33 #include "defines.h"
34 #include "fa_read.h"
35 
40 typedef struct _node {
41  struct _node *children[T_ACGT];
42 } Node;
43 
60 typedef struct _tree {
61  uint32_t L;
62  uint32_t pool_count;
63  uint32_t pool_available;
64  uint32_t nnodes;
66 } Tree;
67 
68 Node *get_new_pool(Tree *tree_ptr);
69 
70 Node *new_node_buf(Tree *tree_ptr);
71 
72 void free_all_nodes(Tree *tree_ptr);
73 
74 void insert_Lmer(Tree *tree_ptr, char *Lmer);
75 
76 void insert_entry(Tree *tree_ptr, Fa_entry *entry);
77 
78 double check_path(Tree *tree_ptr, char *read, int Lread);
79 
80 Tree *tree_from_fasta(Fa_data *fasta, int L);
81 
82 void save_tree(Tree *tree_ptr, char * filename);
83 
84 Tree *read_tree(char *filename);
85 
86 /* static functions
87  * check_path(Tree *tree_ptr, char *Lmer, int Lread);
88  * */
89 
90 #endif // endif TREE_H_
double check_path(Tree *tree_ptr, char *read, int Lread)
checks if read is found in tree and outputs a score
Definition: tree.c:199
void insert_Lmer(Tree *tree_ptr, char *Lmer)
Lmer insertion in the tree (depth L).
Definition: tree.c:145
stores sequences of a fasta file
Definition: fa_read.h:46
reads in and stores fasta files
struct _node Node
Node structure: formed out of T_ACGT pointers to Node structure.
void free_all_nodes(Tree *tree_ptr)
frees the whole tree structure
Definition: tree.c:117
Node structure: formed out of T_ACGT pointers to Node structure.
Definition: tree.h:40
Tree * read_tree(char *filename)
read tree from file
Definition: tree.c:309
Node * get_new_pool(Tree *tree_ptr)
reallocs pool_2D (++NPOOL_2D) if all existing nodes have been used
Definition: tree.c:44
uint32_t pool_available
Definition: tree.h:63
struct _node * children[T_ACGT]
Definition: tree.h:41
Tree * tree_from_fasta(Fa_data *fasta, int L)
create Tree structure from fasta structure.
Definition: tree.c:177
Macro definitions.
void save_tree(Tree *tree_ptr, char *filename)
saves Tree to disk in filename
Definition: tree.c:237
void insert_entry(Tree *tree_ptr, Fa_entry *entry)
fasta entry insertion in the tree (depth L).
Definition: tree.c:162
uint32_t pool_count
Definition: tree.h:62
struct _tree Tree
structure containing a T_ACGT-tree.
uint32_t nnodes
Definition: tree.h:64
Node * new_node_buf(Tree *tree_ptr)
moves to the next node (allocating new memory if necessary)
Definition: tree.c:84
Node ** pool_2D
Definition: tree.h:65
structure containing a T_ACGT-tree.
Definition: tree.h:60
fasta entry
Definition: fa_read.h:38
uint32_t L
Definition: tree.h:61
#define T_ACGT
Definition: defines.h:84