samtools / htslib

C library for high-throughput sequencing data formats
Other
808 stars 446 forks source link

vcf: how to enumerate all INFO and FORMAT fields from header. #825

Closed brentp closed 5 years ago

brentp commented 5 years ago

I want to create a lookup of bcf_idpair_t.key -> (bcf_idpair_t.val.id, TYPE) where TYPE is either BCF_HL_INFO or BCF_HL_FMT.

During iteration over bcf_hdr_t.id[0] and looking at bcf_idinfo_t, how to tell if it's an INFO or a FORMAT? Or is there another obvious way I am missing to accomplish this?

brentp commented 5 years ago

if hrec[1] is not null, it's an INFO if hred[2] is not null it's a FMT

pd3 commented 5 years ago

I think you want to use the bcf_hdr_id2coltype macro.

brentp commented 5 years ago

by the docs, that appears to take the type as a parameter and that's documented as:

@type:      one of BCF_HL_FLT, BCF_HL_INFO, BCF_HL_FMT

which is what I want to know.