VCFWriter

Basic support for writing VCF, BCF files

Constructors

this
this()
Undocumented in source.
this
this(string fn)

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

this
this(string fn, T other)

setup and copy a header from another BCF/VCF as template

Members

Functions

addFiledate
deprecated int addFiledate()
Undocumented in source. Be warned that the author may not have intended to support it.
addFilterTag
deprecated void addFilterTag(string id, string description)

Add FILTER tag (§1.2.3)

addHeaderLineKV
deprecated int addHeaderLineKV(string key, string value)
Undocumented in source. Be warned that the author may not have intended to support it.
addHeaderLineRaw
deprecated int addHeaderLineRaw(string line)
Undocumented in source. Be warned that the author may not have intended to support it.
addRecord
int addRecord(S contig, int pos, S id, S alleles, N qual, S[] filters)

Add a record

addSample
deprecated int addSample(string name)

Add sample to this VCF * int bcf_hdr_add_sample(bcf_hdr_t *hdr, const(char) *sample);

addTag
deprecated void addTag(string id, HeaderLengths number, HeaderTypes type, string description, string source, string _version)

Add INFO (§1.2.2) or FORMAT (§1.2.4) tag

addTag
deprecated void addTag(string id, string description)

Add FILTER tag (§1.2.3)

addTag
deprecated auto addTag(const(char)[] id, int length, string other)

Add contig definition (§1.2.7) to header meta-info

getHeader
VCFHeader getHeader()
Undocumented in source. Be warned that the author may not have intended to support it.
writeHeader
int writeHeader()

as expected

writeRecord
int writeRecord(VCFRecord r)

as expected

writeRecord
int writeRecord(bcf_hdr_t* hdr, bcf1_t* rec)

as expected

Variables

fp
VcfFile fp;

rc htsFile wrapper

rows
Bcf1[] rows;

individual records

vcfhdr
VCFHeader vcfhdr;

header wrapper

Examples

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();

Meta