yat  0.12.3pre
Public Member Functions | Friends | Related Functions | List of all members
theplu::yat::omic::BamRead Class Reference

Class holding a bam query. More...

#include <yat/omic/BamRead.h>

Public Member Functions

 BamRead (void)
 default constructor More...
 
 BamRead (const BamRead &other)
 Copy constructor.
 
virtual ~BamRead (void)
 Destructor.
 
const BamReadoperator= (const BamRead &rhs)
 assignment operator
 
const uint8_t * aux (void) const
 
const uint8_t * aux (const char tag[2]) const
 
void aux_append (const char tag[2], char type, int len, uint8_t *data)
 append a new tag to aux field More...
 
void aux_del (const char tag[2])
 remove a tag in aux field More...
 
int aux_size (void) const
 
const bam1_core_t & core (void) const
 access core data struct More...
 
bam1_core_t & core (void)
 access core data struct More...
 
const uint32_t * cigar (void) const
 access CIGAR array More...
 
uint32_t cigar (size_t i) const
 
uint32_t cigar_op (size_t i) const
 
uint32_t cigar_oplen (size_t i) const
 
std::string cigar_str (void) const
 
void cigar (const std::vector< uint32_t > &c)
 set CIGAR More...
 
void cigar (const utility::Aligner::Cigar &cigar)
 set CIGAR More...
 
int32_t end (void) const
 rightmost coordinate More...
 
uint16_t flag (void) const
 bitwise flag More...
 
int32_t mpos (void) const
 leftmost position for mate
 
int32_t mtid (void) const
 Chromosome ID for mate.
 
const char * name (void) const
 
void name (const std::string &n)
 modify name More...
 
int32_t pos (void) const
 0-based laftmost coordinate
 
uint8_t qual (size_t i) const
 
void qual (size_t i, uint8_t q)
 set quality of a base More...
 
std::string sequence (void) const
 
uint8_t sequence (size_t index) const
 
void sequence (size_t i, uint8_t x)
 modify a base in sequence More...
 
void sequence (const std::string &seq, const std::vector< uint8_t > &qual)
 set sequence and quality More...
 
uint32_t sequence_length (void) const
 
void swap (BamRead &other)
 
int32_t tid (void) const
 chromosome ID
 

Friends

class InBamFile
 
class OutBamFile
 
class BamReadIterator
 

Related Functions

(Note that these are not member functions.)

void swap (BamRead &lhs, BamRead &rhs)
 
bool soft_clipped (const BamRead &bam)
 
uint32_t left_soft_clipped (const BamRead &bam)
 
uint32_t right_soft_clipped (const BamRead &bam)
 
bool same_query_name (const BamRead &lhs, const BamRead &rhs)
 

Detailed Description

Class holding a bam query.

This is a wrapper around bam1_t and most of its information is held in the core struct. A BamRead is typically created from a InBamFile.

See Also
samtools
Since
New in yat 0.10

Constructor & Destructor Documentation

theplu::yat::omic::BamRead::BamRead ( void  )

default constructor

Constructed object contains no data and most operations are not defined

Member Function Documentation

const uint8_t* theplu::yat::omic::BamRead::aux ( void  ) const
Returns
pointer to auxiliary data
See Also
aux_size(void)
const uint8_t* theplu::yat::omic::BamRead::aux ( const char  tag[2]) const

Use bam_aux2? functions (in samtools C api) to convert returned pointer to corresponding type.

Returns
pointer to field associated with tag, NULL if tag doesn't exist.
See Also
bam_aux_get
Since
New in yat 0.11
void theplu::yat::omic::BamRead::aux_append ( const char  tag[2],
char  type,
int  len,
uint8_t *  data 
)

append a new tag to aux field

Parameters
tagtwo-charcter tag to append
typedescribes which type and can be 'iIsScCdfAZH'
lenlength of data
datapointer to data
Since
New in yat 0.11
See Also
SAM specification
void theplu::yat::omic::BamRead::aux_del ( const char  tag[2])

remove a tag in aux field

Exceptions
utility::runtime_errorif tag is not present in read
Since
New in yat 0.11
int theplu::yat::omic::BamRead::aux_size ( void  ) const
Returns
length of aux field
Since
New in yat 0.11
const uint32_t* theplu::yat::omic::BamRead::cigar ( void  ) const

access CIGAR array

In each element the lower 4 bits gives a CIGAR operation and the upper 28 bits keep the length.

uint32_t theplu::yat::omic::BamRead::cigar ( size_t  i) const
Returns
i th element of CIGAR array
void theplu::yat::omic::BamRead::cigar ( const std::vector< uint32_t > &  c)

set CIGAR

Parameters
cnew cigar
Deprecated:
Provided for backward compatibility with 0.11 API. Use cigar(const utility::Aligner::Cigar&) instead.
void theplu::yat::omic::BamRead::cigar ( const utility::Aligner::Cigar cigar)

set CIGAR

Parameters
cigarnew cigar
Since
new in yat 0.12
uint32_t theplu::yat::omic::BamRead::cigar_op ( size_t  i) const
Returns
i th CIGAR operation
uint32_t theplu::yat::omic::BamRead::cigar_oplen ( size_t  i) const
Returns
length of i th CIGAR element
std::string theplu::yat::omic::BamRead::cigar_str ( void  ) const

Translate CIGAR array to a string such as '72M3S'

const bam1_core_t& theplu::yat::omic::BamRead::core ( void  ) const

access core data struct

See Also
samtools C api documentaion
bam1_core_t& theplu::yat::omic::BamRead::core ( void  )

access core data struct

See Also
samtools C api documentaion
int32_t theplu::yat::omic::BamRead::end ( void  ) const

rightmost coordinate

Coordinate is 0-based, i.e., the end is one passed the last matching position.

See Also
bam_calend
uint16_t theplu::yat::omic::BamRead::flag ( void  ) const

bitwise flag

See Also
Preprocessor defines BAM_F*
Since
implemented since yat 0.12
const char* theplu::yat::omic::BamRead::name ( void  ) const
Returns
query name

Length of array is described by core().l_qname

void theplu::yat::omic::BamRead::name ( const std::string &  n)

modify name

Since
New in yat 0.11
uint8_t theplu::yat::omic::BamRead::qual ( size_t  i) const
Returns
Quality of base i
void theplu::yat::omic::BamRead::qual ( size_t  i,
uint8_t  q 
)

set quality of a base

Parameters
ibase to modify
qnew quality
Since
New in yat 0.11
std::string theplu::yat::omic::BamRead::sequence ( void  ) const

Each character in returned sequence is either A, C, G, T, or N.

Returns
sequence
uint8_t theplu::yat::omic::BamRead::sequence ( size_t  index) const

4-bit integer describing base index

See Also
bam_nt16_rev_table
void theplu::yat::omic::BamRead::sequence ( size_t  i,
uint8_t  x 
)

modify a base in sequence

Set i-th base in sequence to x, where seq is a 4-bit integer.

See Also
bam_nt16_table
Since
New in yat 0.11
void theplu::yat::omic::BamRead::sequence ( const std::string &  seq,
const std::vector< uint8_t > &  qual 
)

set sequence and quality

Since
New in yat 0.11
uint32_t theplu::yat::omic::BamRead::sequence_length ( void  ) const
See Also
core().l_qseq
void theplu::yat::omic::BamRead::swap ( BamRead other)

Exchanging this read with other.

See Also
swap(BamRead&, BamRead&)

Friends And Related Function Documentation

uint32_t left_soft_clipped ( const BamRead bam)
related

If read is soft clipped on left side, return how many bases are clipped, otherwise return 0.

Since
New in yat 0.10
uint32_t right_soft_clipped ( const BamRead bam)
related

If read is soft clipped on right side, return how many bases are clipped, otherwise return 0.

Since
New in yat 0.10
bool same_query_name ( const BamRead lhs,
const BamRead rhs 
)
related

return true if query names are equal

See Also
BamRead::name()
Since
New in yat 0.10
bool soft_clipped ( const BamRead bam)
related
Returns
true if read is soft clipped, either left_soft_clipped or right_soft_clipped.
Since
New in yat 0.10
void swap ( BamRead lhs,
BamRead rhs 
)
related

Swap specialization for BamRead that is faster than generic std::swap as it just swap a pair of pointers.

Since
New in yat 0.10

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

Generated on Mon Jun 1 2015 12:29:52 for yat by  doxygen 1.8.5