vg
tools for working with variation graphs
|
#include <vcf_buffer.hpp>
Public Member Functions | |
vcflib::Variant * | get () |
void | handle_buffer () |
void | fill_buffer () |
bool | has_tabix () const |
bool | set_region (const string &contig, int64_t start=-1, int64_t end=-1) |
VcfBuffer (vcflib::VariantCallFile *file=nullptr) | |
Protected Attributes | |
bool | has_buffer = false |
bool | safe_to_get = true |
vcflib::Variant | buffer |
vcflib::VariantCallFile *const | file |
Private Member Functions | |
VcfBuffer (const VcfBuffer &other)=delete | |
VcfBuffer & | operator= (const VcfBuffer &other)=delete |
Provides a one-variant look-ahead buffer on a vcflib::VariantFile. Lets construction functions peek and see if they want the next variant, or lets them ignore it for the next construction function for a different contig to handle. Ought not to be copied.
vg::VcfBuffer::VcfBuffer | ( | vcflib::VariantCallFile * | file = nullptr | ) |
Make a new VcfBuffer buffering the file at the given pointer (which must outlive the buffer, but which may be null).
|
privatedelete |
void vg::VcfBuffer::fill_buffer | ( | ) |
Can be called when the buffer is filled or empty. If there is no variant in the buffer, tries to load a variant into the buffer, if one can be obtained from the file.
vcflib::Variant * vg::VcfBuffer::get | ( | ) |
Return a pointer to the buffered variant, or null if no variant is buffered. Pointer is invalidated when the buffer is handled.
Although the variant is not const, it may not be moved out of or modified in ways that confuse vcflib.
void vg::VcfBuffer::handle_buffer | ( | ) |
To be called when the buffer is filled. Marks the buffered variant as handled, discarding it, and allowing another to be read.
bool vg::VcfBuffer::has_tabix | ( | ) | const |
This returns true if we have a tabix index, and false otherwise. If this is false, set_region may be called, but will do nothing and return false.
bool vg::VcfBuffer::set_region | ( | const string & | contig, |
int64_t | start = -1 , |
||
int64_t | end = -1 |
||
) |
This tries to set the region on the underlying vcflib VariantCallFile to the given contig and region, if specified. Coordinates coming in should be 0-based, and will be converted to 1-based internally.
Returns true if the region was successfully set, and false otherwise (for example, if there is not tabix index, or if the given region is not part of this VCF. Note that if there is a tabix index, and set_region returns false, the position in the VCF file is undefined until the next successful set_region call.
If either of start and end are specified, then both of start and end must be specified.
Discards any variants previously in the buffer.
|
protected |
|
protected |
|
protected |
|
protected |