vg
tools for working with variation graphs
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
vg::VcfBuffer Class Reference

#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
 
VcfBufferoperator= (const VcfBuffer &other)=delete
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ VcfBuffer() [1/2]

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).

◆ VcfBuffer() [2/2]

vg::VcfBuffer::VcfBuffer ( const VcfBuffer other)
privatedelete

Member Function Documentation

◆ fill_buffer()

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.

◆ get()

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.

◆ handle_buffer()

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.

◆ has_tabix()

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.

◆ operator=()

VcfBuffer& vg::VcfBuffer::operator= ( const VcfBuffer other)
privatedelete

◆ set_region()

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.

Member Data Documentation

◆ buffer

vcflib::Variant vg::VcfBuffer::buffer
protected

◆ file

vcflib::VariantCallFile* const vg::VcfBuffer::file
protected

◆ has_buffer

bool vg::VcfBuffer::has_buffer = false
protected

◆ safe_to_get

bool vg::VcfBuffer::safe_to_get = true
protected

The documentation for this class was generated from the following files: