Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Classes | Functions
gamgee::utils Namespace Reference

utility functions for the gamgee library More...

Classes

struct  HtsFileDeleter
 a functor object to delete an htsFile pointer More...
 
struct  SamBodyDeleter
 a functor object to delete a bam1_t pointer More...
 
struct  SamHeaderDeleter
 a functor object to delete a bam_hdr_t pointer More...
 
struct  VariantBodyDeleter
 a functor object to delete a bcf1_t pointer More...
 
struct  VariantHeaderDeleter
 a functor object to delete a bcf_hdr_t pointer More...
 

Functions

shared_ptr< bam1_t > make_shared_sam (bam1_t *sam_ptr)
 wraps a pre-allocated bam1_t in a shared_ptr with correct deleter More...
 
shared_ptr< bam_hdr_t > make_shared_sam_header (bam_hdr_t *sam_header_ptr)
 wraps a pre-allocated bam_hdr_t in a shared_ptr with correct deleter More...
 
shared_ptr< bcf1_t > make_shared_variant (bcf1_t *bcf_ptr)
 wraps a pre-allocated bcf1_t in a shared_ptr with correct deleter More...
 
shared_ptr< bcf_hdr_t > make_shared_variant_header (bcf_hdr_t *bcf_hdr_ptr)
 wraps a pre-allocated bcf_hdr_t in a shared_ptr with correct deleter More...
 
bam1_t * sam_deep_copy (bam1_t *original)
 creates a deep copy of an existing bam1_t More...
 
bam_hdr_t * sam_header_deep_copy (bam_hdr_t *original)
 creates a deep copy of an existing bam_hdr_t More...
 
bcf1_t * variant_deep_copy (bcf1_t *original)
 creates a deep copy of an existing bcf1_t More...
 
bcf_hdr_t * variant_header_deep_copy (bcf_hdr_t *original)
 creates a deep copy of an existing bcf_hdr_t More...
 
char complement_base (const char base)
 
std::string complement (std::string &sequence)
 calculates the complement of a sequence in-place More...
 
std::string complement (const std::string &sequence)
 calculates the complement of a sequence More...
 
std::string reverse_complement (const std::string &sequence)
 calculates the reverse complement of a sequence More...
 
template<typename T , typename... Args>
std::unique_ptr< T > make_unique (Args &&...args)
 herb sutter's implementation of make unique More...
 
std::vector< std::string > hts_string_array_to_vector (const char *const *const string_array, const uint32_t array_size)
 converts an array of c-strings into a vector<string> More...
 
char complement (const char base)
 calculates the complement of a base More...
 

Detailed Description

utility functions for the gamgee library

This namespace includes typical functors and templates for DNA sequence manipulation as well as low level routines for htslib memory management

Function Documentation

std::string gamgee::utils::complement ( std::string &  sequence)

calculates the complement of a sequence in-place

Parameters
sequencethe sequence to turn into the complement
Returns
the complement of the sequence calculated in-place (modifies the sequence)
std::string gamgee::utils::complement ( const std::string &  sequence)

calculates the complement of a sequence

Parameters
sequencethe sequence to get the complement from
Returns
a new string with the complement of the sequence
char gamgee::utils::complement ( const char  base)

calculates the complement of a base

Parameters
basethe base to get the complement from
Returns
a new char with the complement of base
char gamgee::utils::complement_base ( const char  base)
std::vector< std::string > gamgee::utils::hts_string_array_to_vector ( const char *const *const  string_array,
const uint32_t  array_size 
)

converts an array of c-strings into a vector<string>

Useful in many hts structs where a list of names is stored as a char** and we want to manipulate it in a vector<string> to maintain data contiguity and improve usability

std::shared_ptr< bam1_t > gamgee::utils::make_shared_sam ( bam1_t *  sam_ptr)

wraps a pre-allocated bam1_t in a shared_ptr with correct deleter

Parameters
sam_ptran htslib raw bam pointer
std::shared_ptr< bam_hdr_t > gamgee::utils::make_shared_sam_header ( bam_hdr_t *  sam_header_ptr)

wraps a pre-allocated bam_hdr_t in a shared_ptr with correct deleter

Parameters
sam_header_ptran htslib raw bam header pointer
std::shared_ptr< bcf1_t > gamgee::utils::make_shared_variant ( bcf1_t *  bcf_ptr)

wraps a pre-allocated bcf1_t in a shared_ptr with correct deleter

Parameters
bcf_ptran htslib raw vcf pointer
std::shared_ptr< bcf_hdr_t > gamgee::utils::make_shared_variant_header ( bcf_hdr_t *  bcf_hdr_ptr)

wraps a pre-allocated bcf_hdr_t in a shared_ptr with correct deleter

Parameters
bcf_hdr_ptran htslib raw variant header pointer
template<typename T , typename... Args>
std::unique_ptr< T > gamgee::utils::make_unique ( Args &&...  args)

herb sutter's implementation of make unique

Note
this is going to become standard in C++14, we can drop this as soon as gcc 4.9 and clang 3.5 are released
std::string gamgee::utils::reverse_complement ( const std::string &  sequence)

calculates the reverse complement of a sequence

Parameters
sequencethe sequence to get the reverse complement from
Returns
a new string with the reverse complement of the sequence
bam1_t * gamgee::utils::sam_deep_copy ( bam1_t *  original)

creates a deep copy of an existing bam1_t

Parameters
originalan htslib raw bam pointer
bam_hdr_t * gamgee::utils::sam_header_deep_copy ( bam_hdr_t *  original)

creates a deep copy of an existing bam_hdr_t

Parameters
originalan htslib raw bam header pointer
bcf1_t * gamgee::utils::variant_deep_copy ( bcf1_t *  original)

creates a deep copy of an existing bcf1_t

Parameters
originalan htslib raw bcf pointer
bcf_hdr_t * gamgee::utils::variant_header_deep_copy ( bcf_hdr_t *  original)

creates a deep copy of an existing bcf_hdr_t

Parameters
originalan htslib raw bcf header pointer