2016-04-12 11:21:14 +02:00
|
|
|
/****************************************************************************
|
2016-04-12 14:52:27 +02:00
|
|
|
* Obiblob header file *
|
2016-04-12 11:21:14 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file obiblob.h
|
|
|
|
* @author Celine Mercier
|
|
|
|
* @date November 18th 2015
|
|
|
|
* @brief Header file for handling Obi_blob structures.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef OBIBLOB_H_
|
|
|
|
#define OBIBLOB_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "obitypes.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define ELEMENT_SIZE_STR (8) /**< The size of an element from a value of type character string.
|
|
|
|
*/
|
|
|
|
#define ELEMENT_SIZE_SEQ_2 (2) /**< The size of an element from a value of type DNA sequence encoded on 2 bits.
|
|
|
|
*/
|
|
|
|
#define ELEMENT_SIZE_SEQ_4 (4) /**< The size of an element from a value of type DNA sequence encoded on 4 bits.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Blob structure.
|
|
|
|
* TODO
|
|
|
|
*/
|
|
|
|
typedef struct Obi_blob {
|
|
|
|
uint8_t element_size; /**< Size in bits of one element from the value.
|
|
|
|
*/
|
|
|
|
int32_t length_encoded_value; /**< Length in bytes of the encoded value.
|
|
|
|
*/
|
|
|
|
int32_t length_decoded_value; /**< Length in bytes of the decoded value.
|
|
|
|
*/
|
|
|
|
byte_t value[]; /**< Encoded value.
|
|
|
|
*/
|
|
|
|
} Obi_blob_t, *Obi_blob_p;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Converts a character string to a blob.
|
|
|
|
*
|
|
|
|
* @warning The blob must be freed by the caller.
|
|
|
|
*
|
|
|
|
* @param value The character string to convert.
|
|
|
|
*
|
|
|
|
* @returns A pointer to the blob created.
|
|
|
|
* @retval NULL if an error occurred.
|
|
|
|
*
|
|
|
|
* @since October 2015
|
|
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
|
|
*/
|
|
|
|
Obi_blob_p obi_str_to_blob(char* value);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Converts a blob to a character string.
|
|
|
|
*
|
|
|
|
* @param value_b The blob to convert.
|
|
|
|
*
|
|
|
|
* @returns A pointer to the character string contained in the blob.
|
|
|
|
*
|
|
|
|
* @since October 2015
|
|
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
|
|
*/
|
|
|
|
const char* obi_blob_to_str(Obi_blob_p value_b);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Converts a DNA sequence to a blob with a header.
|
|
|
|
*
|
|
|
|
* @warning The blob must be freed by the caller.
|
|
|
|
*
|
|
|
|
* @param value The DNA sequence to convert.
|
|
|
|
*
|
|
|
|
* @returns A pointer to the blob created.
|
|
|
|
* @retval NULL if an error occurred.
|
|
|
|
*
|
|
|
|
* @since November 2015
|
|
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
|
|
*/
|
|
|
|
Obi_blob_p obi_seq_to_blob(char* seq);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Converts a blob to a DNA sequence.
|
|
|
|
*
|
|
|
|
* @param value_b The blob to convert.
|
|
|
|
*
|
|
|
|
* @returns A pointer to the DNA sequence contained in the blob.
|
|
|
|
* @retval NULL if an error occurred.
|
|
|
|
*
|
|
|
|
* @since November 2015
|
|
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
|
|
*/
|
|
|
|
const char* obi_blob_to_seq(Obi_blob_p value_b); // TODO move to encode source files
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* OBIBLOB_H_ */
|
|
|
|
|