open file or network resources for writing setup incl header allocation if mode==w: bcf_hdr_init automatically sets version string (##fileformat=VCFv4.2) bcf_hdr_init automatically adds the PASS filter
setup and copy a header from another BCF/VCF as template
Add FILTER tag (§1.2.3)
Add a record
Add sample to this VCF * int bcf_hdr_add_sample(bcf_hdr_t *hdr, const(char) *sample);
Add INFO (§1.2.2) or FORMAT (§1.2.4) tag
Add FILTER tag (§1.2.3)
Add contig definition (§1.2.7) to header meta-info
as expected
as expected
as expected
rc htsFile wrapper
individual records
header wrapper
import std.exception: assertThrown; import std.stdio: writeln, writefln; import dhtslib.vcf.writer; hts_set_log_level(htsLogLevel.HTS_LOG_TRACE); auto vw = VCFWriter("/dev/null"); vw.addHeaderLineRaw("##INFO=<ID=NS,Number=1,Type=Integer,Description=\"Number of Samples With Data\">"); vw.addHeaderLineKV("INFO", "<ID=DP,Number=1,Type=Integer,Description=\"Total Depth\">"); // ##INFO=<ID=AF,Number=A,Type=Float,Description="Allele Frequency"> vw.addTag!(HeaderRecordType.Info)("AF", HeaderLengths.OnePerAltAllele, HeaderTypes.Integer, "Number of Samples With Data"); vw.addTag!(HeaderRecordType.Filter)("filt","test"); vw.addFilterTag("filt2","test2"); assert(vw.getHeader.getHeaderRecord(HeaderRecordType.Filter, "filt2").getDescription == "\"test2\""); vw.writeHeader();
Basic support for writing VCF, BCF files