First version of quality handling (not working yet) and now it is
checked that a column is writable before enlarging it
This commit is contained in:
115
src/obidmscolumn_qual.c
Normal file
115
src/obidmscolumn_qual.c
Normal file
@ -0,0 +1,115 @@
|
||||
/****************************************************************************
|
||||
* OBIDMS_column_qual functions *
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file obidsmcolumn_qual.c
|
||||
* @author Celine Mercier
|
||||
* @date May 4th 2016
|
||||
* @brief Functions handling OBIColumns containing data in the form of indices referring to sequence quality arrays.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "obidmscolumn.h"
|
||||
#include "obitypes.h"
|
||||
#include "obidmscolumn_str.c"
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* D E F I N I T I O N O F T H E P U B L I C F U N C T I O N S
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
int obi_column_set_obiqual_char_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx, const char* value)
|
||||
{ // TODO discuss
|
||||
return obi_column_set_obistr_with_elt_idx(column, line_nb, element_idx, value);
|
||||
}
|
||||
|
||||
|
||||
int obi_column_set_obiqual_int_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx, const uint8_t* value)
|
||||
{
|
||||
char* value_char;
|
||||
|
||||
// Transform the int array into a char array
|
||||
// Length??
|
||||
//value_char = ;
|
||||
|
||||
obi_column_set_obiqual_char_with_elt_idx(column, line_nb, element_idx, value_char)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char* obi_column_get_obiqual_char_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx)
|
||||
{ // TODO discuss
|
||||
char* value;
|
||||
|
||||
value = obi_column_get_obistr_with_elt_idx(column, line_nb, element_idx);
|
||||
if (strcmp(value, OBIStr_NA) == 0)
|
||||
return OBIQual_char_NA;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
uint8_t* obi_column_get_obiqual_int_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx) // TODO const? (mapped)
|
||||
{
|
||||
index_t idx;
|
||||
|
||||
if (obi_column_prepare_to_get_value(column, line_nb) < 0)
|
||||
return OBIQual_int_NA;
|
||||
|
||||
idx = *(((index_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx);
|
||||
|
||||
// Check NA
|
||||
if (idx == OBIIdx_NA)
|
||||
return OBIQual_int_NA;
|
||||
|
||||
return obi_retrieve_quality_int(column->indexer, idx);
|
||||
}
|
||||
|
||||
|
||||
int obi_column_set_obiqual_char_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name, const char* value)
|
||||
{
|
||||
index_t element_idx = obi_column_get_element_index_from_name(column, element_name);
|
||||
if (element_idx == OBIIdx_NA)
|
||||
return -1;
|
||||
|
||||
return obi_column_set_obiqual_char_with_elt_idx(column, line_nb, element_idx, value);
|
||||
}
|
||||
|
||||
|
||||
int obi_column_set_obiqual_int_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name, uint8_t* value)
|
||||
{
|
||||
index_t element_idx = obi_column_get_element_index_from_name(column, element_name);
|
||||
if (element_idx == OBIIdx_NA)
|
||||
return -1;
|
||||
|
||||
return obi_column_set_obiqual_int_with_elt_idx(column, line_nb, element_idx, value);
|
||||
}
|
||||
|
||||
|
||||
char* obi_column_get_obiqual_char_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name)
|
||||
{
|
||||
index_t element_idx = obi_column_get_element_index_from_name(column, element_name);
|
||||
if (element_idx == OBIIdx_NA)
|
||||
return OBIQual_char_NA;
|
||||
|
||||
return obi_column_get_obiqual_char_with_elt_idx(column, line_nb, element_idx);
|
||||
}
|
||||
|
||||
|
||||
uint8_t* obi_column_get_obiqual_int_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name) // TODO const? (mapped)
|
||||
{
|
||||
index_t element_idx = obi_column_get_element_index_from_name(column, element_name);
|
||||
if (element_idx == OBIIdx_NA)
|
||||
return OBIQual_int_NA;
|
||||
|
||||
return obi_column_get_obiqual_int_with_elt_idx(column, line_nb, element_idx);
|
||||
}
|
||||
|
Reference in New Issue
Block a user