Added possibility to specify the offset for encoding and decoding
sequence quality character strings
This commit is contained in:
@ -26,13 +26,16 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
int obi_column_set_obiqual_char_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx, const char* value)
|
||||
int obi_column_set_obiqual_char_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx, const char* value, int offset)
|
||||
{
|
||||
uint8_t* int_value;
|
||||
int int_value_length;
|
||||
int i;
|
||||
int ret_value;
|
||||
|
||||
if (offset == -1)
|
||||
offset = QUALITY_ASCII_BASE;
|
||||
|
||||
// Check NA value
|
||||
if (value == OBIQual_char_NA)
|
||||
{
|
||||
@ -45,7 +48,7 @@ int obi_column_set_obiqual_char_with_elt_idx(OBIDMS_column_p column, index_t lin
|
||||
|
||||
// Convert in uint8_t array to index in that format
|
||||
for (i=0; i<int_value_length; i++)
|
||||
int_value[i] = ((uint8_t)(value[i])) - QUALITY_ASCII_BASE;
|
||||
int_value[i] = ((uint8_t)(value[i])) - offset;
|
||||
ret_value = obi_column_set_obiqual_int_with_elt_idx(column, line_nb, element_idx, int_value, int_value_length);
|
||||
free(int_value);
|
||||
}
|
||||
@ -101,13 +104,16 @@ int obi_column_set_obiqual_int_with_elt_idx(OBIDMS_column_p column, index_t line
|
||||
}
|
||||
|
||||
|
||||
char* obi_column_get_obiqual_char_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx)
|
||||
char* obi_column_get_obiqual_char_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx, int offset)
|
||||
{
|
||||
char* value;
|
||||
const uint8_t* int_value;
|
||||
int int_value_length;
|
||||
int i;
|
||||
|
||||
if (offset == -1)
|
||||
offset = QUALITY_ASCII_BASE;
|
||||
|
||||
int_value = obi_column_get_obiqual_int_with_elt_idx(column, line_nb, element_idx, &int_value_length);
|
||||
|
||||
// Check NA
|
||||
@ -118,7 +124,7 @@ char* obi_column_get_obiqual_char_with_elt_idx(OBIDMS_column_p column, index_t l
|
||||
|
||||
// Encode int quality to char quality
|
||||
for (i=0; i<int_value_length; i++)
|
||||
value[i] = (char)(int_value[i] + QUALITY_ASCII_BASE);
|
||||
value[i] = (char)(int_value[i] + offset);
|
||||
|
||||
value[i] = '\0';
|
||||
|
||||
@ -143,13 +149,13 @@ const uint8_t* obi_column_get_obiqual_int_with_elt_idx(OBIDMS_column_p column, i
|
||||
}
|
||||
|
||||
|
||||
int obi_column_set_obiqual_char_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name, const char* value)
|
||||
int obi_column_set_obiqual_char_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name, const char* value, int offset)
|
||||
{
|
||||
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);
|
||||
return obi_column_set_obiqual_char_with_elt_idx(column, line_nb, element_idx, value, offset);
|
||||
}
|
||||
|
||||
|
||||
@ -163,13 +169,13 @@ int obi_column_set_obiqual_int_with_elt_name(OBIDMS_column_p column, index_t lin
|
||||
}
|
||||
|
||||
|
||||
char* obi_column_get_obiqual_char_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name)
|
||||
char* obi_column_get_obiqual_char_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name, int offset)
|
||||
{
|
||||
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);
|
||||
return obi_column_get_obiqual_char_with_elt_idx(column, line_nb, element_idx, offset);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user