Minimac4
Loading...
Searching...
No Matches
reduced_haplotypes Class Reference

Represents a collection of haplotype blocks with reduced storage. More...

#include <unique_haplotype.hpp>

Classes

class  iterator
 Iterator for traversing variants within reduced_haplotypes. More...
 

Public Member Functions

iterator begin () const
 
iterator end () const
 
 reduced_haplotypes ()
 
 reduced_haplotypes (std::size_t min_block_size, std::size_t max_block_size)
 Constructs a reduced_haplotypes object with specified block size limits.
 
bool compress_variant (const reference_site_info &site_info, const std::vector< std::int8_t > &alleles, bool flush_block=false)
 Compresses a variant into the current reduced haplotype block.
 
void append_block (const unique_haplotype_block &block)
 Appends a new haplotype block to the collection of reduced haplotype blocks.
 
void fill_cm (genetic_map_file &map_file)
 Fills the centimorgan (cM) values for all variants in all blocks using the provided genetic map.
 
float compression_ratio () const
 Calculates the overall compression ratio of all haplotype blocks.
 
const std::deque< unique_haplotype_block > & blocks () const
 Accesses the stored haplotype blocks.
 
std::size_t variant_size () const
 Returns the total number of variants across all blocks.
 

Detailed Description

Represents a collection of haplotype blocks with reduced storage.

This class manages a sequence of unique_haplotype_block objects, allowing efficient storage and access to haplotypes across multiple genomic variants. It maintains block offsets, variant counts, and supports compression of variants.

Note
Iterators traverse variants across all blocks in order.

Constructor & Destructor Documentation

◆ reduced_haplotypes() [1/2]

reduced_haplotypes::reduced_haplotypes ( )
inline
Here is the caller graph for this function:

◆ reduced_haplotypes() [2/2]

reduced_haplotypes::reduced_haplotypes ( std::size_t min_block_size,
std::size_t max_block_size )

Constructs a reduced_haplotypes object with specified block size limits.

This constructor initializes the minimum and maximum haplotype block sizes. It ensures that both sizes are at least 1.

Parameters
min_block_sizeMinimum allowed size for a haplotype block.
max_block_sizeMaximum allowed size for a haplotype block.

Member Function Documentation

◆ append_block()

void reduced_haplotypes::append_block ( const unique_haplotype_block & block)

Appends a new haplotype block to the collection of reduced haplotype blocks.

If the first variant of the new block is identical to the last variant of the previous block (same position, reference, and alternate alleles), the duplicate variant from the previous block is removed to avoid redundancy.

Parameters
blockThe unique haplotype block to append.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ begin()

iterator reduced_haplotypes::begin ( ) const
inline
Here is the caller graph for this function:

◆ blocks()

const std::deque< unique_haplotype_block > & reduced_haplotypes::blocks ( ) const
inline

Accesses the stored haplotype blocks.

Returns
A constant reference to the deque of unique_haplotype_block objects.
Here is the caller graph for this function:

◆ compress_variant()

bool reduced_haplotypes::compress_variant ( const reference_site_info & site_info,
const std::vector< std::int8_t > & alleles,
bool flush_block = false )

Compresses a variant into the current reduced haplotype block.

This function attempts to add a variant to the last haplotype block. If the compression ratio improves or the flush flag is set, a new block is started.

Parameters
site_infoReference information for the variant (chromosome, position, alleles, etc.).
allelesVector of alleles corresponding to each haplotype.
flush_blockIf true, forces the current block to flush and start a new block.
Returns
True if the variant was successfully compressed into the block, false otherwise.
Here is the caller graph for this function:

◆ compression_ratio()

float reduced_haplotypes::compression_ratio ( ) const

Calculates the overall compression ratio of all haplotype blocks.

The compression ratio is defined as the ratio between the sum of expanded haplotype sizes plus the product of unique haplotype size and variant count, divided by the total expanded haplotype size multiplied by the number of variants across all blocks.

Returns
The compression ratio as a float.

◆ end()

iterator reduced_haplotypes::end ( ) const
inline
Here is the caller graph for this function:

◆ fill_cm()

void reduced_haplotypes::fill_cm ( genetic_map_file & map_file)

Fills the centimorgan (cM) values for all variants in all blocks using the provided genetic map.

Parameters
map_fileThe genetic map file used to interpolate centimorgan values.
Here is the caller graph for this function:

◆ variant_size()

std::size_t reduced_haplotypes::variant_size ( ) const
inline

Returns the total number of variants across all blocks.

Returns
Total variant count as std::size_t.
Here is the caller graph for this function:

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