|
From: Gregory B. <g.b...@im...> - 2017-08-04 07:08:36
|
I’m writing a Mac app using the htslib C API, and I’m trying to work out how to add INFO lines to a bcf_hdr_t and then INFO fields to bcf_1_t records. I can add INFO lines to the header using, eg.: NSString *iLine = [NSString stringWithFormat:@"##INFO=<ID=UMME1,Number=1,Type=Integer,Description=\"UMassME1Hotspot;danRer7\",Source=\"http://hgdownload.soe.ucsc.edu/goldenPath/danRer7/database/UMassME1Hotspot.txt.gz\">"]; bcf_hdr_append(hdr, infoLine.UTF8String); And the header seems to be OK, eg. kstring_t htxt = {0,0,0}; if (bcf_hdr_format(hdr, 1, &htxt) == 0) { return [NSString stringWithUTF8String:htxt.s]; } returns a string with the new INFO lines added (albeit after all of the contig lines). But when I try to add an INFO field to a bcf_1_t record: const char *key_c = “UMME1”; int32_t val_i = 1; bcf_update_info_int32(hdr, rec, key_c, &val_i, 1); it crashes at line 3267 in vcf.c (bcf_update_info()): if ( !bcf_hdr_idinfo_exists(hdr,BCF_HL_INFO,inf_id) ) return -1; If I add an INFO field for one of the pre-existing INFO lines, it succeeds. Any help would be appreciated. Greg. |