HtslibFile

HtslibFile is an abstraction for htslib's htsFile using dhtslib.memory for reference counting.

Ideally this struct and its methods can replace file io across dhtslib through a standard interface. It can also centralize the ability to duplicate a file so that it can be iterated several times. It pairs with HtslibIterator.

Constructors

this
this(T f)

File or string ctor

this
this(T1 f, T2 mode)

File or string ctor with mode

Alias This

getFilePtr

allow HtslibFile to be used as underlying ptr type

Members

Functions

byRecord
auto byRecord()

iterate over all records in a file returns a HtslibIterator

dup
HtslibFile dup()

Duplicate the file with the same offset

loadHeader
void loadHeader(char commentChar)

Read a SAM/BAM header, VCF/BCF header, or text header and internally store it

loadHeader
void loadHeader(char commentChar)

Read a SAM/BAM header, VCF/BCF header, or text header and internally store it

loadHtsIndex
HtsIdx loadHtsIndex()

load BAM/BCF index

loadHtsIndex
HtsIdx loadHtsIndex(string idxFile)

load SAM/BAM index from filename

loadTabixIndex
Tbx loadTabixIndex()

load tabix index

loadTabixIndex
Tbx loadTabixIndex(T idxFile)

load tabix index from file

query
auto query(int tid, long beg, long end)

Query htsFile with tid, start, and end returns an HtslibIterator that has type T requires index be loaded first can use Tabix index or BAI/CSI index

query
auto query(string region)

Query htsFile with string region returns an HtslibIterator that has type T requires index and header be loaded first can use Tabix index or BAI/CSI index

query
auto query(string[] regions)

Query htsFile with array of regions returns an HtslibIterator that has type Bam1 requires index and header be loaded first

readRecord
auto readRecord()

read a BAM/SAM/BCF/VCF record

reset
void reset()

reset file reading

resetToFirstRecord
void resetToFirstRecord()

reset file reading

seek
void seek(long loc)

seek to offset in file

setExtraThreads
void setExtraThreads(int extra)

set extra multithreading

setHeader
void setHeader(T hdr)

set header for a HtlsibFile

tell
off_t tell()

get file offset

write
void write(T rec)

write SAM/BAM/VCF/BCF record, string, or ubyte data requires the header be loaded if writing SAM/BAM/VCF/BCF record

writeHeader
void writeHeader()

write internally stored header

writeln
void writeln(T rec)

write a string with a newline appended

Properties

getFilePtr
inout(HtsFile) getFilePtr [@property getter]

get underlying file pointer wrapper

Variables

bamHdr
BamHdr bamHdr;

SAM/BAM/CRAM header

bcfHdr
BcfHdr bcfHdr;

BCF/VCF header

eof
bool eof;

is file end reached?

f
File f;

D File if used

fn
Kstring fn;

dhtslib.memory kstring_t rc wrapper Since we need the filename as a null terminated string anyway just use kstring

fp
HtsFile fp;

dhtslib.memory htsFile* rc wrapper File pointer

headerOffset
off_t headerOffset;

offset of file after header if it has been loaded

idx
HtsIdx idx;

SAM/BAM/CRAM index

mode
char[] mode;
Undocumented in source.
tbx
Tbx tbx;

Tabix index

textHdr
Kstring textHdr;

text header

Meta