pos-list.c
/***************************************************************************
 *  Library:
 *      #include <biolibc/pos-list.h>
 *      -lbiolibc -lxtend
 *
 *  Description:
 *      Convert a comma-separated list of positions to a bl_pos_list_t list.
 *      The array_size argument should be your best guess at the final size
 *      of the list.  Choosing a large enough value is not critical since
 *      it will be extended by bl_pos_list_add_position() if needed.
 *
 *  Arguments:
 *      pos_list    Pointer to the bl_pos_list_t to receive the list
 *      list_str    Character string containing comma-separated list of positions
 *      array_size  Initial array size
 *
 *  Returns:
 *      The number of positions added to the list
 *
 *  See also:
 *      bl_pos_list_allocate(3), bl_pos_list_add_position(3), bl_pos_list_free(3),
 *      bl_pos_list_sort(3)
 *
 *  History: 
 *  Date        Name        Modification
 *  2021-04-17  Jason Bacon Begin
 ***************************************************************************/
#include 
-lbiolibc -lxtend

Convert a comma-separated list of positions to a bl_pos_list_t list.
The array_size argument should be your best guess at the final size
of the list.  Choosing a large enough value is not critical since
it will be extended by bl_pos_list_add_position() if needed.

pos_list    Pointer to the bl_pos_list_t to receive the list
list_str    Character string containing comma-separated list of positions
array_size  Initial array size

The number of positions added to the list



Date        Name        Modification
2021-04-17  Jason Bacon Begin
#include - lbiolibc - lxtend Convert a comma - separated list of positions to a bl_pos_list_t list . The array_size argument should be your best guess at the final size of the list . Choosing a large enough value is not critical since it will be extended by bl_pos_list_add_position () if needed . pos_list Pointer to the bl_pos_list_t to receive the list list_str Character string containing comma - separated list of positions array_size Initial array size The number of positions added to the list Date Name Modification 2021 - 04 - 17 Jason Bacon Begin
int     bl_pos_list_from_csv(bl_pos_list_t *pos_list, const char *bounds_str,
		       size_t array_size)
{
    char        *copy, *p, *token, *end;
    size_t      c;
    int64_t    position;
    if ( (copy = strdup(bounds_str)) == NULL )
    {
	fputs("peak-classifier: Cannot allocate temporary bounds string.\n", stderr);
	exit(EX_UNAVAILABLE);
    }
    bl_pos_list_allocate(pos_list, array_size);
    for (p = copy, c = 0; (c < BL_POS_LIST_ARRAY_SIZE(pos_list)) &&
			  ((token = strsep(&p, ",")) != NULL); ++c)
    {
	position = strtoull(token, &end, 10);
	if ( *end != '\0' )
	    return BL_POS_LIST_DATA_INVALID;
	else
	    bl_pos_list_add_position(pos_list, position);
    }
    return c;
}
int bl_pos_list_from_csv ( bl_pos_list_t * pos_list , const char * bounds_str , size_t array_size ) { char * copy , * p , * token , * end ; size_t c ; int64_t position ; if ( ( copy = strdup ( bounds_str ) ) == NULL ) { fputs ( " \n " , stderr ) ; exit ( EX_UNAVAILABLE ) ; } bl_pos_list_allocate ( pos_list , array_size ) ; for ( p = copy , c = 0 ; ( c < BL_POS_LIST_ARRAY_SIZE ( pos_list ) ) && ( ( token = strsep ( & p , " " ) ) != NULL ) ; ++ c ) { position = strtoull ( token , & end , 10 ) ; if ( * end != ' \0 ' ) return BL_POS_LIST_DATA_INVALID ; else bl_pos_list_add_position ( pos_list , position ) ; } return c ; }
Library:
      #include <biolibc/pos-list.h>
      -lbiolibc -lxtend
Library : #include <biolibc / pos - list . h > - lbiolibc - lxtend