PackedRead Class Reference
Collaboration diagram for PackedRead:
[legend]

## Public Member Functions

int | size ()
void | clear ()
void | set (const char *rhs, int padWithNCount=0)
uint8_t | operator[] (int index)

## Public Attributes

std::vector< uint8_t > | packedBases
uint32_t | length

## Detailed Description

Definition at line 141 of file GenomeSequenceHelpers.h.

## Member Function Documentation

## clear()

void PackedRead::clear | ( |  | ) |

inline

Definition at line 157 of file GenomeSequenceHelpers.h.

{
packedBases.clear();
length=0;
}

## operator[]()

uint8_t PackedRead::operator[] | ( | int | index | ) |

inline

Definition at line 163 of file GenomeSequenceHelpers.h.

{
return (packedBases[index>>1] >> ((index&0x1)<<2)) & 0xf;
}

## set()

void PackedRead::set | ( | const char * | rhs,
|  | int | padWithNCount = `0`
| ) |  |

Definition at line 56 of file GenomeSequence.cpp.

{
clear();
// pad this packed read with 'N' bases two at a time
while (padWithNCount>1)
{
packedBases.push_back(
BaseAsciiMap::base2int[(int) 'N'] << 4 |
BaseAsciiMap::base2int[(int) 'N']
);
padWithNCount -= 2;
length+=2;
}
// when we have only one base, pack one 'N' base with
// the first base in rhs if there is one.
if (padWithNCount)
{
// NB: *rhs could be NUL, which is ok here - just keep
// the length straight.
packedBases.push_back(
BaseAsciiMap::base2int[(int) *rhs] << 4 |
BaseAsciiMap::base2int[(int) 'N']
);
// two cases - have characters in rhs or we don't:
if (*rhs)
{
length+=2; // pad byte plus one byte from rhs
rhs++;
}
else
{
length++;
}
padWithNCount--; // should now be zero, so superfluous.
assert(padWithNCount==0);
}
// pad pairs of bases from rhs, two at a time:
while (*rhs && *(rhs+1))
{
packedBases.push_back(
BaseAsciiMap::base2int[(int) *(rhs+1)] << 4 |
BaseAsciiMap::base2int[(int) *(rhs+0)]
);
rhs+=2;
length+=2;
}
// if there is an odd base left at the end, put it
// in a byte all its own (low 4 bits == 0):
if (*rhs)
{
packedBases.push_back(
BaseAsciiMap::base2int[(int) *(rhs+0)]
);
length++;
}
return;
}
BaseAsciiMap::base2int
static unsigned char base2int[256+1]
Map ASCII values to a 2 (or 3) bit encoding for the base pair value for just base space (ACTGNactgn).
Definition: BaseAsciiMap.h:61

## size()

int PackedRead::size | ( |  | ) |

inline

Definition at line 153 of file GenomeSequenceHelpers.h.

{
return length;
}

## Member Data Documentation

## length

uint32_t PackedRead::length

Definition at line 152 of file GenomeSequenceHelpers.h.

## packedBases

std::vector<uint8_t> PackedRead::packedBases

Definition at line 151 of file GenomeSequenceHelpers.h.

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

- general/GenomeSequenceHelpers.h
- general/GenomeSequence.cpp