Represents a collection of haplotype blocks with reduced storage.
More...
#include <unique_haplotype.hpp>
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.
◆ reduced_haplotypes() [1/2]
reduced_haplotypes::reduced_haplotypes |
( |
| ) |
|
|
inline |
◆ 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_size | Minimum allowed size for a haplotype block. |
max_block_size | Maximum allowed size for a haplotype block. |
◆ append_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
-
block | The unique haplotype block to append. |
◆ begin()
iterator reduced_haplotypes::begin |
( |
| ) |
const |
|
inline |
◆ blocks()
Accesses the stored haplotype blocks.
- Returns
- A constant reference to the deque of unique_haplotype_block objects.
◆ 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_info | Reference information for the variant (chromosome, position, alleles, etc.). |
alleles | Vector of alleles corresponding to each haplotype. |
flush_block | If 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.
◆ 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 |
◆ fill_cm()
Fills the centimorgan (cM) values for all variants in all blocks using the provided genetic map.
- Parameters
-
map_file | The genetic map file used to interpolate centimorgan values. |
◆ 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.
The documentation for this class was generated from the following files: