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 | Static Public Member Functions | Static Public Attributes | Friends | List of all members
gamgee::Cigar Class Reference

Utility class to manage the memory of the cigar structure. More...

#include <cigar.h>

Public Member Functions

 Cigar (const std::shared_ptr< bam1_t > &sam_record)
 creates a Cigar object that points to htslib memory already allocated More...
 
 Cigar (const Cigar &other)
 creates a deep copy of a Cigar object More...
 
 Cigar (Cigar &&other)=default
 
Cigaroperator= (const Cigar &other)
 creates a deep copy of a Cigar object More...
 
Cigaroperator= (Cigar &&other)=default
 
 ~Cigar ()=default
 default destruction is sufficient, since our shared_ptr will handle deallocation More...
 
CigarElement operator[] (const uint32_t index) const
 use freely as you would an array. More...
 
CigarElementoperator[] (const uint32_t index)
 use freely as you would an array More...
 
uint32_t size () const
 number of base qualities in the container More...
 
bool operator== (const Cigar &other) const
 check for equality with another Cigar More...
 
bool operator!= (const Cigar &other) const
 check for inequality with another Cigar More...
 
std::string to_string () const
 produce a string representation of this Cigar More...
 

Static Public Member Functions

static CigarOperator cigar_op (const CigarElement cigar_element)
 gets the operator of an individual cigar element More...
 
static uint32_t cigar_oplen (const CigarElement cigar_element)
 gets the length of an individual cigar element More...
 
static CigarElement make_cigar_element (const uint32_t oplen, const CigarOperator op)
 creates an encoded htslib cigar element suitable for direct insertion into a Cigar out of a length and a CigarOperator More...
 
static CigarElement parse_next_cigar_element (std::stringstream &cigar_stream)
 utility function to parse cigar strings (in a stringstream) one element at a time More...
 
static bool consumes_read_bases (const CigarOperator op)
 returns true if operator is one of the following: Match (M), Insertion (I), Soft-Clip (S), Equal (=) or Different (X) More...
 
static bool consumes_reference_bases (const CigarOperator op)
 returns true if operator is one of the following: Match (M), Deletion (D), Reference-Skip (N), Equal (=) or Different (X) More...
 

Static Public Attributes

static const std::vector< int8_t > cigar_op_parse_table = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,-1,-1,-1,-1,9,-1,2,-1,-1,-1,5,1,-1,-1,-1,0,3,-1,6,-1,-1,4,-1,-1,-1,-1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
 Table used to parse chars representing cigar operations into their htslib encodings. More...
 

Friends

class SamBuilder
 builder needs access to the internals in order to build efficiently More...
 

Detailed Description

Utility class to manage the memory of the cigar structure.

Constructor & Destructor Documentation

gamgee::Cigar::Cigar ( const std::shared_ptr< bam1_t > &  sam_record)
explicit

creates a Cigar object that points to htslib memory already allocated

Note
the resulting Cigar object shares ownership of the pre-allocated memory via shared_ptr reference counting
gamgee::Cigar::Cigar ( const Cigar other)

creates a deep copy of a Cigar object

Note
the copy will have exclusive ownership over the newly-allocated htslib memory
gamgee::Cigar::Cigar ( Cigar &&  other)
default
gamgee::Cigar::~Cigar ( )
default

default destruction is sufficient, since our shared_ptr will handle deallocation

Member Function Documentation

static CigarOperator gamgee::Cigar::cigar_op ( const CigarElement  cigar_element)
inlinestatic

gets the operator of an individual cigar element

static uint32_t gamgee::Cigar::cigar_oplen ( const CigarElement  cigar_element)
inlinestatic

gets the length of an individual cigar element

static bool gamgee::Cigar::consumes_read_bases ( const CigarOperator  op)
inlinestatic

returns true if operator is one of the following: Match (M), Insertion (I), Soft-Clip (S), Equal (=) or Different (X)

static bool gamgee::Cigar::consumes_reference_bases ( const CigarOperator  op)
inlinestatic

returns true if operator is one of the following: Match (M), Deletion (D), Reference-Skip (N), Equal (=) or Different (X)

static CigarElement gamgee::Cigar::make_cigar_element ( const uint32_t  oplen,
const CigarOperator  op 
)
inlinestatic

creates an encoded htslib cigar element suitable for direct insertion into a Cigar out of a length and a CigarOperator

bool gamgee::Cigar::operator!= ( const Cigar other) const

check for inequality with another Cigar

Cigar & gamgee::Cigar::operator= ( const Cigar other)

creates a deep copy of a Cigar object

Note
the copy will have exclusive ownership over the newly-allocated htslib memory

< check for self assignment

< shared_ptr assignment will take care of deallocating old sam record if necessary

Cigar& gamgee::Cigar::operator= ( Cigar &&  other)
default
bool gamgee::Cigar::operator== ( const Cigar other) const

check for equality with another Cigar

CigarElement gamgee::Cigar::operator[] ( const uint32_t  index) const

use freely as you would an array.

access an individual cigar element by index

Returns
cigar element at the specified index as an encoded uint32_t. use cigar_op() and cigar_oplen() to unpack the cigar operator and length
CigarElement & gamgee::Cigar::operator[] ( const uint32_t  index)

use freely as you would an array

access and/or modify an individual cigar element by index

Returns
cigar element at the specified index as an encoded uint32_t. use cigar_op() and cigar_oplen() to unpack the cigar operator and length
CigarElement gamgee::Cigar::parse_next_cigar_element ( std::stringstream &  cigar_stream)
static

utility function to parse cigar strings (in a stringstream) one element at a time

This function is useful if you are parsing a cigar string into elements and operators. A simple way to iterate over all the elements is :

auto cigar_stream = stringstream{cigar_string}; // requires gcc 4.9's stdlibc++ if you can't use that, don't use auto on this line
while (cigar_stream.peek() != std::char_traits<char>::eof()) {
const auto element = parse_next_cigar_element(cigar_stream);
do_something_with(Cigar::cigar_op(element), Cigar::cigar_oplen(element));
}
Returns
a CigarElement with length and operator that can be extracted using the Cigar API (Cigar::cigar_op and Cigar::cigar_oplen) to actual elements.
uint32_t gamgee::Cigar::size ( ) const
inline

number of base qualities in the container

string gamgee::Cigar::to_string ( ) const

produce a string representation of this Cigar

returns a string representation of this cigar

Friends And Related Function Documentation

friend class SamBuilder
friend

builder needs access to the internals in order to build efficiently

Member Data Documentation

const std::vector< int8_t > gamgee::Cigar::cigar_op_parse_table = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,-1,-1,-1,-1,9,-1,2,-1,-1,-1,5,1,-1,-1,-1,0,3,-1,6,-1,-1,4,-1,-1,-1,-1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
static

Table used to parse chars representing cigar operations into their htslib encodings.

Note
: This table should eventually be moved to htslib. Currently htslib dynamically allocates and fills the equivalent of this table on-demand, which makes little sense.

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