IndexedFastaFile

FASTA file with .fai or .gzi index

Reads existing FASTA file, optionally creating FASTA index if one does not exist.

Convenient member fns to get no. of sequences, get sequence names and lengths, test for membership, and rapidly fetch sequence at offset.

Constructors

this
this(string fn, bool create)

construct from filename, optionally creating index if it does not exist throws Exception (TODO: remove) if file DNE, or if index DNE unless create->true

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Functions

fetchSequence
string fetchSequence(string region)

Fetch sequence in region by assoc array-style lookup: string sequence = fafile.fetchSequence("chr2:20123-30456")

fetchSequence
string fetchSequence(string contig, int start, int end)

Fetch sequence in region by multidimensional slicing: string sequence = fafile.fetchSequence("chr2", 20123, 30456)

hasSeq
bool hasSeq(const(char)[] seqname)

Test whether the FASTA file/index contains string seqname

opIndex
auto opIndex(string region)

Fetch sequence in region by assoc array-style lookup: string sequence = fafile["chr2:20123-30456"]

opIndex
auto opIndex(string contig, int[2] pos)
opSlice
int[2] opSlice(int start, int end)

Fetch sequence in region by multidimensional slicing: string sequence = fafile["chr2", 20123 .. 30456]

seqLen
int seqLen(const(char)[] seqname)

Return sequence length, -1 if not present

seqName
string seqName(int i)

Return the name of the i'th sequence

setCacheSize
void setCacheSize(int size)

Enable BGZF cacheing (size: bytes)

setThreads
void setThreads(int nthreads)

Enable multithreaded decompression of this FA/FQ Reading fn body of bgzf_mt, this actually ADDS threads (rather than setting) but we'll retain name for consistency with setCacheSize NB: IN A REAL-WORLD TEST (swiftover) CALLING setThreads(1) doubled runtime(???)

Properties

nSeq
auto nSeq [@property getter]

Return the number of sequences in the FASTA file/index

Meta