vcf.c
/***************************************************************************
 *  Library:
 *      #include <biolibc/vcf.h>
 *      -lbiolibc -lxtend
 *
 *  Description:
 *      Convert a comma-separated list of VCF fields to a field bit mask
 *
 *  Arguments:
 *      spec    Character string containing comma-separated field list
 *
 *  Returns:
 *      A vcf_field_mask_t value with bits set for specified fields
 *
 *  See also:
 *      vcf_read_call(3), vcf_write_call(3)
 *
 *  History: 
 *  Date        Name        Modification
 *  2020-01-22  Jason Bacon Begin
 ***************************************************************************/
#include 
-lbiolibc -lxtend

Convert a comma-separated list of VCF fields to a field bit mask

spec    Character string containing comma-separated field list

A vcf_field_mask_t value with bits set for specified fields



Date        Name        Modification
2020-01-22  Jason Bacon Begin
#include - lbiolibc - lxtend Convert a comma - separated list of VCF fields to a field bit mask spec Character string containing comma - separated field list A vcf_field_mask_t value with bits set for specified fields Date Name Modification 2020 - 01 - 22 Jason Bacon Begin
vcf_field_mask_t    bl_vcf_parse_field_spec(char *spec)
{
    vcf_field_mask_t    field_mask;
    char            *field_name;
    if ( strcmp(spec, "all") == 0 )
    {
	field_mask = BL_VCF_FIELD_ALL;
    }
    else
    {
	field_mask = 0x0;
	while ((field_name = strsep(&spec, ",")) != NULL)
	{
	    if ( strcmp(field_name, "chrom") == 0 )
		field_mask |= BL_VCF_FIELD_CHROM;
	    else if ( strcmp(field_name, "pos") == 0 )
		field_mask |= BL_VCF_FIELD_POS;
	    else if ( strcmp(field_name, "id") == 0 )
		field_mask |= BL_VCF_FIELD_ID;
	    else if ( strcmp(field_name, "ref") == 0 )
		field_mask |= BL_VCF_FIELD_REF;
	    else if ( strcmp(field_name, "alt") == 0 )
		field_mask |= BL_VCF_FIELD_ALT;
	    else if ( strcmp(field_name, "qual") == 0 )
		field_mask |= BL_VCF_FIELD_QUAL;
	    else if ( strcmp(field_name, "filter") == 0 )
		field_mask |= BL_VCF_FIELD_FILTER;
	    else if ( strcmp(field_name, "info") == 0 )
		field_mask |= BL_VCF_FIELD_INFO;
	    else if ( strcmp(field_name, "format") == 0 )
		field_mask |= BL_VCF_FIELD_FORMAT;
	    else
		field_mask = BL_VCF_FIELD_ERROR;
	}
    }
    return field_mask;
}
vcf_field_mask_t bl_vcf_parse_field_spec ( char * spec ) { vcf_field_mask_t field_mask ; char * field_name ; if ( strcmp ( spec , " " ) == 0 ) { field_mask = BL_VCF_FIELD_ALL ; } else { field_mask = 0x0 ; while ( ( field_name = strsep ( & spec , " " ) ) != NULL ) { if ( strcmp ( field_name , " " ) == 0 ) field_mask |= BL_VCF_FIELD_CHROM ; else if ( strcmp ( field_name , " " ) == 0 ) field_mask |= BL_VCF_FIELD_POS ; else if ( strcmp ( field_name , " " ) == 0 ) field_mask |= BL_VCF_FIELD_ID ; else if ( strcmp ( field_name , " " ) == 0 ) field_mask |= BL_VCF_FIELD_REF ; else if ( strcmp ( field_name , " " ) == 0 ) field_mask |= BL_VCF_FIELD_ALT ; else if ( strcmp ( field_name , " " ) == 0 ) field_mask |= BL_VCF_FIELD_QUAL ; else if ( strcmp ( field_name , " " ) == 0 ) field_mask |= BL_VCF_FIELD_FILTER ; else if ( strcmp ( field_name , " " ) == 0 ) field_mask |= BL_VCF_FIELD_INFO ; else if ( strcmp ( field_name , " " ) == 0 ) field_mask |= BL_VCF_FIELD_FORMAT ; else field_mask = BL_VCF_FIELD_ERROR ; } } return field_mask ; }
Library:
      #include <biolibc/vcf.h>
      -lbiolibc -lxtend
Library : #include <biolibc / vcf . h > - lbiolibc - lxtend