Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering > Class Template Reference

#include <merged_vcf_lut.h>

Public Member Functions

 VariantHeaderMerger ()
 empty constructor, initialize 'large' LUTs More...
 
 VariantHeaderMerger (const std::shared_ptr< bcf_hdr_t > &input_vcf_header)
 Constructor with a single input VCF header as input. More...
 
 VariantHeaderMerger (const VariantHeader &input_vcf_header)
 Constructor with a single input VCF header as input. More...
 
 VariantHeaderMerger (const std::vector< std::shared_ptr< bcf_hdr_t >> &input_vcf_headers)
 Constructor with a vector of input VCF headers to be merged. More...
 
 VariantHeaderMerger (const std::vector< VariantHeader > &input_vcf_headers)
 Constructor with a vector of input VCF headers to be merged. More...
 
 VariantHeaderMerger (const VariantHeaderMerger &)=delete
 
VariantHeaderMergeroperator= (const VariantHeaderMerger &)=delete
 
 VariantHeaderMerger (VariantHeaderMerger &&)=default
 
VariantHeaderMergeroperator= (VariantHeaderMerger &&)=default
 
 ~VariantHeaderMerger ()=default
 
void reset ()
 : resets all mappings, but does not de-allocate LUT memory More...
 
void clear ()
 : resets all mappings, de-allocates LUT memory More...
 
void add_header (const std::shared_ptr< bcf_hdr_t > &hdr)
 add a new header into the merged header and update LUTs More...
 
void add_header (const VariantHeader &hdr)
 add a new header into the merged header and update LUTs More...
 
void add_headers (const std::vector< std::shared_ptr< bcf_hdr_t >> &headers)
 add a vector of new VCF headers into the merged header and update LUTs More...
 
void add_headers (const std::vector< VariantHeader > &headers)
 add a vector of new VCF headers into the merged header and update LUTs More...
 
const std::shared_ptr
< bcf_hdr_t > & 
get_raw_merged_header () const
 Get merged VCF header shared_ptr. More...
 
const VariantHeader get_merged_header () const
 Get merged VCF header. More...
 
int get_merged_sample_idx_for_input (unsigned inputGVCFIdx, int inputSampleIdx) const
 Get sample idx for the merged VCF corresponding to sample idx inputSampleIdx in the input VCF of index inputGVCFIdx. More...
 
int get_merged_header_idx_for_input (unsigned inputGVCFIdx, int inputIdx) const
 Get header field (FLT/FMT/INFO) idx for the merged VCF corresponding to field idx inputIdx in the input VCF of index inputGVCFIdx. More...
 
int get_input_sample_idx_for_merged (unsigned inputGVCFIdx, int mergedSampleIdx) const
 Get sample idx for the input VCF inputGVCFIdx corresponding to sample mergedSampleIdx in the merged VCF. More...
 
int get_input_header_idx_for_merged (unsigned inputGVCFIdx, int mergedIdx) const
 Get header field (FLT/FMT/INFO) idx for the input VCF inputGVCFIdx corresponding to field mergedIdx in the merged VCF. More...
 
void store_merged_field_idx_for_enum (const std::string &field, unsigned field_enum_idx)
 utility function for storing index of frequently used fields in the merged VCF Sometimes the user/developer may know beforehand that certain fields are needed/accesssed (for example "PL") for every variant in a merged VCF Instead of doing a string search everytime, the user may wish to define an enum corresponding to the relevant fields and store the index of the relevant fields in the merged VCF after the merged header is built. Subsequent accesses to the fields need not use any string searches, instead directly using the idx in the LUT Example, the user could define an enum { PL_FIELD=0, AD_FIELD, AF_FIELD } and call the function store_merged_field_idx_for_enum("PL", PL_FIELD); store_merged_field_idx_for_enum("AD", AD_FIELD); ... More...
 
int get_merged_field_idx_for_enum (unsigned field_enum_idx) const
 
int get_enum_for_merged_field_idx (int merged_field_idx) const
 

Constructor & Destructor Documentation

template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::VariantHeaderMerger ( )
inline

empty constructor, initialize 'large' LUTs

template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::VariantHeaderMerger ( const std::shared_ptr< bcf_hdr_t > &  input_vcf_header)
inline

Constructor with a single input VCF header as input.

Parameters
input_vcf_headerheader of input VCF
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::VariantHeaderMerger ( const VariantHeader input_vcf_header)
inline

Constructor with a single input VCF header as input.

Parameters
input_vcf_headerheader of input VCF
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::VariantHeaderMerger ( const std::vector< std::shared_ptr< bcf_hdr_t >> &  input_vcf_headers)
inline

Constructor with a vector of input VCF headers to be merged.

Parameters
input_vcf_headersvector of headers of input VCFs which are being merged
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::VariantHeaderMerger ( const std::vector< VariantHeader > &  input_vcf_headers)
inline

Constructor with a vector of input VCF headers to be merged.

Parameters
input_vcf_headersvector of headers of input VCFs which are being merged
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::VariantHeaderMerger ( const VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering > &  )
delete
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::VariantHeaderMerger ( VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering > &&  )
default
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::~VariantHeaderMerger ( )
default

Member Function Documentation

template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
void gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::add_header ( const std::shared_ptr< bcf_hdr_t > &  hdr)

add a new header into the merged header and update LUTs

Parameters
hdrnew input header to add
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
void gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::add_header ( const VariantHeader hdr)

add a new header into the merged header and update LUTs

Parameters
hdrnew input header to add
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
void gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::add_headers ( const std::vector< std::shared_ptr< bcf_hdr_t >> &  headers)

add a vector of new VCF headers into the merged header and update LUTs

Parameters
headersvector of new input VCF headers to add
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
void gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::add_headers ( const std::vector< VariantHeader > &  headers)

add a vector of new VCF headers into the merged header and update LUTs

Parameters
headersvector of new input VCF headers to add
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
void gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::clear ( )
inline

: resets all mappings, de-allocates LUT memory

template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
int gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::get_enum_for_merged_field_idx ( int  merged_field_idx) const
inline
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
int gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::get_input_header_idx_for_merged ( unsigned  inputGVCFIdx,
int  mergedIdx 
) const
inline

Get header field (FLT/FMT/INFO) idx for the input VCF inputGVCFIdx corresponding to field mergedIdx in the merged VCF.

Parameters
inputGVCFIdxindex of the input VCF file
mergedIdxindex of the field in the merged VCF file
Returns
index of the field in the input VCF file inputGVCFIdx
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
int gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::get_input_sample_idx_for_merged ( unsigned  inputGVCFIdx,
int  mergedSampleIdx 
) const
inline

Get sample idx for the input VCF inputGVCFIdx corresponding to sample mergedSampleIdx in the merged VCF.

Parameters
inputGVCFIdxindex of the input VCF file
mergedSampleIdxindex of the sample in the merged VCF file
Returns
index of the sample in the input VCF file inputGVCFIdx
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
int gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::get_merged_field_idx_for_enum ( unsigned  field_enum_idx) const
inline
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
const VariantHeader gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::get_merged_header ( ) const
inline

Get merged VCF header.

Returns
return the merged VCF header
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
int gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::get_merged_header_idx_for_input ( unsigned  inputGVCFIdx,
int  inputIdx 
) const
inline

Get header field (FLT/FMT/INFO) idx for the merged VCF corresponding to field idx inputIdx in the input VCF of index inputGVCFIdx.

Parameters
inputGVCFIdxindex of the input VCF file
inputIdxindex of the field in the input VCF file
Returns
index of the field in the merged VCF file
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
int gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::get_merged_sample_idx_for_input ( unsigned  inputGVCFIdx,
int  inputSampleIdx 
) const
inline

Get sample idx for the merged VCF corresponding to sample idx inputSampleIdx in the input VCF of index inputGVCFIdx.

Parameters
inputGVCFIdxindex of the input VCF file
inputSampleIdxindex of the sample in the input VCF file
Returns
index of the sample in the merged VCF file
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
const std::shared_ptr<bcf_hdr_t>& gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::get_raw_merged_header ( ) const
inline

Get merged VCF header shared_ptr.

Returns
return the merged VCF header shared_ptr
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
VariantHeaderMerger& gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::operator= ( const VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering > &  )
delete
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
VariantHeaderMerger& gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::operator= ( VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering > &&  )
default
template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
void gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::reset ( )
inline

: resets all mappings, but does not de-allocate LUT memory

template<bool fields_forward_LUT_ordering, bool fields_reverse_LUT_ordering, bool samples_forward_LUT_ordering, bool samples_reverse_LUT_ordering>
void gamgee::VariantHeaderMerger< fields_forward_LUT_ordering, fields_reverse_LUT_ordering, samples_forward_LUT_ordering, samples_reverse_LUT_ordering >::store_merged_field_idx_for_enum ( const std::string &  field,
unsigned  field_enum_idx 
)

utility function for storing index of frequently used fields in the merged VCF Sometimes the user/developer may know beforehand that certain fields are needed/accesssed (for example "PL") for every variant in a merged VCF Instead of doing a string search everytime, the user may wish to define an enum corresponding to the relevant fields and store the index of the relevant fields in the merged VCF after the merged header is built. Subsequent accesses to the fields need not use any string searches, instead directly using the idx in the LUT Example, the user could define an enum { PL_FIELD=0, AD_FIELD, AF_FIELD } and call the function store_merged_field_idx_for_enum("PL", PL_FIELD); store_merged_field_idx_for_enum("AD", AD_FIELD); ...

While processing variants, the user could directly use the merged field idx using the function auto merged_PL_idx = get_merged_field_idx_for_enum(PL_FIELD); This completely avoids string searches during variant processing

The reverse function (get_enum_for_merged_field_idx) is also useful: for(i=0;i<bcf1_t->n_info;++i) { switch(VariantHeaderMerger.get_enum_for_merged_field_idx(bcf1_t->d.info[i].key)) { case PL_FIELD: do_something_with_PL(); break; .... } }


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