Base class to store look up information between fields of merged header and input headers.
More...
|
void | reset_luts () |
| : clear all mappings More...
|
|
void | add_input_merged_idx_pair (unsigned inputGVCFIdx, int inputIdx, int mergedIdx) |
|
template<bool M = merged_2_inputs_LUT_is_input_ordered, typename std::enable_if< M >::type * = nullptr> |
int | get_input_idx_for_merged (unsigned inputGVCFIdx, int mergedIdx) const |
| Get field idx for input VCF inputGVCFIdx corresponding to field idx mergedIdx in the mergedVCF file. More...
|
|
template<bool M = merged_2_inputs_LUT_is_input_ordered, typename std::enable_if<!M >::type * = nullptr> |
int | get_input_idx_for_merged (unsigned inputGVCFIdx, int mergedIdx) const |
|
template<bool M = inputs_2_merged_LUT_is_input_ordered, typename std::enable_if< M >::type * = nullptr> |
int | get_merged_idx_for_input (unsigned inputGVCFIdx, int inputIdx) const |
| Get field idx for the merged VCF corresponding to field idx inputIdx in the input VCF of index inputGVCFIdx. More...
|
|
template<bool M = inputs_2_merged_LUT_is_input_ordered, typename std::enable_if<!M >::type * = nullptr> |
int | get_merged_idx_for_input (unsigned inputGVCFIdx, int inputIdx) const |
|
void | reset_merged_idx_for_input (unsigned inputGVCFIdx, int inputIdx) |
| reset/invalidate merged field index for field inputIdx of input VCF inputGVCFIdx More...
|
|
void | reset_input_idx_for_merged (unsigned inputGVCFIdx, int mergedIdx) |
| reset/invalidate the input field index for input VCF inputGVCFIdx for merged field mergedIdx More...
|
|
|
| MergedVCFLUTBase () |
|
| MergedVCFLUTBase (unsigned numInputGVCFs, unsigned numMergedFields) |
|
| ~MergedVCFLUTBase ()=default |
|
void | clear () |
| deallocates memory More...
|
|
template<bool M = inputs_2_merged_LUT_is_input_ordered, typename std::enable_if< M >::type * = nullptr> |
void | resize_inputs_2_merged_lut_if_needed (unsigned numInputGVCFs, unsigned numMergedFields) |
| resize LUT functions More...
|
|
template<bool M = inputs_2_merged_LUT_is_input_ordered, typename std::enable_if<!M >::type * = nullptr> |
void | resize_inputs_2_merged_lut_if_needed (unsigned numInputGVCFs, unsigned numMergedFields) |
|
template<bool M = merged_2_inputs_LUT_is_input_ordered, typename std::enable_if< M >::type * = nullptr> |
void | resize_merged_2_inputs_lut_if_needed (unsigned numInputGVCFs, unsigned numMergedFields) |
|
template<bool M = merged_2_inputs_LUT_is_input_ordered, typename std::enable_if<!M >::type * = nullptr> |
void | resize_merged_2_inputs_lut_if_needed (unsigned numInputGVCFs, unsigned numMergedFields) |
|
void | resize_luts_if_needed (unsigned numInputGVCFs, unsigned numMergedFields) |
|
template<bool inputs_2_merged_LUT_is_input_ordered, bool merged_2_inputs_LUT_is_input_ordered>
class gamgee::utils::MergedVCFLUTBase< inputs_2_merged_LUT_is_input_ordered, merged_2_inputs_LUT_is_input_ordered >
Base class to store look up information between fields of merged header and input headers.
LUT = Look Up Table (to avoid confusion with map, unordered_map etc)
- Note
- This is the helper class for VariantHeaderMerger to store mapping for fields and samples Each MergedVCFLUTBase object contains 2 matrices (vector of vector): one for mapping input field idx to merged field idx (m_inputs_2_merged_lut) and the second for mapping merged field idx to input field idx (m_merged_2_inputs_lut).
Missing field information is stored as bcf_int32_missing, but should be checked with gamgee::missing() function
The boolean template parameters specify how the 2 tables are laid out in memory - whether the outer vector corresponds to fields or input vcfs. For example, in object of type MergedVCFLUTBase<true, true>, both LUTs are laid out such that m_inputs_2_merged_lut[0] contains mappings for all fields for input VCF file 0. This would lead to fast traversal of all fields for a given input VCF (cache locality). However, traversing over all input VCFs for a given field would be slow (many cache misses). The object MergedVCFLUTBase<false,false> would have the exact opposite behavior
The 'best' value of the template parameters depends on the application using the LUT. Almost all the 'complexity' of the code comes from being able to handle the different layouts in a transparent manner
Alternate explanation: This class contains two matrices (vector<vector<int>>) to store the mapping information: m_inputs_2_merged_lut and m_merged_2_inputs_lut. You can layout each matrix in one of the 2 following ways: (a) LUT[i][j] corresponds to input VCF i and field j (b) LUT[i][j] corresponds to field i and input VCF j Option (a) is optimal where you are looking at all the fields of a VCF in quick succession, while (b) is optimal when you are looking at all VCFs for a particular field. The 2 boolean template parameters control the layout of the two matrices. If the parameter value is true, then option (a) is picked, else option (b)
Although the class provides functions to resize the tables, for obtaining good performance, reallocations should be extremely infrequent. Making the resize_luts_if_needed() a protected member forces developers to think twice instead of blindly calling this function.
Uses the enable_if trick from http://en.cppreference.com/w/cpp/types/enable_if (foo3) to handle different memory layouts