I would like to print the alternative allele from a vcf file which i load in with htslib. The description of some functions: https://github.com/samtools/htslib/blob/develop/htslib/vcf.h
I have used bcf1_t objects by creating a header and reading the information.
htsFile *test_vcf = NULL;
// creates header
bcf_hdr_t *test_header = NULL;
// initialize and allocate bcf1_t object
bcf1_t *test_record = bcf_init();
test_vcf = vcf_open("Testfile.vcf", "r");
// returning a bcf_hdr_t struct
test_header = bcf_hdr_read(test_vcf);
while(bcf_read(test_vcf, test_header, test_record) == 0){
std::cout << "chr" << bcf_hdr_id2name(test_header, test_record->rid) << ":" <<test_record->pos+1 << std::endl;
}
bcf_hdr_destroy(test_header);
bcf_destroy(test_record);
bcf_close(test_vcf);
But im not able to extract the reference or alternative allele information using this structure bcf1_t.
As far as i can read its perhaps possible with the structure and function:
bcf_dec_t
bcf_unpack()
But i am not able to get it to work since all the other functions seems limited to the bcf1_t struct.
Can anyone help with extracting the REF and ALT sequence? Thanks for your time