The objective of this project is to define and manipulate data structures in C to represent DNA sequences and phylogenetic trees.
dna.h File)nucleo Type
nucleo that can take the values A, T, G, or C. (Note: you are asked to define these four values, not to work with a simple char).
dna_t Type
dna_t containing:
code pointer to a nucleo (which will correspond to an array of nucleo).size (which will correspond to the size of this array).tree_t Type (Phylogenetic Trees)
dna_t (a leaf), or two pointers to other such trees (a node).
tree_t containing:
isaleaf (indicating whether it is a leaf or not).content field (a union) which can contain, either:
tree_t.dna_t.dna.c File)You must implement the following functions (prototyped in dna.h).
dna_t* createdna(int size)
size, allocate space for a dna_t of that size, including the space for the code array.
NULL.
void freedna(dna_t* d)
createdna.
d is non-null but d->code is null).
tree_t* makeNode(tree_t* t1, tree_t* t2)
t1 and t2.
t1 or t2 is NULL), any potentially allocated memory must be freed, and the function must return NULL.
tree_t* makeLeaf(dna_t* d)
dna_t d.
d is NULL), any potentially allocated memory must be freed, and the function must return NULL.
void freetree(tree_t* t)
t.
freedna when necessary.
int distdna (dna_t* d1, dna_t* d2)
dna_t.
ATAGCAG and ATCGC have a distance of 3 (one for A vs C at the 3rd index, and two for the last two missing nucleotides).dna_t* readdna (FILE* f)
f.
ATTATCG), without separation.dna_t and fill it with the read data.
NULL.
main Function)Write a main function that adheres to the following instructions:
argv[1]).readdna).tree_t) (of any form you like) with these codes."TATGCTTG".stderr).